Optical Encoder 101
A typical optical encoder employs a light mask,
an LED emitter, and a pair of phototransistors to
generate a quadrature two-bit signal. The optical
encoder we will use in our design is a Grayhill Series
A highly simplified schematic diagram of the 61C11-01-
00-02 optical encoder can be seen in Figure 1. The
quadrature output signals that emit from the 61C optical
encoder’s outputs are laid out in Figure 2. Note that from
left to right, the A output waveform leads the B output
waveform by 90°. Just for kicks, let’s call left to right
forward rotation. Now, if we follow the waveforms from
right to left, output B leads output A by 90°.
According to our forward designation, output B leading
output A is a sign that the rotation is reversed. Note also
that the Figure 1 logic sequence repeats every four
positions. The leading edges and/or the output A and
output B logical states at each position (every 90°) can be
used to determine the direction of rotation and the number
of positions that have been traversed.
FIGURE 1. This is a simplified schematic of the Grayhill Series 61C
optical encoder. The selection of the resistor values determines the
logic level of the optical encoder outputs. Our design is powered by
five volts. So, the recommended TTL pullup resistor value is 8. 2 KW.
Sometimes a keypad is not the most practical human
I/O device for an embedded design. For instance, a CNC
machine controller may not have room for a full QWERTY
keyboard layout. Also, a QWERTY keyboard layout would be
overkill for setting the position of a cursor or selecting a
simple RPM of drill depth value. In the case of the CNC
example, a rotary optical encoder with an integral
pushbutton switch is the most logical choice.
As a roboteer, you’re used to seeing optical encoders at
the end of a motor shaft. Rotary optical encoders are also
awesome human input devices. If you’ve been avoiding
them in your robotic controller data entry gear because of
the complicated code it takes to support them, cast aside
your fears as we’re about to assemble and code a universal
rotary optical encoder input device.
FIGURE 2. There are multitudes of ways to interpret the
phase relationships and logical relationships of this quadrature
signal pair. I like to keep things simple. So, instead of writing
yet another optical encoder driver, we’ll use some specialized
hardware to do the job.
Coding with Hardware
You’re probably expecting to see some fancy
quadrature encoder interface code. Instead of decoding the
optical encoder outputs with mnemonics, we’re going to
use a specialized piece of hardware called a QEI
(Quadrature Encoder Interface).
Detent is the term for a method — as well as the actual device —
used to mechanically resist or arrest the rotation of a wheel, axle,
A detent can be used to intentionally divide a rotation into
discrete increments or, as in perhaps its original concept and most
rudimentary form, to simply arrest rotation in one direction.
Courtesy of www.answers.com
44 SERVO 07.2010