![NXP Semiconductors LCP43 Series User Manual Download Page 910](http://html1.mh-extra.com/html/nxp-semiconductors/lcp43-series/lcp43-series_user-manual_1721817910.webp)
UM10503
All information provided in this document is subject to legal disclaimers.
© NXP B.V. 2012. All rights reserved.
User manual
Rev. 1.3 — 6 July 2012
910 of 1269
NXP Semiconductors
UM10503
Chapter 31: LPC43xx Quadrature Encoder Interface (QEI)
is then cleared. The velocity timer is loaded with the contents of the velocity reload
register (LOAD). Finally, the velocity interrupt (TIM_Int) is asserted. The number of edges
counted in a given time period is directly proportional to the velocity of the encoder.
Setting the reset velocity bit (RESV) will clear the velocity counter, reset the velocity
capture register to 0xFFFF FFFF, and load the velocity timer with the contents of the
velocity reload register (LOAD).
The following equation converts the velocity counter value into an RPM value:
RPM = (PCLK
Speed
60) / Load
PPR
Edges)
where:
•
PCLK is the QEI controller clock.
•
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 CON 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 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 load
value was 2,500 (¼ of a second), it would count 20,480 pulses per update. Using the
above equation:
RPM = (10000
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
102400
60) / (2500
2048
4) = 3000 RPM
31.7.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 (CAP) 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.