Quadrature Decoder
Libraries:
Motor Control Blockset /
Sensor Decoders
Motor Control Blockset HDL Support /
Sensor Decoders
Description
The Quadrature Decoder block computes the position of the quadrature encoder.
To calculate the angular position of the quadrature encoder (and the rotor) in either degrees, radians, or per-unit, the block uses one of the following methods.
Difference between current encoder counter value and encoder counter value at the previous index pulse (when index pulse is available).
Current encoder counter value (when index pulse is not available).
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:
Equations
The block computes the angular position (in counts) of the quadrature encoder using the
Cnt
and Idx
block inputs:
When Cnt ≥ Idx:
When Cnt < Idx:
When Cnt
(an unsigned integer) exceeds the maximum value of the
selected counter size, the block adds the necessary compensation internally.
When you clear the External index count checkbox, only
Cnt
input is available, 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 (Counts per revolution = Encoder slits ⨯ Encoder counts per slit).
The block computes the output θm as:
Where, MaxPosition = 360 (degrees) or 2π (radians) or 1 (per-unit), based on the selected value of the Position unit parameter.
Examples
Ports
Input
Output
Parameters
Extended Capabilities
Version History
Introduced in R2020a