In previous experiments, the induction motor dq model and its controller were developed and tested in simulation and real time. The power-processing unit was considered a black box that generated the desired inverter-output voltage from a reference voltage. In this experiment, the operation of the power-processing unit and its modulation algorithm is explored in detail. The next section covers the theoretical background for this experiment, followed by a simulation of a switched-mode DC-AC converter. Finally, the simulation model is verified in real-time.
Consider the 3Φ two-level inverter shown below:

At no instant can both switches of a leg be simultaneously ON, as this will lead to shoot-through by directly shorting the DC bus. Thus, switches SA+ and SA- cannot be ON simultaneously. Similarly, switches SB+ and SB-, and SC+ and SC- cannot be ON simultaneously. Under normal complementary PWM operation, exactly one transistor in each leg is commanded ON. During the inserted dead time, both transistors are commanded OFF and the load-inductor current freewheels through a body diode, depending on the current direction. When switch SA+ is ON, the phase-A output voltage with respect to the DC bus neutral VaN = Vdc. When switch SA- is ON, VaN = 0. Similarly, the other phase output voltages can be controlled by turning ON and OFF their respective switches. The common-mode voltage VnN, i.e., the voltage between the load's neutral terminal n and the DC-bus negative terminal N, is given by Eqn. 1, and the phase voltages Van, Vbn, and Vcn are given by Eqns. 2, 3, and 4:
The output voltage of each phase can be controlled by adjusting the ratio of the top-switch ON time to the bottom-switch ON time for that leg. If SA+ is switched ON for time Ton and SA- is switched ON for time Toff alternatively, then the average output voltage is given by Eqn. 5. In pulse-width modulation, the sum Ton + Toff is held constant and is called the switching period, Tprd. Its inverse is the switching frequency. As Ton is varied from 0 to Tprd, the output voltage varies between 0 and Vdc. The duty cycle is the fraction of the switching period for which switch SA+ must be held ON to generate the desired output voltage, as given in Eqn. 6. The duty cycles for phases B and C are obtained similarly.
The duty cycles of the three phases can be modulated to generate the desired voltage at the inverter terminals. One modulation algorithm that does this is sine PWM (SPWM). In this method, the three phase duty cycles are generated from the desired 3Φ sinusoidal reference output phase voltages, as given by Eqns. 7, 8, and 9.
If the desired 3Φ output voltages are balanced sinusoidal voltages, as is the case here, the equations above can be rewritten as follows:
where m is the modulation index, defined as the ratio of the peak output phase voltage to the DC-bus voltage:
To generate the gate signal for switch SA+ from dutyA, the duty cycle is compared with a triangular carrier that varies from 0 to 1. The triangular carrier repeats every 1/fswitch, where fswitch is the desired switching frequency. In SPWM, the reference output voltage is used to generate the duty cycles. This limits the maximum magnitude of the modulation index to 0.5. As shown by Eqns. 10 through 12, if the modulation index exceeds this limit, the output becomes saturated because the duty cycles exceed the range [0, 1]. With this method, the peak line-to-line output voltage is limited to \(\frac{\sqrt{3}}{2}V_{\mathrm{dc}}\). This is not the maximum achievable output voltage, and this limitation is overcome by space-vector pulse-width modulation (SVPWM).
SVPWM uses the fact that the load's neutral point n is floating to increase the output-voltage range further. If all three duty cycles are equal, the phase voltages Van, Vbn, and Vcn are all 0, even though the output-terminal voltages with respect to the DC-bus negative terminal—VaN, VbN, and VcN— need not be zero. Applying an equal voltage to all three phases produces only the common-mode voltage given by Eqn. 1 and no net potential difference between the output terminals. This is used to increase the output-voltage range by modifying the duty-cycle equations as follows:
Adding the third-harmonic component, \(\frac{\sin(3\theta )}{6}\), allows the modulation index to reach \(\frac{1}{\sqrt{3}}\). Thus, the peak line-to-line output voltage can reach Vdc using SVPWM, compared with \(\frac{\sqrt{3}}{2}V_{\mathrm{dc}}\) using SPWM. Despite the addition of the third-harmonic component, the output phase voltages are sinusoidal and contain only the fundamental component when switching-frequency components are ignored. The third-harmonic components appear only as common-mode voltage because they are the same in all three phases.
The same algorithm can be implemented in different ways using other combinations of odd triplen harmonics, all of which produce the same theoretical maximum output voltage. The duty cycles for one such method, which avoids direct computation of the third-harmonic component, are given below:
The above operation is simulated in this section using Workbench.
Sine-PWM:
Create a new project, and add a new model file to the project.
Set this model file as the Start model/Function in project properties.
Drag and drop the following tools from the Toolbox and connect them as shown.
| # | Tool type | Tool class | Tool name |
|---|---|---|---|
| 1 | Sine | Signal Sources | Sine |
| 2 | Gain | Math Block | Gain |
| 3 | Increment | Math Block | Increment |
| 4 | Triangle | Signal Sources | Triangle |
| 5 | Mag-Time Scope | Display | Scope |
| 6 | Comparator | Logical Block | Comparator |
| 7 | Boolean-Numeric cast | Signal Conversion | TypeCast |
| 8 | Gain | Math Block | Gain1 |
| 9 | Demux | Signal Routing | Demux |
| 10 | Adder Subtractor | Math Block | Add |
| 11 | Adder Subtractor | Math Block | Add1 |
| 12 | Gain | Math Block | Gain2 |
| 13 | Moving Average | Discrete | MovingAvg |
| 14 | Adder Subtractor | Math Block | Add2 |
| 15 | Mag-Time Scope | Display | Scope1 |
| 16 | Mag-Time Scope | Display | Scope2 |
| 17 | Demux | Signal Routing | Demux1 |
| 18 | Moving Average | Discrete | MovingAvg1 |
| 19 | Mag-Time Scope | Display | Scope3 |
| 20 | Mag-Time Scope | Display | Scope4 |

Change the properties of each tool to the values listed in the table below. The reason for each value is given in the rightmost column. To access a tool's properties, double-click the tool; its properties will appear in the Properties dock.
| Tool name | Property field | Property value | Comments |
|---|---|---|---|
| Sine | Phase shift | {0, -120, -240} | 3Φ reference voltage signal. |
| Sine | Frequency | 50 | 50 Hz reference voltage. |
| Gain | Gain | 0.5 | Maximum modulation index in Eqns. 7 through 9. |
| Increment | Offset | 0.5 | 0.5 offset in Eqns. 7 through 9. |
| Triangle | Frequency | 10000 | Carrier/switching frequency is 10 kHz. |
| Triangle | Waveform | Triangle | Choosing a triangular carrier instead of a sawtooth carrier reduces the THD and switching losses for this converter. |
| Scope | - | - | Scope to display the 3Φ duty-cycles. |
| Comparator | Function | < | Compares the triangle carrier with dutyA, dutyB, and dutyC and outputs True when the carrier is less than the corresponding duty cycle; otherwise, it outputs False. |
| TypeCast | - | - | True/False does not have an intrinsic numeric value. This tool converts True to 1 and False to 0. Other values can also be selected in the properties. |
| Gain1 | Gain | 100 | When switch is ON, i.e. output of TypeCast is 1, the output voltage is 100 V. This scales the gate signal by the DC bus voltage to model an ideal switch. |
| Demux | Number of ports | 3 | Splits the muxed 3Φ terminal voltages into the individual components VaN, VbN, and VcN. |
| Add | Number of ports | 3 | Computes the common-mode voltage in Eqn. 1. |
| Add1 | Arithmetic operation | +- | Line-line voltage Vab = VaN - VbN. |
| Gain2 | Gain | 1/3 | Computes the common-mode voltage in Eqn. 1. |
| MovingAvg | Number of Samples | 100 | Averages the output line-to-line voltage Vab over a switching period. |
| Add2 | Arithmetic operation | +- | Computes the 3Φ output phase voltages in Eqns. 2 through 4. |
| Scope1 | - | - | Scope to display Vab switching voltage. |
| Scope2 | - | - | Scope to display Vab average voltage. |
| MovingAvg1 | Number of Samples | 100 | Averages the output phase voltage Van over a switching period. |
| Demux1 | Number of ports | 3 | Splits the muxed 3Φ phase voltages into the individual components Van, Vbn, and Vcn. |
| Scope3 | - | - | Scope to display Van average voltage. |
| Scope4 | - | - | Scope to display Van switching voltage. |
Since the carrier frequency is set to 10 kHz, the simulation step frequency is set to at least 100 times the carrier frequency to provide sufficient resolution. Set the model step time to 1/(10 kHz)/100 = 1E-6 s. To do this, double-click anywhere in the blank space of the model file. This opens the model properties in the Properties dock. Change the Step time from 0.01 to 1E-6.
While at it, change the Run time from 10 to 0.05.
Run the simulation and observe the scope results. The switching phase voltage Van and switching line-to-line voltage Vab are shown in Scope4 and Scope1, respectively. Their waveforms after filtering the switching-frequency component are shown in Scope3 and Scope2, respectively. Verify that the frequency, waveform, and magnitude are as expected.
Rerun the simulation for different output voltages. Change the output voltage by adjusting the gain of the Gain block from 0 to 0.5, and observe the results. Also note the generated output waveform when the gain is set to 1/√3.
Space vector PWM - Third harmonic injection:
Create a new project, and add a new model file to the project.
Set this model file as the Start model/Function in project properties.
Open the previously created Sine-PWM model file. Select all the tools in the model CtrlA and copy them CtrlC.
Paste CtrlV the copied model into the newly created model file.
Edit the pasted model by adding a third-harmonic component to the reference sine wave, as shown below. The newly added tools are highlighted in green.

Set the property of the newly added Sine1 tool as given below.
| Tool name | Property field | Property value | Comments |
|---|---|---|---|
| Sine1 | Magnitude | 1/6 | Magnitude of the third-harmonic voltage, as given by Eqns. 14 through 16. |
| Sine | Phase shift | 0 | The third-harmonic voltages are in phase. |
| Sine | Frequency | 150 | The frequency of the third-harmonic voltages is three times the fundamental frequency. |
Set the model run time to 0.05s and step time to 1E-6 s.
Run the simulation and observe the scope result.
Rerun the simulation for different output voltages. Change the output voltage by adjusting the gain of the Gain block from 0 to 1/√3, and observe the results. Rerun the simulation for a gain value greater than 1/√3 and observe the results.
Space vector PWM - Min-max method:
Create a new project, and add a new model file to the project.
Set this model file as the Start model/Function in project properties.
Open the previously created Sine-PWM model file. Select all the tools in the model CtrlA and copy them CtrlC.
Paste CtrlV the copied model into the newly created model file.
Edit the pasted model by adding the tools highlighted in green to implement the min-max method as given by Eqns. 17 through 19.
| # | Tool type | Tool class | Tool name |
|---|---|---|---|
| 1 | De-mux | Signal Routing | Demux2 |
| 2 | Maximum Minimum | Math Block | MinMax |
| 3 | Maximum Minimum | Math Block | MinMax1 |
| 4 | Adder Subtractor | Math Block | Add3 |
| 5 | Gain | Math Block | Gain3 |
| 6 | Adder Subtractor | Math Block | Add4 |

Set the properties of the newly added tools as given below.
| Tool name | Property field | Property value | Comments |
|---|---|---|---|
| Demux2 | Number of ports | 3 | Separates the three muxed 3Φ reference signals. |
| MinMax | Number of ports | 3 | Maximum of the three reference voltages. |
| MinMax | Function | Maximum | Maximum of the three reference voltages. |
| MinMax1 | Number of ports | 3 | Minimum of the three reference voltages. |
| MinMax1 | Function | Minimum | Minimum of the three reference voltages. |
| Add3 | Arithmetic operation | ++ | Dutyk as given by Eqn. 20. |
| Gain3 | Gain | 0.5 | Eqns. 17 through 19. |
| Add4 | Arithmetic operation | +- | Eqns. 17 through 19. |
Set the model run time to 0.05s and step time to 1E-6 s.
Run the simulation and observe the scope result.
Rerun the simulation for different output voltages. Change the output voltage by adjusting the gain of the Gain block from 0 to 1/√3, and observe the results. Rerun the simulation for a gain value greater than 1/√3 and observe the results.
The above simulation is run in real-time in this section.
Sine-PWM:
Open the previously developed Sine-PWM simulation model.
The real-time controller inside the three-inverter module has a dedicated PWM peripheral that can generate PWM pulses from a duty cycle. It automatically generates the triangular carrier and compares it with the duty cycles to generate the pulses. Hence, the tools that generated the triangular carrier and compared it with the reference to generate the switching pulses are no longer needed for real-time control. The tools that generate the reference signals are retained, as shown below.

Separate the three duty cycles using a Demux tool.
The functionality of tools deleted in the previous step is replaced by the PWM Output tool from the Hardware Integration tool class. Add three of these and connect them as shown:

As shown in the image above, the three PWM blocks are highlighted in red, which indicates an error. To view the cause of the error, click the Messages tab in the bottom dock. This displays the following window:

This error occurs because the real-time controller being used has not been specified. Not all controllers support PWM peripherals. To select a device, open the project properties by double-clicking the project node in Explorer. In the Properties dock, click the uppermost drop-down menu, labeled Simulation Settings, and select Device Configuration. Change the Device property from None to 3 Inverter. Also change the following properties:
Frequency in PWM Configuration from 6000 to 10000
Waveform in PWM Configuration from Sawtooth to Triangle
Since the control algorithm no longer needs to generate the reference carrier, the model step time can be relaxed. To increase it, open the model properties by double-clicking anywhere in the model's blank space. Change the Step time to 0.001 in the Properties dock.
At this point, the initial error is replaced by new errors stating that the three PWM peripherals point to the same channel. They will be cleared when the channels are set. All three phases of Inverter 1 are used. Leave PWM on channel 1 for phase A, change PWM1 to channel 2 for phase B, and change PWM2 to channel 3 for phase C. Once these are set, the errors disappear.
NoteAs long as there is any error, the model cannot be run.
By default, the inverter outputs are held in a high-impedance state. To enable the inverter so that it can be actively driven, the reset pin must be pulled high. Add the following two blocks, as shown, and set the properties given in the table below:
| Tool name | Tool Class | Property field | Property value |
|---|---|---|---|
| Boolean | Signal Sources | Value | True |
| GPO | Hardware Integration | Channel | 1 |

Click the
icon in the top dock to save all files.
WarningEnsure that the DC power supply is turned off. Avoid any accidental short-circuit in the following connections.
Connect the three-inverter module to the DC supply via the back panel. Connect the USB cable from the computer to the inverter module. Connect the DSO probe across the Phase A (black terminal) output of Inverter 1 and input DC bus negative (black terminal on the back panel of the inverter module). Similarly, connect another probe across Phase B (red terminal) output of Inverter 1 and input DC bus negative.
Click the
button on the top dock to transition from simulation to real-time mode.
WarningTake all necessary lab safety precautions.
Turn ON the DC power supply and set the voltage to 40 V. Click the
to run the system in real-time.
Observe the switching waveform on the DSO. Click
to halt the communication between the computer and the inverter.
This only stops the data transfer and not the inverter module, as can be seen with the switching pulses still being actively generated.
Change the modulation index in the Gain tool to a value between 0 and 0.5, and press the
to run the inverter with the new duty cycles.
Repeat this step for different modulation-index values. With a 40 V DC bus, the corresponding peak phase-voltage reference ranges from 0 to 20 V.
WarningEnsure that the probe attenuation is set to 10x to avoid overloading the DSO.
Click
and turn OFF the DC power supply.
Space vector PWM - Third harmonic injection:
Open the previously developed third-harmonic-injection simulation model.
Open project properties and change the Device property from None to 3 Inverter in the Device Configuration page. Also change the following properties:
Frequency in PWM Configuration from 6000 to 10000
Waveform in PWM Configuration from Sawtooth to Triangle
As in the real-time sine-PWM implementation, remove all tools other than those that generate the reference duty cycles. Add the PWM and GPO tools as before, and set them to the same channels used earlier. The final model after these modifications is shown below.

Change the model Step time to 0.001.
Click the
button on the top dock to transition from simulation to real-time mode.
WarningTake all necessary lab safety precautions.
Turn ON the DC power supply and set the voltage to 40 V. Click the
to run the system in real-time.
Observe the switching waveform on the DSO. Click
to halt the communication between the computer and the inverter.
This only stops the data transfer and not the inverter module, as can be seen with the switching pulses still being actively generated.
Change the modulation index in the Gain tool to a value between 0 and 1/√3, and press the
to run the inverter with the new duty cycles.
Repeat this step for different modulation-index values. With a 40 V DC bus, the corresponding peak phase-voltage reference ranges from 0 to approximately 23.1 V.
Click
and turn OFF the DC power supply.
Space vector PWM - Min-max method:
Open the previously developed min-max simulation model.
Open project properties and change the Device property from None to 3 Inverter in the Device Configuration page. Also change the following properties:
Frequency in PWM Configuration from 6000 to 10000
Waveform in PWM Configuration from Sawtooth to Triangle
As in the real-time sine-PWM implementation, remove all tools other than those that generate the reference duty cycles. Add the PWM and GPO tools as before, and set them to the same channels used earlier. The final model after these modifications is shown below.

Change the model Step time to 0.001.
Click the
button on the top dock to transition from simulation to real-time mode.
WarningTake all necessary lab safety precautions.
Turn ON the DC power supply and set the voltage to 40 V. Click the
to run the system in real-time.
Observe the switching waveform on the DSO. Click
to halt the communication between the computer and the inverter.
This only stops the data transfer and not the inverter module, as can be seen with the switching pulses still being actively generated.
Change the modulation index in the Gain tool to a value between 0 and 1/√3, and press the
to run the inverter with the new duty cycles.
Repeat this step for different modulation-index values. With a 40 V DC bus, the corresponding peak phase-voltage reference ranges from 0 to approximately 23.1 V.
Click
, turn OFF the DC power supply, and disconnect all connections, including the USB cable.
This concludes the experiment on a DC-AC switched-mode converter.
Attach separate screenshots of the simulation and real-time models for all three PWM control schemes.
Attach screenshots of the phase voltage Van and line-to-line voltage Vab at different modulation indices for all three PWM control schemes.
Attach the phase-A and phase-B voltages observed on the DSO at different duty cycles in real-time mode for all three PWM control schemes.
Measure the output voltage, i.e., the voltage at phase A with respect to phase B. This can be done using the subtract function on the scope.
WarningDo not connect a nonisolated probe directly across phases A and B, especially when the USB cable is connected, as this will create a ground loop with nonzero potential and could destroy the computer, inverter module, or DSO.
Verify whether the output-voltage frequency matches the set frequency. Check whether the voltage matches the expected value. If not, explain why.
For a DC-bus voltage of 40 V, what is the maximum balanced sinusoidal peak phase voltage attainable using each of the three PWM control schemes?