February 7, 2018 1:54 pm

Rotary encoders, henceforth “encoders,” are used to measure the amount that a shaft has rotated at any given time. They are used across a wide range of industries to determine the location of moving assemblies, detect system jams, track user input, and keep track of robot motion. Encoders are a key component in many automated systems.

Your car has encoders to track speed and engine RPMs. Your computer has encoders which make your platter drives work, Roombas use encoders to know where they are and drive in straight lines, and if you lived through the 90s, your trackball mouse used two of them to determine where the mouse was moved.

This article is designed to educate technically-minded readers on the basic workings of encoders, and some of the key differences that separate various types of encoders.

Engineers who are in the early stage of designing mechatronic systems can use the information in this article to guide decisions on when to use an encoder and which type of encoder to use for monitoring a given task. We have a strong robotics background and this article reflects that in many of the application examples.

Optical vs. Magnetic Encoders

Optical encoders consist of one or more sensors that send and receive light, either by reflecting it off of a patterned disk (fig. 2, fig. 3, fig 4) or by sending and receiving it through holes in a notched disk.

Magnetic encoders are offered as an alternative to optical encoders, and operate using similar principles but with magnets instead of patterned disks and magnetic field sensors instead of optical sensors and emitters.

You wouldn’t want to use a magnetic encoder around strong magnetic fields, but otherwise, the technologies are roughly equivalent, with the choice between magnetic and optical coming down to cost, accuracy and what environment an engineered system will be operating in. Manufacturers’ data sheets are the best place to get this information. The remainder of the figures in this article show components of optical encoders because they are easier to conceptualize.

Absolute vs. Incremental Encoders

The two main types of encoders from a functional perspective are absolute and incremental. It is important to know the difference so that you can select the right one for your application.

How They Work

The patterns shown in Fig 2 are interpreted by optical sensors inside of encoders. The sensors use reflected light to tell if they are looking at black or white. The disks are connected with mechanical linkages so that they move with an input shaft. The sensors are oriented in a line starting at the outside of the disk and moving in towards the center, with one sensor per “track” of data. Each optical sensor outputs a zero or a one depending on whether it is looking at white or black.

In order to keep the wires on the sensors from getting tangled, the sensors are typically fixed to the chassis of the encoder. Both of the above-encoders measure the angle of a shaft, but they do it in different ways.

The incremental encoder disk on the left contains two discrete tracks of uniform spacing. The readings from its 2 optical sensors are counted and compared in software to keep track of how far the encoder disk has turned clockwise or counterclockwise. We will revisit this type of encoder later in the article.

The absolute encoder disk on the right contains 10 tracks of pattern which are read by 10 sensors in order to determine, precisely which way the spinning disk is facing relative to its fixed sensors. If you look closely, you will notice that all 10 tracks are never the same at any two positions on the disk when compared in a strip as wide as the ticks on the outside track. It can, therefore, be deduced that the encoder contains 210 or 1024 unique positions. If you divide 360 by 1024, you will see that this absolute encoder has a resolution of approximately 0.35 degrees.

What This Means in Practice

Absolute encoders tell you, to a specified resolution, the angle that a shaft is facing at any given time, usually truncated within a complete turn. They are used on sub-assemblies where knowing the angular orientation of two parts relative to one-another is critical to the devices function. For example, scanning LiDAR sensors use absolute encoders to tell which direction they are facing when they take a measurement.

Incremental encoders send signals as the angle they are monitoring changes and so they measure changes in angle, rather than which angle a shaft is turned to on a circle. Changes in position over time can be differentiated to provide velocity and velocity can be differentiated to provide acceleration. When combined with a means of indexing a known position, such as a limit switch, incremental encoders can be used in a similar way to absolute encoders. This is common in systems that convert rotary motion into linear motion, such as ball-screw driven axes on CNC machines.

In robotics, incremental encoders are often mounted to wheels or the motors driving those wheels to give a rough approximation of the distance a robot has traveled. The reason the approximation is rough is not due to imprecision in the encoders themselves, but rather due to uncontrollable factors such as the slippage of wheels against the ground.

Single-Channel Incremental Encoders

The most simple type of rotary encoder is a single-channel incremental encoder. A single-channel encoder can be used to determine the total amount a shaft has turned. This positional data can be combined with time to figure out speed and acceleration.

The disadvantage of single-channel encoders is that they offer no data on which direction a shaft has turned, so the above-pictured encoder being turned back and forth a very small amount could give the same signal as a shaft spinning clockwise, which would also look the same as the signal given by a shaft spinning counter-clockwise.

You can engineer around this in a controlled mechatronic system by using a state machine to log travel in the direction a motor is commanded to spin. This fix can still be undone by stalls and drifting in reverse if motors are overpowered by external factors or a linkage malfunctions.

Single channel encoders are a safe-bet for speedometers on human operated machines such as cars and airplanes since the direction of travel of an observable system is obvious to a human operator. The combination of a single-channel encoder and a mechanism for converting its ticks into speed are known as a tachometer.

Quadrature Encoders

A simple, yet elegant solution to the shortcomings of the single channel encoders is to add a second track of data (fig 2) or a second sensor (fig 4). The resulting dual-channel incremental encoder is known as a quadrature encoder. Quadrature encoders send ticks on 2 channels in order to unambiguously communicate both distance and direction traveled.

Quadrature encoders are the most widely used type of encoders on autonomous and semi-autonomous mechatronic devices. They can be found on robot drivetrains, CNC machines, old computer mice, instrument panel knobs, and many other devices.

Encoders may not be glamorous, but they are ubiquitous. Every systems integrator should be intimately familiar with encoders due to both their prevalence and utility. Encoders wide-usage means that they can be very inexpensive. For example, every five-dollar 90’s-era computer mouse has 2 encoders inside of it. High-end encoders for industrial applications (fig 1) can run up to several thousand dollars per unit. Many motors sold for robotics come with built-in encoders.

Feel free to reach out if you have a specific application in mind or just want to know more about encoders in general. We enjoy sharing knowledge and discussing ideas.