FiRST Year Team - need Timer HeLP

hey guys. Well heh, im havin trouble settin up the timer on my bot. the motor is supposed to go 36 cycles/s so in the code we are using this for a timer…

if a_count = (36 *4) then y
y:
drive_R=220

a_count = a_count+1

:confused:
if i can get the counter to pause for 3 seconds and do the drive_r action the 4th second, that would be all the help i need for now.The code is in the main loop, and all i want it to do is obey the timer… ill be waitin for your replies…ty
:confused:

pause for 3 seconds

Duhhhhh(inserted because i forgot what it was) its the pause command and you denote how long you want it to pause but it’s units are in miliseconds. Now all it’s a matter of figuring out where to pause it. Hmmm… I believe it should be at the end of the code you posted.

Is there a way i can find out how many times the Main Loop runs in one second?

That is getting a whee bit too complicated for me. Someone else answer his second question. All I know about pbasic is that in order to pause the program at a certain point you use the pause command. I know a little more but trying to learn about robotics when you have five million things going on is a bit on the insane side:)

Maybe i can output the counter out to a display, and time it with a timer, but i think thatll be to many digits. Thanks For your helps though. How long does pause pause for?

it pauses the program from 0-65535ms Of course now that I think of it do you really want to pause the whole program??? btw why don’t u download the manual on parallax.com too:)

i really dont need the pause, i just need a workin timer to hardcode the autonomous code.

First of all, don’t use the pause command. This will cause the robot controller to stop executing all code, and miss packets from the OI. If it misses 5 packets in a row, the robot controller resets, which is a bad thing.

Radio data is sent approximately every 26ms. You can use this exactly as a timer if your loop speed is guaranteed to be less then 26ms. Otherwise, you can use the delta_t variable, which tells how many packets that you missed.

The code in the first post is on the right track, but has some logic errors, here is how I would write it.

if a_count < 115 then firstthreesec
if a_count >= 115 & a_count < 154 then fourthsecond
'do whatever you want after fourth second here
goto done
firstthreesec:
drive_R = 127 'neutral
goto done
fourthsecond:
drive_R = 224
done:
a_count = a_count + 1 + delta_t

PS: this thread is close to violating the part of the user agreement that says

You also agree not to post the same message in multiple forums, or use the forums as a real-time chat, continuing a 2-3 person conversation on for numerious posts in a short period of time.

I really should read up on the innovation first controller and how to program it. I’m always thinking of the basic stamp when I try to answer these questions.

so, delta_t counts the packets bein sents, where if delta_t = 1 then it would be at 26ms, so i can do if delta_t=4(x) (4= roughly 1 second, x= multiplier of how long i want it to go ie. 41= 1 sec, 42= 2 sec) i should be able to use delta_t as atimer without even a_count? is delta_t already in the default code and used to count the packets every 26ms?

delta_t will tell you how many packets you have missed since your last SERIN. It is NOT a running timer. As the code posted by Joe Ross shows, you should still keep your own counter and increment it by 1+delta_t (delta_t will be 0 if your loop is exactly 26ms) each time. Then, multiply this counter by 26ms to get the actual number of seconds that have gone by.

–Rob

*Originally posted by Cobra *
**Is there a way i can find out how many times the Main Loop runs in one second? **

http://www.chiefdelphi.com/forums/showthread.php?threadid=16805

The Thread “How long is one stamp loop” has stuff that can help you figure out how long of loop of your edited program will take. and from this u can find out how many time ur main loop will run in one second.

http://www.emesystems.com/BS2speed.htm

That site has some stuff about speed etc. {Its also in that other Thread}

Cipher X

the scan time on the controller is roughly 26 milliseconds as we tested it, and there are ways other than counting time you want the motor to run…be creative, use your eyes, we have our robot already going around and up the ramp in 4 seconds flat simply by counting wheel revs.

~Erick