Skip to main content

Subsection 11.6.5 Direction, and Quadrature

One sensor and identical slots give a signal that is the same in both directions, so a program that only counts pulses cannot know which way the shaft turned. A quadrature encoder puts a second sensor a quarter of a cycle away from the first, so its two pulse trains are a quarter of a cycle apart and which one leads says which way the shaft is turning. What a program looks at is the state of one channel at the moment the other changes: on a rising edge of A, channel B is LOW in one direction and HIGH in the other. That is a two-bit state machine, and it also multiplies the resolution, because there are now four distinguishable edges per slot instead of one. Some parts do the whole decode in hardware and make the finished count available over a bus.