Quadrature Decoder (Q-Decoder)
User Manual All information provided in this document is subject to legal disclaimers. © REALTEK 2019. All rights reserved.
455
21.2.2
Position Measurement
21.2.2.1
Position Counter Measurement
This hardware IP is designed to decode the quadrature signals from I/O pin. The Q-Decoder hardware can generate the position counter(PC)
and the direction by the state changes of the signal PHA and PHB. So the software can get the position by reading related registers. Fig 21-4
shows how a Q-decoder counts the position and detects the direction by PHA and PHB .
00
10
11
01
+1
+1
+1
+1
-1
-1
-1
-1
State Error
Fig 21-4 Quadrature decoder phase state
In the example of Fig 21-5 and Fig 21-6, the maximum position counter(MPC) is set to 199. If the movement direction is forward and the
position counter is equal to MPC, the PC is reset to 0 on the next state. If the movement direction is reverse and the position counter is 0, the
PC is reset to MPC on the next state. The difference between these two examples is CNT_SC. CNT_SC bit is used to configure the number of
phase state changed for the position accumulation counter to be increased/decreased by 1, if CNT_SC = 0, position counter
increases/decreases on every phase state change. If CNT_SC = 1, only PHA changes can trigger position counter change.
+1
+1
+1
+1
199
+1
1
+1
+1
+1
+1
+1
+1
+1
+1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
2
3
4
5
6
7
8
198
197
196
7
6
5
4
3
2
1
0
199
198 197
196
PHA
PHB
PC
Direction
0
195
195
MPC=199
Fig 21-5 Position count state when CNT_SC = 0
Realtek confidential files
The document authorized to
SZ99iot
2019-05-15 10:08:03