Rotary shaft encoders convert an angular position into an electrical quantity or digital code that a computer can use to determine the location of a connected object. Encoders come in two varieties - absolute and incremental - and most rely on optoelectric or magnetic sensors. Both types divide a 360° rotation into hundred or thousands of equally spaced units, or counts. Thus, engineers can choose an angular resolution that meets their needs. An absolute encoder indicates a specific position within the shaft's 360° rotation and an incremental position indicates the change in rotation from one position to another. (You also can derive velocity and acceleration from encoder signals.)

A typical incremental encoder provides two square-wave signals - 90° out-of-phase - for each increment. Count the pulses from both outputs and you get the relative change in position. The phase relationship of the two signals - A leads B or B leads A - indicates the rotation direction. The 90° phase relationship leads to the alternate name of "quadrature encoder" for these position sensors.

A counter circuit or a microcontroller (MCU) can track position changes easily. Encoders also may provide an "index" signal that corresponds to the same position during each complete shaft rotation. Incremental encoders work well with equipment that can return a mechanism to a starting position and begin to track movement from there. (An optical interrupter or limit switch would indicate this "home" position.) Keep in mind that loss of power means loss of position information.

An absolute encoder provides a unique output for each shaft position. A 10-bit encoder would divide a rotation into 210, or 1,024 parts. Select this type of encoder when you must know a shaft's specific position within a 360° rotation. Power loss does not affect position information.

So, a 10-bit output would indicate a shaft position within 360°/1,024, or 0.35°. An n-bit converter may produce a straight-binary code, a Gray-scale binary code, or a custom code. The Gray code alters only one bit per increment, so it avoids multi-bit transitions such as 01111 to 10000 that can produce glitches.

Figure 1. This Avago Technologies AEDx-9340 detector/code-wheel combination provides commutation information for a brushless DC motor. General-purpose encoders look similar but employ different code wheels and may come in housings and connect directly to a shaft. 
Avago Technologies offers both types of optical encoders either as "housed" devices or as separate code wheels and optical emitter/detector assemblies. Engineers can simply bolt a housed encoder onto a device, or they can select a matched code wheel and emitter/detector assembly and incorporate them within a mechanical package of their own design. Thomas Yue, an applications engineer at Avago cautions engineers that each detector has a specific lines-per-inch resolution, so the engineers must properly match code wheels and detectors. Engineers also can design and fabricate their own code wheels, although most buy them off the shelf. Housed encoders come with standard mounting holes that mate directly with many types of motors.

Although engineers may envision encoders attached to large stepper motors, even small motors or positioners used in portable consumer-electronic products may use encoders. The AEDR-84xx line from Avago may qualify as the smallest encoder, and it detects 254 lines/in. or 10 lines/mm. Other Avago encoders can produce 16-bit absolute-position information.

Avago's Yue also cautions engineers to check a detector's frequency response. "If you have a motor that runs at 10,000 rpm and a code wheel with 2000 divisions/rotation, you have 20 million pulses per minute or 333K pulses/second. So you must choose a detector that offers a bandwidth greater than 333 kHz."

Austriamicrosystems now manufactures a magnetic sensor that several companies have incorporated into rotary encoders. US Digital, for example, produces a small absolute encoder that can replace manual controls that might have relied on potentiometers. The company's MA2 encoder ($29) provides either a stepped voltage ramp or a PWM output that indicates position with 10-bit resolution. An MCU could measure the voltage or determine the width of pulses. Because the sensor chip measures the differential field produced by a rotating magnetic shaft, nearby fields from motors or other equipment appear as common-mode noise and do not affect the sensor.

The company will have a 12-bit encoder on the market by April. "You would use the higher-resolution encoder in an application with a longer throw; the distance from the center to the outer circumference," explained Jim Stevens, engineering manager at US Digital. "So you might find the 12-bit device in a rotary positioning table or in a precision telescope mount."

According to Stevens, customers appreciate the PWM output because it lets them transmit an absolute position long distances in digital form. If engineers do not want to measure a pulse width, they can use a low-pass filter at the receiver and reconstruct an analog signal they can measure with an MCU's ADC.

Although encoder suppliers offer products with many standard numbers of counts per rotation, some designs may require a special count. Sick Stegmann offers programmable incremental encoders that users can preset for one to 8192 counts per rotation and they can change the width of the index pulse. Thus, engineers can customize an encoder in the company's DRS-21, -26, and 61 lines for the number of counts they need. The company's software and a USB-port connection change the count at any time.

For further reading

For information about Gray codes, see: