An optical incremental encoder is a sensor that turns motor shaft rotation into electrical pulses. In robotics, these pulses help a controller measure how far a wheel, joint, or gear has moved. This matters because robots need accurate feedback to drive straight, stop at target angles, and control speed.
The encoder does not directly report an absolute angle after power-up, but it tracks changes in angle very precisely once motion begins.
Inside the encoder, a slotted or striped disk rotates with the motor shaft between a light source and photodetectors. As slots pass the sensor, light alternates between blocked and unblocked, producing a square-wave pulse train. Two output channels, usually called A and B, are spaced one quarter cycle apart so the controller can determine direction from which signal leads.
Many encoders also include an index channel, Z, which produces one pulse per revolution and helps establish a repeatable reference position.
Understanding Robotics: Optical Incremental Encoder
The controller does more than simply add pulses. It watches for each change in the electrical signal, often using a hardware counter so no changes are missed while the program handles other tasks. With two channels, the controller checks the order of signal changes.
One order means forward motion. The reverse order means backward motion. This sequence is called quadrature decoding.
A controller can count only selected edges for simpler operation, or count every rising and falling edge for finer measurement. More counted edges give smaller movement steps, but they require the electronics and software to keep up with faster signals.
Resolution is not the same as accuracy. A high count encoder can detect very small shaft movements, yet the robot may still stop in the wrong place. Gear backlash can leave a gap between gear teeth when direction changes.
A wheel can slip on a smooth floor. A flexible shaft can twist under load. If the encoder sits on a motor shaft, it measures motor rotation rather than the exact motion of the robot arm or wheel.
Gear ratios must be included when converting encoder counts into real wheel travel or joint angle. These limits explain why a robot can have precise sensor readings but imperfect physical movement.
Encoders are part of a feedback loop. The robot receives a target, such as moving a wheel a certain distance or rotating a joint to a chosen position. It compares the running encoder count with that target.
The difference is the position error. The motor driver then changes motor power to reduce that error. For speed control, the controller measures how quickly counts arrive.
Fast arriving counts mean fast rotation. At very low speed, few counts may arrive during a short time window, making a speed reading jump around.
Measuring the time between edges can give a steadier low speed estimate. This feedback is used in mobile robots, conveyor systems, 3D printers, camera mounts, and robotic arms.
Real encoder signals can fail in ways that look like motion errors. Electrical noise may create false edges. Long wires can weaken signals or pick up interference from motors.
A poor ground connection can cause the controller to read the wrong logic level. If a motor spins faster than the controller can process, counts can be lost. Students should learn to inspect the A and B signals with a logic analyzer or oscilloscope, then turn the shaft slowly in both directions and verify that the count rises and falls correctly.
After power is removed, the stored count is usually lost. A robot often performs a homing move to a limit switch or an index mark before it begins accurate position work.
Key Facts
- Counts per revolution, CPR, is the number of electrical cycles or counts produced for one full turn of the encoder disk.
- Angle per count = 360 degrees / counts per revolution.
- Angular displacement = number of counts × angle per count.
- Rotational speed = counts per second / counts per revolution in revolutions per second.
- Quadrature signals A and B are 90 electrical degrees out of phase, allowing direction detection.
- With 4x quadrature decoding, effective counts per revolution = 4 × cycles per revolution.
Vocabulary
- Optical incremental encoder
- A sensor that measures changes in shaft rotation by converting light interruptions from a rotating disk into electrical pulses.
- Slotted disk
- A wheel attached to the shaft with evenly spaced openings or markings that alternately pass and block light.
- Photodetector
- An electronic sensor that produces a signal when light from the encoder LED reaches it.
- Quadrature
- A two-channel signal arrangement in which channel A and channel B are offset so direction can be determined.
- Index pulse
- A once-per-revolution pulse used as a reference mark for locating a known shaft position.
Common Mistakes to Avoid
- Confusing incremental position with absolute position, because an incremental encoder only reports changes in position unless it is referenced to a known starting point.
- Ignoring quadrature direction, because counting pulses without checking whether A leads B or B leads A can make forward and reverse motion look the same.
- Using CPR without checking the decoding mode, because 1x, 2x, and 4x decoding can give different effective counts per revolution.
- Calculating speed from too short a time interval, because a small sample may contain too few pulses and produce a noisy or jumpy speed estimate.
Practice Questions
- 1 An encoder has 500 counts per revolution using the selected decoding mode. What angle in degrees does each count represent?
- 2 A motor shaft produces 2400 counts in 3.0 seconds with an encoder set to 800 counts per revolution. What is the rotational speed in revolutions per second and revolutions per minute?
- 3 A robot wheel encoder has channels A and B. During motion, channel A consistently changes before channel B. Explain how this information can be used by the controller, and why counting pulses alone is not enough.