Pape 13
Pape 13
Pape 13
Processor Applications in
Power Electronics
TMS320f28335
ePWM
Siba Kumar Patro
ePWM
• What is PWM and its use?
• ePWM: Enhanced PWM. These are of two types: standard 16 bit mode
and 24-bit high resolution PWM mode (HRPWM)
ePWm can generate two PWMs (EPWMxA and EPWMxB, x=1, 2, …6)
related to each other or independent from each other. It can be single
ended signal or a pair of output signals.
ePWM Block Diagram
CMPA . 15 - 0 CMPB . 15 - 0
TBCTL . 12 - 7
Shadowed Shadowed
Clock Compare Compare
Prescaler Register Register
AQCTLA . 11 - 0
TBCTR . 15 - 0
AQCTLB . 11 - 0 DBCTL . 4 - 0
16-Bit
Compare Action Dead
Time-Base
TBCLK Logic Qualifier Band
Counter
EPWMxSYNCI EPWMxSYNCO
Period
Register EPWMxA
PWM Trip
Shadowed
Chopper Zone
SYSCLKOUT TBPRD . 15 - 0 EPWMxB
PCCTL . 10 - 0
TZy
TZSEL . 15 - 0
ePWM
1. Register TBPRD defines the length of a period of an output signal, in
multiples of the time-period of the input signal.
2. Another unique feature of the F2833x is its “shadow” functionality of
operating registers, in the case of ePWM units available for compare
register A, B and period register.
3. For some applications it is necessary to modify the values inside a compare
or period register, every period. The advantage of the background registers
is that we can prepare the values for the next period in the current one.
Without a background function we would have to wait for the end of the
current period, and then trigger a high prioritized interrupt. Sometimes this
form of scheduling will miss its deadline…
ePWM Phase Synchronisation
1. Two hardware signals "SYNCI" (synch in) and "SYNCO" (synch out) can
be used to synchronize ePWM units to each other.
2. For example, we could define one ePWM unit as a "master" to generate an
output signal "SYNCO" each time the counter equals period.
3. Two more ePWM units could be initialized to recognize this signal as
"SYNCI" and start immediately counting, each time they receive this
signal.
4. In such way we have established a synchronous set of 3 ePWM channels.
But we can do even better. By using another register called "TBPHS" we
can introduce a phase shift between master, slave 1 and slave 2, an
absolute necessity for three-phase control systems.
5
ePWM Phase Synchronization
Ext. SyncIn
(optional)
Phase
=0°
En
o o
SyncIn
EPWM1A
o
CTR=zero o
CTR=CMPB o o EPWM1B
X o
SyncOut
To eCAP1
SyncIn
Phase
=120°
En
o o
SyncIn
EPWM2A =120°
o
CTR=zero o
CTR=CMPB o o EPWM2B
X o
SyncOut
Phase
=240°
En
o o
SyncIn
EPWM3A
=120°
o
CTR=zero o
CTR=CMPB o o EPWM3B
X o
SyncOut =240°
1. Register TBCNT of ePWM2 and ePWM3 are preloaded with
a start value that corresponds to 120° and 240° respectively.
2. In this example ePWM1 has been initialized as master to
generate SYNCO each time the counter register equals zero.
3. With the enabled phase input feature for ePWM2 and ePWM3
the two channels operate as slave 1 and slave 2 and will load
their counter registers TBCNT with numbers stored in the
corresponding phase registers TBPHS.
Example:
• ePWM1 counts from 0 to 6000. TBPRD = 6000
• ePWM2 register TBPHS = 2000
• ePWM3 register TBPHS = 4000
ePWM Time-Base Count Modes
TBCTR
TBPRD
Asymmetrical
Waveform
Count Up Mode
TBCTR
TBPRD
Asymmetrical
Waveform
TBPRD
Symmetrical
Waveform
TBCTL :
EPwm1Regs.TBCTL.all = 0x1234;
A bit field access to fields "CLKDIV" only would look like:
EPwm1Regs.TBCTL.bit.CLKDIV = 7;
ePWM Register TBCTL
Lower Register:
Counter Mode
00 = count up
Software Force Sync Pulse 01 = count down
0 = no action 10 = count up and down
1 = force one-time sync 11 = stop – freeze (default)
6 5-4 3 2 1-0
SWFSYNC SYNCOSEL PRDLD PHSEN CTRMODE
15 - 14 13 12 - 10 9-7
FREE_SOFT PHSDIR CLKDIV HSPCLKDIV
15 - 3 2 1 0
reserved CTRMAX SYNCI CTRDIR
• Registers involved:
• TBPRD: define signal frequency
• TBCTL: setup operating mode and time prescale
• AQCTLA: define signal shape for ePWM1A
1 TPWM
TBPRD
2 TSYSCLKOUT CLKDIV HSPCLKDIV
GPIO - A Multiplex Register GPAMUX1
GPAMUX1 - Bits 00 01 10 11
1,0 GPIO0 EPWM1A - -
3,2 GPIO1 EPWM1B ECAP6 MFSRB
5,4 GPIO2 EPWM2A - -
7,6 GPIO3 EPWM2B ECAP5 MCLKRB
9,8 GPIO4 EPWM3A - -
11,10 GPIO5 EPWM3B MFSRA ECAP1
13,12 GPIO6 EPWM4A EPWMSYNCI EPWMSYNC0
15,14 GPIO7 EPWM4B MCLKRA ECAP2
17,16 GPIO8 EPWM5A CANTXB /ADCSOCA0
19,18 GPIO9 EPWM5B SCITXDB ECAP3
21,20 GPIO10 EPWM6A CANRXB /ADCSOCB0
23,22 GPIO11 EPWM6B SCIRXDB ECAP4
25,24 GPIO12 /TZ1 CANTXB SPISIMOB
27,26 GPIO13 /TZ2 CANRXB SPISOMIB
29,28 GPIO14 /TZ3_/XHOLD SCITXDB SPICLKB
31,30 GPIO15 /TZ4_/XHOLDA SCIRXDB /SPISTEB
• Registers involved:
• TBPRD: define signal frequency
• TBCTL: setup operating mode and time prescale
• AQCTLA: define signal shape for ePWM1A
1 TPWM 1 103
TBPRD
2 TSYSCLKOUT CLKDIV HSPCLKDIV 2 150 106 1 1 2
up down
mod e
Action Qualifier Control Register
EPwmxRegs.AQCTLy (y = A or B)
1 TPWM
TBPRD
2 TSYSCLKOUT CLKDIV HSPCLKDIV
Objective-3:
Generate a 3 phase system
• Generate three 1 KHz square wave signals at ePWM1A, 2A
and 3A with duty cycles of 50 % and a phase shift of 120°
and 240° between the signals
• Measure all three signals with an oscilloscope
• Registers involved:
• TBPRD: define signal frequency
• TBCTL: setup operating mode and time prescale
• AQCTLA: define signal shape for ePWM1A
• TBPHS: definition of the phase shift for 2A and 3A
1 TPWM
TBPRD
2 TSYSCLKOUT CLKDIV HSPCLKDIV
Objective-3:
• define ePWM1A as the master phase to generate a SYNCOUT pulse each time its
counter register TBCNT equals zero.
• For ePWM2, enable a SYNCIN - pulse and also define SYNCIN as SYNCOUT to drive
it into ePWM3 unit.
• for ePWM2 and ePWM3, a phase shift of 1/3rd and 2/3rd of that value preloaded in
register TBPHS.
• Step 1
EPwm1Regs.TBCTL: Sync Out Select: generate a signal if CTR = 0
6 5-4 3 2 1-0
SWFSYNC SYNCOSEL PRDLD PHSEN CTRMODE
• Registers involved:
• TBPRD: define signal frequency
• TBCTL: setup operating mode and time prescale
• AQCTLA: define signal shape for ePWM1A
• TBPHS: definition of the phase shift for 2A and 3A
1 TPWM
TBPRD
2 TSYSCLKOUT CLKDIV HSPCLKDIV
What is Pulse Width Modulation?
• PWM is a scheme to represent a signal as a sequence of pulses
Solution:- modulation is based on another set of control registers of a unit called “Compare Module”.
t t
T
Original Signal PWM representation
Why use PWM with Power Switching Devices?
DC Supply DC Supply
? PWM
Desired PWM approx.
signal to of desired
system signal
Unknown Base Signal Base Signal known with PWM
ePWM Compare Module
CMPA . 15 - 0 CMPB . 15 - 0
TBCTL . 12 - 7
Shadowed Shadowed
Clock Compare Compare
Prescaler Register Register
AQCTLA . 11 - 0
TBCTR . 15 - 0
AQCTLB . 11 - 0 DBCTL . 4 - 0
16-Bit
Compare Action Dead
Time-Base
TBCLK Logic Qualifier Band
Counter
EPWMxSYNCI EPWMxSYNCI
Period
Register EPWMxA
PWM Trip
Shadowed
Chopper Zone
SYSCLKOUT TBPRD . 15 - 0 EPWMxB
PCCTL . 10 - 0
TZy
TZSEL . 15 - 0
ePWM Compare Event Waveforms
TBCTR = compare events are fed to the Action Qualifier Module
Depending on the
TBPRD
CMPA
CMPB Asymmetrical
Waveform
pre-selected
operating mode of the
ePWM unit, it is Count Up Mode
possible to define 2 TBCTR
or 4 events within a
period of the PWM - TBPRD
frequency, by CMPA Asymmetrical
choosing the CMPB Waveform
appropriate values in
CMPA and/or CMPB. Count Down Mode
TBCTR
TBPRD
CMPA
CMPB
Symmetrical
Waveform
By changing this set-point between 0 and 100% of the period, we can adjust the duty
cycle of the output signal.
With a PWM signal we can represent any analogue output signal as a series of digital
pulses! All we need to do with this pulse series is to integrate it (with a simple low
pass filter) to imitate the desired signal. This way we can build a sine wave shaped
output signal. The more pulses we use for one period of the desired signal, the more
precisely we can imitate it. We speak very often of two different frequencies, the
PWM-frequency (or sometimes “carrier frequency”) and the desired signal
frequency.
A lot of practical applications have an internal integrator. For example the windings
of an electrical motor are perfectly suited to behave as a low-pass filter.
Shadows or Background registers can be used to prepare a new value for the next coming period while the current period
is still running and may still rely on the value in the foreground.
ePWM Compare Control Register
EPwmxRegs.CMPCTL CMPA and CMPB Shadow Full Flag
(bit automatically clears on load)
0 = shadow not full
1 = shadow full
15 - 10 9 8 7
reserved SHDWBFULL SHDWAFULL reserved
6 5 4 3-2 1-0
SHDWBMODE reserved SHDWAMODE LOADBMODE LOADAMODE
CMPA and CMPB Operating Mode CMPA and CMPB Shadow Load Mode
0 = shadow mode; 00 = load on CTR = 0
double buffer w/ shadow register 01 = load on CTR = PRD
1 = immediate mode; 10 = load on CTR = 0 or PRD
shadow register not used 11 = freeze (no load possible)
LOADxMODE:
• define the hardware event, which will copy a value from background into the active foreground register
SHDWxMODE:
• enable (0) or disable (1) the background update mode. If disabled, all write instructions will immediately change the value
in register CMPA or CMPB
SHDWxFULL:
• read only status field. If shadow is full (1) and the hardware copies the value into foreground, the bit is cleared
automatically
For most applications it is highly recommended to use this shadow feature, since it eases the urgency of accesses to the
CMP registers, when we change these values on a cycle-by-cycle base, sometimes called “on the fly”.
After a hardware reset, or by default, shadow mode is enabled and LOADxMODE is set to “load on CTR=0”; If we don’t
initialize CMPCTL at all, the default mode will be active.
Thank You
33