A rotary encoder, also called a shaft encoder, can be used in positioning and motor speed feedback applications. In this video we explain the function of an incremental rotary encoder. Incremental rotary encoders use discs which contains transparent sections that are equally spaced.
A light-emitting diode serves a sender and it's light is detected by a photo detector. Therefore the encoder can generate a sequence of pulses. The output is measured in pulses per revolution which can be used to determine either the position or the rotational speed.
To detect the sense of rotation the encoder needs two tracks. The sense of rotation determines which signal coming from track a or track B is leading. Here you can see the signal form coming from clockwise rotation.
To have a comparison you see now the signal form coming from counterclockwise rotation. Now the signal coming from track be is leading. It is now up to the electronics to evaluate these signals.