Quote:
|
Originally Posted by Gdeaver
From what I read, the chip puts out pulses in mode 2 on one pin and direction state on another. It still requires counting pulses and interrupts. However the interrupt routine would not have to include the state machine that quadrature requires. Simpler and faster handler
|
Quadrature doesn't require a state machine to decode the input. Use one channel on an interrupt and the other on a regular digital input. In the ISR, the value of the channel on the digital input provides the direction.
ISR code (assume channel A is on the interrupt pin, fire on rising edge, and channel B is on input 0). distance is a signed int.
distance += (dig_in0 == 0) ? 1 : -1;