Implementating Space Vector Modulation ADMC300
Implementating Space Vector Modulation ADMC300
Implementating Space Vector Modulation ADMC300
Implementing
Space Vector Modulation
with the ADMC300
AN300-17
Table of Contents
SUMMARY...................................................................................................................... 3
Summary
The introduction of space vectors, originally only for the purpose of analysis of three-phase machines, has
led to the development of an inherently digital modulation method, in contrast to some mere digital
approximations to traditional analogue techniques. This technique is nowadays commonly known as
space vector modulation (SVM). This application note gives an extensive introduction to its theory and
provides routines that allow for easy implementation of SVM into the user’s control algorithm. They are
implemented in a library-like module for immediate and intuitive application.
Reference Vref
waveforms
Vcarrier
(fs)-1
Comparator
ouput
Vd/2
VA0
t
-Vd/2
It may be shown that the magnitude of the fundamental component varies linearly with the fraction
magnitude
= , called the modulation index.
referen
m triangular
magnitude
carrie
A sinusoidal output voltage may therefore be produced, which is proportional to the desired value and
whose magnitude is varied by varying the reference's magnitude. The resultant output voltage, of course,
contains all the high frequency switching components. It is also an easy task to vary its frequency by
changing the frequency of the reference signal.
However, the maximum output voltage amplitude obtainable with this approach is ½Vd as mtriangular may
not exceed unity. By applying a rectangular square wave on one inverter leg the fundamental is
4 ⋅ 1 ⋅V = 2 ⋅V . This mode is known as six-step and entails increased harmonic distortion. It follows
π 2 d π d
that only 78.5% of the inverter's capacity is used with sinusoidal modulation. In addition, a separate
modulator has to be used for each of the inverter legs, generating three reference signals forming a
balanced three-phase system.
The approach to pulse width modulation that is described in this application note is based on the space
vector representation of the voltage in the stationary reference frame, which was defined in a previous
note1. Given a set of inverter pole voltages (VA0,VB0,VC0), the vector components (Vα , Vβ) in this frame
are found by the Forward Clarke transform:
2π
r 2 r r r r j
V = Vα + jV β = (V A0 a 0 + VB 0 a 1 + VC 0 a 2 ) where a=e 3
(1)
3
It is known that a balanced three-phase set of voltages is represented in the stationary reference frame by
a space vector of constant magnitude, equal to the amplitude of the voltages, and rotating with angular
speed ω = 2π ⋅ fRe f . As will be seen in the next section, the eight possible states of an inverter are
represented as two null-vectors and six active-state vectors forming a hexagon. SVM now approximates
the rotating reference vector in each switching cycle by switching between the two nearest active-state
vectors and the null-vectors. In order to maintain the effective switching frequency of the power devices
at a minimum, the sequence of toggling between these vectors is organised such that only one leg is
affected in every step.
It may be anticipated that the maximum obtainable output voltage is increased with ordinary SVM up to
90.6% of the inverter capability. It is also a relatively easy task to improve this technique in order to reach
full inverter capability.
1
AN300-11: Reference Frame Conversions with the ADMC300
β
V3=(0,1,0) V2=(1,1,0)
II
Vd/2
III I
0 A B C V4=(0,1,1) V0=(0,0,0)
V
ref V1=(1,0,0)
Vd V7=(1,1,1) α
IV VI
Vd/2
V
V5=(0,0,1) V6=(1,0,1)
a) b)
It is easily shown that the six non-null states, in the following called active states, are represented by
space vectors
π
r 2 j ( k −1)
Vk = Vd e 3
with ( k=1,...,6 ) (2)
3
forming a regular hexagon and dividing it into six equal sectors denoted as I, II, III, IV, V, VI in Figure
2b.
r
A mean space vector Vref over a switching period TS can be defined. Assuming that TS is sufficiently
r
small, V ref can be considered approximately constant during this interval, and it is this vector which
generates the fundamental behaviour of the machine.
r
The Continuous Space Vector Modulation technique is based on the fact that every vector Vref inside the
dashed hexagon can be expressed as a weighted average combination of the two adjacent active space
vectors and the null-state vectors 0 and 7. Therefore, in each cycle imposing the desired reference vector
may be achieved by switching between these four inverter states. Looking at Figure 2b one finds that,
r r r
assuming Vref to be laying in sector k, the adjacent active vectors are Vk and Vk +1 , where k+1 is set to 1
for k=6. In order to obtain optimum harmonic performance and the minimum switching frequency for
each of the power devices, the state sequence is arranged such that the transition from one state to the next
is performed by switching only one inverter leg. This condition is met if the sequence begins with one
zero-state and the inverter poles are toggled until the other null-state is reached. To complete the cycle the
sequence is reversed, ending with the first zero-state. If, for instance, the reference vector sits in sector 1,
the state sequence has to be ...0127210... whereas in sector 4 it is ...0547450... The central part of the
space vector modulation strategy is the computation of both the active and zero-state times for each
modulation cycle. These may be calculated by equating the applied average voltage to the desired value.
r
In the following, Tk denotes half the on-time of vector Vk . T0 is half the null-state time. Hence, the on-
times are evaluated by the following equations:
TS T0 T0 T0 TS
+Tk +Tk +Tk +1
2r 2 r 2 r 2 r 2r
∫0
Vref dt = ∫
0
V0 dt + ∫ V k dt
T0
+ ∫ k +1 dt +
V
T0 T0
∫ 7 dt
V (3)
2 2
+Tk 2
+Tk +Tk +1
T
T0 + Tk + Tk +1 = S (4)
2
r r r r r r
Taking into account that V0 = V7 ≡ 0 and that VRe f is assumed constant and the fact that Vk , Vk +1 are
constant vectors, equation (3) reduces to
r T r r
VRe f ⋅ S = Vk ⋅ Tk + Vk +1 ⋅ Tk +1 (5)
2
Splitting this vectorial equation into its real and imaginary components, from (2) follows that:
cos
(k − 1)π kπ (k − 1)π kπ
Vα TS 2 cos cos cos
= Vd Tk 3 + T 1 3 = 2V 3 3 Tk (6)
V 2 3 (k − 1)π k+
kπ d
3 sin (k − 1)π kπ Tk +1
β sin sin sin
3 3 3 3
where k is to be determined from the argument of the reference vector
Vα
α = arg (7)
Vβ
(k − 1)π Vα kπ
such that ≤ arg ≤
3 . (8)
3 Vβ
The request of minimal number of commutations per cycle is met if in every odd sector the
r r r r r r r
sequence of applied vectors is V0 Vk Vk +1 V7 Vk +1 Vk V0 , whereas in even sector the active vectors
r r r r r r r
are applied in the reversed order, hence V0 Vk +1 Vk V7 Vk Vk +1 V0 .
Solving system (6), one finds:
kπ kπ
sin 3 − cos
Tk
=
3 TS
⋅ 3 ⋅ Vα
(9)
Tk +1 2 Vd − sin
(k − 1)π cos
(k − 1)π Vβ
3 3
The total null-state time T0 may be divided in an arbitrary fashion between the two zero states. A common
solution is to divide T0 equally between the two null-state vectors V 0 and V 7 . From (4), T0 results as
TS
T0 = − (Tk + Tk +1 ) (10)
2
As an example for the switching scheme, in sector 1 one finds:
1 PWMa
0 PWMb
1
0 PWMc
Figure 3: PWM output signals for a particular case with the reference vector sitting in sector I
Assuming that is desired to produce a balanced system of sinusoidal phase voltages, it is known that the
r r r
corresponding space vector locus is circular. Imposing VRe f = VRe f e jωt = VRe f ⋅ (cos(ωt ) + j sin (ωt )) ,
r
where V Re f is the magnitude and ω is the angular frequency of the desired phase voltages, it follows
from (9) that
kπ kπ
3 V ref sin 3 − cos
Tk
= ⋅ TS ⋅ 3 ⋅ cos ωt (11)
Tk +1 2 Vd − sin
(k − 1)π cos
(k − 1)π sin ωt
3 3
While 0 ≤ ωt ≤ π 3 the reference vector lies in sectors 1 and equation (11) reduces to
r π
V
T
1 3 Re f sin( − ωt )
= TS 3 (12)
T2 2 V d sin ωt
The mean values of the inverter pole voltages averaged over one switching cycle are thus
r
Vd T0 T0 3 VRe f
V A0 (ωt ) = 2TS (− 2 + T1 + T2 + T0 + T2 + T1 − ) = 2 2 V Vd cos(ωt − π6 )
r d
3 VRe f
VB 0 (ωt ) = 2VTdS (− T20 − T1 + T2 + T0 + T2 − T1 − T20 ) = 2 Vd Vd sin(ωt − π6 ) (13)
VC 0 (ωt ) = − V A0 (ωt )
Analogous, solving equation (11) for the other sector one finds
r
V A0 (ωt ) = 2
3
VRe f cos(ωt − π6 ) 0 ≤ ωt ≤ π3
r
= 2 VRe f cos ωt ≤ ωt ≤
3 π 2π
3 3
r
= 2 VRe f cos(ωt + 6 ) ≤ ωt ≤ π
3 π 2π
3
r
= 2 VRe f cos(ωt − 6 ) π ≤ ωt ≤
3 π 4π
3
r (14)
= 2 VRe f cos ωt ≤ ωt ≤
3 4π 5π
3 3
r
= Re f cos(ωt + 6 ) ≤ ωt ≤ 2π
3 π 5π
2 V 3
vA0
π 2π
π
_ ωt
3
in Figure 5, where the six different voltage levels, corresponding to operation at each of the active
inverter states, are clearly seen.
V
AN
4π 5π
Vmaxsixstep 3
π 3 ωt
π 2π 2V 2π
d
3 3 3
Figure 5: Resultant inverter phase voltage and corresponding fundamental component for six-step
operation.
The fundamental component of the six-step voltage waveform is also illustrated in Figure 5. From the
Fourier analysis, the fundamental voltage magnitude is given by:
4 Vd
Vmax sixstep = . (16)
π 2
This voltage level is achieved only at the expense of significant low frequency distortion. It was already
mentioned that for conventional sinusoidal modulation the maximum achievable fundamental voltage is:
Vd
Vmax sin pwm = (17)
2
so that only 78.5% of the available inverter capacity is used.
If the space vector modulator is required to produce a balanced three-phase system of voltages of
magnitude Vref and frequency ω, given by:
V AN = Vref cos(ω t )
VBN = Vref cos(ω t − 23π ) (18)
VCN = Vref cos(ω t − 43π )
the corresponding reference voltage space vector is given by:
Therefore, the reference space vector describes a circular trajectory of radius Vref at an angular velocity ω
in the complex plane. Clearly, the largest possible voltage magnitude that may be achieved using the
space vector modulation strategy corresponds to the radius of the largest circle that can be inscribed
within the hexagon of Figure 2b. This circle is tangential to the midpoints of the lines connecting the ends
of the active state vectors. The maximum fundamental phase voltage that may be achieved is:
r
VRe f = 23 Vd 2
3
= 1
3
Vd (21)
max
Following the definition of modulation index introduced in above, the corresponding maximum
modulation index is given by
r
VRe f 1 ⋅ Vd π
3
mmax cont = max
= = = 0.906 (22)
Vmax sixstep 2
π ⋅ Vd 2 3
As seen, the maximum peak fundamental magnitude that may be obtained with the SVM technique is
about 90.6 % of the inverter capacity. This represents a 15% increase in the maximum voltage compared
with conventional sinusoidal modulation.
The maximum output line voltage magnitude is, from equation (15):
r
VˆAB max = 3 VRe f = Vd (23)
max
With the definition of modulation index the computation of the inverter switching times does not require
the knowledge of the adopted DC-link voltage but depends only on the desired modulation index. This
r
may be seen observing that VRe f = m ⋅ Vmax sixstep = m ⋅ 2 π ⋅ Vd and substituting this equation in (11),
leading to:
kπ kπ
sin 3 − cos
Tk
= m ⋅
3
TS ⋅ 3 ⋅ cos ωt (24)
Tk +1 π − sin
(k − 1)π cos
(k − 1)π sin ωt
3 3
It is possible to increase this modulation index up to operation in six-step mode (m=1) by operating in
discontinuous SVM introducing additional distortion of the line currents. This is achieved by directly
modifying the magnitude and/or angle of the reference vector. This issue is not treated in this application
note. However, the adopted scaling choice of m leaves the options to the user of easily extending the
inverter’s range of operation to full modulation.
When the desired trajectory passes outside the hexagon, the time average equations (10) give negative
(and therefore meaningless) values for the on-duration T0 of the zero-state vectors. It is possible to
overcome this problem by simply 'rescaling' the active state times Tk and Tk+1 to:
TS Tk
T 'k =
2 Tk + Tk +1
(25)
T Tk +1
T 'k +1 = S
2 Tk + Tk +1
so that T ' k +T ' k +1 = 12 TS and T0=0 . It is clear from (5) that the magnitude of the produced vector is
reduced by the same factor.
r 2 r r 2 r r r
V ' Re f =
TS
(Vk ⋅ T 'k +Vk +1 ⋅ T ' k +1 =
TS
) (
Vk ⋅ Tk + Vk +1 ⋅ Tk +1 ⋅
TS
=) TS
2(Tk + Tk +1 ) 2(Tk + Tk +1 )
⋅VRe f (26)
The effective locus now follows the hexagon line causing a reduction in the output fundamental voltage.
This may be shown, for instance, in sector I by observing that:
rT r r
V S = V1 ⋅ T1 '+V2 ⋅ T2 ' (27)
2
Hence, from equation (12):
π
r 2 TS r sin ( −α ) r
⋅ V1 =
sin α
V = ⋅ 3
+ V2
TS 2 π
sin ( −α ) + sin α sin ( −α ) + sin α
π
3 3
2 1 π 2 cosα =
= Vd ⋅ 1π ⋅ sin( − α ) + 1
1 3
2
sin α = Vd ⋅ π ⋅ 2 (28)
3 sin ( +α )
3 0 3
3
2 3 sin ( +α )
3
3
2
sinα
=
Vd
3
⋅ 1
π
sin ( +α )
( )
⋅ cosα
sinα
3
Although the rescaling of the on-state times solves the problem of the obtained meaningless
switching instants, it also causes a reduction of the output voltage with respect to the desired
value.
Vβ
Θ = arctan , Θ ∈ [0,2π ] (30)
Vα
However, this approach involves two time-intensive operations arctan(x) and the division and, in addition,
imposes the condition on Vα to be not equal to zero. These difficulties may be overcome by observing
that each quadrant is shared by two sectors. The quadrant in which the reference vector sits is easily
determined by examining the sign of its real and imaginary components. Having determined the quadrant,
for instance 1, the vector lies in sector I if
Vβ π
arctan ≤ (31)
Vα 3
π
hence Vβ ≤ Vα tan = 3 ⋅ Vα , (32)
3
otherwise the vector lies in sector II. In our case this condition reduces to sin ωt ≤ 3 ⋅ cos ωt . This
method needs only a multiplication and a few comparisons.
Analogous, in quadrant 2 (with Vα < 0,Vβ > 0 ) one finds:
Vβ π
sector III if arctan ≤
− Vα 3
or Vβ ≤ 3 ⋅ (−Vα ) ; sector II otherwise.
Similar considerations apply to quadrant 3 and 4.
The input vector Vαβ consists of two elements holding the components of the stator quantity vector. In the
case of a necessity to re-scale the on-times, this vector will become also an output, since the routine will
reflect the reduction of it’s magnitude. The OnTime_vector contains the current sector and the on-times
of both the active vectors and zero-state vectors after a call to SVM_Calc_Ontimes. Finally, the
Dutycycles_vector holds the duty-cycles for each phase after a call to SVM_Calc_Dutycycles. They may
be loaded into the PWM block by a call to SVM_Update_Dutycycles. The format of inputs and outputs
are explained in more detail in the next section.
The reason for splitting the SV modulation process into three separate subroutines is to maintain the
maximum of flexibility. Having access to the on-times and duty-cycles leaves the options of
compensating for switching dead-times, inverter on-state voltages and/or DC-link voltage ripple in an
optimal fashion.
The routines do not require any configuration constants from the main include-file “main.h” that comes
with every application note. For more information about the general structure of the application notes and
including libraries into user applications refer to the Library Documentation File. Section 3 shows an
example of usage of this library. In the following sections each routine is explained in detail with the
relevant segments of code which is found in either “svpwm.h” or “svpwm.dsp”. For more information see
the comments in those files.
reference as in (20) leads to a reference vector with magnitude equal to the modulation index and
comprised in the range from zero to one (90.6% for continuous SVM).
In conclusion, if the input vector is of constant magnitude m and rotates at constant angular speed, the
amplitude VˆxN of the produced three-phase system is related to m such that
2
VˆAN , BN ,CN = Vd ⋅ m (33)
π
where m is in the range of 0 (0x0000) to 0.906 (0x7415) for continuous SVM (reference vector inside the
hexagon at all times) and 0.906 (0x7416) to 1 (0x7FFF) when trajectories that are partially outside the
hexagon are demanded. In the latter case, Vα and Vβ will be replaced by the scaled values after executing
SVM_Calc_Ontimes.
The output OnTime_vector stores information about the sector (1 to 6) that the reference vector lays in,
the on-time of the first vector to be applied (Vk for odd sectors, Vk+1 for even sectors), the on-time of the
second vector to be applied (Vk+1 for odd sectors, Vk for even sectors) and finally the total zero state time
T0.
The output DutyCylces_vector holds the duty cycles value for channel A, B and C respectively.
On-times and duty-cycles are expressed as increments of the PWM timer, therefore in the range of 0 to
the content of the PWM period register PWMTM.
2
^vector stands for ‘address of vector’
3
N/A: The output values are stored in the output vector in Data Memory. No DSP core register is used.
The first task of the SVM routine is to determine the current sector, which the reference vector lays in. The
following piece of code achieves this through the algorithm presented in section 1.5. After executing this
piece, ax0 contains the number of the sector (0x0001 to 0x0006).
SVPWM_Ontimes_:
ax1= DM(I0,M0);
ay1= DM(I0,M0);
my0=One_Over_Sqrt3;
ar = pass ay1;
if lt jump Sector456;
af=pass ax1, ar = ax1;
if lt jump Sector32;
mx0=ay1;
mr=mx0*my0 (rnd);
none=mr1 -af;
if gt jump Sector2;
Sector1: ax0= 1;
jump Solve_equation;
Sector32:
af=abs ar;
if AV af=af-1;
mx0=ay1;
mr=mx0*my0 (rnd);
none=mr1 - af;
if gt jump Sector2;
Sector3: ax0= 3;
jump Solve_equation;
Sector2: ax0= 2;
jump Solve_equation;
Sector456:
af=pass ax1, ar = ax1;
if lt jump Sector45;
ar = pass ay1;
ar=abs ar;
if AV ar=ar-1;
mr=ar*my0 (rnd);
af= pass ax1;
none=mr1-af;
if gt jump Sector5;
Sector6: ax0= 6;
jump Solve_equation;
Sector45:
ar=abs ar;
if AV ar=ar-1;
af=pass ar;
ar = pass ay1;
ar=abs ar;
if AV ar=ar-1;
mr=ar*my0 (rnd);
none=mr1-af;
if gt jump Sector5;
Sector4: ax0= 4;
jump Solve_equation;
Sector5: ax0= 5;
jump Solve_equation;
Next, equation (24) is effectively computed. The core is a sequence of MAC operations, which implement the
matrix multiplication. The comments show what values are calculated. Then the values are multiplied by the
PWM period. However, since the PWMTM register is represents half of the PWM period, the obtained value
has to be multiplied by two (shifted to the left). Note that it is not possible to incorporate the factor 2 into the
vectors of constant since some of them would be greater than one. Also, depending on whether the sector is
even or odd, the values for Ta and Tb are organised into sr such that the lower word contains the on-time for
the first vector to be applied and the higher word the on-time for the second vector.
Solve_equation:
DM(I1,M1)=ax0; { store no. of sector }
ay0= ^SineVector - 1;
ar = ax0 + ay0;
I6 = ar;
M6 = 1;
L6 = %SineVector;
ay0= ^CosineVector - 1;
ar = ax0 + ay0;
I7 = ar;
M7 = 1;
L7 = %CosineVector;
mx0 = ax1;
mx1 = ay1;
my1 = DM(PWMTM); {Ts/2 }
astat = ax0;
if EQ jump Sector_odd;
Sector_even:
sr = ASHIFT mr1 by 1 (HI); { Tb for even sectors }
sr = sr or ASHIFT si BY 1 (LO); { Ta for even sectors }
jump SVM_saturate;
Sector_odd:
sr = ASHIFT si by 1 (HI); { Tb for odd sectors }
sr = sr or ASHIFT mr1 BY 1 (LO); { Ta for odd sectors }
At last, the computation of the zero-state time is executed. Clearly, if this value is negative, the demanded
vector lays outside the hexagon and needs to be re-scaled, as explained in section 1.4. In that case, a division
is necessary (code labelled by saturation). Since the on-times are positive numbers and Ta+Tb is greater
that Ts/2, a very simple division routine is implemented. The last instructions just copies the obtained values
into the output vector.
SVM_saturate:
ay0 = sr0;
ar = sr1 + ay0; { Ta + Tb }
ay0= ar;
ar = DM(PWMTM); { Ts/2 }
af = pass ar; { store Ts/2 into af for eventual division }
ar = ar - ay0; { T0 }
if GE jump NO_saturation;
sr0 = mr1;
mr = sr1 * my0 (SS); { Tb scaled }
sr1 = mr1;
ar = pass 0; { T0 }
NO_saturation:
DM(I1,M1) = sr0; { first ontime }
DM(I1,M1) = sr1; { second ontime }
DM(I1,M1) = ar; { T0 }
rts;
The routines for calculating the duty-cycles is really only a jump-table which assigns the right values to
channels A, B and C, depending on the current sector. The duty-cycles are calculated from the on-times and
denoted as small, middle and big duty-cycle. Then, depending on the sector, these values are related to the
correct channel and copied into the output vector.
SVPWM_DutyCycles_:
ax0= DM(I1,M1); { sector }
ar = ax0 - 1;
sr = ASHIFT ar by 2 (LO);
af = pass sr0; { af = 4*(sector-1) }
ar = ^Jump_table;
ar = ar + af;
I4 = ar;
jump(I4);
Jump_table:
Sec1: DM(I2,M2) = mr1;
DM(I2,M2) = sr1;
DM(I2,M2) = sr0;
rts;
Sec2: DM(I2,M2) = sr1;
DM(I2,M2) = mr1;
DM(I2,M2) = sr0;
rts;
Sec3: DM(I2,M2) = sr0;
DM(I2,M2) = mr1;
DM(I2,M2) = sr1;
rts;
Sec4: DM(I2,M2) = sr0;
DM(I2,M2) = sr1;
DM(I2,M2) = mr1;
rts;
Sec5: DM(I2,M2) = sr1;
DM(I2,M2) = sr0;
DM(I2,M2) = mr1;
rts;
Sec6: DM(I2,M2) = mr1;
DM(I2,M2) = sr0;
DM(I2,M2) = sr1;
rts;
I1= ^%1;
M1 = 1;
L1 = 0;
call SVPWM_Ontimes_;
.ENDMACRO;
I2= ^%1;
M2 = 1;
L2 = 0;
call SVPWM_DutyCycles_;
.ENDMACRO;
.MACRO SVPWM_Update_DutyCycles(%0);
I1 = ^%0;
M1 = 1;
L1 = 0;
4
AN300-03: Generation of Three-Phase Sine-Wave PWM
5
AN300-11: Reference Frame Conversions with the ADMC300
on it from Windows Explorer. This will create the object files and the main.exe example file. This file
may be run on the Motion Control Debugger.
In the following, a brief description of the additional code (put in evidence by bold characters) is given.
Start of code – declaring start location in program memory
.MODULE/RAM/SEG=USER_PM1/ABS=0x60 Main_Program;
Next, the general systems constants and PWM configuration constants (main.h – see the next section) are
included. Also included are the PWM library, the DAC interface, the reference conversion library and the
space vector modulation module definitions
{***************************************************************************************
* Include General System Parameters and Libraries *
***************************************************************************************}
#include <main.h>;
#include <pwm300.h>;
#include <dac300.h>;
#include <trigono.h>;
#include <refframe.h>;
#include <svpwm.h>;
Variables, Labels and Scope definitions. Here is where all the vectors for the SVM routines are declared.
{***************************************************************************************
* Local Variables Defined in this Module *
***************************************************************************************}
.VAR/RAM/DM/SEG=USER_DM OnTime_struct[1*4];
.INIT OnTime_struct: 0x0000, 0x0000, 0x0000, 0x0000;
.VAR/RAM/DM/SEG=USER_DM Dutycycles_struct[1*3];
.INIT Dutycycles_struct: 0x0000, 0x0000, 0x0000;
Startup:
PWM_Init(PWMSYNC_ISR, PWMTRIP_ISR);
DAC_Init;
rts;
The interrupt service routine simply shows how to generate a balanced three-phase system similar to the
already cited previous application note. Since the conversion routines make use of the pointer register I1, the
DAC operations are to be stopped during their execution. Obviously, this may be removed when removing
the DAC from the final application (refer to the application note on the DAC for a description of its
commands and to section 2.3 for details of register usage of the conversion routines). What follows (in bold
characters) is the actual generation. First, the current angle Theta is computed by incrementing it by an
amount which is dependent on the demanded frequency AD_IN. This is almost identical as in the application
note AN300-03, except for the fact that this time only one angle is required. This angle is then used by the
forward Park transformation to convert a constant vector in the rotor reference frame of components AD_IN
and 0 into a uniformly rotating vector in the stationary reference frame. Note that the default value given in
this example is set to the limit of continuous SVM mentioned in section 1.3. This reference vector is the one
used in the actual sequence of calls, which calculates on-times and duty-cycles and updates the PWM block.
The following lines just update the DAC buffer for the digital-to-analog conversion. The default is the
conversion of the angle Theta, the demanded duty-cycles for channels A,B and C (multiplied by 0x8 for
visualisation purposes), the current sector (multiplied by 0x800 for visualisation purposes) and the reference
vector Vαβ. Section 3.3 will show the outputs that are produced by this example.
{********************************************************************************************}
{ PWM Interrupt Service Routine }
{********************************************************************************************}
PWMSYNC_ISR:
ar = DM(AD_IN);
mr = 0; {Clear mr }
mr1 = dm(Theta); {Preload Theta }
my0 = Delta;
mr = mr + ar*my0 (SS); {Compute new angle & store }
dm(Theta) = mr1;
refframe_Set_DAG_registers_for_transformations;
refframe_Forward_Park_angle(Vdq_ref,Valphabeta_ref,mr1);
{ generate Vreference in alpha-beta frame }
Dac_Resume;
mx0 = 0x8;
my0 = DM(Dutycycles_struct ); mr = mx0 * my0 (SS); Dac_Put(2, mr0);
my0 = DM(Dutycycles_struct+1); mr = mx0 * my0 (SS); Dac_Put(3, mr0);
my0 = DM(Dutycycles_struct+2); mr = mx0 * my0 (SS); Dac_Put(4, mr0);
mx0 = 0x800;
my0 = DM(OnTime_struct ); mr = mx0 * my0 (SS); Dac_Put(5, mr0);
DAC_Update;
RTI;
{********************************************************************************************}
ωt Vα Vβ Va0
Vb0
Vc0
ωt
Figure 6: Reference vector (left) and inverter pole voltages (right) in continuous SVM
The effects of the scaling in order to limit the reference vector within the hexagon are shown in the next
figure. This time, the modulation index is set to full modulation, i.e. m=+1 (0x7FFF). Therefore, the
(scaled) reference vector entirely follows the hexagon.
ωt Vα Vβ
Va0
Vb0
Vc0
ωt
Figure 7: Reference vector (left) and inverter pole voltages (right) in full modulation