Unidirectional counters accumulate bidirectional pulses
Edited by Bill Travis
Stephen Woodward, University of North Carolina, Chapel Hill, NC -- EDN, 4/11/2002
Quadrature-output incremental optical shaft encoders are popular in high-performance, bidirectional rotation-sensing applications. Available with resolution options extending beyond 2000 pulses/revolution, incremental encoders provide a fast, inexpensive, and reliable way to digitally read out bidirectional mechanical motion. The encoders are fast, too; you can usually operate them at 10,000 rpm and faster. However, the interface logic they need can sometimes be somewhat problematic. Such logic typically includes at least one long-bit-length (for example, 16-bit) bidirectional counter. Although several handy peripheral chips, such as the 8253, 8254, and 9511, are available that implement flexible unidirectional counting, bidirectional-counter chips are relatively scarce. ASICs exist that can provide the needed function, and hard-wired or programmable logic is a viable approach. Unfortunately, none of these alternatives is ideal from a cost or pc-board-area standpoint. The configuration in Figure 1 combines the industry-standard 82C54 unidirectional counter-timer peripheral chip with simple software to provide a convenient interface of quadrature encoders with the ISA I/O bus. The technique digitizes bidirectional motion without tears. As Figure 2 illustrates, the trick is to use two unidirectional counters of the three that the 82C54 contains. You use one counter for each encoder-rotation direction. One of the encoder quadrature-output signals, A, drives the gate pins of both counters. This connection selectively enables counting once every encoder-output cycle. A couple of Schmitt-trigger inverter stages phase-split the other encoder output, B, into two complementary signals. One phase drives the trigger input of the clockwise counter (82C54, Counter 1); the other phase drives the trigger input of the counterclockwise counter (82C54, Counter 2). The result is that only the clockwise counter, Counter 1, is active during the active B transition during clockwise rotation, and only the counterclockwise counter, Counter 2, is active during counterclockwise rotation. Listing 1 , written in MBasic,
suffices to periodically latch, read, and sum the counter contents to produce a
continuous 32-bit readout of encoder position. The technique can easily accommodate pulse rates as high as 500 kHz. Passive RC filtering and Schmitt-trigger signal conditioning provide robust rejection of noise pickup in the encoder cabling. The design is thus suited for typical industrial motion-sensing applications. Is this the best Design Idea in this issue? Select at www.ednmag.com. |