robotics//sensor//rotary encoder
A rotary encoder is a sensor that reports the angle of a shaft as a digital signal, a pulse or a code for each small step of rotation, and it closes the position and speed loops of servo motors, robot joints, conveyors and the wheels of mobile robots. An optical encoder shines light through a disc with fine slots; a magnetic one reads a magnetized ring with Hall or magnetoresistive elements, sturdier against dust and oil.
A rotary encoder is a sensor that reports the angle of a shaft as a digital signal, a pulse or a code for each small step of rotation, and it closes the position and speed loops of servo motors, robot joints, conveyors and the wheels of mobile robots. An optical encoder shines light through a disc with fine slots; a magnetic one reads a magnetized ring with Hall or magnetoresistive elements, sturdier against dust and oil.
An incremental encoder produces two square waves, A and B, a quarter period apart. Counting their edges gives the angle relative to where counting began, and which wave leads gives the direction; counting every edge of both gives four counts per slot, so a disc of NNN lines resolves 360∘/(4N)360^\circ/(4N)360∘/(4N) (0.09° for 1000 lines). A third channel gives one index pulse per turn as a reference. An absolute encoder gives instead a unique code for every position, so it knows the angle at power-up without a homing move, at a higher price.
Resolution is the step, and counting is exact until a pulse is lost. Electrical noise on a long cable, a speed beyond what the counter can follow or a slipping coupling make an incremental encoder miss or add counts, and the error then stays in the angle until the next index pulse or homing; nothing in the signal says it happened.
Speed has to be derived, and at low speed that is hard. Counting pulses in a fixed period gives a quantized speed (at two or three counts per period, consecutive readings jump by a third or more), and timing the interval between pulses instead suits slow motion; servo drives switch between the two (quantization).
An encoder measures the shaft, nothing beyond it. On a wheel it counts turns faithfully while the wheel slips on a wet floor, so the robot's odometry drifts although every pulse was right; the gap between motor encoder and load (backlash, elastic shafts) is a classic source of limit cycles in a position loop.