You are on page 1of 24

a V/F Controller on the ADMCF32X ANF32X-24

Constant Volts/Hertz Operation for


Variable Speed Control of Induction
Motors
Software example of a Space Vector Modulation
driven Volts/Hertz converter with the ADMCF32X

ANF32X-24

© Analog Devices Inc., February 2001 Page 1 of 24


a V/F Controller on the ADMCF32X ANF32X-24

Table of Contents

SUMMARY...................................................................................................................... 3

1 THE INDUCTION MACHINE .................................................................................... 3

1.1 Theory / Construction ....................................................................................................................................3


1.1.1 Change of Speed ......................................................................................................................................5
1.1.2 The Torque...............................................................................................................................................5
1.1.3 “Number-plate” of the machine ...............................................................................................................6

2 THE FREQUENCY CONVERTER............................................................................ 7

2.1 The "standard" system - Hardware .............................................................................................................7

2.2 The control-functions build up in the ADMCF32X.....................................................................................8


2.2.1 Basics - Standard .....................................................................................................................................8
2.2.2 Third-harmonic Injected ..........................................................................................................................9
2.2.3 Space Vector Modulation – SVM..........................................................................................................10
2.2.4 Ramps / Boost........................................................................................................................................12

3 THE V/F APPLICATION ROUTINES ..................................................................... 14

3.1 Using the V/F Application Routines............................................................................................................14

3.2 Configuring / resetting the PowerIRtrain: IR_reset_PIO3 ......................................................................15

3.3 Ramps-module - Configuration of the Ramps: Ramps_Init_Speed_profile; ..........................................15

3.4 Ramps-module - Setting the minimum speed: Set_Minimum_Speed;.....................................................16

3.5 Ramps-module - Set the acceleration of the speed ramp: .........................................................................16

3.6 V_F-module - Calculate Voltage and Angle: V_F_ctrl_Calculate_Angle_volt .......................................18

3.7 V_F-module - Update the SVM and Dutycycles: V_F_ctrl_SVM_Calculation ......................................20

4 SOFTWARE EXAMPLE: CONSTANT VOLT/HERTZ OPERATION - WITH SVM


AND RAMPS ................................................................................................................ 20

4.1 The main program: Main.dsp .....................................................................................................................20

4.2 The main include file: main.h ......................................................................................................................23

5 REFERENCE.......................................................................................................... 24

© Analog Devices Inc., February 2001 Page 2 of 24


a V/F Controller on the ADMCF32X ANF32X-24

Summary

This applications note describes how to control an ACIM with the use of a frequency converter. The
theory behind the system and several different ways of speed-controlling an induction motor are
discussed. Finally an example of control-schemes are described and illustrated in code.

1 The induction Machine


The induction machine is the most common motor today. It has been around for the last century and are
therefor "the" motor in many applications. Besides being a well-known motor it is manufactured all over
the world - which makes it easy to find a dealer anywhere in the world. One of the reasons for being "the"
motor of choice is that the induction will run directly on the distribution net, this has until today been the
most important factor. Today speed controlling is a necessary and therefore different control applications
have to be introduced.

1.1 Theory / Construction


The standard motor is designed with a short-circuiting rotor (on Figure 1 done in aluminum) and a set of
coils placed in the stator. The housing surrounds the complete "package" where the terminals for the
stator-coils are accessible.

Figure 1 - Photo of induction machine

Looking at the motor from an electrical side, the ACIM consists of six coils, three coils in the stator and
three in the rotor (See Figure 2). Looking at these coils it is possible to make the electrical equivalent
diagram for the machine. This equivalent is represented by reactance's and resistors, here X = 2π•f•L [Ω].

© Analog Devices Inc., February 2001 Page 3 of 24


a V/F Controller on the ADMCF32X ANF32X-24

Stator

Rotor

Figure 2 - Principal of Induction Machine


L is the inductance and f is the frequency. The 2π•f = ω is in this case the current change per. time-unit.
The coils in the rotor and stator are interacting on each other due to the common magnetic induction. This
interaction are described though RFE - iron core and hysteresis losses Xh - magnetic losses.
R1 X1 X’2 R’2/s

I1

RFE Xh

Figure 3 - Equivalent circuit for one phase

When the motor is loaded in the normal load area, the rotor-frequency will differ from the frequency
made from the rotational-field created on stator - the slip. In the equivalent this change can be described
as an adjustment of R'2 with the factor 1/s (see Figure 4), where s = the slip.

R1 X1 X’2 R’2

I1 I’2

1− s 
RFE Xh R2 '  
 s 

Figure 4 - Equivalent circuit for one phase with load

© Analog Devices Inc., February 2001 Page 4 of 24


a V/F Controller on the ADMCF32X ANF32X-24

1.1.1 Change of Speed


The change of speed on the induction machine can be changed in 3 different ways, which can be
described towards the definition of the rotor speed:

f * 60
n = n0 − ns = − ns [1]
p
where,
n0 is the rotational field created from stator.
ns is the slip speed.
p the number of polepairs.

This equation indicates the three ways of changing the speed on the shaft. Changing the slip, the polepairs
or the frequency. Slip-changes can only be done from either changing the rotor resistant (Phase-Wound
Motors) or the input-voltage on stator. Polepair change; again a direct change of the motor-windings,
where a coupling between different phases can be achieved. The last control-way is the frequency here
the only limit is the source added to the motor. If the voltage applied to the machine can be changed from
low voltage / frequency to high voltage /frequency an optimal speed-control is achievable.

1.1.2 The Torque


Looking at Figure 4 the equivalent can be rearranged to express the current-flow in the load I'2. The
equivalent will now be:
RTH XTH X’2 R’2

I’2

1− s 
UTH R2 '  
 s 

Figure 5 - Thévenin's equivalent for the motor


Where,
Z TH = (R 1 + jX1 ) ( jX h ) (R FE ) = R TH + jX TH [2]

The current can now be expressed as:

U TH
I'2 = [3]
R TH + R' 2 /s + j(X TH + x'2 )

© Analog Devices Inc., February 2001 Page 5 of 24


a V/F Controller on the ADMCF32X ANF32X-24

Now the torque can be expressed as:


2
3 U TH R' 2 /s P
T= * = [4]
Ù 0 (R TH + R' 2 /s ) + (X TH + X' 2 )
2 2
Ù0
Where,

Ω0 the angular speed.


P the Power.

The torque for the machine can now be expressed from [4] - the torque as a function of the slip-change
and gives us:

T Tkip, nkip

n
1 = n/n0 n0

Figure 6 - Torque as a function of slip-change

The area 0 < n/n0 < 1 is called the area for standard operation, here the machine is functioning as a motor.
When the ratio is moved to n/n0 > 1 the drive starts to work as a generator, the motor will in this area
contribute with a back-torque and deliver energy back though the powerstage. In this application note the
discussion is only concerning the motor-area.

1.1.3 “Number-plate” of the machine


Looking at the “number plate” of the machine, many of the wanted information can be directly calculated
on base of some simple parameters. First of all the Speed and Power of the machine which from [5] gives
us the Torque [6]

P * 9.55 1500 * 9.55


T= = = 4.9Nm [6]
n 2910
Here specific motor-parameters are added to calculate the torque. (Power[P] and Speed[n])

© Analog Devices Inc., February 2001 Page 6 of 24


a V/F Controller on the ADMCF32X ANF32X-24

2 The Frequency Converter


Since the development of power-electronics a new way of controlling the motor-speed has been
introduced. This topology is based on changing the frequency and / or the amplitude voltage on the
motor-windings. With this controllable frequency / voltage it is possible to achieve a high efficient speed-
controller for induction motor. One thing to consider is the torque on the shaft. If the voltage added to the
motor changes, the frequency also has to change to ensure torque on the shaft. Looking at the torque,
expressed from the power (P) and the speed the following equation is given:

P * 9.55 η * 3 * V * I * cosϕ * 9.55 V


T= = = k* [7]
n 60 f
f * (1 − s)
p
This equation implies that if the ration between the voltage and the frequency are kept constant the torque
also stays constant. These terms are the ones used to implement the speed-controller for the induction-
machine.

2.1 The "standard" system - Hardware


The frequency converter can be build up in many different ways, depending on the topology and
flexibility of the system. One of the ways, which has become the most common is the way illustrated
below.

Figure 7 - Principle of the controller

As it can be seen at Figure 7 the system includes 4 basic blocks which are:

I. A rectifier used to generate DC from the 1 or 3 phase distribution net.


II. The intermediate circuit - incorporates the DC-link control. Different control-aspects can be taken
into account, such as PFC, DC-chopping or stabilization.
III. An Inverter used to reproduce three controlled waveforms. In this case the output from the
inverter is three 120-degree phase-shifted sine-shaped voltages.

© Analog Devices Inc., February 2001 Page 7 of 24


a V/F Controller on the ADMCF32X ANF32X-24

IV. Control-block - here all the necessary adjustment of the system are done. For the frequency
converter this control-block controls the inverter to deliver the wanted waveforms to the motor,
meaning the voltage to frequency ratio.

Today many power-electronic companies manufacture integrated power devices, in this case the
integration of the rectifiers, inverters and drive-circuit for the IGBT's are packaged in one or two chips
and can be bought as standalone devices with all the relevant electronics included. Such a device is
chosen for this demo-application. The device is International Rectifiers PowIRtrain (IRPTXXX1) but any
other power device could have been used.

2.2 The control-functions build up in the ADMCF32X.


In this section three different topologies of constant Voltage over Frequency control are discussed.
Basically the induction motor needs a voltage-controlled input for the three phases. These three phase
voltages can be produced in many different ways. In this applications note the use of PWM controlled
from the ADMCF32X is utilized.
In this section the theory behind basics, third-harmonic and Space-Vector-Modulated2 references are
discussed.

2.2.1 Basics - Standard


The generation of the three-phase supply voltage is done on base of basic PWM generation3. In this case
the three phase reference voltages are generated in the processor and though the PWM-block these pattern
are used as input parameter for the Power Inverter.

Figure 8 – Sine, corresponding angle and PWM

At Figure 8 the voltage reference for one of the three phases with corresponding angle and PWM are
illustrated. The three-phase references VrefA, VrefB and VrefC can be expressed as:

1
For more information see http://www.irf.com/
2
For more information see applications note ANF32X-17
3
For more information see applications note ANF32X-3

© Analog Devices Inc., February 2001 Page 8 of 24


a V/F Controller on the ADMCF32X ANF32X-24

VrefA = u r (t) = U1sin(ω t)



VrefB = u s (t) = U1sin(ω t+ ) [8]
3

VrefC = u t (t) = U1sin(ω t− )
3

where the displacement of the voltages are as expressed 120°. These three-phase references can be used
directly in this simple three-phase generation as control-voltages for the frequency converter with
sinusoidal reference.

2.2.2 Third-harmonic Injected


One of the major disadvantages with sinusoidal PWM is the poor utilization of the DC-link voltage. The
amplitude value of the first harmonic in the phase-voltage has a maximum of Vc/2 – referring to an actual
reference voltage, measured on the terminals to be 0.866.

3
Motorvoltage = Netvoltage = 0.866 * Netvoltage [9]
2

One of the simple ways of extending the usage of the DC-link voltages is by adding an extra harmonic to
the sinusoidal voltage reference. In this case the third harmonic are added which results in three phase
references expressed as:

VrefA = u r (t) = u s1 (t) + u 0 (t) = U 1 sin( ω t) + U 3 sin(3ω t )


2
VrefB = u s (t) = u s2 (t) + u 0 (t) = U 1 sin( ω t + ) + U 3 sin(3ω t )
3
2 [10]
VrefC = u t (t) = u s3 (t) + u 0 (t) = U 1 sin( ω t − ) + U 3 sin(3ω t )
3
Where
U1
u o = U 3 sin(3ω t ), U3 =
6

By utilizing just the unity scaled sine as generation platform for the third harmonic, this results in a
maximum amplitude of 0.886*Netvoltage. By adjusting this value by 15.5% a better utilization of the
DC-bus voltage is achieved, meaning the efficiency from the distribution-net to the Power Inverter.

 Vc Vc   Vc 
 −    • 100% = 15.5 % [11]
 3 2   2 

© Analog Devices Inc., February 2001 Page 9 of 24


a V/F Controller on the ADMCF32X ANF32X-24

Figure 9 - Simulation of third-harmonic references


The same control angle as for the standard sine generation can be used with this method and the result can
be seen on Figure 9. In Figure 10 the comparison of the reference voltage with the dedicated PWM are
illustrated.

Figure 10 - Including third harmonic with corresponding angle and PWM

2.2.3 Space Vector Modulation – SVM


Since the introduction of reference frames4 there are for many applications huge advantages in utilising
these frames for the complete control scheme. In the terms of PWM generation this technique (SVM) can
directly be controlled within this frame (α-β). The three voltages references VrefA, VrefB and VrefC can
be converted to the α-β-frame as:
r 2 r r r
V = Vα + jVβ = (VrefA a 0 + VrefB a 1 + VrefC a 2 ) [12]
3
where

r j
a=e 3 [13]

4
For more information see applications note ANF32X-11

© Analog Devices Inc., February 2001 Page 10 of 24


a V/F Controller on the ADMCF32X ANF32X-24

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 can be seen at Figure 11, 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% of the inverter capability. It is also a relatively easy task to improve this technique in order to reach
full inverter capability.

β
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 V1=(1,0,0)
Vd V7=(1,1,1) α
IV VI
Vd/2
V
V5=(0,0,1) V6=(1,0,1)

a) b)

Figure 11: a) Configuration of the switches in the state V1=(1,0,0),

b) Representation of the inverter states in the stationary reference frame

Plotting the control-angle with corresponding voltage-references is illustrated on Figure 12. The relations
between the voltage-reference the PWM-sequence can be seen on Figure 12 (2)

Figure 12 - SVM with corresponding angle and PWM

© Analog Devices Inc., February 2001 Page 11 of 24


a V/F Controller on the ADMCF32X ANF32X-24

2.2.4 Ramps / Boost


In every motor-application the need of controlling the speed is essential and depends on the system. For
that reason speed set-points and required tracking ramps have to be controllable by the user.
Per phase Motor Voltage

V/F ratio = 1 Volts rms/Hz

Max Voltage

Acceleration time

Boost Voltage Max Speed

Frequency of Motor
Boost Speed Cut Speed
Voltage (Hz)

Figure 13 - Ramps examples


In Figure 13 the ramp / boost profile for this example is illustrated. Basically the ramps are defined by a
max. / boost speed and a step time (acceleration). Setting these three parameters allows the user to define
the profile of the ramp. In the code for the ADMCF32X these ramps / profiles are coded and can be called
when needed. profiles are coded and can be called when needed. The mathematical description of the
ramps are described below:
Here,
PWM_freq : PWM update frequency.
Number_of_Steps : How many steps are used in the ramp.
Count_Init : Number of counts for correct acceleration time.
Delta_Init : Step-size.
are defined as, and result in:
PWM_freq
Count_Div = [14]
Number_of_steps

15 bit
Delta_init = , 15 bit = 32768 [15]
Number_of_steps
For the voltage profile the syntax is the same,

V_F_SCALE : Scaling factor for the V/F ratio.


VOLT_SCALING : Voltage scaling factor (divisor of maximum voltage)
Maximum_voltage : Set to 1 (0x7FFF);
MAX_FREQ : Maximum frequency of the period
CUT_FREQ : Maximum frequency of the end slope
BOOST_FREQ : BOOST frequency of the period
MIN_FREQ : MIN frequency of the period
and the mathematical description are:

© Analog Devices Inc., February 2001 Page 12 of 24


a V/F Controller on the ADMCF32X ANF32X-24

PWM_freq 1
PWMCycles_period = , Increment = [16]
MAX_FREQ PWMCycles_period

15 Bit
Boost Voltage = [17]
VOLT_SCALING

15 bit * BOOST_FREQ
Boost_speed = [18]
MAX_FREQ

15 bit * CUT_FREQ
Boost_speed = [19]
MAX_FREQ

15 bit * MAX_FREQ
Boost_speed = [20]
MAX_FREQ

All these general constants are defined in “main.h” and together with the associated macros (further
description see code section) they enable the full RAMP / Boost control. A specific macro is done to
calculate the acceleration speed anywhere in the code. The mathematical calculation of the parameters is
done in the "main.h" and the "v_f_ctrl.dsp" files.

© Analog Devices Inc., February 2001 Page 13 of 24


a V/F Controller on the ADMCF32X ANF32X-24

3 The V/F Application Routines


3.1 Using the V/F Application Routines
These application routines provide various functions that configure and enable the ADMCF32X to control
an induction machine, with constant voltage over frequency ratio. With the use of ADIs Standard Motor
Control Library (see Library Documentation File) a full space vector modulation and control scheme are
performed on an induction machine. The routines are developed as easy-to-use blocks, which has to be
linked with the used library functions to build the complete application software. The routines for this
application consist of eight files.
File name Usage
Set-up of the structure for the PWM generation. Define set-
Main.dsp (dsp,h)
points in frequencies and voltages
IR_Reset (dsp, h) Reset the PowerIRtrain with the use of PIO3
Speed profile - Define and calculate the acceleration and
Ramp (dsp,h)
ramp-profile for the speed.
Voltage over frequency profile - Define the voltage amplitude
V_F_Ctrl (dsp,h)
and generate the given SVPWM scheme.

Table 1: Files used with the V_F application routines

As with the structure from the ADIs Standard Motor Control Library, macros are defined. For this
application six macros are used for configuration and update in the code. The following table reassumes
the set of macros that are defined with this application.
Operation Usage
Configuration of the IR_Reset IR_reset_PIO3;
Configuration of the Ramps Ramps_Init_Speed_profile;
Set the minimum speed Set_Minimum_Speed;
Set the acceleration of the speed ramp Ramps_Calculate_Speed_Profile(EXP,NOM)
Calculate the projecting voltage and angle V_F_ctrl_Calculate_Angle_volt
Update the SVM and calculate duty-cycle V_F_ctrl_SVM_Calculation

Table 2: Implemented routines for the V_F Controller

As already mentioned in the theory, these routines require some configuration constants, which are
declared in a dedicated section of the main include-file "main.h". If a routine require internal
configuration constants are declared in the associated include-file "Ramps.h", "V_F_CTRL.h" or
"IR_reset.h". The following section will explain each of the routines in details linked with the relevant
segments of code that are found in any of the files described in Table 1.

© Analog Devices Inc., February 2001 Page 14 of 24


a V/F Controller on the ADMCF32X ANF32X-24

3.2 Configuring / resetting the PowerIRtrain: IR_reset_PIO3


This macro initializes and resets the PowerIRtrain though PIO3. It checks the SYSSTAT(0) bit to clarify
the status of the PWMTRIP pin. If a PWMTRIP is detected the routine resets the PowerIRtrain though
PIO3. The routine is as described below - the nacros Set_Bit_DM , Clear_Bit_DM, Clear_Bit_DM,
Test_Bit_DM and If_Clr_Jump are macros defined in the general purpose macro file "macro.h".
Ir_reset_PIO3_:

Set_Bit_DM(PIODIR0, 3); { configure PIO(3) as output }


Clear_Bit_DM(PIOINTEN0, 3); { disable PIO interrupt 3 }
rst:
Set_Bit_DM(PIODATA0, 3); { set PIO(3) high to reset the PowIRtrain }

{ wait 10 usec }
cntr = 150;
do IR_delay until ce;
nop;

IR_delay: nop;
Clear_Bit_DM(PIODATA0, 3); { set PIO(3) low to enable the PowIRtrain }

{ wait 100 usec }


cntr = 1500;
do IR_delay2 until ce;
nop;

IR_delay2: nop;

wait_IR:
Test_Bit_DM(SYSSTAT,0); { wait for PowIRtrain fault output to be }
{ deserted i.e. high }
If_Clr_Jump(rst);

rts;

.ENDMOD;

The call of the Ir_reset_PIO3 macro are defined as following:

.MACRO ir_reset_PIO3;
call ir_reset_PIO3_;
.ENDMACRO;

3.3 Ramps-module - Configuration of the Ramps: Ramps_Init_Speed_profile;


The macro that configures the initialization of the Ramp module is defined to clear the input to the
routine. The Ramps_Init_Speed_profile macro calls the Ramps_Init_Speed_profile_ routine and clears
all input values
Ramps_Init_Speed_profile_:

ar = 0;
dm(speed_command) = ar;
dm(speed_profile) = ar;
dm(count) = ar;
dm(delta) = ar;

RTS;

© Analog Devices Inc., February 2001 Page 15 of 24


a V/F Controller on the ADMCF32X ANF32X-24

3.4 Ramps-module - Setting the minimum speed: Set_Minimum_Speed;


This macro checks the setting of the minimum speed. If the speed command is less than the minimum
speed, the speed command is set to the minimum chosen speed. The Set_Minimum_Speed macro calls
the Set_Minimum_Speed_ routine and returns to subroutine.
Set_Minimum_Speed_:

ar = abs ar; { Check if speed is in the minimum speed range }


ay0 = Minimum_speed;
ar = ar - ay0;
if ge jump Over_Min_Speed; { if speed_Command< Minspeed jump Over_Min_Speed}

my0 = Minimum_speed;
dm(Speed_command) = my0;

Over_Min_Speed:

RTS;

3.5 Ramps-module - Set the acceleration of the speed ramp:


The Ramps_Calculate_Speed_Profile(EXP,NOM) macro controls the acceleration ramps input to the
ramps_Speed_Profiles_ routine. With the use of this macro the acceleration can be changed for anywhere
in the code. The routine expects some constants defined in "main.h" as already discussed in section 2.2.4
and illustrated in the section below. These constants are the number of steps in the ramp, the count
number for the timescaling and the stepsize.

{**************************************************************************************}
* *
* Constants that need to be defined in main.h: *
* *
*.CONST Number_of_Steps = xxx; Number of steps in the ramp *
*.CONST Count_div = (PWM_freq/Number_of_Steps);Count number for timescaling *
*.CONST Delta_Init = xxx; stepsize for the speedsteps *
***************************************************************************************}
With these values declared, the ramp definition and calculation can be done in the
Ramps_Speed_Profiles_ routine.
Change the speed set point using a ramp profile. When a speed change is requested, produce a ramp, which
takes the chosen acceleration-time to get to next speed level. The input value for this ramp generator is the
value stored in init_count and the constant Delta_Init calculated in "main.h". The routine checks the
speed_command value. Is the value less than the last calculated speed_profile the value is decreased. If the
value of speed_command is bigger than last calculation the speed_profile are increased.

Ramps_Speed_Profiles_:

ar = dm(count); { if count is 0,then calculate the speed profile}


ar = pass ar; { Other wise decrement count and quit. }
if eq jump calc_profile;
ar = ar - 1;
dm(count) = ar;
jump End_Profile;

Calc_Profile:
ar = dm(init_count);
dm(count) = ar;
ar = Delta_Init; { Calculated in the main.h }
dm(delta)=AR;

ar = dm(speed_command);
ay0 = dm(speed_profile);

© Analog Devices Inc., February 2001 Page 16 of 24


a V/F Controller on the ADMCF32X ANF32X-24

ar = ar-ay0;
if le jump negative_speed_change; { If speed_profile > Speed_command jump }
{ negative_speed_change }
}
Positive_Speed_Change:
ar = ABS ar;
ay0 = dm(delta);
ar = ar - ay0;
if le jump Done; { if speed_profile = Speedcommand jump Done }

ar = dm(speed_profile); { speed_profile + delta }


ay0 = dm(delta);
ar = ar + ay0;
dm(speed_profile) = ar;
jump End_Profile;

Negative_Speed_Change:
ar = ABS ar;
ay0 = dm(delta);
ar = ar - ay0;
if le jump Done; { if speed_profile = Speedcommand jump Done }

ar = dm(speed_profile); { speed_profile - delta }


ay0 = dm(delta);
ar = ar - ay0;
dm(speed_profile) = ar;
jump End_Profile;

Done:

ar = dm(Speed_command); { speed_profile = Speed_command }


dm(speed_profile) = ar;

End_Profile:

RTS;

The macro functionality for Ramps_Calculate_Speed_Profile(EXP,NOM) is as illustrated below.


This macro takes two values, a numerator and an exponent, and uses them as acceleration definition. In the
case illustrated in the code, the wanted acceleration is 20 sec. For that reason an exponent of 5 is selected.5
correspont to 2^5=32. To get 20, this number has to be multiplied with 20/32 in fixedpoint (20/32*(2^15-1)).
In 1.15 format 20/32 = 4FFF, which then is going to be the numerator.
{***************************************************************************************
* Call: Ramps_Calculate_Speed_Profile(%0,%1); *
* *
* Call: %1 : Inititalisation of numerator *
* %0 : Inititalisation of exponent *
* *
* 20 sec.=2^5*20/32 ==> %1 = 4FFF %0 = 5 *
***************************************************************************************}
.MACRO Ramps_Calculate_Speed_Profile(%0,%1);

ar = Count_Div; { Calculated in the Main.h }


SR = ASHIFT ar BY %0 (LO); { Result in SR0 }
my0 = %1;
mr = sr0 * my0 (SS);
dm(init_count)=mr1;

CALL ramps_Speed_Profiles_;

.ENDMACRO;

© Analog Devices Inc., February 2001 Page 17 of 24


a V/F Controller on the ADMCF32X ANF32X-24

3.6 V_F-module - Calculate Voltage and Angle: V_F_ctrl_Calculate_Angle_volt


This macro V_F_ctrl_Calculate_Angle_volt controls the voltage profile to the motor. As in the other
modules, constants are defined in the "main.h" file to enable control of the profile. As already discussed
in section 2.2.4 these constants defines the profile illustrated on Figure 13. The constants are as can be
seen on the figure: Voltage and Frequency related and are described below.
{***************************************************************************************
* Constants that need to be defined in main.h: *
*.CONST V_F_SCALE = xxx; To get X in Scaling factor *
* Calculation (Gain of 8 in code) *
*.CONST VOLT_SCALING = xxx; Voltage scaling factor (divisor of V) *
* *
*.CONST Maximum_voltage = xxx; *
*.CONST MAX_FREQ = xxx; Maximum frequency of the sine pwm *
*.CONST CUT_FREQ = xxx; Maximum frequency of the end slope *
*.CONST BOOST_FREQ = xxx; BOOST frequency of the sine pwm *
*.CONST MIN_FREQ = xxx; MIN frequency of the sine pwm *
* *
***************************************************************************************}

From these values, the calculated constants for the voltage profile are defined and ready to use in the
related code. The complexity of the equations is easy to understand comparing with those of section 2.2.4.

.CONST PWMCycles_period = (PWM_freq/MAX_FREQ); { Number of pwm cycles pr period }


.CONST INCREMENT = 0x10000 / PWMCycles_period; { Angle increment at MAX_FREQ }
.CONST Boost_voltage = 0x7FFF / VOLT_SCALING; { XX % Of maximum voltage }
.CONST Boost_speed = 0x7FFF / MAX_FREQ * BOOST_FREQ; { In this case 30 Hz }
.CONST Maximum_speed = MAX_FREQ / MAX_FREQ *0x7FFF; { The Maximum_speed }
.CONST Cut_Speed = 0x7FFF / MAX_FREQ * CUT_FREQ; { The Cut_speed }

The macro itself calls the V_F_ctrl_Calculate_Angle_volt_ routine which and returns with d/q voltage
references for the space vector modulation.
The routine consists of two parts. First section calculates the angle on base of the calculated angle
increment (Increment) and the speed_profile returned from the Ramps_Calculate_Speed_Profile macro.
V_F_ctrl_CALCULATE_ANGLE_VOLT_:
mr = 0; { Clear mr }
mr1 = dm(Theta); { Preload Theta }
mx0 = dm(Speed_Profile); { Load Speed profile signal }
my0 = Increment;
mr = mr + mx0*my0 (SS); { Compute new angle & store }
dm(Theta) = mr1;

Second section of the routine checks the Speed_profile and depending on the selected speed_profile see
Figure 13 the voltage is projected. Due to the SVM5, the voltage is applied in the d/q-frame and not the
standard three-phase frame. On additional parameter is included this code (V_F_SCALE) - The scaling
of voltages compared to the speed. By this meaning not an even ration of Voltage over Frequency
operation.
EX. The motor needs to run from 0 to 120 Hz but the applied voltage has to be max. at 60 Hz. (see
Figure 13). In this case the ratio of V/F is not one but two. This means that the slope actually has
to be twice the size. For that reason a gain factor V_F_SCALE ("main.h") is introduced. This
factor controls the scaling of the V/F (In the code an extra scaling of 8 is done to overcome higher
frequencies).

5
For further information see ANF32X-11,17

© Analog Devices Inc., February 2001 Page 18 of 24


a V/F Controller on the ADMCF32X ANF32X-24

Boost_Frequency:

ar = dm(Speed_Profile);
ar = abs ar; { Check if speed is in the minimum speed range }
ay0 = Boost_speed;
ar = ar - ay0;
if ge jump Over_Boost_Frequency;
{ if speed_profile=>Boost_speed jump Over_Boost_Frequency }
my0 = Boost_voltage;
dm(voltage_profile) = my0;

DM(Vdq_ref)= my0; { Set constant Vdq reference (Voltage_profile,0) }


ar = pass 0;
DM(Vdq_ref+1)= ar;

JUMP Out_of_Voltage_setting;

Over_Boost_Frequency:

ar = dm(Speed_Profile);
ar = abs ar; { Check if speed is in the minimum speed range }
ay0 = Cut_Speed;
ar = ar - ay0;
if ge jump Max_voltage; { if speed_profile = Speedcommand jump Boost_added }

ar = dm(Speed_Profile); { Load Speed profile signal }


my0 = V_F_SCALE; { V_F_SCALE }
mr = ar*my0 (SS); { Compute new angle & store }
sr=LSHIFT mr1 by 3 (LO); { shift 3 to multiply v_f ratio with 8 }

my0 = sr0;
dm(voltage_profile) = my0;

DM(Vdq_ref)= my0; { Set constant Vdq reference (Voltage_profile,0) }


ar = pass 0;
DM(Vdq_ref+1)= ar;
JUMP Out_of_Voltage_setting;

Max_voltage:
my0 = Maximum_voltage;
dm(voltage_profile) = my0;
DM(Vdq_ref)= my0; { Set constant Vdq reference (Voltage_profile,0) }
ar = pass 0;
DM(Vdq_ref+1)= ar;

Out_of_Voltage_setting:

RTS;

© Analog Devices Inc., February 2001 Page 19 of 24


a V/F Controller on the ADMCF32X ANF32X-24

3.7 V_F-module - Update the SVM and Dutycycles: V_F_ctrl_SVM_Calculation


The final macro in the V_F-module is the V_F_ctrl_SVM_Calculation. This macro takes angle and the
Vdq_references returned from the V_F_ctrl_Calculate_Angle_volt macro and calculate the dutycycles of
the SVM6. The routine that the macro calls is described below.
V_F_ctrl_SVM_CALCULATION_:

{*******************************************************************************************}
{ Set up SVM-module for transformation and SVM-generated PWM }
{*******************************************************************************************}

mr1 = dm(Theta); { control angle }


refframe_Set_DAG_registers_for_transformations;
refframe_Forward_Park_angle(Vdq_ref,Valphabeta_ref,mr1);{ generate Vreference in }
{ alpha-beta frame }

SVPWM_Calc_Ontimes(Valphabeta_ref, OnTime_struct); { use SVPWM routines }


SVPWM_Calc_Dutycycles(OnTime_struct, Dutycycles_struct);
SVPWM_Update_DutyCycles(Dutycycles_struct);

RTS;
.ENDMOD;

4 Software Example: Constant Volt/Hertz operation - With SVM and


Ramps
As talked about though this and other applications notes the V/F operation of the induction machine is
commonly used in many variable speed-drives. This example combines all the application-modules
discussed in this applications note. The program reads a value from the converter and returns 6 dutycycles
patterns on the PWM-block of the ADMCF32X. In combination with this software, some additional
hardware has to be used. For autocalibrating the converter see AN331-05, some references are needed and
to amplify the output signals from the ADMCF32X-Eval Board some kind of Power Inverter has to be
selected. For this specific example the Power Inverter is from International Rectifier (PowerIRtrain -
serie).

4.1 The main program: Main.dsp


The file “main.dsp” contains the initialisation and PWM Sync and Trip interrupt service routines. To
activate, build the executable file using the attached build.bat either within your DOS prompt or clicking
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 this is given.
Start of code – declaring start location in program memory
.MODULE/RAM/SEG=USER_PM1/ABS=0x30 Main_Program;

Next, the general systems constants and PWM configuration constants (main.h – see the next section) are
included. Also included are the Library functions for the PWM, ADC, DAC, Transformations to D/Q - Alpha
/ Beta, SVM and of course the applications specific routines - IR_reset, ramps and v_f_ctrl.

6
For further information see ANF32X-17

© Analog Devices Inc., February 2001 Page 20 of 24


a V/F Controller on the ADMCF32X ANF32X-24

{***************************************************************************************
* Include General System Parameters and Libraries *
***************************************************************************************}

#include <main.h>;

#include <adcF32x.h>;
#include <autocalx.h>;

#include <pwmF32x.h>;
#include <refframe.h>;
#include <svpwm.h>;
#include <aux_dac.h>;

#include <ir_reset.h>; { Application Specific Module }


#include <ramps.h>; { Application Specific Module ! }
#include <v_f_ctrl.h>; { Application Specific Module ! }

The first thing that is done in the initialisation block (Startup) is checking a selected PIO line for level. If the
PIO-pin is high jump to an ERASE BOOT FROM FLASH BIT routine in ROM and return. If not, just go
ahead with normal operation. This small macro is done to enable re-coding of the FLASH memory. For
further information (See Reference Manual). In this example the PIO-pin 6 is chosen as erase pin. Secondly
the Resetting of the PowerIRtrain is activated. Followed by the PWM block initialisation. Note how the
interrupt vectors for the PWMSync and PWMTrip service routines are passed as arguments. Then
initialisation of the ADC, AutoCalibration and AUXDAC block is completed. The next step is to initialise the
profiles used in the speed definition. As the next thing in the start-up sequence the interrupt IRQ2 is enabled
by setting the corresponding bit in the IMASK register after this the program enters a loop which just waits
for interrupts.
Finally all the variables declared in DM are initialised – This is done in the Main.h

{********************************************************************************************}
{ Start of program code }
{********************************************************************************************}

Startup:

FLASH_erase_PIO(6); { Select PIO6 as clearing PIO Remember that sport1 is }


{ muxed with the PIO-lines If the bit is LOW Clear }
{ Memory and Boot from Flash bit }

IR_reset_PIO3; { Reset PowIRTrain Module }

PWM_Init(PWMSYNC_ISR, PWMTRIP_ISR);
ADC_Init;
AutoCal_INIT;
Write_AUXDAC_Init; { Initialize the use of AUXPWM channels as DAC }
Ramps_Init_Speed_profile;

IFC = 0x80; { Clear any pending IRQ2 inter. }


ay0 = 0x200; { unmask irq2 interrupts. }
ar = IMASK;
ar = ar or ay0;
IMASK = ar; { IRQ2 intr. fully enabled here }

InitDM_Variables; { Initialize all DM varialbes }


{ main.h }

Main: { Wait for interrupt to occur }


jump Main;

rts;

© Analog Devices Inc., February 2001 Page 21 of 24


a V/F Controller on the ADMCF32X ANF32X-24

The first thing that is done in the PWMSYNC_IRS is the Autocalibration. The Speed_command is read
though the converter on ADC1 and used as set-point for the control. With the call of Set_Minimum_Speed the
minimum selected speed (see "main.h") is selected. Using ramps_Calculate_Speed_Profile(0x5,0x4fff) the
acceleration time is set to 20 seconds and from here the Speed_profile value is used to calculate the Angle
and the Voltages. Finally the complete PWM sequence is calculated with the use of v
V_F_ctrl_SVM_Calculation. Before exiting the ISR the Auxiliary channels on the PWM block are updated –
used as DAC though a low-pass filter.

{********************************************************************************************}
{ PWM Interrupt Service Routine }
{********************************************************************************************}
PWMSYNC_ISR:

Auto_Calibrate;
ADC_Read(ADC1); { Read value on ADC1 }

DM(Speed_command) = ar; { Store in Speed_command}

Set_Minimum_Speed; { Set the minimum speed }


Ramps_Calculate_Speed_Profile(0x5,0x4fff); { 20 sec. see ramps.h }
V_F_ctrl_Calculate_Angle_volt;
V_F_ctrl_SVM_Calculation;

{********************************************************************************
* Use the Write_AUXPWM macro to plot on AUXDAC for debugging *
********************************************************************************}

Write_AUXPWM(AUXCH0,Theta);
Write_AUXPWM(AUXCH1,Speed_Command);

RTI;

The PWM-Trip routine is in this example used to check on the trip pin on the PowerIR-train7. This TRIP-pin
is hardwired to the PWM_TRIP_PIN on the ADMCF32X device. When the PowerIRtrain’s pin goes low, in
the case of over-current or temperature the PWMTRIP_ISR check on the status of the pin. The actions are as
given
1. Check the PWMTRIP in the SYSSTAT – if high jump to restart
2. If not wait 80 µs – and then check SYSSTAT again
3. If it now has gone high call restart PWM …..

PWMTRIP_ISR:
{********************************************************************************
* PWM Trip Interrupt Service Routine *
********************************************************************************}
Trip_Ena:

CNTR = H#3FF ;
DO Wait0 UNTIL CE; { wait 80us}
Wait0: NOP;
Test_Bit_DM(SYSSTAT,0); { check the PWMTRIP input. Still low ? }
If_Clr_Jump(Trip_Ena);

Test_Bit_DM(SYSSTAT,0); { check the PWMTRIP input again. Gone high restart }


If_Set_Jump(RESTART_PWM);

DIS SEC_REG;

RTI;

{********************************************************************************
* After a shutdown - restart the PWM. *
********************************************************************************}

7
For more information look in datasheet on IRPTXXX family at www.irf.com

© Analog Devices Inc., February 2001 Page 22 of 24


a V/F Controller on the ADMCF32X ANF32X-24

RESTART_PWM:

IFC = 0X80; { clear IRQ2 interupt }


PWM_Init(PWMSYNC_ISR, PWMTRIP_ISR);
AR = 0; { clear SPEED_PROFILE to ensure SAFE start }
DM(SPEED_PROFILE)=AR;

RTI;

.ENDMOD;

4.2 The main include file: main.h


This file contains the definitions of ADMCF32X constants, general-purpose macros and the configuration
parameters of the system and library routines. It should be included in every application. For more
information refer to the “The Library Documentation File” document.
This file is mostly self-explaining. The relevant sections to this example are shown here. The frequency of the
used crystal (10MHz in case of the ADMCF32X Evaluation Kit) is expressed in kHz. Then ADMCF32X
specific constants, Flash - Utilities and general-purpose macros are included. Refer to the ADMCF32X
documentation for details on the Flash-Utilities.
{***************************************************************************************
* General System Parameters and Constants *
***************************************************************************************}

.CONST Cry_clock = 10000; {Crystal clock frequency [kHz] }

#include <admcf32x.h>;
#include <macro.h>;
#include <putvectr.h>; { Put_vector function }
#include <Flash_CT.h>; { Special Control unit for the Flash }

As described in the “The Library Documentation File”, every library routine has a section in main.h for its
configuration parameters. The following defines the parameters for the RAMPS and V_F_CTRL block used
in this example.
{********************************************************************************************}
{ Library: RAMP BLOCK }
{ file : Ramp.dsp }
{ Application Note: V/F control with the ADMCF32X }
.CONST Number_of_Steps = 256; { Number of steps in the ramp 8 bit }
.CONST Count_div = (PWM_freq/Number_of_Steps); { Count number for timescaling }
.CONST Delta_Init = (32768/Number_of_Steps) ; { stepsize for the speedsteps }

{********************************************************************************************}

{********************************************************************************************}
{ Library: V_F_CTRL BLOCK }
{ file : V_F_CTRL.dsp }
{ Application Note: V/f control with the ADMCF32X }

.CONST V_F_SCALE = 0x1000; { To get 1 in scaling factor 60Hz/60Hz }


{ calculation (Gain of 8 in code) }

.CONST VOLT_SCALING = 6; { Voltage scaling factor (divisor of V) }

.CONST Maximum_voltage = 0x7FFF;


.CONST MAX_FREQ = 60; { Maximum frequency of the sine pwm }
.CONST CUT_FREQ = 60; { Maximum frequency of the end slope }
.CONST BOOST_FREQ = 10; { BOOST frequency of the sine pwm }
.CONST MIN_FREQ = 6; { MIN frequency of the sine pwm }

{********************************************************************************************}
……..

© Analog Devices Inc., February 2001 Page 23 of 24


a V/F Controller on the ADMCF32X ANF32X-24

5 Reference
[1] A Tutorial in AC Induction and Permanent Magnet Synchronous Motors. Analog Devices Inc. '94.

© Analog Devices Inc., February 2001 Page 24 of 24

You might also like