|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Timer Function
Hello all,
The programming team on our team is trying to get a timer function where we can run this code every x seconds or something like that. We've searched high and low and have not been able to find a good timer code that works for us. Does anybody have any timer code that works without having a degree in nuclear physics to install and use? Thanks -Tanner |
|
#2
|
||||
|
||||
|
Re: Timer Function
We've got some code, but right now it seems not to be working, sorry. Here it is if you want to look, though.
|
|
#3
|
||||
|
||||
|
Re: Timer Function
Do you have the FRC base? That should include a timers.c file.
|
|
#4
|
|||
|
|||
|
Re: Timer Function
Quote:
What I love about WPILib is it has simple code for timers, gyros, ultrasonic sensors -- just about everything. But it was also easy to switch our code to WPILib, since you don't have to use their simplified functions if you don't want to. Instead of using SetPWM(1, 127), you can still say pwm01=127 if you want. I highly recommend using WPILib. |
|
#5
|
|||||
|
|||||
|
Re: Timer Function
We've had timers in the past. Our code is in CHOPSHOP.C. Just search for "timer" in that file and follow the instructions in the function headers.
Here is our sourceforge project, you can download our code here: http://sourceforge.net/projects/frst166code08 Last edited by Eric Finn : 27-01-2008 at 15:27. |
|
#6
|
||||
|
||||
|
Re: Timer Function
You could try this code which I developed 2 years ago - it is compatible with MPLAB.
http://www.sunsys.net/frc/ |
|
#7
|
||||
|
||||
|
Re: Timer Function
Team 1425 has as schedular function which allows a routine to be run in some amount of time in the future, or set a routine to run every so often, or some amount of time since it last ran.
We do this by having timer 1 keep a time base for us, and a scheduler routine which keeps track of function pointers for routines that are to be run at the specific times. Getting the function pointers to work was an interesting exercise for the students, but the system works well. It is not as generic as we would have liked due to the limits imposed by the available memory (used to store the info relating to the scheduled events). A side benefit of this code is a general set of clock routines that allow any part of our code to tell how much time has elapsed. We return ms since the robot started as a long integer. The timer setup is all based on the timer white paper available at the ifi site. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Timer Question | lightning_blast | Programming | 15 | 30-03-2007 07:12 |
| Timer questions | Rick TYler | Programming | 3 | 12-02-2006 19:24 |
| Timer 0/Serial Communications? | steven114 | Programming | 2 | 13-02-2005 20:50 |
| timer | omega | Programming | 3 | 30-03-2004 18:52 |
| Timer Preview | Nate Smith | General Forum | 2 | 05-03-2003 12:25 |