Encoders Explained

Spread the love

An encoder is a sensor that reports the position, speed, and direction of a rotating shaft to a motor controller. Incremental (quadrature) encoders track relative movement and must be homed at power-up. Absolute encoders report the true shaft position at all times. Both types work with RoboClaw motor controllers.

In all but the simplest motion systems, the controller needs feedback about what the motor is actually doing. Encoders provide that feedback. This article explains what encoders are, how the two most common types work, and how to choose between them for a robotics or automation project.

What Is an Encoder?

An encoder is a device that can produce signals indicating the position, direction, and speed of a rotating shaft. A motor controller reads these signals to run closed-loop speed and position control. Encoders are most often mounted on motors, but they also appear on linear actuators and other moving parts. Several sensing technologies produce the same result, including optical, magnetic (Hall effect), capacitive, and inductive sensing.

What Are Encoders Used For?

The most common job of an encoder is feedback for motor control. A robot can use encoders to measure exactly how far it has traveled or move to a commanded distance. With a feedback loop in place, encoders let a robot hold a consistent wheel speed despite slopes and changing loads. The controller compares the commanded speed or position against the encoder reading and corrects the difference, a process covered in PID Control and Motor Controllers. For a closer look at how encoders are used on wheeled robots and robotic arms, see Encoders in Robotics.

Incremental vs Absolute Encoders: What’s the Difference?

Incremental encoders report movement relative to where the shaft started. Absolute encoders report the true shaft position at every moment. The difference matters most at power-up: an incremental encoder must first move to a known home position before its counts mean anything, while an absolute encoder knows its position immediately. Both types indicate speed and direction of rotation.

Characteristic Incremental (Quadrature) Absolute
Position reporting Relative to the starting point True shaft position at all times
Power-up behavior Must be homed after every power-up Position known immediately
Output signal Two square waves (A and B) 90 degrees out of phase A unique code for each shaft position, often an analog voltage
Direction sensing Yes, from which channel leads Yes, from the changing position value
Typical applications Drive wheels, speed control, distance tracking Robotic arms, steering, positioning that must survive power cycles

Choose an incremental (quadrature) encoder for drive wheels, speed control, and distance tracking. Choose an absolute encoder when the exact position must be known the moment the system powers on, such as a robotic arm joint or a steering mechanism. Cost matters too: quadrature encoders generally deliver high resolution at a lower price point.

How Do Incremental (Quadrature) Encoders Work?

Inside an incremental encoder is a disc with two tracks of identical markings. As the shaft rotates, the markings pass a sensing unit that produces one pulse per mark. The two tracks are offset from each other, so the output is a pair of square wave pulse streams 90 degrees out of phase. This phase relationship is why they are called quadrature encoders. The controller reads which channel leads to determine the direction of rotation, counts pulses to track position, and measures the pulse rate to calculate speed.

Animated quadrature encoder disc with two offset tracks producing out of phase pulse signals
Figure 1: A quadrature encoder in action. The two offset tracks produce pulse streams 90 degrees out of phase. Image: Sidehack, public domain.

Resolution depends on the number of markings per revolution. Many quadrature encoders provide thousands of counts per revolution, and RoboClaw tracks these counts as full 32 bit values. For a deeper look at quadrature signals and how controllers decode them, see Quadrature Encoders: How They Work.

In systems that use quadrature encoders, a home position is commonly used to establish a known reference point for measuring distance or position. Without a defined starting position, encoder counts are relative only to the position of the motor at power-up.

How Do Absolute Encoders Work?

An absolute encoder contains a track of unique values, one for each possible shaft position. A sensing unit reads the value and outputs a code that corresponds directly to the real shaft position. No arbitrary starting point is involved, so the reading survives power cycles: the moment the system powers on, the encoder reports where the shaft actually is, even if the shaft moved while power was off.

Cutaway diagram of an absolute encoder showing the shaft, coded disc, and sensing unit that reads a unique code for each shaft position
Figure 2: How an absolute encoder works. The sensing unit reads a unique code from the disc for every position of the shaft.

Absolute encoders used in hobbyist and light industrial robotics commonly output an analog voltage proportional to shaft position, while industrial units may use digital interfaces. RoboClaw reads analog absolute encoders directly over its 0 to 2 volt input range, resolving the range into 2048 steps.

Coded disc of a 13 track Gray code absolute encoder
Figure 3: The coded disc of a 13 track absolute encoder. Each shaft position produces a unique code. Image: Mike1024, public domain.

Which Motor Controllers Support Encoders?

RoboClaw motor controllers support quadrature encoders, analog absolute encoders, and potentiometers for closed-loop operation. Feedback can drive velocity control, position control, or a cascaded mode that combines both. The built-in auto-tune function produces usable values for most motor and quadrature encoder combinations, while analog absolute encoders sometimes require manual tuning because of their lower resolution. The MCP series of advanced motor controllers supports encoder feedback as well. Browse the full range of RoboClaw motor controllers to find a model with the channel count and current rating your project needs.

Next Steps

To go deeper on the concepts, Quadrature Encoders: How They Work and Encoders in Robotics continue where this article leaves off. Ready to put an encoder to work? Pololu Encoder Wiring shows the physical hookup, Using Encoders with the Arduino Library and Using Encoders with the Python Library cover reading counts and speeds in code, and Auto Tuning with Motion Studio walks through tuning velocity and position control once your encoder is connected.