View Full Version : Delay Help!
waiakea2024
19-02-2007, 18:50
We have been working on our autonomous mode and we cant figure out how to make a delay. Our mentor has tried to make his own but the bot wont recive it. Any Suggestions or ideas? Thanks!
waiakea2024
19-02-2007, 18:59
We are trying to make our arm move and then stop without it hitting the ground and messing up the motor.
Ari Allyn-Feuer
19-02-2007, 19:18
We have been working on our autonomous mode and we cant figure out how to make a delay. Our mentor has tried to make his own but the bot wont recive it. Any Suggestions or ideas? Thanks!
I would like to say that FFR, the real best way to do this is to have a quadrature encoder on the arm. But let's do it your way since that's the hardware!
Basically to make a delay, without going into using the onboard timers, is to increment a loop counter every loop and have a test statement which will do something when a certain number of loops has elapsed.
Pseudocode:
if(arm_is_moving && loops < NEEDED_LOOPS)
{
loops++;
}
if(arm_is_moving && loops = NEEDED_LOOPS)
{
arm_pwm=127;
arm_is_moving=0;
loops=0;
}
This is quick and ugly, and it would be more elegant to use the timers or have an encoder. But it'll work in a pinch.
I hope this helps. If we see each other at a regional I can help you some more, or post again or use a PM.
Ari.
waiakea2024
19-02-2007, 21:58
that didnt work :l thanks for the help though
buddy.smith
19-02-2007, 22:49
Well if you copied and pasted his code, then you should change the '=' to '==' :)
Also 'loops' will need to be static
ttyl,
--buddy
We are trying to make our arm move and then stop without it hitting the ground and messing up the motor.
This is where a limit (either a software one from a shaft encoder or potentiometer) is good. Otherwise, if you really want a delay, let us know (there are several ways of doing this, ranging from crude (loop counting) to good (setting up a timer and interrupt routine to get real-time clocks)
waiakea2024
20-02-2007, 12:47
well we just downloaded the WPILib and are currently trying to get it to download into our controller. Thanks to all for your advice. We have been trying many different things and we have officially run out of ideas. We are currently waiting for our mentor to see if he has any new ideas.
waiakea2024
21-02-2007, 12:41
Thanks to everyone for the help and expertice. We finally got it and we are well on our way. Thanks again!
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.