Vector Control Induction Machine
Vector Control Induction Machine
dx
Code Generation
DEMO MODEL
www.plexim.com
Request a PLECS and PLECS Coder trial license
1 Overview
This demo model shows the simulation of an induction motor drive system, and provides an expla-
nation of the typical workflow of the PLECS Embedded Coder, using Texas Instruments (TI) C2000
MCUs. Combined with a PLECS RT Box, the performance of the MCU can be verified directly.
Note This model contains model initialization commands that are accessible from:
PLECS Standalone: The menu Simulation + Simulation Parameters... + Initializations
PLECS Blockset: Right click in the Simulink model window + Model Properties + Callbacks +
InitFcn*
Analog Analog
Out Out
Probe
Vdc Is
Scope
Model
Settings
sw1
Vdc+ sw3
sw5
V IM
sw2
Vdc- sw4
sw6
Incr.
Probe
Encoder
θ
sw1
PWM sw2 Digital Digital Digital Digital
1 sw3
Capture sw4 In Out In Out
sw5
PWM sw6 Tz_i Tz_o En_i En_o
2 Model
The demo model is composed of two subsystems: the “Plant” subsystem includes the power circuit and
the “Controller” subsystem includes the control loop.
www.plexim.com 1
Vector Control of an Induction Machine
block. The encoder pulses can be accessed on the corresponding port of the “Plant” subsystem mask.
Two Digital Output blocks forward the external digital input signals to two digital output pins of the
RT Box. These pins should be connected with the GPIOs of the MCU to enable/disable the PWM out-
puts via software or trip zones. The mechanism of the MCU’s PWM enable/disable will be elaborated
in Section 2.2.
2.2 Controls
In the “Controller” subsystem, rotor-field oriented control is applied to the drive system. The basic
structure is shown in Fig. 2, where the stator current is regulated in the dq frame.
QEP
ic ψr esti.
QEP i
c c θe
PWM
ωe ωe V*->d
Trigger abc
*
Is Idq Idq Vs* dq
/
i o PWM
ADC 20 ADC
Idq*
Task Id* PI rst
Id*
ADC 100 Te*
Iq*
U(I)
Digital
z-1
Out
Scope NOT LED Blinking
Fig. 3 shows the equivalent circuit of the induction machine in the dq frame, which rotates syn-
chronously with the rotor flux. The values of LM , LσS and RR are calculated from the original machine
parameters, which can be found in the initialization commands of the model.
Rs
I Md
Vsd LM RR
Rs RR
Vsq
The PI controllers for the d and q axis current are included in the subsystem “PI”, as shown in Fig. 4.
The proportional and integral gains are designed following the “magnitude optimum” method [2][3].
www.plexim.com 2
Vector Control of an Induction Machine
+ o i
− +
− K
d-axis Idq*
Kp +
* ωe K +
* Idq i o
Vs* Lσ
q-axis K +
− 1/s
+
+ o i
Ki
+
K −
To avoid the use of an embedded flux sensor, a magnetic flux estimator introduced on page 322 of [1] is
employed in the subsystem “Ψr esti.”. Making use of the measured mechanical angular speed ωm , the
~ r,xy in the
stator current is transformed into the rotor rotational frame (“xy”) as I~s,xy . The rotor flux dΨ
rotor rotational frame is governed by the differential equation given below:
~ r,xy
dΨ ~ r,xy
−dΨ
= RR ( ) + I~s,xy (1)
dt LM
+
+ p
ωe
C-Script
θe->ωe
+
+ 1/s p
θe ωm
dq
abc
Idq Is
abc K
dq
1/s
−
+ RR
The measurements of the DC-link voltage and the stator currents are introduced to the model environ-
ment from the ADC block of the TI C2000 Target component library. In order to convert the detected
analog voltage into values with physical units to be used for the control algorithm, a scaling factor and
an offset factor are provided to each channel, via the parameter window of the ADC block. The ADC
unit and the Analog input channel parameters can be modified accordingly per available resources
of different MCUs.
The mechanical angular speed of the rotor is obtained from the Quadrature Encoder Counter (QEP)
block, which converts the orthogonal digital pulses into the rotational position-related counter value.
The Maximum counter value must be provided according to the configuration of the real encoder
hardware, along with the index of the GPIO numbers.
www.plexim.com 3
Vector Control of an Induction Machine
The gate signals are generated by the PWM block. The Carrier type, Carrier frequency and
Blanking time parameters can be configured in an intuitive way from the Main tab of the PWM
block parameters window. The input to the PWM block is obtained from the controller in the form of a
duty cycle, in the range of [0,1]. Please note that each duty cycle signal is fed to both A and B outputs
of an ePWM module, but with opposite polarity. From the Events tab of the PWM block parameter
window, the ADC Trigger parameter is configured as Underflow. This makes the first ePWM module
configured in the PWM generator of the Main tab generate a “start of conversion” impulse for the
ADCs, whenever the carrier value reaches its minimum. With this configuration, an additional output
port called “ADC” appears on the mask of the PWM block. This is connected to the input port called
“Trigger” of the ADC block, via the red dashed signal wire.
The control task is executed after each ADC conversion. This is configured by connecting the output
port called “Task” of the ADC block to a “Control Task Trigger” port from the TI C2000 Target compo-
nent library.
In order to quickly shut down the PWM gate signals in reaction to certain GPIO inputs under fault
condition, three “Trip Zone” events (Tz1 - Tz3) can be configured to the PWM output channels. The
behavior after each trip zone event can be chosen between “Disabled”, “Cycle-by-cycle” and “One-shot”
via the TZx mode parameter of the PWM block. The GPIOs to trigger the trip zone events Tz1 - Tz3
are defined by the TZx GPIO number parameter of the Powerstage Protection block. This block also
controls the software turn on/off of the PWM output and resetting the trip zone event, using its input
port.
3 Simulation
In addition to running a simulation of this demo model in offline mode on a computer, the “Controller”
subsystem can be directly converted into a target specific code for the TI 28069 LaunchPad [4], as con-
figured.
Follow the instructions below to upload the “Controller” subsystem to a TI MCU.
• Connect the MCU to the host computer through a USB cable.
• From the System tab of the Coder + Coder options... window, select “Controller”.
• Next, from the Target tab, select the appropriate target from the dropdown menu. Then under the
General subtab, select the desired Build type.
• Then, to Build and program the MCU directly from PLECS, choose either Run from Flash or Run
from RAM as the Build configuration to program the MCU either to flash memory or to RAM re-
spectively, then select LaunchPad as the Board type, and click Build.
If programmed correctly, LED “D9” (or the LED corresponding to GPIO “DO_DSP_LED” listed in the
model initilization commands) should blink.
For advanced users who are familiar with Code Composer Studio, there is an option to Generate code
into CCS project. Locate the appropriate cg folder from the CCS project (refer to [9] for step-by-step
instructions), enter its path into the CCS project directory field and click Build. The code of the
“Controller” subsystem will be automatically generated. Then, proceed to build and debug the project
as a normal CCS project.
Note If using the RT Box LaunchPad Interface board, make sure that the RST jumper is open
throughout the simulation.
Prior to controlling a real hardware prototype of the power stage with the programmed MCU, it is
highly recommended to first verify the behavior of the controller using a PLECS RT Box and perform
a hardware-in-the-loop (HIL) test. A typical hardware configuration is shown in Fig. 6, where the eval-
uation kit, a TI 28069 LaunchPad (the red board), is connected to the RT Box via an RT Box Launch-
Pad Interface (the green board).
www.plexim.com 4
Vector Control of an Induction Machine
PLECS RT Box
TI 28069
Launchpad
Breakout
Note At this stage, verify that the LEDs corresponding to “DO-28” and “DO-29” on the RT Box
LaunchPad Interface board are turned on.
In order to tune the parameters of the control program in the MCU and observe any intermediate val-
ues, follow the instructions below to connect to the external mode of the TI MCU.
• First, Disconnect the “Plant” subsystem from the External Mode of the PLECS RT Box, if con-
nected.
• Then, from the System tab of the Coder + Coder options... window, select “Controller”.
• Next, from the External Mode tab, select the appropriate Target device and click Connect.
• Then, Activate autotriggering to observe the test results in the “Controller” subsystem Scope.
www.plexim.com 5
Vector Control of an Induction Machine
In this demo model, a step change to the reference torque can be configured by changing the value of
the Constant block “Te”, on the fly, in real-time, since it has been added to the Exceptions list in the
Parameter Inlining tab of the Coder options... window. The step response can be observed in real-
time, as shown in Fig. 7, by setting up an appropriate Trigger control from the External Mode tab.
200
100
0
Stator currents in d-axis (Id)
40 Id*
Current (A)
Id
20
0
Stator currents in q-axis (Iq)
300
Iq*
Current (A)
200 Iq
100
0
Stator currents (Is)
400
Isa
Current (A)
200
Isb
0 Isc
-200
-400
0.0 0.5 1.0 1.5 2.0 × 1e-2
Time (s)
Figure 7: Transient response to a step change of the torque reference in the controller in real-time
Please note that the IO configuration of all the peripheral blocks (ADC, PWM) are configured by map-
ping to the TI 28069 LaunchPad [4]. For a TI MCU other than the TI 28069 LaunchPad, the IO config-
uration has to be adapted. In addition to the TI 28069 LaunchPad, this demo model also supports code
generation for other TI C2000 MCUs, such as the TI 28377S [5], 28379D [6] and 280049C LaunchPads
[7], and TI 28335 controlCARD [8]. From the Model initialization commands window of Simula-
tion Parameters... + Initializations tab from the Simulation menu, change the value of type_evm,
to choose the desired target. Also, remember to configure the corresponding Target in the Coder Op-
tions window accordingly.
4 Conclusion
This model demonstrates an induction machine drive system that supports embedded code generation
for TI C2000 MCUs.
References
[1] R. De Doncker, D. Pulle and A. Veltman, “Advanced Electrical Drives”, Springer, 2011.
www.plexim.com 6
Vector Control of an Induction Machine
[2] Konstantinos G. Papadopoulos, “PID Controller Tuning Using the Magnitude Optimum Crite-
rion”, Springer, 2015.
[3] Damir Vrancic, “Magnitude Optimum Techniques for PID Controllers”, 2012.
www.plexim.com 7
Revision History: