Simple Quadrature Decoder Suits Rotary Encoders

July 9, 2009
Rotary quadrature encoders often are used to command digital potentiometers or digital controllers, and quadrature decoding is typically performed in a programmable device (like an FPGA or microcontroller).

Rotary quadrature encoders often are used to command digital potentiometers or digital controllers, and quadrature decoding is typically performed in a programmable device (like an FPGA or microcontroller). This design performs quadrature decoding with commonly available components, and it comes in handy when you need to use a quadrature encoder in the lab or in a simple product.

This design uses a manually turned contact encoder. Contact encoders are relatively inexpensive, and their internal switches produce switch closures that can be debounced and converted into two voltage pulse trains (often labeled A and B). The pulse trains are 90° out of phase with each other in time due to the encoder’s construction. The design works equally well with an optical encoder, which doesn’t require switch debouncing.

The presence of pulses shows that the encoder is turning (indicating a command), and the order of arrival of the channel A and B pulses shows the direction the encoder is turning (indicating the commanded direction). Figures 1a and 1b show pulse trains A and B (plotted in time) resulting from opposite encoder rotation directions. These pulse trains are called quadrature outputs, and their conversion to a single pulse train and a separate digital signal indicating direction is called quadrature decoding.

The circuit shown in Figure 2 initially debounces the switch signals. When a mechanical switch closes, its contacts can bounce open briefly (and sometimes repeatedly) before settling in the closed state. The debounce circuit, of course, mitigates this characteristic . The circuit functions conceptually like the simplified schematic shown in Figure 3.

After the switch closes, the switch voltage rises exponentially with a time constant of R5 × C6 (1 ms in this case). Any switch bounce (contact closures) during this time simply pulls this voltage back to ground and doesn’t trigger false outputs. In the actual design, a FET is used to short the capacitor to avoid capacitor discharge currents, degrading the encoder switch contacts and limiting the encoder life (Fig. 2, again).

After debouncing, one of the two channels is converted into pulses that are shorter than the minimum duration of a switch signal. These pulses are sent with the second channel to a classic “set/reset” circuit that produces an output indicating the direction of encoder motion. The pulses are then delayed relative to the direction signal. This delay is needed because when the user turns the encoder one “click,” the circuit must indicate the new direction before sending out the pulse.

Components R4 and C4 allow U1b to create a pulse on the falling edge of the debounced signal. The pulse will be approximately 1 ms wide (about the time it takes the voltage at U1, pins 4 and 5, to fall exponentially to U1b’s transition voltage). This pulse is sized to be shorter than the briefest expected contact closure.

In this case, the manually operated encoder generates 24 contact closures per revolution. The fastest expected rate that a user could reasonably be expected to turn the encoder knob is two revolutions per second. This would result in a 50-Hz signal, which is equivalent to a 10-ms switch closure signalcomfortably longer than a 1-ms pulse. Diode D1 prevents the signal at U1, pins 4 and 5, from rising significantly above VCC when the debounced switch signal (U1, pin 3) transitions high.

U2 forms a classic digital “set/reset” logic circuit. Its output (U2, pin 6) will be high or low based upon the phase of the quadrature switch signal (U1, pins 9 and 10) relative to the 1-ms pulse (U1, pin 6). Thus, the output of the “set/reset” circuit (DIR, U2, pin 6) indicates the direction that the rotary encoder is turned. As mentioned previously, each pulse is delayed by the low-pass filter R1 and C1 relative to this direction signal. That’s because the direction indicated by a new pulse needs to be provided before the pulse itself.

Figure 4 illustrates the various circuit outputs. This circuit was used to command digital potentiometers that used negative pulse edges to increment their resistance, so the INC signal (U1, pin 11) is normally high.

Sponsored Recommendations

TTI Transportation Resource Center

April 8, 2024
From sensors to vehicle electrification, from design to production, on-board and off-board a TTI Transportation Specialist will help you keep moving into the future. TTI has been...

Cornell Dubilier: Push EV Charging to Higher Productivity and Lower Recharge Times

April 8, 2024
Optimized for high efficiency power inverter/converter level 3 EV charging systems, CDE capacitors offer high capacitance values, low inductance (< 5 nH), high ripple current ...

TTI Hybrid & Electric Vehicles Line Card

April 8, 2024
Components for Infrastructure, Connectivity and On-board Systems TTI stocks the premier electrical components that hybrid and electric vehicle manufacturers and suppliers need...

Bourns: Automotive-Grade Components for the Rough Road Ahead

April 8, 2024
The electronics needed for transportation today is getting increasingly more demanding and sophisticated, requiring not only high quality components but those that interface well...

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!