|
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.
|