Matlab Simulink SimPowerSystems For Power Lab 2014

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Matlab Simulink SimPowerSystems

The Matlab software package will be used, with its companion products Simulink and
SimPowerSystem, to model and simulate power-electronics circuits. In order to enable Matlab
to successfully represent the performance of power circuits, a special library of component
blocks, Powerlib, is used in SimPowerSystems. Note that SimPowerSystems works with
Simulink within Matlab. A guide to creating a circuit in SimPowerSystems can be found at:
http://www.mathworks.com/help/physmod/powersys/ug/building-and-simulating-a-simplecircuit.html
A. Starting Matlab, Simulink and SimPowerSystems
Note that there are two versions of Matlab in H-945 and H-921. Version 2009 is in H-945 while
later versions 2012 and 2013 appear in the undergraduate computer labs.To begin using either
versions use the sequence: Start, All Programs, MATLAB from the Windows desktop.
Matlab Version 2009. For version 2009, the Matlab display will appear as shown in Fig. 1.
When the Matlab desktop opens, at the >> prompt in the command window type: powerlib .

Figure 1. The opening display of Matlab Version 2009.


The library of components used by SimPowerSystems, powerlib, will open a panel as shown in
Fig. 2. Point and click on the sequence File, New and Model to open a window that will be used
1

to draw the test circuit. As soon as the circuit window opens, assign a name to the circuit (file)
and save it with a .mdl extension.

Figure 2. Starting a circuit (model file .mdl) from the Powerlib panel.
Later Matlab Versions, 2012, 2013. For the later versions of Matlab (2012 and 2013), the
Matlab window will appear as shown in Fig.3. To open a file type Simulink in the command
window after the >> prompt. Wait until the display changes, it may take some time to load.
When the Simulink panel appears, click on either SimPowerSystems or Simscape and then
SimPowerSystems in the drop-down file menu that appears on the left. Item 1 of Fig. 4 is the
Simulink command. The locations of the Simscape and SimPowerSystems files are shown in
items 2 and 3. The library of power components will appear as shown in Fig. 3, item 4. These
library groups will be opened and used to select the required circuit components. The next step
is to create a panel that will contain the schematic of the circuit that you wish to simulate.
Create A New Workspace. To create a new workspace panel click on the open new model
icon shown as item 5 in Fig. 3. Name the new circuit-drawing file before starting to build the
schematic. The location of the commands is shown in Fig. 4. The new model will have either an
.mdl or a .slx extension. If a schematic window opens immediately, use the File. Save As
commands to start the new drawing. Take note of the location where the file is stored.

Figure 3. Opening SimPowerSystems in Matlab Version 2013.


Open An Existing Schematic. Note that immediately to the right of the new-model icon, (item
5, Fig.3) there is a folder icon that is used to open an existing file. Clicking on this symbol will
open a menu with previously opened schematics or projects. Note that the new-model window
shown in Fig. 4 also will provide access to existing circuits. The existing circuit files shown in
the upper right panel can be opened using the mouse.

B. Building the Circuit


This introductory exercise will create a simple diode circuit in the SimPowerSystems
environment. The circuit is shown in Fig. 5. The circuit consists of a sinusoidal source, a diode
and a resistive-inductive (RL) load. The frequency of the source is 60 Hz and the rms value of
the source is 120 Vac.

Figure 6 shows the workspace and the placement of the first element of the example circuit the
ac voltage source. First click on the Electrical Sources library as shown in Fig. 6, step 1. The
3

Figure 4. The new-file creation window.


library panel will appear as shown in step 2. Choose the icon for the ac voltage source and drag
it into the work space.

is

vs = Vmax sin t

vD
+

iload

+
vs

iD
vload

Vs rms = 120 Vac

Figure 5. The diode circuit.


4

300
vR

iR
iL

+
+

0.8 H
vL

Figure 6. Adding the ac voltage source to the schematic.

The remaining circuit components are chosen from the SimPowerSystems libraries and placed in
the diagram as shown in Fig. 7. The components are :
1 Ground. The element is found in Simulink/Simscape/SimPowerSystems/Elements.
2. AC Voltage Source. The element is found in Simulink/ Simscape/SimPowerSystems
/Electrical Sources
3. Diode. The element is found in Simulink/Simscape/SimPowerSystems/Power Electronics.
4. Voltage Measurement. The element is found in Simulink/Simscape/SimPowerSystems/
Measurements.
5. Current Measurement. The element is found in Simulink/Simscape/SimPowerSystems/
Measurements.
6. Series RLC Branch. The element is found in Simulink/Simscape/SimPowerSystems/
Elements.
7. MUX. The element is found in Simulink/Signal Routing or /Commonly Used Blocks.
5

Figure 7. The single-diode circuit in the workspace.


8. Scope. The element is found in Simulink/Math Operators or /Commonly Used Blocks.
9. The Bus Selector Block. The element is found in Simulink/Signal Routing or
/CommonlyUsed Blocks.
10. Power GUI. The element is found in Simulink/Simscape/SimPowerSystems.
11. The Gain Block. The element is found in Simulink/Math Operations or
/CommonlyUsed Blocks.
12. Text. Text can be added to the circuit diagram by double-clicking the right-side button
on the mouse. The text can be re-positioned by circling the text box with the cursor and the
moving it.
13. The Multimeter is found in Simulink/Simscape/SimPowerSystems/ Measurements.

The operating parameters must be set for the individual blocks before the circuit can be
simulated.
1. The AC Voltage Source. Click on the component and in the dialogue box that opens, set
the following parameters: Peak Amplitude (V) = 169 V. Phase = (deg)- 0 (This will be
changed later to -130.71 deg. To make the load voltage a reference at 0 deg.), Frequency
6

(Hz) = 60 Hz, Sample Time = 0 and Measurements = None. Enable the Set
Measurements to voltage function so that the values can be seen by the Multimeter
block. Click on the Apply and OK buttons to save the changes. Click the Help button to
get more information.
2. Diode. Click on the component and in the dialogue box that opens, set the following
parameters: Resistance, Ron = 0.001, Inductance Lon = 0, Forward Voltage Vf = 0.8 V,
Initial Current = 0, Snubber Resistance = 500 Ohms, The Snubber Capacitance is Cs =
250 nF or 250e-9. Be sure to check the box titled Show measurement Port. This allows
the component voltage and current to be measured. Note that the output, m, is a bus (two
signals on one line) and must go to a Bus Selector Block or a DEMUX block set up as a
bus selector. Click on the Apply and OK buttons to save the changes. Click the Help

Figure 8. The General parameter settings for Scope1.


button to get more information.
3. Voltage Measurement and Current Measurement. Click on the component and in the
dialogue box note that there are no parameters to be set. The Diode block allows only the
Continuous Solver setting in the Power GUI block. This will be set later.
4. The Bus Selector Block. Click on the component and in the dialogue box that opens, set
the following parameters: In the signals-in-bus column on the left, highlight the Diode
Current and use the select command to add it to the selected signals on the left. Do the
same for the Diode Voltage. Highlight the lines marked signal 1 and signal 2 and use the
remove button to cancel them. Click on the Apply and OK buttons to save the changes.
Click the Help button to get more information.
5. Scope1. This configuration of a Scope block will show how to get 2 separate plots for 2
different signal traces. Also, the Scope is connected to a Bus Selector block which is
7

Figure 9. The History and Style parameter settings for Scope1.


required to view the m output port of the Diode. Click on the component and in the
dialogue box that opens, set the following parameters as shown in Fig. 8: In the tool bar
at the top click on the second icon. The Parameters window will open with the General
pane active. Set number of axes = 2, this will produce two separate curves. Set Time
Range = auto or a number larger than the simulation time. Leave the Sampling field at
the default Decimation, 1. Do not use the Floating Scope option since the Scope1 is
connected to the circuit by 2 wires. The Legends command will add a default label to
each curve trace. The History section is set to Save Data to WorkSpace as shown in
Fig.9. The Structure selection is set to Save Data With Time. The Style section shown
in Fig. 9 must be modified so that the curves and the plots will appear as black traces on a

Figure 10. The output waveforms of the scope block with legends enabled.
white background. Set Figure Color so that the color white appears below the bucket.
Set the Axes Colors fill bucket to be white and set the paintbrush to the color black.
Since there are two individual plots, the Properties for both lines 1 and 2 are Line =
solid, 0.5 thickness and the paintbrush black. To get a higher resolution and the
8

corresponding value of the waveform at a particular point, use the Zoom buttons on the
Toolbar (3rd, 4th and 5th buttons from the left). Use Autoset, the 6th button from the left to
reset the plot. Click on the Apply and OK buttons to save the changes. Click the Help
button to get more information.
6. Scope. This configuration of a Scope block will produce 1 plot for 2 different signal
tracesas shown in Fig. 10. Click on the component and in the dialogue box that opens,
set the following parameters: In the tool bar at the top click on the second icon. The
Parameters window will open with the General pane active. Set number of axes = 1, this
will produce two separate curves in one plot. This scope has 2 signals connected through
a MUX block. Set Time Range = auto or a number larger than the simulation time.
Leave the Sampling field at the default: Decimation, 1. Do not use the Floating Scope
option since the Scope1 is connected to the circuit by 2 wires. The Legends command
will add a default label to each curve trace. The History section is set to Save Data to
WorkSpace. The Structure selection is set to Structure With Time. The Style section
must be modified so that the curves and the plots will appear as black traces on a white
background and each trace has a different type of line. This is shown in Fig. 11. Set
Figure Color so that the color white appears below the bucket. Set the Axes Colors fill
bucket to be white and set the paintbrush to the color black. Since there are two curves
on the same set of axes plots, the Properties for both lines 1 and 2 must be distinct. Thus,

Figure11. The properties for lines 1 and 2 of the Scope block.


Line1 could be set to: Line = solid, 0.5 thickness and the paintbrush black. Line2 could
be set to: Line = dashed, thickness = 2.0 and the paintbrush black. To get a higher
resolution and the corresponding value of the waveform at a particular point, use the
Zoom buttons on the Toolbar (3rd, 4th and 5th buttons from the left). Use Autoset, the
6th button from the left to reset the plot. Click on the Apply and OK buttons to save the
changes. Click the Help button to get more information.
7. Series RLC Branch. Click on the component and in the dialogue box that opens, set the
following parameters: Set the branch type as RL. Set the resistance to 300 Ohms and the
9

Figure 12. The Multimeter setup window.


inductor to 0.8 H. Note that in the Series RLC Branch, setting R = 0, L = 0 and C = inf,
creates an open circuit. Enable the Set Measurements to Branch Voltage and Current
function so that the values can be seen by the Multimeter block. Click on the Apply and
OK buttons to save the changes. Click the Help button to get more information.
8. Multimeter. Click on the Multimeter block and choose from the available voltage and
current sources in the left-side panel. Use the >> tool to transfer the variables to the
right-hand side panel. Enable the Plot command to create diagrams of the output curves.
Highlight selected measurements to change the order that they will appear or to remove
them. The available measurements variables are enabled by clicking on the
Measurements box associated with each element. Click on the Update button to save the
changes. Click the Help button at the top to get more information.
9. Power GUI. Click on the component and in the dialogue box that opens, set the
following parameters: The first menu item is the Configure Parameters block shown in
Fig. 12. Set the Solver to continuous. In the Analysis Tools section use the Steady-State
Voltages and Currents tool and check States, Measurements, Sources and NonLinear Elements. The FFT Analysis tool is useful since it will provide information
about the characteristics of the non-linear waveforms. Click on the Apply and OK
10

Figure 13. The PowerGUI block parameters are set to the continuous mode.
buttons to save the changes. Note that the Diode in this circuit means that the Continuous
Simulation setting is the only type allowed. The box that allows the use of ideal switches
can be set if the snubber or other circuit elements are not required Click the Help button
to get more information.

C. Starting the Simulation


Return to the workspace panel with the circuit schematic. Use the File command in the upper
toolbar to Save the circuit and the changes that have been made.
Click on the Simulation command in the upper toolbar. Open the Model Configuration
Parameters window in the drop-down Menu shown in Fig. 13. Highlight the first item on the
tree: Solver. In the window that appears on the right enter the following information: set the
Start Time = 0 seconds, the Stop Time is 50 ms Three cyles at 60 Hz). The calculation Type is
Variable Time Step and the Solver is ode45 Dormand-Prince. The Relative Tolerance is 1e-3.
All other variables are set to Auto. In the Zero Crossing section the control is set to Use Local
Setting. The Time Tolerance is 10*128*eps, and the Algorithm is Adaptive with 1000 Zero
Crossings. All other settings remain in the default settings.

D. Running the Simulation


11

Figure 14. Setting the Solver parmeters in the Configure Parameters window.
Click on the Simulation command in the upper toolbar. Click on the Update Diagram button to
reset the schematic. In Simulation mode use the Run button to start the simulation. Check the
Matlab Command window to verify the progress of the simulation and find any errors that may
halt the program execution.

E. Viewing the Results


When the simulation is complete the results can be obtained by 1.) viewing the output from the
Scopes elements and 2.). by means of the GUI output functions. Click on the Scope blocks to
see the output. Fig. 15 shows the results of the scope blocks, Scope and Scope1. Note that the
plot from Scope has two distinct line-types to distinguish between the voltage and current traces.
Also the Legends function has been enabled when the parameters were set for the Scope block.
Fig. 16 shows how the Zoom tool can be used to get a better resolution of the Diode voltage
trace. The maximum value of the diode reverse-voltage is indicated.
The Multimeter display starts automatically after the simulation has completed. The Data
cursor can be used to identify points on the curve by means of amplitude (y value) and time in
seconds (x value) as shown in Fig. 17. To start, select the data cursor from the upper toolbar.
Use the cursor to select a point on a curve. Once the point has been placed on a curve with the
cursor, the right and left arrow keys will move the point to a desired value or time. The
coordinates and the data text box can be fixed to the display by right-clicking on the box and

12

Figure 15. The output of the Scope and Scope1 elements.


choosing Create New Datatip from the dialog box. In Fig. 17 the load angle can be found by
calculating: = 360 ( ( ) (.01666) ) degrees.
The output of the Multimeter can be printed or saved by selecting the appropriate icons from the
upper toolbar.

Figure 15. The output plots of Scope and Scope1.

Figure 16. The Zoom tool is used to magnify the diode voltage curve.

The PowerGUI can also be used to generate data describing the results of the simulation. Fig.
18 shows the output from the Steady-State Voltages and Currents tool. Note that the angle of the
13

Figure 17. The Multimeter output plot.


Voltage source has been set to -130.71 degrees. This was accomplished by clicking on the
Voltage source icon and setting the Phase parameter to -130.71. Now the reference angle is the
load voltage, U Vload, and is 0 degrees. The load angle between the load voltage and current, I
ILoad, is the expected value of 45 degrees. Also, the amplitude of the load voltage has been
divided by the base voltage, Vs = 169 Vac by means of the gain block. Thus, the voltage
waveform of Fig. 15 is unity or 1.0 pu. A similar gain block could be placed after the current
measurement element to produce a per-unit value.
The PowerGUI Simulation and Configuration Options panel also also has the capability of
producing a FFT analysis of the output and a report using the Generate Report tab.

F. Print and Saving Results of the Simulation.


There are several means of saving the results of a simulation and placing them in a report.
Waveform traces and plots from the Multimeter and the Scope blocks can be printed directly.
The Scope traces can also be copied by using the MS Snipping tool or the Print Screen Utility.
14

The results are copied to the Clipboard where they can be edited by using a basic graphics editor
such as Paint or Visio. The results of the Steady-State Voltages and Currrents tool are

Figure 18. The Simulation and Configuration Options panel and the Steady-State
Voltages and Currents window.
reproduced in the Generate Report Function of the Simulation and Configuration Options
dialogue box of the PowerGUI block shown in Fig. 18.

15

You might also like