UM10360 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2013. All rights reserved.
User manual Rev. 3 — 19 December 2013  547 of 841
NXP Semiconductors
UM10360
Chapter 26: LPC176x/5x Quadrature Encoder Interface (QEI)
 
Figure 129 shows how quadrature encoder signals equate to direction and count.
 
26.4.1.2 Digital input filtering
All three encoder inputs (PhA, PhB, and index) require digital filtering. The number of 
sample clocks is user programmable from 1 to 4,294,967,295 (0xFFFF FFFF). In order for 
a transition to be accepted, the input signal must remain in new state for the programmed 
number of sample clocks.
26.4.2 Position capture
The capture mode for the position integrator can be set to update the position counter on 
every edge of the PhA signal or to update on every edge of both PhA and PhB. Updating 
the position counter on every PhA and PhB provides more positional resolution at the cost 
of less range in the positional counter.
The position integrator and velocity capture can be independently enabled. Alternatively, 
the phase signals can be interpreted as a clock and direction signal as output by some 
encoders.
The position counter is automatically reset on one of two conditions. Incrementing past 
the maximum position value (QEIMAXPOS) will reset the position counter to zero. If the 
reset on index bit (
RESPI) is set, sensing the index pulse will reset the position counter to 
zero.
26.4.3 Velocity capture
The velocity capture has a programmable timer and a capture register. It counts the 
number of phase edges (using the same configuration as for the position integrator) in a 
given time period. When the velocity timer (QEITIME) overflows the contents of the 
velocity counter (QEIVEL) are transferred to the capture (QEICAP) register. The velocity 
counter is then cleared. The velocity timer is loaded with the contents of the velocity 
reload register (QEILOAD). Finally, the velocity interrupt (TIM_Int) is asserted. The 
Table 481. Encoder direction 
DIR bit DIRINV bit direction
00forward
10reverse
01reverse
11forward
Fig 129.Quadrature Encoder Basic Operation
PhA
PhB
direction
position
-1 -1 -1 -1 -1-1 -1 -1 -1 -1-1 -1 -1 -1-1-1 -1 -1 -1 -1-1 -1 -1 -1 +1 +1 +1 +1 +1 +1 +1 +1