A+B, pulse and direction, CW/CCW, Z pulse, absolute and Gray code
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.
| Mode | Signals | How direction is known | Typical use |
|---|---|---|---|
| Single pulse | A | It is not; it only counts | Part detector, flow meter |
| Pulse and direction | Pulse + direction level | Level of the direction signal | Stepper and servo drive inputs |
| CW/CCW | Up pulses + down pulses | Which line the pulse arrives on | Bidirectional counters, some drives |
| A+B quadrature | A and B 90° apart | Which channel leads the other | Incremental encoders |
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.
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.
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.
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.