In the previous experiment, a pre-built DC motor speed control model was simulated and executed in real-time. In this experiment, one of the components, the switched mode converter will be explored in further detail. The next section deals with the theoretical background for this experiment followed by the simulation of a switched-mode DC converter. Finally, the simulation model is verified in real-time.
Consider half-bridge converter shown below:
At no instant, can both switches be simultaneously ON, because this will lead to shoot-through because of directly shorting the DC bus. When switch S1 is ON, the output voltage Vo = Vdc. When switch S2 is ON, the output voltage Vo = 0. If S1 is switched ON for time Ton and S2 is switched ON for time Toff alternatively, then the average output voltage is given by Eqn. 1. In pulse width modulation, the total, Ton + Toff is held constant, called the switching period, Tprd. Inverse of this gives the switching frequency. As Ton is varied from 0 to Tprd, the output voltage varies between 0 and Vdc. The duty-cycle is the ratio of switching period during which, switch S1 must be held ON to generate the desired output voltage, as given in Eqn. 2.
Vo = TonTon + Toff × Vdc = duty × Vdc(1)
duty = VoVdc(2)
The half-bridge converter allows only generation of a unipolar output voltage of variable magnitude. This limitation is overcome by using a full-bridge converter shown below:
The output voltage is given in Eqn. 3 where Van and Vbn are the output voltage of each half-bridge with respect to the DC bus negative. The duty-cycle for each half-bridge is given in Eqns. 4 and 5.
Vo = Van − Vbn(3)
dutyA = 12 + Vo2×Vdc(4)
dutyB = 12 − Vo2×Vdc(5)
This configuration allows the output voltage to be varied between +Vdc and -Vdc. When Vo is positive: dutyA > 0.5 and dutyB < 0.5, and when it is negative: dutyA < 0.5 and dutyB > 0.5. dutyA corresponds to the ratio of ON time to that of total switching time period, of switch S1. dutyB corresponds to the ratio of ON time to that of total switching time period, of switch S3.
To generate the gate signal for switch S1 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.
The above operation is simulated in this section using Workbench.
Open Workbench and create a new model file as follow:
Click on to open the application.
Pin () the Explorer dock on the right and the Toolbox dock on the left.
Within the toolbar in the Explorer dock, click on the /1st icon, to create a new project file. Give a suitable name and location and, click Accept to create a new project. This adds a .project file along with a folder by the same name, as that of project, to house the project files.
A project can have multiple model and code files within it. This experiment requires just a single model file. To add this file, first click and select the newly created project node in the Explorer dock. To add a file to the selected project, click the /3rd icon in the Explorer toolbar. The following window will open:
Change the file name from UntitledFile to FullBridge. The path by default will point to the newly created project folder. Leave it as it is. Click Accept to add the new model file to the project.
The project must be selected for the New File icon to become active.
Drag and drop the following tools from the Toolbox onto the open model.
Triangle - Signal Sources.
Mag-Time Scope - Display
The Triangle tool is present within the Signal Sources tool class and Scope is present in the Display tool class. Use the drop-down menu in the Toolbox to transition between the tool classes.
Connect the output of the Triangle tool to the input of Scope.
Click in the top dock to run the simulation. This will throw the following error in the Ouput window in the bottom dock.
As mentioned earlier, a project can have multiple files within it and hence the compiler must be told which of these files is the starting point. In this case there is just a single file, and this should be set as the starting point. To do this, double click on the project node in the Explorer. This should bring up the project properties in the Properties dock on the left. Within the properties, set the Start model/Function property field to the name of the model file, i.e. FullBridge as shown below:
Once again, click the in the top dock to run the simulation. The simulation should run successfully this time as can be inferred from the messages in the Output dock. Double click on the Scope block in the model to view the simulation result. The following window will pop-up:
Double click anywhere on the plot or click on the /3rd icon on the Scope's toolbar to auto-focus the result.
A 1Hz switching frequency is too small for typical motor controls applications. For all the experiments a switching frequency of 10 kHz is used. Also, for a carrier, a triangle is preferred over a sawtooth due to reductions in lower order switching frequency harmonics. To make these changes, go back to the model file and double click on the Triangle tool to reveal its properties in the Properties dock. Change the Frequency (Hz) from 1 to 10000.
Also change the Waveform from Sawtooth to Triangle. Re-run the simulation.
Open the scope to view the results. Auto-focusing the result just shows random spikes close to zero. This is because the simulation is being "refreshed" at much slower rate than needed, to be able to process and capture sufficient data points. To fix this, the simulation step time should be one-hundredth of the carrier triangle's time period, Tprd, which equals 1/(10 kHz)/100 = 1E-6 s. To do this, double click anywhere on the blank space in 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 1E-3.
Re-run the simulation and observe the scope result. Verify that the frequency, waveform and magnitude are as expected. So, far, the carrier waveform has been generated. In the next few steps this carrier will be compared with reference voltage to generate the switching signals.
Drag and drop tools 3 through 12 listed in the table below, from the Toolbox, in addition to the tools 1 and 2 already added, as shown:
# | Tool type | Tool class | Tool name |
---|---|---|---|
1 | Triangle | Signal Sources | Triangle |
2 | Mag-Time Scope | Display | Scope |
3 | Constant | Signal Sources | Constant |
4 | Constant | Signal Sources | Constant1 |
5 | Gain | Math Block | Gain |
6 | Adder Subtractor | Math Block | Add |
7 | Adder Subtractor | Math Block | Add1 |
8 | Comparison operator | Logical Block | Comparator |
9 | Comparison operator | Logical Block | Comparator1 |
10 | Boolean-Numeric cast | Signal Conversion | Type cast |
11 | Boolean-Numeric cast | Signal Conversion | Type cast1 |
12 | Mag-Time Scope | Display | Scope1 |
Click on the link connecting Triangle and Scope and delete it. Reposition the Scope and interconnect the tools as shown.
Change the properties of each tool to values listed in table below. The reasons for each of those values are mentioned in the right-most column. To access a tool's property, double click on the tool and its properties will show up in the Properties dock.
Tool name | Property field | Property value | Comments |
---|---|---|---|
Triangle | Frequency | 10000 | Carrier/switching frequency is 10 kHz. |
Triangle | Waveform | Triangle | - |
Constant | Magnitude | 0.5 | Center point in Eqn. 4 and 5. |
Constant1 | Magnitude | 5 | This is the desired output voltage. |
Gain | Gain | 1/(2*40) | 1/(2*Vdc) in Eqn. 4 and 5. Vdc = 40 V. |
Add | No change | Output of this block is dutyA in Eqn. 4. | |
Add1 | Arithmetic operation | +- | Output of this block is dutyB in Eqn. 5. |
Comparator | Function | < | Compares triangle carrier to dutyA and if the former is greater, outputs True else False. |
Comparator1 | Function | < | Compares triangle carrier to dutyB and if the former is greater, outputs True else False. |
TypeCast | No change | True/False does not have any intrinsic numeric value to it. This tool converts True to 1 and False to 0. Other values can be chosen as well in the properties. |
Re-run the simulation and observe the results in the scope. Scope shows the gating signal for switch S1 and Scope1 shows the gating signal for switch S3. Gating signals for switch S2 and switch S4 are for theoretical purposes, complimentary of gating signals for switch S1 and S3 respectively.
Change the output voltage from 5 to the following values: 0, 40, 20 and 10, and observe the dutyA and dutyB waveforms.
The above simulation is run in real-time in this section.
The real-time controller inside the three-inverter module has a dedictated PWM peripheral that can generate PWM pulses from the duty cycle. It automatically generates the triangular carrier and compares the duty-cycles to generate the pulses. Hence the following tools: Triangle, Comparator, Comparator1, TypeCast, TypeCast1, Scope, and Scope1 are no longer needed and must be deleted from the model.
The functionality of tools deleted in the previous step is replaced by the PWM Output tool from the Hardware Peripheral tool class. Add two of these and connect them as shown:
As can be seen in the above image, the two PWM blocks are highlighted in red which indicates an error. To view the cause of error, click the Messages tab in the bottom dock. This will bring the following window to view:
This error is thrown because the real-time controller that is being used is not mentioned. Not all controllers support PWM peripherals. To select a device, open project properties by double clicking on the project node in Explorer. In the Properties dock, click on the top-most drop-down menu which says: Simulation Settings, and select: Device Configuration. Within this, change the Device property from None to 3 Inverter. While at it, 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 more relaxed. To increase it, open model properties, by double clicking anywhere on 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 error. This error basically says that both the PWM peripherals point to the same channel. This will be cleared when the channels are set. For this experiment, Phase A and B of Inverter 1 will be used. In the properties of PWM1 tool, change the Channel from 1 to 2, which represents B phase gate signal. Once this is set, both the errors disappear.
If there are any errors, the model cannot be run.
Replace the Constant1 tool with Variable tool from the Runtime Source tool class in the Toolbox.
By default, inverter outputs are held in high-impedance. To enable the inverter, to be actively driven, the reset pin must be pulled high. This is done by adding the following two blocks as shown and setting the properties given in table below:
Tool name | Tool Class | Property field | Property value |
---|---|---|---|
True/False | Signal Sources | Value | True |
Digital Output | Hardware Integration | Channel | 1 |
Click the icon in the top dock to save all the file.
Ensure 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 in the top dock to transition from simulation to real-time mode.
Take 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. Change the output voltage in the Variable tool to a value between 0 and 40 to change the inverter duty cycle. To edit the value of Variable tool in real-time, click on the tool to bring up the on-screen numpad shown below:
Click DEL to clear and enter the new value and press ENTER ↲. The same can be typed using keyboard instead of using the on-screen numpad. Repeat this step for different output voltage reference values.
Ensure that the probe attenuation is set to 10x to avoid over-loading the DSO.
Click , Turn OFF the DC power supply and disconnect all the connections including the USB.
This concludes the experiment of switched mode DC converter.
Attach separate screenshots of the simulation and real-time model.
Attach screenshot of results in Scope and Scope1 from the simulation model for different reference voltages mentioned.
Attach Phase A and Phase B voltage as observed on the DSO for different duty-cycles in real-time mode.
Measure the output voltage, i.e. voltage at Phase A with respect to Phase B. This can be done by using the subtract function on the scope.
Do not connect a (non-isolated) probe directly across Phase A and Phase B, especially when the USB is connected, since this will lead to a ground loop with non-zero potential, and possibly destroying the computer, inverter module, and/or the DSO.
Verify if the frequency of the output voltage matches the set frequency. Check if the voltage matches the expected value. If not explain why.