DR
AFT
DR
AFT
DRAFT
DR
D
RAFT
DRAFT
DRA
FT DRAF
D
RAFT DRAFT DRAFT DRAFT DRAFT D
DRAFT
D
RAFT DRA
FT DRAFT DRAFT DRAFT DRA
UM10316_0
© NXP B.V. 2008. All rights reserved.
User manual
Rev. 00.06 — 17 December 2008
461 of 571
NXP Semiconductors
UM10316
Chapter 27: LPC29xx Quadrature Encoder Interface (QEI)
4.
Functional description
The QEI module interprets the two-bit gray code produced by a quadrature encoder wheel
to integrate position over time and determine direction of rotation. In addition, it can
capture the velocity of the encoder wheel.
4.1 Input signals
The QEI module supports two modes of signal operation: quadrature phase mode and
clock/direction mode. In quadrature phase mode, the encoder produces two clocks that
are 90 degrees out of phase; the edge relationship is used to determine the direction of
rotation. In clock/direction mode, the encoder produces a clock signal to indicate steps
and a direction signal to indicate the direction of rotation. ).
This mode is determined by the SigMode bit of the QEI Control (QEICON) register (See
). When the SigMode bit = 1, the quadrature decoder is bypassed and the
PhA pin functions as the direction signal and PhB pin functions as the clock signal for the
counters, etc. When the SigMode bit = 0, the PhA pin and PhB pins are decoded by the
quadrature decoder. In this mode the quadrature decoder produces the direction and
clock signals for the counters, etc. In both modes the direction signal is subject to the
effects of the direction invert (DIRINV) bit.
4.1.1 Quadrature input signals
When edges on PhA lead edges on PhB , the position counter is incremented. When
edges on PhB lead edges on PhA , the position counter is decremented. When a rising
and falling edge pair is seen on one of the phases without any edges on the other, the
direction of rotation has changed.
[1]
All other state transitions are illegal and should set the ERR bit.
Interchanging of the PhA and PhB input signals are compensated by complementing the
DIR bit. When set = 1, the direction invertion bit (DIRINV) complements the DIR bit.
Table 382. Encoder states
Phase A
Phase B
state
1
0
1
1
1
2
0
1
3
0
0
4
Table 383. Encoder state transitions
from state
to state
Direction
1
2
positive
2
3
3
4
4
1
4
3
negative
3
2
2
1
1
4