|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Looking for help with creating a timer.
We want to use a timer for executing commands. (if x button is pushed than p happens and after a certain amount of time q happens) This would most likely be for controlling the solenoids on our robot so that with one button push a piston would extend before the other. We would also use it for driving functions.
|
|
#2
|
||||
|
||||
|
Re: Looking for help with creating a timer.
you need to add a global variable at the top and if you put a counter in the while loop for autonomous you can count the iterations. this is the only way you can do it. if you put a delay in you will get the red light of death.
|
|
#3
|
|||||
|
|||||
|
Re: Looking for help with creating a timer.
For MPLAB IFI/Watson based programming...
To use a real timer take a look at the IFI explanation in this white paper: http://www.ifirobotics.com/docs/time...004-jan-14.pdf Kevin Watson has some examples here: http://www.kevin.org/frc/2005/ Last edited by Mark McLeod : 15-02-2008 at 10:26. Reason: What was that word? |
|
#4
|
|||
|
|||
|
Re: Looking for help with creating a timer.
use a "wait" function in the code
if(button){ do thing one; Wait(3000); do thing two; } The value inside the "wait" function is in milliseconds, so the above code would pause for 3 seconds between thing one and thing two. |
|
#5
|
|||||
|
|||||
|
Re: Looking for help with creating a timer.
For Easy C or WPILIB based programming ...
|
|
#6
|
||||
|
||||
|
Re: Looking for help with creating a timer.
Quote:
-Kevin |
|
#7
|
||||
|
||||
|
Re: Looking for help with creating a timer.
the program loops at 36 times a second. With this knowledge, you could create something that would measure this. I wouldn't advise letting a counter variable get into the thousands, because then the program starts running slower. something like this worked nicely for me:
Code:
//global variables
int count = 0;
int second = 0;
//somewhere in code
if (count >= 37)
{
count = 0;
}
count++;
//you could compare things like this
switch second
{
case 0: //what happens right off the back
break;
case 1: //what happens in the first second
break;
case 2: //what happens in second second (ha!)
break;
default: //what should happen when out of time
}
|
|
#8
|
||||
|
||||
|
Re: Looking for help with creating a timer.
The code says we are missing IFI_FRC.h
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| looking for help on chairman award | grandmother cul | Chairman's Award | 19 | 15-02-2008 09:27 |
| Looking for help | sfshilo | General Forum | 3 | 10-04-2006 18:30 |
| Looking for a Team to Work With | KevinB | Finding A Team | 0 | 21-11-2004 14:26 |
| Looking for contact with Millenium team. | Gene F | General Forum | 3 | 09-11-2003 13:18 |
| Looking for some help with buttons and pins... | Amanda Morrison | General Forum | 4 | 26-02-2003 17:32 |