|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 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 ![]() |
|
#2
|
||||
|
||||
|
Quote:
Last edited by Adam Y. : 22-01-2003 at 19:39. |
|
#3
|
|||
|
|||
|
hm..
Is there a way i can find out how many times the Main Loop runs in one second?
|
|
#4
|
||||
|
||||
|
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
![]() Last edited by Adam Y. : 22-01-2003 at 19:42. |
|
#5
|
|||
|
|||
|
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?
|
|
#6
|
||||
|
||||
|
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
![]() |
|
#7
|
|||
|
|||
|
nah
i really dont need the pause, i just need a workin timer to hardcode the autonomous code.
|
|
#8
|
||||||
|
||||||
|
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:
Last edited by Joe Ross : 22-01-2003 at 20:03. |
|
#9
|
||||
|
||||
|
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.
|
|
#10
|
|||
|
|||
|
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?
|
|
#11
|
||||||
|
||||||
|
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 |
|
#12
|
||||
|
||||
|
Re: hm..
Quote:
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 |
|
#13
|
|||
|
|||
|
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 |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| The Death of FIRST | Anton Abaya | General Forum | 23 | 03-05-2006 17:18 |
| The 2003 Index of team's post about their robot... | Ken Leung | Robot Showcase | 4 | 28-02-2003 00:18 |
| More 'Best' Robots (a well thought list) | archiver | 2000 | 2 | 23-06-2002 23:11 |
| Disqualifications | archiver | 1999 | 13 | 23-06-2002 21:53 |
| How many people are leaving you team this year? | Elgin Clock | General Forum | 26 | 01-07-2001 23:39 |