Quote:
|
Originally Posted by jdong
Well, it's difficult and processor-expensive to do so. You'd have to measure the length of each pulse, by interrupting on rising edge, then having the handler switch to interrupt on falling edge. By using a timer to count the ticks between these two, you can obtain the length of the pulse.
However, the time to pulse also varies with the speed (no direction) of the rotations. You sort of have to know the speed to do much with it.
|
If I understand this correctly, the duty cycle (time pulse is high/total period) is fixed at some value if the gear is going one way and fixed at a different value when spinning in the opposite direction. If this is true, all you need to do is use a timer to keep track of the delta time between edges to know which direction you're spinning. This *can* be done. In fact, this is very close to how the beacon receiver code worked last year. Perhaps someone can grab a copy of receiver.c and make it work? Last years code is kept here:
http://kevin.org/frc/2004.
-Kevin