EN
SensorsBasicencoderquadratureGray code

Rotary encoders

In 30 secondsAn encoder tells the motor where it is. With two phase-shifted channels (A and B) you know how far it has turned and in which direction.

Also available in: Català · Castellano

The idea

Without an encoder, the motor doesn’t know where it is. The encoder is the sensor that closes the loop: the PID compares its reading with the desired position.

Incremental (quadrature)

  • Two channels, A and B, shifted by a quarter of a period.
  • Counting edges tells you how far it has turned; seeing which channel leads tells you the direction.
  • With a single channel there is no direction.
  • x1 / x2 / x4 modes: counting more edges gives more resolution from the same disc.

Absolute

Every position has a unique code, so you know where you are at power-up. It uses Gray code: only one bit changes between neighbouring positions, so a reading taken halfway never gives a wild value.

Resolution

A 12-bit encoder has 4096 positions per turn: one step is 360/4096 ≈ 0.088°.

In the demo: drag the disc, switch between x1/x2/x4 and then go to the absolute tab with Gray code.

Interactive demo

Related concepts