![]() |
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? :confused: |
Re: question about autonomous timing
Quote:
|
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
|
Re: question about autonomous timing
Quote:
|
Re: question about autonomous timing
i want to know what 1 second equals to in this part
1000? 400? what is it!?!?!? |
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 ) |
Re: question about autonomous timing
oooo ok thx for clearing that up ;)
|
| All times are GMT -5. The time now is 04:17. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi