Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   FiRST Year Team - need Timer HeLP (http://www.chiefdelphi.com/forums/showthread.php?t=16849)

Cobra 22-01-2003 19:27

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:

Adam Y. 22-01-2003 19:30

Quote:

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.

Cobra 22-01-2003 19:38

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

Adam Y. 22-01-2003 19:40

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:)

Cobra 22-01-2003 19:46

heh
 
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?

Adam Y. 22-01-2003 19:56

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:)

Cobra 22-01-2003 20:00

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

Joe Ross 22-01-2003 20:01

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
Quote:

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.

Adam Y. 22-01-2003 20:02

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.

Cobra 22-01-2003 20:30

ok i think i get it
 
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. 4*1= 1 sec, 4*2= 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?

rbayer 22-01-2003 21:07

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

Cipher X 24-01-2003 23:00

Re: hm..
 
Quote:

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/sh...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

comet22 25-01-2003 19:46

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


All times are GMT -5. The time now is 09:57.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi