How does a carton pusher know when to retract?
A rotary encoder is a sensor that converts shaft rotation into an electrical signal. On a carton pusher, an encoder on the drive shaft lets the controller track the pusher’s travel. To convert shaft turns to inches or millimeters, the controller needs the drive ratio and the distance the mechanism travels per turn.
Watch the outward stroke in the demonstration. The controller commands the pusher to advance, reads its position and orders the return stroke when it reaches the target. The encoder then tells the controller when the mechanism is home. If the carton slips, the shaft can still reach its target. Confirming the carton itself arrived takes a sensor at the destination.
▶ Play the encoder demonstration
How an absolute encoder reads shaft angle
1100 identifies position 8.0100) to position 8 (1100), only the outer track changes.Imagine stopping the shaft and asking, “Where are we within this turn?” A single-turn absolute encoder can answer as soon as its position data is valid, even after power returns. Each angular interval has its own code. A multi-turn encoder also reports a turn number within its specified range.
In a simple optical absolute encoder, an LED shines through a disc fixed to the shaft. Clear and opaque areas form concentric tracks. On the other side, photodetectors read the tracks together. Signal-conditioning electronics turn the light and dark readings into bits.
Four tracks give 16 positions. Four bits have 2 × 2 × 2 × 2 possible combinations. Divide 360° by 16 and each code covers 22.5°. That step size is the encoder’s resolution. Accuracy tells you how closely its reported angle matches the actual shaft angle.
Why use Gray code on the disc?
At the boundary between positions 7 and 8, ordinary four-bit binary changes from 0111 to 1000. If one detector switches slightly before the others, a reader can briefly see a code far from either position. In reflected Gray code the same transition is 0100 to 1100. Only one track changes, so a reading at that boundary resolves to one of the two neighboring positions.
How an incremental encoder shows direction
An incremental encoder reports movement in steps. Its receiver adds or subtracts counts from a known reference. If the stored count is lost, the machine needs a way to reestablish that reference, often a homing sequence.
A quadrature encoder produces two signals, A and B, offset by a quarter of a signal cycle. In the example below, A rises first. When the shaft reverses, B leads A. The counter uses that order to decide whether to count up or down.
For an encoder rated at 1,000 complete A-channel cycles per revolution, ×1 decoding gives 1,000 counts per turn. Counting both edges on both channels gives 4,000. The disc is the same in both cases. Check how the encoder and counter manuals define pulses and counts before setting the PLC scaling.
Can the PLC keep up with the encoder?
Run that same encoder at 600 RPM. That is 10 revolutions per second, so channel A produces 10,000 cycles per second. One complete cycle lasts just 0.1 ms. A PLC program checking an ordinary input every 5 ms could see it low on two consecutive checks while 50 complete cycles passed between them.
A high-speed counter (HSC) captures transitions in hardware independently of the ladder program’s scan. The program reads the accumulated count. At ×4, this example produces 40,000 counts per second. When selecting a counter, check its per-channel input frequency, supported quadrature modes and input-filter setting against the encoder signal at maximum shaft speed.
Check the scaling with one revolution. In this example the count should change by 4,000 for one shaft turn at ×4. A change of 1,000 points you toward the decoding or scaling setting. If the magnitude is correct but the sign is reversed, check the configured direction and the A/B channel assignment.
For a step-by-step example of when a controller reads inputs and updates outputs, see PLC Programming Lesson 3 – Understanding the PLC Scan Cycle on our parent site, BIN95.
Rotary encoder FAQs
What does a rotary encoder do?
It converts shaft rotation into an electrical signal. A controller can use that feedback to track angle, detect direction or calculate speed. On the carton pusher, the controller uses shaft position to determine when to reverse the drive.
What is the difference between an incremental encoder and an absolute encoder?
An incremental encoder sends pulses as the shaft moves. The controller counts them from a known reference. An absolute encoder reports a position code that the controller can read even when the shaft is stationary. After a power interruption, a single-turn absolute encoder can report the angle within the current turn. Tracking which turn the shaft is on requires multi-turn information.
What is the difference between PPR, CPR, and resolution?
PPR usually means pulses per revolution on one channel. CPR can mean cycles per revolution or decoded counts per revolution, depending on the manufacturer. Resolution describes the smallest angular step the system can distinguish. For example, 1,000 A-channel cycles per turn with ×4 decoding gives 4,000 counts per turn, or 0.09° per count. Check which unit your PLC expects before entering the value.
What are the main sensing technologies used in rotary encoders?
Optical encoders read a patterned disc with light. Magnetic encoders sense a changing magnetic field. Capacitive encoders measure changes in capacitance as a patterned rotor turns, while inductive encoders detect changes in coupling between coils and a rotating target. Mechanical contact encoders, often found in hand-operated knobs, use a wiper that opens and closes electrical contacts.
What is the difference between an optical and a mechanical encoder in terms of lifespan?
An optical encoder typically lasts longer than a mechanical contact encoder, although the application and operating environment affect the lifespan of both. A mechanical contact encoder has a wiper that rubs against a track, so repeated turns wear the contacts. An optical encoder reads its disc without touching it, which generally suits frequent or continuous rotation. Its service life still depends on factors such as bearing load, temperature and contamination. For a specific application, compare the manufacturers’ life ratings under the expected operating conditions.