SLAU846A June 2023 – October 2023 MSPM0G1105 , MSPM0G1106 , MSPM0G1107 , MSPM0G1505 , MSPM0G1506 , MSPM0G1507 , MSPM0G3105 , MSPM0G3105-Q1 , MSPM0G3106 , MSPM0G3106-Q1 , MSPM0G3107 , MSPM0G3107-Q1 , MSPM0G3505 , MSPM0G3505-Q1 , MSPM0G3506 , MSPM0G3506-Q1 , MSPM0G3507 , MSPM0G3507-Q1
QEI is used to decode signals from optical position encoders. Optical position encoders typically output 2 signals (PHA/PHB) which are often used to measure rotary or linear movement of physical items with rotating shafts, such as 3-phase motors. The measurement provided by the interface is incremental, which means as movement occurs, the interface provides the ability to capture the relative change from the previous position.
When operating in QEI mode, a counter accumulates the incremental updates, deriving current position from initial position and the accumulated change. The initial position can be determined by the signal of the IDX input (3-signal QEI mode) or by other software means (software directly setting the initial position). The capture and compare register can be used to store the position value by defining a capture condition.
When a direction change (DC) occurs, a DC interrupt is generated in the RIS register.
Figure 25-18 shows the state machine in the QEI interface to detect the directional rotation from the two CCP input signals, PHA and PHB.
QEI 2-Signal Mode Configuration
Configure input capture settings as described in Section 25.2.3.1.1, if desired.
Example using QEI mode with 2 input signals
The behavior of PHA/PHB follows Table 25-12 and Figure 25-19.
Current State (PHA, PHB) | Next State (PHA, PHB) | Direction (DIR) | Counter Action |
---|---|---|---|
00 | 10 | 1 (Up) | +1 (If TIMx.CTR = LOAD, then CTR = 0) |
10 | 11 | ||
11 | 01 | ||
01 | 00 | ||
00 | 01 | 0 (Down) | -1 (If TIMx.CTR = 0, then CTR = TIMx.LOAD) |
01 | 11 | ||
11 | 10 | ||
10 | 00 |