Thread: Timers and Such
View Single Post
  #6   Spotlight this post!  
Unread 19-02-2007, 16:08
Dave K.'s Avatar
Dave K. Dave K. is offline
Engineer/Mentor
FRC #0930
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2005
Location: WI
Posts: 91
Dave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to behold
Re: Timers and Such

Quote:
Originally Posted by gnirts View Post
You might want to investigate using WPILib. You can use a function like sleep() (except it's called wait()) there because it handles things differently. See the bottom of page 50 of the manual (pdf). More information is available in the WPILib section of this forum.

For someone coming from a InteractiveC background it might be much more familiar.
That looks like a good suggestion.


I suppose the other thing that could be suggested here is that if a true stall of all code execution is really what is desired, and precison wasn't a primary concern, that a simple FOR/NEXT loop could be setup to approximate the correct delay.

Code:
#define LOOPTIME  50   // emperically choose a number that provides the desired timer resultion

void Sleep(unsigned int timer) {

unsigned int i;

    while(timer--) {
        for (i=0;i<LOOPTIME;i++);
    }

}
__________________
--Dave