View Single Post
  #12   Spotlight this post!  
Unread 30-01-2007, 11:06
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 592
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: Welcome to the WPILib forum

Quote:
Originally Posted by Joohoo View Post
Just curious what interrupts/timers does each encoder and ultrasonic sensor use. Is there a listing of what each sensor uses in terms of internal timers, external interrupts, and how they are configured?

Also has any one used wpilib in addition to the default code?... kevin watson's?
WPILib uses timer 1 for everything. It maintains a timer queue internally and there are calls to register for timer support. So a device driver can call a function to register for repeating timer interrupts with 1ms resolution and that request is put in a list. On each timer interrupt the WPILib checks to see what outstanding requests exist at that time and call the registered timer handlers.

Devices can also get the time with about 10us accuracy by calling other functions. These work by using looking at the prescaler registers on timer1 to see where in the 1ms interval it is and compute the running time in microseconds.

So, for example, a Vex ultrasonic sensor registers for interrupts every 100ms that it uses to send the pings. But it has to do sub-millisecond timing to get the distance right, so it times the echo line using the microsecond timing functions.

All this happens only using timer 1.

External interrupts are handled by devices registering for interrupts (another function). They can look for rising or falling edges. The ultrasonic sensor, for example, uses this to watch the echo line on the sensor.

All these functions - registering for timer events, and registering for interrupts is done with functions that anyone can call. This makes the library extensible. You can write your own drivers for new devices just as I did for the ones in the library. And all the functions are documented in the manual that is on the web site along with the code.

I hope this answers your questions.

Brad
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute