|
Re: Question about Gear Sensor
Quote:
Originally Posted by Alan Anderson
The word "quadrature" refers to two signals which are out of phase with each other by one quarter of a cycle. The signals on a quadrature encoder are digital, and there are four possible combinations: 00, 01, 11, and 10. Notice that they don't "count" in binary; instead, only one of the signals changes for a transition between states. A change from 00 to 01 indicates the encoder is turning in one direction; a change fom 01 to 00 indicates it is turning in the other. Here's the full list of possibilities:
Code:
from to direction
00 01 forward
00 10 reverse
01 11 forward
01 00 reverse
11 10 forward
11 01 reverse
10 00 forward
10 11 reverse
A simple way to use quadrature encoders is to use interrupts to detect a transition from 0 to 1 on one signal (usually called Phase A), and look at the state of the other signal (Phase B) at that time to decide which direction the sensor is turning. That only uses two of the possible eight changes, but it's sufficient: 01 to 11 is forward, and 00 to 10 is reverse.
|
but how can you easily get the bits content? Can you please write a code(I work in MPLAB). Thanks.
Last edited by beefy23 : 28-03-2008 at 19:20.
|