View Single Post
  #3   Spotlight this post!  
Unread 08-10-2005, 16:38
seanwitte seanwitte is offline
Registered User
None #0116
Team Role: Engineer
 
Join Date: Nov 2002
Location: Herndon, VA
Posts: 378
seanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant future
Send a message via AIM to seanwitte
Re: Non Contact Magnetic Encoder with PWM Output

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;