Beruflich Dokumente
Kultur Dokumente
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 2 / 23
Encoders
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 3 / 23
Incremental Encoders
Incremental encoders do NOT generate a code
corresponding to the shaft position
Absolute encoders do
Instead, incremental encoders generate pulses based
on shaft movement
Relative movement of the shaft can be measured by
counting these pulses (edges)
Usually, the act of counting is not done by the encoder
The eQEP module takes care of it
By measuring the time elapsed between pulses, rotor
speed can be calculated
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 4 / 23
What is an Incremental Quadrature Encoder?
A digital (angular) position sensor
photo sensors spaced /4 deg. apart
slots spaced deg. apart /4
light source (LED)
QEPA
QEPB
shaft rotation
1 3
2 4
1 line
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 7 / 23
eQEP Module
The eQEP module is a logic circuit inside the DSP
A peripheral
It facilitates measurement of position and speed with
minimum CPU intervention
It receives the quadrature pulses from the encoder,
and counts them
The eQEP hardware also extracts direction data and
reflects it in the QEPSTS:QDF flag bit
The eQEP decodes the encoded data
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 8 / 23
eQEP Module
The decoder submodule of the eQEP module generates a
QCLK clock pulse on every edge of the QA and QB signals
Counting the number of edges instead of pulses doubles the
position measurement resolution
Use of two light sensors again doubles the resolution.
If there are 1000 lines on the disk:
The resolution is 4*1000 clock pulses per revolution
That means the smallest detectable shaft movement is
360/4000
Some Encoders have built-in decoders, i.e., they generate
CLK and DIR instead of quadrature signals. eQEP can also
work with such encoders. (The QDECCTL:QSRC should be
set to 1)
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 9 / 23
Quadrature Clock and Direction Decoding
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 10 / 23
Decoding Direction
At each QCLK interval, only 1 of the QEP signals changes status
The optical sensors are mounted with a 90 phase shift
Counting the number of edges instead of pulses doubles the position
measurement resolution
If a change of status in both is detected, the QFLG:PHE error flag will
be set and an interrupt may be requested
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 11 / 23
Delfino eQEP
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 12 / 23
eQEP
Measures position by counting QCLK pulses in the 32-bit eQEP Position
Counter Register (QPOSCNT)
The QPOSCNT increments on a QCLK pulse when the direction signal
(QDIR) is one (forward)
The QPOSCNT decrements on a QCLK pulse when the direction signal
(QDIR) is zero (reverse)
The position counter has 32 bits
Cannot exceed the range [0 , 232-1]
The maximum value of QPOSCNT is imposed by the programmer via
the QPOSMAX register, and its minimum is zero
It wraps around to zero when it overflows (instead of going to QPOSMAX+1)
It jumps to QPOSMAX upon an underflow (instead of going to -1)
It can also be configured to reset to zero upon a Unit Time-Out event via
the QEPCTL:PCRM field
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 13 / 23
eQEP Main Signals
QPOSMAX=3999 (0xF9F)
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 14 / 23
Simple Speed Measurement Method
Configure the eQEP module and reset QPOSCNT to 0
Configure one of the CPU or ePWM timers to periodically
request an interrupt
Inside the ISR, read and then reset QPOSCNT
This value indicates the shaft rotation during the timer period
Divide the movement by the timer period to find speed
If required, scale the result to the desired unit (rpm, rad/sec, etc)
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 15 / 23
Speed Measurement Using eQEPs
Unit Timer
Use the eQEPs 32-bit Unit Timer, i.e., QUTMR
It always operates at the CPU clock (non-prescalable)
Automatically resets to zero when it hits its period register
value (QUPRD)
Generates a Unit Time-Out pulse upon resetting
The QPOSCNT value is automatically captured and saved in the
QPOSLAT register
An interrupt is requested from the PIE
The program can read the latched value in the ISR and
calculate speed
The numerator of v(k) depends on rotor speed,
The denominator is fixed and does not depend on speed.
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 16 / 23
Speed Measurement Using eQEPs
Unit Timer
Angular velocity formula
x(k) - x(k - 1)
v(k ) ,
T
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 17 / 23
Speed Measurement using eQEPs
Unit Timer
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 18 / 23
Problem with the Unit Timer Position
Measurement Approach
What is the problem with this unit timer position
measurement approach?
Hint: think about the velocity formula
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 19 / 23
Speed Measurement Over a Unit Distance
Instead of counting pulses in a unit of time, this approach
measures the elapsed time during a unit of distance
Unit of distance is a multiple of QCLK edges
The previous approach fixed time and measured distance
This approach fixes distance and measures time
It uses the eQEPs Capture Timer
If an application requires high accuracy at low and high
speeds?
Switch between the two approaches based on the motor speed
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 20 / 23
Comparison of Speed Measurement
Approaches
Fixed time interval
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 21 / 23
Comparison of Speed Measurement
Approaches
Fixed
time
approach
Fixed
distance
approach
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 22 / 23
eQEP Module Block Diagram
Measure the elapsed time
between the unit position events;
used for low speed measurement
Quadrature
Generate periodic
Capture
interrupts for velocity Quadrature -
calculations clock mode
Monitors the quadrature
clock to indicate proper
operation of the motion EQEPxA/XCLK
control system
32-Bit Unit EQEPxB/XDIR
Timer Quadrature
QEP Decoder EQEPxI
Watchdog
SYSCLKOUT
Position Counter
& Compare
Generate the direction and
clock for the position counter
Measure rotor in quadrature count mode
movement and generate
a sync output and/or
interrupt on a position
compare match
2017 Texas A&M University Advanced Electric Machines & Power Electronics (EMPE) Lab 23 / 23