Optical Encoder Signal Conditioning Design
An optical encoder produces two square waves in quadrature and often a third index pulse once per revolution. The signal conditioning circuit turns those into counts, and its quality decides the resolution, the immunity to noise and the maximum speed of the axis.
The Outputs and What They Mean
Channels A and B are in quadrature, which means they are ninety degrees apart. The direction of rotation is derived from which channel leads, and the resolution is quadrupled by counting both edges of both channels.
The index pulse marks a known position once per revolution, and it is used to establish an absolute reference at power up. Its width is one count of the encoder, which is why it needs a fast input or a latch.
Some encoders also provide a commutation output for a motor, which gives the coarse position needed to start a brushless drive. The signals are usually differential and the timing between them has to be preserved.
Differential and Single Ended Outputs
A differential output, driven by a line driver, is the normal choice for a cable of any length. The receiver is a differential comparator, and the pair rejects the noise that the cable picks up.
A single ended output works over a short cable inside a machine, and it is more sensitive to the ground difference between the encoder and the controller. Where both are available, the differential output is worth the extra conductors.
The differential pair should be terminated at the receiver with a resistor equal to the cable impedance, usually a hundred and twenty ohms. Some drivers have the termination built in, and adding a second one halves the amplitude.

Thresholds and Hysteresis
The receiver threshold sits at the middle of the differential swing, and it must not be disturbed by the common mode of the pair. A receiver with a wide common mode range and a hysteresis of a few tens of millivolts is the right choice.
Hysteresis prevents the output from chattering while the input is crossing the threshold, which happens when the disc edge is slow or when the LED current has dropped. A receiver without hysteresis produces extra counts at certain speeds.
Where the encoder signal is single ended, a Schmitt trigger input with a defined threshold and hysteresis replaces the differential receiver. The threshold should be set from the actual signal levels measured at the controller.
Filtering and Bandwidth
A filter on the encoder inputs removes the noise that would otherwise be counted. Its corner has to be above the highest signal frequency, which is the count rate at maximum speed, or the edges will be rounded and the counts lost.
The count rate is the resolution multiplied by the speed. An encoder with four thousand counts per revolution turning at three thousand revolutions per minute produces two hundred thousand counts per second per channel, which sets the bandwidth the conditioning circuit has to pass.
Filtering in the digital domain cannot remove what has already been counted. An analog filter at the receiver, followed by a digital filter that rejects pulses shorter than a defined width, is the combination that works.

interpolation and Resolution
The resolution of the encoder is set by the number of lines on the disc and by the electronics. interpolation increases the resolution by dividing each period into a number of parts using the analog shape of the signal.
An interpolator needs the sine and cosine components of the signal rather than the square waves, and those come from an encoder with analog outputs or from a filtering technique applied to the digital ones. The accuracy depends on how closely the signals approximate a sine.
interpolation is limited by the quality of the disc and the alignment of the read head. Beyond a certain division, the periodic errors of the encoder dominate and more resolution does not mean more accuracy.
The index pulse and Its Handling
The index pulse is narrow and it arrives at the same position every revolution. It is used to set an absolute reference, and a missed index means the axis loses its reference without any other symptom.
A hardware latch that captures the count when the index arrives is more reliable than a software interrupt, because the interrupt latency would introduce a position error. The captured value is then used to correct the count.
The index should be validated over several revolutions before it is accepted as the reference. A single pulse that arrives at an unexpected count indicates noise rather than a genuine index.
Counting and the Controller Interface
The counter counts edges and derives the direction from the state of the two channels. A hardware quadrature counter in a timer peripheral removes the software timing jitter and allows a much higher count rate.
A counter that overflows must be handled without losing counts. Reading the counter periodically and adding the difference to a wider software value is the standard approach, and the period has to be short enough that the counter cannot wrap twice.
The controller has to know whether the count is valid. A channel that has lost a signal produces a count that looks plausible, and a plausibility check against the expected speed catches it.
Cable and Connector Practice
The encoder cable carries signals at the count rate and it usually runs beside the motor cables that carry the drive current. Separation, screening and a twisted pair for each channel are what keep the two apart.
The screen should be earthed at the controller end. Earthed at both ends it carries the machine ground current, and the resulting noise then appears in every channel at the same instant.
The connector is a common failure point on a moving axis. A connector that is pulled by the cable eventually makes an intermittent contact, and the count then jumps by a random amount that takes a long time to trace.
Verification and Faults
Verify the channels with an oscilloscope at the controller input while turning the shaft slowly. The four edges per period should be evenly spaced, and an uneven spacing indicates a misaligned read head.
Measure the signal amplitude at the far end of the cable. A differential amplitude below the receiver threshold at one end of the travel indicates a cable or a termination problem.
A count that is lost only at high speed is a bandwidth problem, and one that is lost only at low speed is usually a threshold problem. The release checks that keep such an interface consistent are collected in our PCB design release checklist, the assembly points in judging PCB quality, and the measures that control a fast differential signal in our guide to high speed PCB design rules.
FAQ
Do I need differential encoder signals? For any cable longer than a few tens of centimetres, yes. The pair rejects the noise that a single ended signal carries into the counter.
Why do I lose counts at high speed? The bandwidth of the receiver or the filter is too low for the count rate. Check the corner against the maximum count rate.
What is the index pulse for? It gives an absolute reference once per revolution. Without it the axis position is only known relative to where it started.



