How to Use a Rotary Encoder with a PLC?

Two encoder measuring wheels on a spring arm ride on cardboard as it feeds through a cutting machine.
Table of Contents

A carton passes a photoelectric sensor on its way to a labeler 300mm farther down a conveyor. If the line slows, a timer set for the original belt speed will trigger too early. A rotary encoder gives the PLC a way to follow the carton through that speed change. The sensor marks its arrival, a measuring wheel tracks the belt, and the PLC triggers the labeler after the belt has advanced 300mm. This assumes the carton travels with the belt.

To set that up, decide where to measure the motion, match the encoder signal to a compatible input, and give each count a value in machine units. The example below uses an incremental rotary encoder with two pulse channels, A and B. If your encoder sends an absolute position word, configure its specified interface and read that value from the drive or controller. The mechanical relationship between shaft rotation and belt travel still applies.

Choose Where to Measure the Motion

For motor speed, the motor shaft is a sensible place to measure. For the distance a carton travels, follow the belt surface. A motor-mounted encoder can keep reporting shaft rotation even when the belt slips at the drive roller. A spring-loaded measuring wheel on the belt follows the motion that matters to the labeler. Choose a wheel surface and contact force suitable for the material.

Demonstration conveyor with a measuring wheel on top of the belt and a second encoder at the end roller.
The measuring wheel near the center follows the belt surface. The encoder at the lower left follows the roller shaft. Photo from Encoder Products Company’s conveyor demonstration.

With the wheel directly coupled to the encoder and rolling without slip, one wheel turn moves the belt by one effective wheel circumference. A 300mm wheel therefore travels 150mm in half a turn. If a gearbox or belt drive sits between the encoder and the measured shaft, include its ratio when calculating counts per turn of that shaft.

Match the Encoder Output to the PLC Input

Start with the output type and voltage on the encoder’s exact part number. An NPN open-collector output and a differential line driver need different receiving circuits. For example, the CHB38S/H encoder family offers both options. On the controller side, the UE20 high-speed counter family includes separate NPN, PNP and differential input models. Use the terminal assignments for the selected pair and configure the input for A/B quadrature.

The two channels are offset by a quarter of an electrical cycle. Which one changes first tells the counter which way the shaft is turning. In the configuration illustrated below, A leads B during forward travel. In ×4 mode the counter registers every rising and falling edge on both channels. If the encoder also has a Z index, its usual once-per-turn pulse can serve as a shaft reference. The carton sensor supplies the separate event that starts tracking each carton.

Forward motion has A leading B and counts rising from 0 to 4. Reverse motion has B leading A and counts falling from 4 to 0.
Read each trace from left to right. In ×4 mode, every rising or falling edge on either channel changes the count by one. The dashed lines mark those four instants. Diagram based on Beckhoff’s quadrature input documentation.

Convert Counts into Distance and Speed

Kübler gives a conveyor example with a 300mm wheel circumference and a 1000 PPR encoder. For the calculation, take 1000 PPR to mean 1000 full cycles on A per shaft revolution, assume direct coupling and no slip, and set the PLC to ×4 decoding. The PPR definition matters because some datasheets already quote the decoded count. Kübler’s conveyor measuring-wheel example.

Quantity Calculation for this conveyor
PLC counts per wheel revolution 1000 cycles × 4 counts per cycle = 4000 counts
Belt travel per count 300mm ÷ 4000 counts = 0.075mm per count
Average speed over 1s of forward travel 4000 counts × 0.075mm per count ÷ 1s = 300mm/s

At the leading edge of each carton, capture the current count and add 4000 to obtain that carton’s label target. If the belt reverses, the signed count falls and the carton must regain that distance before it reaches the labeler. A run of 300mm forward and 75mm backward leaves the carton 225mm ahead of its start, after 375mm of total travel. Use net count for its position. For shaft speed, the same one-revolution change over 1s equals 60rpm.

Check both ends of the speed range when specifying the hardware. Suppose the controller must distinguish 0.10mm steps. A 300mm wheel needs at least 3000 decoded counts per turn, or 750 cycles per turn at ×4. At a peak belt speed of 1.5m/s, the selected 1000 PPR encoder turns five times a second. That produces 5kHz on each channel and 20,000 count transitions per second. Compare those figures with the encoder output limit and the counter’s rating for the selected input mode. Read the units on each rating.

Check Direction, Scale, and Wheel Contact

Check the installation in the machine’s commissioning mode. First observe the count during a known forward move, then during a reverse move. Next, record the change over one marked wheel revolution. With this setup its magnitude should be 4000. A reading of 1000 points to a ×1 setting or a different interpretation of the encoder’s resolution. This check isolates electronic scaling before wheel contact enters the measurement.

Now compare the indicated distance with an independently measured belt movement. Over 600mm in one direction, the example predicts 8000 counts. A repeatable scale error calls for checking the effective circumference and any transmission ratio. If repeated runs over the same length scatter, look for intermittent wheel contact, then inspect signal quality and count rate. Increasing PPR alone cannot recover movement that the wheel did not follow.

The cardboard cutter in the cover photo illustrates the distinction. Hipsher Tool & Die found that seams in the cardboard briefly lifted the measuring wheel. The replacement kept the same counts per unit length and used a spring-loaded assembly that maintained contact. For the 300mm label offset, the corresponding acceptance check is that the carton reaches the labeler at the target count across the line’s operating speeds. Encoder Products Company’s Hipsher case study.