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

What are the Important Considerations when Assessing Cobot Safety?

April 16, 2024
A review of the requirements of ISO/TS 15066 and how they fit in with ISO 10218-1 and 10218-2 a consideration the complexities of collaboration.

Wire & Cable Cutting Digi-Spool® Service

April 16, 2024
Explore DigiKey’s Digi-Spool® professional cutting service for efficient and precise wire and cable management. Custom-cut to your exact specifications for a variety of cable ...

DigiKey Factory Tomorrow Season 3: Sustainable Manufacturing

April 16, 2024
Industry 4.0 is helping manufacturers develop and integrate technologies such as AI, edge computing and connectivity for the factories of tomorrow. Learn more at DigiKey today...

Connectivity – The Backbone of Sustainable Automation

April 16, 2024
Advanced interfaces for signals, data, and electrical power are essential. They help save resources and costs when networking production equipment.

Comments

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