Definition: Digital encoders convert analog motion (rotary or linear) to a digital output form. An optical encoder is an electromechanical device which has an electrical output in digital form proportional to the angular position of the input shaft. Optical encoders enable an angular displacement to be converted directly into a digital form.
Measurement of rotary motion using optical encoder : An optical encoder is an angular position sensor. It has a shaft mechanically coupled to an input driver which rotates a disc rigidly fixed to it. A succession of opaque and transparent segments is marked on the surface of the disc. On one side of the disc are LEDs and on the other side there are photosensitive receivers like photodiodes or photo transistors. When the disc rotates and opaque segments are between LEDs and receivers, no light reaches the receivers and output is zero. When the transparent segments are between LEDs and receivers, light is received by the receivers and output signal is obtained. In this way a train of pulses equivalent to the rotation is obtained as shown.