In this experiment, a mathematical model of an induction motor will be simulated using the parameters estimated in the previous experiment. Unlike the previous experiment, in which the model was in the abc domain, the motor will be modeled in the dq frame. With proper alignment of the dq frame, the motor model becomes simpler than a motor model in the abc frame. In addition to reducing the simulation run time, this approach makes it easier to design PI controllers for motor speed, current, or position. The controller will also be evaluated on an actual induction motor in real time.
Motor model
The following set of equations represents a linearized induction motor in the dq frame [1]:
where
Vsd, Vsq, Vrd, and Vrq: stator d-axis, stator q-axis, rotor d-axis, and rotor q-axis voltages, respectively
Isd, Isq, Ird, and Irq: stator d-axis, stator q-axis, rotor d-axis, and rotor q-axis currents, respectively
λsd, λsq, λrd, and λrq: stator d-axis, stator q-axis, rotor d-axis, and rotor q-axis flux linkages, respectively
Rs: stator resistance
Rr: reflected rotor resistance
Lm: per-phase mutual inductance
Ls: Lls + Lm, where Lls is the stator leakage inductance
Lr: Llr + Lm, where Llr is the rotor leakage inductance
J: rotor inertia
B: coefficient of viscous friction
P: number of stator poles
Tem: output/electromagnetic torque
Tl: load torque
ωmech: rotor mechanical speed
ωd: d-axis rotational speed with respect to the stator A-phase magnetic axis
ωda: d-axis rotational speed with respect to the rotor A-phase magnetic axis
The dq quantities are obtained from their corresponding abc by the following equations:
where θ is obtained by integrating the d-axis speed with respect to the corresponding magnetic axis.
In induction-motor vector control, the d-axis is aligned with the rotor-flux axis, which implies that λrq = 0. For the motor under consideration, a squirrel-cage induction motor with shorted rotor bars, the rotor voltages vrd and vrq are both zero. Substituting these conditions and combining the d- and q-axis equations lead to the following simplified equations:
From Eqns. 3 and 8
where \(\tau _{r} = \frac{L_{r}}{R_{r}}\)
From Eqns. 4 and 9
From Eqns. 5 and 9
Equations 6 through 16 represent the simplified motor model when the d-axis is aligned with the rotor-flux axis.
Current controller design
In current-control mode, the stator d- and q-axis currents are controlled under varying load conditions. Under steady-state conditions, the rotor flux is solely a function of isd, as can be inferred from Eqns. 3 and 8. Throughout motor operation, isd is maintained at a constant rated value to achieve a fast dynamic response, i.e., to produce maximum torque with minimum isq. This value is calculated as follows.
Under steady-state conditions, the derivative terms in Eqns. 1 through 4 become zero, ωd = ωsync = 2πf, and ωdA = s * ωsync = ωslip, where s is the slip and f is the frequency of the applied voltage. Assume that the d-axis is aligned with the stator-voltage space vector at time t = 0. Then, vsq = 0 and vsd = √(3/2) x Va, where Va is the rated peak phase voltage. This will not be the case in steady state because the d-axis is aligned with the rotor-flux axis, which is not in phase with the applied stator voltage. However, this will be compensated for later in the computation. Substituting these conditions into Eqns. 1 through 4 yields:
From the four equations above, the stator and rotor dq currents can be computed. The rotor dq flux linkages can then be computed using Eqns. 8 and 9. In vector control, where the d-axis is aligned with the rotor-flux axis, λrq must be zero. This will not be the case here because the d-axis was aligned with the stator voltage. To compensate for this, all computed dq values are rotated by:
In implementation, use a quadrant-aware arctangent when computing this angle.
This will make λrq = 0 and give the rated isd for a d-axis aligned with the rotor flux.
Having determined the reference d-axis stator current, let's proceed with designing the controller for the current loop. From Eqns. 6, 7, and 8, it can be derived that:
where σ is the leakage factor of the induction motor, given by \(\sigma = 1 - \frac{L^{2}_{m}}{L_{s}L_{r}}\)
Substituting these into Eqns. 1 and 2 yields:
For controller design, the last two terms can be ignored as disturbances. The resulting equation in transfer function form is given below:
The transfer function for the q-axis current is the same as that for the d-axis current. Hence, tuning the PI loop for one axis is sufficient. The overall system is shown below:

The ki,p and ki,i gain values are adjusted to achieve the desired transient response. There are multiple ways to quantify the desired response. In the time domain, the desired rise time and overshoot for a step input are typically specified, and the gains are adjusted to satisfy these requirements. Alternatively, in the frequency domain, the desired phase margin and crossover frequency are specified. The latter approach is used here because it provides a clearer picture of system stability. The steady-state response of the system is obtained by substituting s = jω in Eqn. 26.
The system above is tuned for a desired phase margin of Φi at a crossover frequency of ωi,c as follows. At the crossover frequency, the system gain equals 1 and the system phase shift equals -π + Φi. Substituting this into Eqn. 27:
where
and
Given the desired Φi and ωi,c, and the motor parameters, the PI gains can be solved using Eqns. 28 through 30.
Speed controller design
The mechanical-system transfer function can be obtained from Eqn. 10. Ignoring the load torque as a disturbance:
Using Eqns. 14 and 16, the electromagnetic torque can alternatively be represented as follows for vector control in steady state:
The inner current loop can be modeled as a unity-gain transfer function. This assumption is valid as long as the response time of the inner current loop is an order of magnitude shorter than that of the outer speed loop. In other words, the crossover frequency of the inner current loop ωi,c >> the crossover frequency of the outer speed loop ωs,c. As with the current controller, the system above can be represented as follows:
The system above is similar to that of the current controller designed earlier. Following the same procedure, the speed-controller gains are:
where
and
where ks,p and ks,i are the proportional and integral gains, respectively, of the speed PI controller.
The above speed control model is simulated using Workbench in this section.
NoteSave the model at frequent steps.
Open-loop motor model
Create a new project and add a new model file and script file to it.
Set this model file as the Start model/Function in project properties.
Open the script file and initialize all the model parameters, as shown below, using the parameters estimated in the previous experiment.
Public Module IM
Public f As Native Double = 50 ! Rated frequency
Public Rs As Native Double = 1.79 ! Stator Resistance
Public Rr As Native Double = 1.05 ! Rotor Resistance
Public Lls As Native Double = 5E-3 ! Stator leakage Inductance
Public Llr As Native Double = 5E-3 ! Rotor leakage Inductance
Public Lm As Native Double = 30E-3 ! Mutual Inductance
Public Ls As Native Double = Lm + Lls ! Stator Inductance
Public Lr As Native Double = Lm + Llr ! Rotor Inductance
Public J As Native Double = 150E-6 ! Rotor Inertia
Public B As Native Double = 100E-6 ! Coefficient of Viscous friction
Public P As Native Double = 4 ! Number of poles
Public Vllrms As Native Double = 14.7 ! Rated line to line voltage
Public slip As Native Double = 0.1 ! Rated slip
Public ωsyn As Native Double = 2 * π * f ! Synchronous speed at rated frequency
Public ωm As Native Double = (1 - slip) * ωsyn ! Speed at rated slip
Public Va As Native Double = VLLrms * √2 / √3 ! Phase voltage peak
Public τr As Native Double = Lr / Rr
End Module
Open the model file and set its Step time property to 5E-5.
Drag a Subsystem tool from the Signal Routing class in the Toolbox to the model.
A subsystem is an enclosure within which more tools can be added. Double-click the subsystem to open it.
Drag the following tools from the Toolbox to the subsystem and connect them as shown to create the abc-to-dq transformation given in Eqn. 12.
| # | Tool type | Tool class | Tool name |
|---|---|---|---|
| 1 | In-port | Signal Routing | I |
| 2 | In-port | Signal Routing | I1 |
| 3 | Constant | Signal Sources | Constant |
| 4 | Adder Subtractor | Math Block | Add |
| 5 | Elementary Function | Math Block | ElemF |
| 6 | Elementary Function | Math Block | ElemF1 |
| 7 | Multiplier Divider | Math Block | Mul |
| 8 | Multiplier Divider | Math Block | Mul1 |
| 9 | Demux | Signal Routing | DeMux |
| 10 | Demux | Signal Routing | DeMux1 |
| 11 | Adder Subtractor | Math Block | Add1 |
| 12 | Adder Subtractor | Math Block | Add2 |
| 13 | Gain | Math Block | Gain |
| 14 | Gain | Math Block | Gain1 |
| 15 | Concatenate | Matrix Manipulation | Concat |
| 16 | Out-port | Signal Routing | O |

Change the properties of each tool to the values listed in the table below.
| Tool name | Property field | Property value | Comments |
|---|---|---|---|
| I | Name | abc | Input abc signal. |
| I1 | Name | theta | Input theta. |
| Constant | Magnitude | {0, 2 * π / 3, 4 * π / 3} | Muxed 3Φ phase shift signal. |
| Add | Arithmetic operation | +- | Add the cosine terms. |
| ElemF | Function | Cos | |
| ElemF1 | Function | Sin | |
| DeMux | Number of Ports | 3 | Splits the muxed signal into independent signals. |
| DeMux1 | Number of Ports | 3 | Splits the muxed signal into independent signals. |
| Add | Number of ports | 3 | Add the cosine terms. |
| Add2 | Number of ports | 3 | Add the sine terms. |
| Gain | Gain | √2 / √3 | Scale by sqrt(2/3). |
| Gain1 | Gain | -(√2) / √3 | Scale by -sqrt(2/3). |
| Concat | Pivot Dimension | 2 | Combines the signals to form a column matrix. |
| O | Name | dq | Output dq. |
Return to the main motor model by clicking its tab at the top.
Resize the subsystem so that all ports are visible. To resize a tool, drag any of the four squares at its corners.
Drag the following tools from the Toolbox to the model and connect them as shown to test whether the abc-to-dq transformation functions as expected.
| # | Tool type | Tool class | Tool name |
|---|---|---|---|
| 1 | Sine | Signal Sources | Sine |
| 2 | Constant | Signal Sources | Constant |
| 3 | Integrator | Math Block | Integrator |
| 4 | Mag-Time Scope | Display | Scope |

Change the properties of each tool to the values listed in the table below.
| Tool name | Property field | Property value | Comments |
|---|---|---|---|
| Sine | Phase shift (in degrees) | {0, -120, -240} | Input abc signal. |
| Constant | Magnitude | 2 * π * 1 | Frequency of the input signal in rad/s. |
Run the simulation and check whether the results are DC values, with the d-axis equal to zero and the q-axis negative.
Drag the following tools from the Toolbox to the subsystem and connect them as shown to create the dq-to-abc transformation.
| # | Tool type | Tool class | Tool name |
|---|---|---|---|
| 1 | In-port | Signal Routing | I |
| 2 | In-port | Signal Routing | I2 |
| 3 | Constant | Signal Sources | Constant |
| 4 | Demux | Signal Routing | DeMux |
| 5 | Adder Subtractor | Math Block | Add |
| 6 | Elementary Function | Math Block | ElemF |
| 7 | Elementary Function | Math Block | ElemF1 |
| 8 | Multiplier Divider | Math Block | Mul |
| 9 | Multiplier Divider | Math Block | Mul1 |
| 10 | Adder Subtractor | Math Block | Add1 |
| 11 | Gain | Math Block | Gain |
| 12 | Out-port | Signal Routing | O |

Change the properties of each tool to the values listed in the table below.
| Tool name | Property field | Property value | Comments |
|---|---|---|---|
| I | Name | dq | Input dq signal. |
| I1 | Name | theta | Input theta. |
| Constant | Magnitude | {0, 2 * π / 3, 4 * π / 3} | Muxed 3Φ phase shift signal. |
| Add | Arithmetic operation | +- | Add the cosine terms. |
| ElemF | Function | Cos | |
| ElemF1 | Function | Sin | |
| Add1 | Arithmetic operation | +- | Subtract the cosine and sine terms. |
| Gain | Gain | √2 / √3 | Scale by sqrt(2/3). |
| O | Name | abc | Output abc. |
Return to the main motor model by clicking its tab at the top.
Resize the subsystem so that all ports are visible. To resize a tool, drag any of the four squares at its corners.
Drag the following tools from the Toolbox to the model and connect them as shown to test whether the abc-to-dq transformation functions as expected. The output of ABCtoDQ is a column matrix, while the input of DQtoABC is a muxed signal. Therefore, the signal format must be converted.
| # | Tool type | Tool class | Tool name |
|---|---|---|---|
| 1 | Decatenate | Matrix Manipulation | Decat |
| 2 | Mux | Signal Routing | Mux |

Change the properties of each tool to the values listed in the table below.
| Tool name | Property field | Property value | Comments |
|---|---|---|---|
| Decat | Pivot Dimension | 2 | Splits along the row. |
Run the simulation and check whether the results are the same as the input.
Delete the Decat and Mux tools.
The next step is to determine the motor's stator flux, as given in Eqn. 13. Create another subsystem, drag the tools listed below into it, and connect them as shown to implement the equation.
| # | Tool type | Tool class | Tool name |
|---|---|---|---|
| 1 | In-port | Signal Routing | I |
| 2 | In-port | Signal Routing | I1 |
| 3 | In-port | Signal Routing | I1 |
| 4 | Constant | Signal Sources | Constant |
| 5 | Multiplier Divider | Math Block | Mul |
| 6 | Multiplier Divider | Math Block | Mul1 |
| 7 | Gain | Math Block | Gain |
| 8 | Adder Subtractor | Math Block | Add |
| 9 | Integrator | Math Block | Integrator |
| 10 | Out-port | Signal Routing | O |

Change the properties of each tool to the values listed in the table below.
| Tool name | Property field | Property value | Comments |
|---|---|---|---|
| I | Name | vsdq | Stator voltage dq signal, vsdq. |
| I1 | Name | isdq | Stator current dq signal, isdq. |
| I2 | Name | wd | d-axis speed, ωd. |
| Gain | Gain | IM:Rs | Stator resistance, Rs. |
| Constant | Magnitude | [[0, -1], [1, 0]] | Rotational matrix. |
| Add | Number of ports | 3 | |
| Add | Arithmetic operation | +-- | |
| Integrator | Initial value | [[0], [0]] | Initial stator flux linkage. |
| O | Name | fsdq | Stator dq flux, λsdq. |
The next step is to determine the stator and rotor currents from the flux, as given in Eqns. 6 through 10. Drag the tools listed below into the model and connect them as shown to implement the equations.
| # | Tool type | Tool class | Tool name |
|---|---|---|---|
| 1 | Constant | Signal Sources | Constant1 |
| 2 | Concatenation | Matrix Manipulation | Concat |
| 3 | Concatenation | Matrix Manipulation | Concat1 |
| 4 | Constant | Signal Sources | Constant2 |
| 5 | Multiplier Divider | Math Block | Mul |
| 6 | Decatenation | Matrix Manipulation | Decat |
| 7 | Decatenation | Matrix Manipulation | Decat |

Change the properties of each tool to the values listed in the table below.
| Tool name | Property field | Property value | Comments |
|---|---|---|---|
| Concat | Pivot Dimension | 2 | Combine λsd and λsq. |
| Concat1 | Pivot Dimension | 2 | Combine λrd and λrq. |
| Constant1 | Magnitude | 0 | λrq = 0. |
| Constant2 | Magnitude | 1/[[IM:Ls, 0, IM:Lm, 0], [0, IM:Ls, 0, IM:Lm], [IM:Lm, 0, IM:Lr, 0], [0, IM:Lm, 0, IM:Lr]] | Eqns. 6 through 10. |
| Decat | Pivot Dimension | 2 | Split into isdq and irdq. |
| Decat | Pivot Dimension | 2 | Split into isd and isq. |
The next step is to determine the rotor flux and d-axis speed to close the model loop. As before, add the following tools and connect them as shown.
| # | Tool type | Tool class | Tool name |
|---|---|---|---|
| 1 | Gain | Math Block | Gain |
| 2 | Adder Subtractor | Math Block | Add |
| 3 | Integrator | Math Block | Integrator1 |
| 4 | Gain | Math Block | Gain1 |
| 5 | Multiplier Divider | Math Block | Mul1 |
| 6 | Multiplier Divider | Math Block | Mul2 |
| 7 | Gain | Math Block | Gain2 |
| 8 | Gain | Math Block | Gain3 |

Change the properties of each tool to the values listed in the table below.
| Tool name | Property field | Property value | Comments |
|---|---|---|---|
| Gain | Gain | IM:Lm / IM:τr | Eqn. 14. λrd calculation. |
| Add1 | Arithmetic operation | -+ | Eqn. 14. λrd calculation. |
| Gain1 | Gain | 1 / IM:τr | Eqn. 14. λrd calculation. |
| Integrator1 | Initial value | 0.001 | Eqn. 14. Prevents a division-by-zero error. Its output is λrd. |
| Mul1 | Arithmetic operation | x/ | Eqn. 15. ωdA calculation. |
| Gain2 | Gain | IM:Lm / IM:τr | Eqn. 15. ωdA calculation. Its output is ωdA. |
| Gain3 | Gain | (IM:p / 2) * IM:Lm / IM:Lr | Eqn. 16. Torque calculation. Its output is Tem. |
The last remaining step is to determine the rotor speed using Eqn. 10. The rotor-flux-axis speed is obtained from the rotor speed and ωdA using Eqn. 11. To do this, add the following tools and connect them as shown.
| # | Tool type | Tool class | Tool name |
|---|---|---|---|
| 1 | Constant | Signal Sources | Constant3 |
| 2 | Adder Subtractor | Math Block | Add1 |
| 3 | Transfer function | Continuous | TransferFnc |
| 4 | Gain | Math Block | Gain4 |
| 5 | Adder Subtractor | Math Block | Add2 |

Change the properties of each tool to the values listed in the table below.
| Tool name | Property field | Property value | Comments |
|---|---|---|---|
| Constant3 | Magnitude | 0 | Eqn. 10. Load torque Tl. |
| Add1 | Arithmetic operation | +- | Eqn. 10. Tem - Tl. |
| TransferFnc | Numerator | {1} | Eqn. 10 can be represented in transfer function form as (Tem - TL)/(sJ + B). |
| TransferFnc | Denominator | {IM:J, IM:B} | Eqn. 10 can be represented in transfer function form as (Tem - TL)/(sJ + B). Output of this block is the motor mechanical speed, ωmech. |
| Gain4 | Gain | IM:p / 2 | ωm = P/2 x ωmech. |
| Add2 | Arithmetic operation | ++ | ωd = ωm + ωdA. |
All that remains is to close the loop. Delete the Constant tool connected to the abc → dq subsystem. This was initially used as the d-axis speed and is no longer needed since we have the actual d-axis speed, aligned with rotor flux. Connect the output of Add2, which is ωd, to the input of Integrator2. The output of Integrator2 is θda, which must be connected to the theta input of the dq → abc subsystem. Also connect the output of Add2, ωd, to the ωd input of the stator-flux subsystem. The stator dq currents for the stator-flux subsystem, isdq, are obtained by connecting the output of Decat. Finally, the rotor d-axis flux, λrd, i.e., the output of Integrator1, is connected to the input of Concat1. The overall induction-motor dq model, with its d-axis aligned with the rotor flux, is shown below.

Set the input voltage and frequency in the Sine block.
| Tool name | Property field | Property value | Comments |
|---|---|---|---|
| Sine | Magnitude | IM:Va | Rated peak phase voltage. |
| Sine | Frequency (Hz) | IM:f | Rated frequency. |
Set the model Run time to 3.
Add scopes to observe the abc and dq stator voltages and currents, motor speed, electromagnetic torque, and any other values of interest.
Run the simulation and observe the results.
Obtain results for the following operating conditions:
Input frequency = 0.5 x Rated frequency, Input voltage = 1 x Rated voltage
Input frequency = 1 x Rated frequency, Input voltage = 0.5 x Rated voltage
Input frequency = 0.5 x Rated frequency, Input voltage = 0.5 x Rated voltage
Input frequency = Rated frequency, Input voltage = Rated voltage
Replace the constant load torque with a Step from Signal Sources. Set the step's Final value to 0.1 and its Step time to 2.
Rerun the simulation and observe the results.
If a runtime exception occurs, use the DataPeek window docked on the right to inspect each tool's inputs, outputs, and parameters immediately before the exception occurred.
This window can be used to observe the value of any tool or code variable at any time.
Click the
icon in the DataPeek window and select a tool to view its value.
Similarly, to view the value of a variable in the script file, place the cursor on the variable and double-click it. Its value will appear in the DataPeek window.
Motor current control
In this section, the current through the motor is controlled using a PI controller.
Compute ki,p and ki,i using Eqns. 28 through 30 so that the system has a phase margin of Φi = π/3 at a crossover frequency of ωi,c = 2π x 200. The crossover frequency is chosen as 200 Hz, which is less than one-tenth of the 6 kHz switching frequency. As a rule of thumb, every additional loop should have a bandwidth no greater than one-tenth that of the inner loop. In this case, it helps prevent the current controller from trying to compensate the switching current harmonics.
Open a new instance of Workbench.
In the motor model designed earlier, the motor currents and speed are determined from the applied terminal voltage and load torque. These two parameters are measured using current and speed sensors for sensored vector control. From these two parameters, the rotor-flux position is established using Eqns. 11 and 15, as implemented earlier within the motor model. The control voltages are generated in the dq frame and must be converted to abc voltages to be generated by the power processing unit. This dq-abc transformation has been implemented earlier as well.
These two blocks are already implemented and can be opened from the examples folder, usually located at C:\Program Files (x86)\Sciamble\WorkBench v1\Examples\CUSPLab\AdvancedDrives\Experiment4\CurrentController. This motor-model subsystem is the model that was built in the previous section and has been enclosed within a subsystem. In addition, the abc-dq transformation and the estimator subsystem have been added to the model file.

Add another subsystem to the model in which the d-axis PI current controller will be modeled. Double-click the subsystem to open it.
Drag the following tools from the Toolbox to the subsystem and connect them as shown.
| # | Tool type | Tool class | Tool name |
|---|---|---|---|
| 1 | In-port | Signal Routing | I |
| 2 | In-port | Signal Routing | I1 |
| 3 | Adder Subtractor | Math Block | Add |
| 4 | Gain | Math Block | Gain |
| 5 | Gain | Math Block | Gain1 |
| 6 | Integrator | Math Block | Integrator |
| 7 | Adder Subtractor | Math Block | Add2 |
| 8 | Saturation | Non-linear | Saturation |
| 9 | Out-port | Signal Routing | O |

Change the properties of each tool to the values listed in the table below.
| Tool name | Property field | Property value | Comments |
|---|---|---|---|
| I | Name | Ref | Desired reference motor current. |
| I1 | Name | Fbk | Actual motor current. |
| Add | Arithmetic operation | +- | Difference between the desired and actual motor current. |
| Gain | Gain | ki,p | Substitute the value of ki,p computed in step 1. |
| Gain1 | Gain | ki,i | Substitute the value of ki,i computed in step 1. |
| Integrator | Integrator Type | Anti-windup | Reason explained later. |
| Integrator | Upper Limit | 20 | |
| Integrator | Lower Limit | -20 | |
| Saturation | Upper Limit | 20 | |
| Saturation | Lower Limit | -20 | |
| O | Name | Out | Applied terminal voltage to generate the desired current profile. |
When there is a large difference between the desired and actual currents, the PI controller produces a large output voltage to correct the error quickly. In a physical system, the magnitude of this voltage is limited by either the available DC-bus voltage or the voltage ratings of the motor and power electronics. Therefore, in a practical implementation of a PI controller, the controller output is limited to the maximum possible voltage. During transient conditions, when the actual current differs from the desired current, the integrator in the PI controller can rapidly build its output to a large value because of the persistent input error. When the error returns to zero, this large accumulated output does not immediately decay and can cause the actual current to overshoot the desired value. The error then becomes negative, causing the integrator output to fall, but it can fall by more than desired and cause the current to undershoot. This cycle can repeat, and the oscillation may decay slowly. To avoid this, the range over which the integrator is active is clamped by setting it to Anti-windup. If the integrator output reaches this limit, the integrator is disabled until the polarity of the error reverses. This improves the response of the system significantly.
Create a copy of the PI subsystem for q-axis current control. Connect the outputs of these two PI controllers to the dq-to-abc subsystem as shown:

Set the d-axis current reference to a constant obtained by solving Eqns. 17 through 21.
Set the q-axis current reference to step from 0 A to 1 A at time t = 2 s.
Add a step load torque and for the time being set the Final value to 0.
Run the simulation and observe whether the steady-state dq currents match the reference currents and whether the transient response is satisfactory.
Motor speed control
In this section, the speed of the motor is controlled using a PI controller.
Compute ks,p and ks,i using Eqns. 33 through 36 so that the system has a phase margin of Φs = π/3 at a crossover frequency of ωs,c = ωi,c/10 = 2π x 20. The crossover frequency is chosen as 20 Hz, which is one-tenth of the crossover frequency of the inner current loop.
Replace the step source for the q-axis current reference with a PI-controller subsystem whose output will be the reference q-axis current.
Change the PI gains to the values computed in the earlier step. Saturate the integrator and the PI subsystem's output to 5, which is the transient current limit of the motor under test.
Connect the feedback input to the motor speed from the motor-model subsystem. Apply a step-speed reference from 0 to 100 rad/s at time t = 2 s.
Change the Final value of the load torque to 0.05 N·m at time t = 4 s.
Run the simulation and observe whether the motor's steady-state speed matches the reference speed.
This concludes the simulation of induction-motor vector control. In the following section, a prebuilt induction-motor vector-control model is run in real time.
Open Workbench and pin the Explorer and Properties docks.
Navigate to and open the IMVectorControl project file in the Experiment4\Realtime folder, usually located at C:\Program Files (x86)\Sciamble\WorkBench v1\Examples\CUSPLab\AdvancedDrives.
Expand the project in the Explorer and open the ModelFile model file shown below:

The top section of the model contains the induction-motor vector control and is a replication of the simulation model developed earlier, with a few additions to enable real-time control. On the left is the speed PI controller, followed by the d- and q-axis current PI controllers, whose outputs are the dq terminal voltages. The following subsystem converts the dq voltages to abc voltages. In the simulation model, this terminal-voltage signal was connected to the motor model. Here, it is converted to the inverter's PWM duty cycles to control the induction motor in real time. In real-time mode, ADCs measure the actual motor stator currents; these are located in the top-right corner of the model. The A-quad-B encoder measures the mechanical rotor position, from which the model obtains the mechanical rotor speed. The encoder does not directly measure the rotor-flux angle. The controller obtains the rotor-flux electrical speed by adding the mechanical electrical speed to the estimated slip speed, then integrates that result to obtain the rotor-flux angle used by the dq transformations.
The bottom section consists of the DC motor current control. This is used to emulate the load torque.
The Init() function in the IMParam script file computes the controller parameters from the motor parameters, loop crossover frequency, and phase margin. Set the speed-loop crossover frequency ωc and phase margin φm in the script to the same values used in the simulation.
The Init() function must be called before running the simulation model to initialize the controller gain values. To do this, open the project properties by double-clicking the IMVectorControl project node in the Explorer, and set the Prerun Model/Function to IMParam:Init() as shown below:
Similarly, set Start model/Function to ModelFile to run the model after parameter initialization.

Click the
button to run the model in simulation mode. Using DataPeek, verify that the controller-gain parameters computed by the Init() function match the values computed earlier.
Turn ON the DC power supply and set the voltage to 40 V.
Ensure that the
button on the top dock is pressed to enter real-time mode. Click the run button.
NoteWhen the real-time mode button is pressed, the motor model is grayed out. Grayed-out tools are not coded for real-time operation. Workbench can automatically identify which tools need to be coded for real-time operation and which do not. This allows a single unified model to be used for both real-time operation and simulation while generating highly optimized real-time code.
Observe the speed and current results in the scope. Click
to focus the results. After about 5 s, stop data logging by clicking
.
Turn OFF the DC power supply.
If necessary, repeat the experiment for different loop crossover frequencies and phase margins.
Turn OFF the DC power supply and disconnect all connections, including the USB cable.
List the kp and ki values of the current and speed PI controllers.
Attach the plot of 3φ stator and rotor currents from simulation.
Attach plots of the electromagnetic-torque response, stator dq currents, and rotor speed from both the simulation and real-time experiment.
Ignoring the noise in the waveform in real-time mode, do the stator dq currents and the electromagnetic torque waveforms match those obtained from simulation? If not, explain why.
Read through the Init() function and add comments to each line of code. Later experiments will require writing a script file to compute the controller parameters.
"Analysis and Control of Electric Drives: Simulations and Laboratory Implementation," Ned Mohan and Siddharth Raju, Wiley Publication.