EN

Pulse counting inputs

A+B, pulse and direction, CW/CCW, Z pulse, absolute and Gray code

1. Resolution and frequency

Encoder and counter
rpm
mm
kHz
\[ f_A = \frac{PPR \cdot n}{60} \]
\[ \text{counts/rev} = PPR \cdot k \qquad k = 1,\ 2,\ 4 \]

2. Timing diagram

Signals

3. Binary and Gray

Converter

Why special inputs

A normal PLC input is read once per cycle and has a filter of several milliseconds: it cannot count more than a few tens of pulses per second. For encoders, flow meters or fast part detectors, high-speed counters (HSC) are used: inputs with a short filter and a hardware counter that keeps counting while the program is busy. They accept from a few kHz to several hundred kHz depending on the model, and usually offer several input modes.

Input modes

ModeSignalsHow direction is knownTypical use
Single pulseAIt is not; it only countsPart detector, flow meter
Pulse and directionPulse + direction levelLevel of the direction signalStepper and servo drive inputs
CW/CCWUp pulses + down pulsesWhich line the pulse arrives onBidirectional counters, some drives
A+B quadratureA and B 90° apartWhich channel leads the otherIncremental encoders

Quadrature and x1, x2 and x4 multiplication

An incremental encoder gives two square signals, A and B, shifted by a quarter of a period. If A rises while B is 0, the shaft turns one way; if it rises while B is 1, the other way. Counting only the rising edges of A gives one count per pulse (x1); both edges of A give two (x2); and all four edges of A and B give four (x4). A 1024-pulse encoder thus gives 4096 positions per revolution with no other change. The drawback is that with x4 the edges arrive four times per period: the input must resolve edges a quarter of the A period apart.

Quadrature has another advantage: if the shaft vibrates at rest right on an edge, the count goes up and down alternately without accumulating error. With a single channel, each vibration would be counted as one more pulse.

The Z pulse

Many encoders have a third channel, Z (also called index or reference mark), with one pulse per revolution at a fixed position. It is used for homing: the machine moves to a home switch and then on to the next Z pulse, which sets the position with the accuracy of the encoder rather than that of the switch. High-speed counters can usually reset the count or capture its value on the Z pulse.

Absolute encoders and Gray code

An incremental encoder loses its position when power is removed and has to be homed. An absolute encoder always gives a number that identifies the position: single-turn (for example 13 bits, 8192 positions) or multi-turn, which also counts revolutions. When the output is parallel or read track by track, Gray code is used, in which only one bit changes between consecutive positions. In plain binary, going from 7 (0111) to 8 (1000) changes all four bits and, if they do not switch at exactly the same moment, any value could be read for an instant. In Gray code a reading during a transition can only give the previous or the next position.

\[ g = b \oplus (b \gg 1) \]
\[ b_{i} = g_{i} \oplus b_{i+1} \]

Today most absolute encoders send the position over a serial link (SSI, BiSS, manufacturer interfaces or fieldbuses), which usually delivers the value already in binary; Gray code still appears on parallel outputs, in some SSI encoders and in rotary selector switches.

See also: Encoders, resolvers and synchros, Number system converter, Counters and Stepper motors.