Compute position of quadrature encoder
Motor Control Blockset / Sensor Decoders
The Quadrature Decoder block computes the position of the quadrature encoder. The block uses the current encoder counter value and encoder counter value at the previous index pulse to calculate the angular position of the quadrature encoder (and the rotor) in either degrees, radians, or per-unit.
This figure shows a quadrature encoder disk with two channels (QEPA and QEPB) and an index pulse (QEPI):
In this example, the timer driven by the QEP increments by four for each slit:
The block computes the angular position (in counts) of the quadrature encoder as:
When the encoder rotates in the clockwise direction:
If ,
If and the shaft rotation direction does not change,
If and the shaft rotation direction reverses,
When the encoder rotates in the anticlockwise direction:
If ,
If and the shaft rotation direction does not change,
If and the shaft rotation direction reverses,
When you clear the External index count parameter, the Idx pulse resets Cnt to zero, therefore:
where:
is the angular position of the quadrature encoder in counts.
is the number of counts in one rotation cycle of the quadrature encoder.
The block computes the output θm as:
(in degrees)
(in radians)
(in per-unit)