|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
question about autonomous timing
im bit confused about 26.2 ms loop area part
does that mean 1 = 26.2 ms when i set up a counter or something? ![]() |
|
#2
|
|||
|
|||
|
Re: question about autonomous timing
Quote:
|
|
#3
|
|||||
|
|||||
|
Re: question about autonomous timing
a better way to set up a timer, if you are comfortable with it, is to use the processor interrupts. www.kevin.org/frc has some sample code that can be cut and pasted into your code. I knew nothing about interrupts and timers and such and after a few hours staring blindly at the screen everything clicked. its really sweet how everything works. search chiefdelphi for other threads related to interrupt driven timers
|
|
#4
|
||||
|
||||
|
Re: question about autonomous timing
Quote:
|
|
#5
|
||||
|
||||
|
Re: question about autonomous timing
i want to know what 1 second equals to in this part
1000? 400? what is it!?!?!? |
|
#6
|
|||||
|
|||||
|
Re: question about autonomous timing
Quote:
So in one second, there are 38 or 39 cycles of the "main loop". You can pre-calculate certain fixed periods of time (using pocket calculator or the Windows calculator accessory, not the robot controller), converting from seconds to cycles of 38 Hz: To know when a certain pre-determined amount of time has passed, say, 11.7 seconds, figure out how many counts that would be: 11.7 / .0262144 = 446.3195801 and round to the nearest integer, because the controller works fastest with integers: 446. A quicker way? Mutliply seconds by 38: 11.7 * 38 = 444.60000 which is 445 when rounded. A little different than 446. An even faster way that you could do in your head: 11.7 * 38 is about: 12 * 40 = 480 Close enough? Think like an engineer and make that decision yourself! Remember, to count these cycles, declare a "static" variable. "static" means that the variable isn't lost every 26.2 ms cycle, which could happen otherwise. Code:
static unsigned int cycleCounter = 0; Code:
if ( cycleCounter < 446 )
{
// this part gets used for the first 11.7 seconds
}
else
{
// this part gets used after the first 11.7 seconds has passed.
}
cycleCounter++; // increase the cycle counter by 1.
Last edited by gnormhurst : 23-02-2004 at 16:30. |
|
#7
|
||||
|
||||
|
Re: question about autonomous timing
oooo ok thx for clearing that up
![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A better autonomous method.. | randomperson | Programming | 4 | 24-02-2004 18:02 |
| Initializing autonomous mode | Mr. Lim | Programming | 7 | 02-02-2004 07:26 |
| variable? | manodrum | Programming | 11 | 01-04-2003 17:20 |
| autonomous mode problem on field | Chris_C | Programming | 17 | 26-03-2003 19:11 |
| Autonomous Kill Switch | UCGL_Guy | Programming | 8 | 15-01-2003 17:39 |