
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
UM10360_0
© NXP B.V. 2009. All rights reserved.
User manual
Rev. 00.06 — 5 June 2009
520 of 808
NXP Semiconductors
UM10360
Chapter 26: LPC17xx Quadrature Encoder Interface (QEI)
number of edges counted in a given time period is directly proportional to the velocity of
the encoder. Setting the reset velocity bit (RESV) has the same effect as an overflow of
the velocity timer, except that the setting the RESV bit will not generate a velocity
interrupt.
The following equation converts the velocity counter value into an RPM value:
RPM = (clock * (2 ^ VelDiv) * Speed * 60) ÷ (Load * ppr * edges)
where:
•
clock is the controller clock rate
•
ppr is the number of pulses per revolution of the physical encoder
•
edges is 2 or 4, based on the capture mode set in the QEICON register (2 for
CapMode set to 0 and 4 for CapMode set to 1)
For example, consider a motor running at 600 RPM. A 2048 pulse per revolution
quadrature encoder is attached to the motor, producing 8192 phase edges per revolution.
With a velocity predivider of ÷1 (VelDiv set to 0) and clocking on both PhA and PhB edges,
this results in 81,920 pulses per second (the motor turns 10 times per second). If the timer
were clocked at 10,000 Hz, and the loadvalue was 2,500 (¼ of a second), it would count
20,480 pulses per update. Using the above equation:
RPM = (10000 * 1 * 20480 * 60) ÷ (2500 * 2048 * 4) = 600 RPM
Now, consider that the motor is sped up to 3000 RPM. This results in 409,600 pulses per
second, or 102,400 every ¼ of a second. Again, the above equation gives:
RPM = (10000 * 1 * 102400 * 60) ÷ (2500 * 2048 * 4) = 3000 RPM
4.4 Velocity compare
In addition to velocity capture, the velocity measurement system includes a
programmable velocity compare register. After every velocity capture event the contents
of the velocity capture register (QEICAP) is compared with the contents of the velocity
compare register (VELCOMP). If the captured velocity is less than the compare value an
interrupt is asserted provided that the velocity compare interrupt enable bit is set. This can
be used to determine if a motor shaft is either stalled or moving too slow.
5.
Pin description
[1]
The Quadrature Encoder Interface uses the same pin functions as the Motor Control PWM feedback inputs
and are connected when the Motor Control PWM function is selected on these pins. If used as part of motor
control, the QEI is an alternative to feedback directly to the MCPWM.
Table 464. QEI pin description
Pin name
I/O
Description
I
Used as the Phase A (PHA) input to the Quadrature Encoder Interface.
I
Used as the Phase B (PHB) input to the Quadrature Encoder Interface.
I
Used as the Index (IDX) input to the Quadrature Encoder Interface.