20.2 Architectural Overview
The Quadrature Encoder Interface (QEI) module provides the interface to incremental encoders for obtaining mechanical position data. Quadrature encoders, also known as incremental encoders or optical encoders, detect position and speed of rotating motion systems. Quadrature encoders enable closed-loop control of motor control applications, such as Switched Reluctance (SR) and AC Induction Motors (ACIM).
A typical quadrature encoder includes a slotted wheel attached to the shaft of the motor and an emitter/detector module that senses the slots in the wheel. Typically, three output channels, Phase A (QEAx), Phase B (QEBx) and Index (INDXx) provide information on the movement of the motor shaft, including distance and direction.
The two channels, Phase A (QEA) and Phase B (QEB), are typically 90º out of phase with respect to each other. The Phase A and Phase B channels have a unique relationship. If Phase A leads Phase B, the direction of the motor is deemed positive or forward. If Phase A lags Phase B, the direction of the motor is deemed negative or reverse. The index pulse occurs once per mechanical revolution and is used as a reference to indicate an absolute position. Figure 20-1 illustrates the Quadrature Encoder Interface signals.
The quadrature signals from the encoder can have four unique states
(‘01
’
, ‘00
’
, ‘10
’
and ‘11
’
) that reflect the
relationship between QEA and QEB. Figure 20-1
illustrates these states for one count cycle. The order of the states get reversed when the
direction of travel changes.
The quadrature decoder increments or decrements the 32-bit up/down Position Counter (POSxCNT) for each Change-of-State (COS). The counter increments when QEA leads QEB and decrements when QEB leads QEA.
Table 2-1 shows the truth table that describes how the quadrature signals are decoded.
Current Quadrature State | Previous Quadrature State | Action | ||
---|---|---|---|---|
QEA | QEB | QEA | QEB | |
1 | 1 | 1 | 1 | No count or direction change |
1 | 1 | 1 | 0 | Count up |
1 | 1 | 0 | 1 | Count down |
1 | 1 | 0 | 0 | Invalid state change, ignore |
1 | 0 | 1 | 1 | Count down |
1 | 0 | 1 | 0 | No count or direction change |
1 | 0 | 0 | 1 | Invalid state change, ignore |
1 | 0 | 0 | 0 | Count up |
0 | 1 | 1 | 1 | Count up |
0 | 1 | 1 | 0 | Invalid state change, ignore |
0 | 1 | 0 | 1 | No count or direction change |
0 | 1 | 0 | 0 | Count down |
0 | 0 | 1 | 1 | Invalid state change, ignore |
0 | 0 | 1 | 0 | Count down |
0 | 0 | 0 | 1 | Count up |
0 | 0 | 0 | 0 | No count or direction change |
Figure 20-2 illustrates the simplified block diagram of the QEI module. The QEI module consists of decoder logic to interpret the Phase A (QEA) and Phase B (QEB) signals, and an up/down counter to accumulate the count. The counter pulses are generated when the quadrature state changes. The count direction information must be maintained in a register until a direction change is detected. The module also includes digital noise filters that condition the input signal.