Lab 3
Lab 3
Lab 3
Implementing a Simple Power System Using Simscape
Toolbox in MATLAB:Simulink
Objectives
▪ To get familiarization with MATLAB and Simulink.
▪ Use the Simscape toolbox to implement and analyze a simple power system.
Software
▪ MATLAB (R2016A)
Theory
MATLAB
MATLAB is a high-performance language for technical computing. It integrates
computation, visualization, and programming in an easy-to-use environment where
problems and solutions are expressed in familiar mathematical notation. Typical
uses include:
1. Math and computation
2. Algorithm development
3. Modeling, simulation, and prototyping
4. Data analysis, exploration, and visualization
5. Scientific and engineering graphics
6. Application development, including Graphical User Interface building
It is an interactive system whose basic data element is an array that does not require
dimensioning. This allows you to solve many technical computing problems,
especially those with matrix and vector formulations, in a fraction of the time it
would take to write a program in a scalar noninteractive language such as C or
Fortran.
The name MATLAB stands for matrix laboratory. It has evolved over a period of years
with input from many users. In university environments, it is the standard instructional
tool for introductory and advanced courses in mathematics, engineering, and
science. In industry, MATLAB is the tool of choice for high-productivity research,
development, and analysis.
MATLAB features a family of application-specific solutions called toolboxes. Very
important to most users of MATLAB, toolboxes allow you to learn and apply
specialized technology. Toolboxes are comprehensive collections of MATLAB
functions (M-files) that extend the MATLAB environment to solve classes of problems.
Areas in which toolboxes are available include electric power systems, control
systems, neural networks, fuzzy logic, and many others.
Simulink
Simulink, an addon product to MATLAB, provides an interactive, graphical
environment for modeling, simulating, and analyzing of dynamic systems. It enables
rapid construction of virtual prototypes to explore design concepts at any level of
detail with minimal effort. It provides an interactive graphical environment and a
customizable set of block libraries that let you design, simulate, implement, and test
a variety of time-varying systems, including power systems, controls,
communications, signal processing, video processing, and image processing. It
offers a quick way of developing your model in contrast to text based-programming
languages and contains integrated solvers. A solver applies one of the many
numerical methods to solve the set of ordinary differential equations that represent
the model. Through this computation, it determines the time of the next simulation
step.
Simscape
Simscape enables you to rapidly create models of physical systems within the
Simulink® environment. The models are easy to understand and interpret because
each model matches the physical structure of the system. You can clearly see all
the systems in your model and how they are connected to one another. With
Simscape, you can build physical component models based on physical
connections that directly integrate with block diagrams and other modeling
paradigms. The modular interface of Simscape components lets you employ them
in new designs with no extra work. Your library of custom models can be reused
across many application-specific projects. The Simscape libraries include
foundation elements, such as resistors, springs, and valves, and more complex
components such as electric drives, transmissions, and heat exchangers. The
libraries include models in more than ten physical domains, such as mechanical,
electrical, and two-phase fluids. You can select the domain that includes the
physical effects required for your application. You can model systems such as
power systems, electric motors, bridge rectifiers, hydraulic actuators, and
refrigeration systems, etc. by assembling fundamental components into a
schematic. Simscape addon products provide more complex components and
analysis capabilities.
Simscape helps you develop control systems and test system-level performance.
You can create custom component models using the MATLAB based Simscape
language, which enables text-based authoring of physical modeling components,
domains, and libraries. You can parameterize your models using MATLAB variables
and expressions, and design control systems for your physical system in Simulink. To
deploy your models to other simulation environments, including hardware-in-the-
loop (HIL) systems, Simscape also supports C-code generation.
Pre-Lab Tasks
Provide 3 – 4 liner answers to the following questions.
1. Point out the basic data element in MATLAB.
2. What benefits does MATLAB hold in contrast with C or Fortran?
3. What benefit does Simulink hold over MATLAB?
4. What do you understand from the term ‘solvers’ in Simulink?
5. Discuss the significance of Simscape in design and analysis of Power Systems.
In-Lab Tasks
Task-1 – Familiarization with MATLAB Environment
1. Launch MATLAB from your system.
2. You should see the MATLAB interface after some time as shown in figure 1.1. The
elements/dialog boxes of your interface may vary with MATLAB version, but you
will be able to see some common dialog boxes like Menu bar, Current Folder,
Command Window, Workspace and Command History.
3. The status of your software is shown at the bottom left portion of the interface.
4. You can change the working directory of MATLAB/Simulink by typing the path
to the folder in the address bar as shown in figure 1.2. You should always create
a new folder for each project and then copy the path to that folder from
windows explorer into the address bar in the MATLAB interface as this ensures
the integrity and security of your work.
5. Press ‘enter’ after pasting the path into the address bar of MATLAB interface.
Now you will be able to view the contents of your project folder in the ‘Current
Folder’ dialog box of the main interface (see figure 1.3 on the next page).
6. You can enter commands into the Command Window. Try entering the following
commands:
a = [1 2]
b = [3 4];
c=a+b
d = a – b;
Report your observations about the ‘;’ operator in your post-lab reports.
7. You can view the defined variables and data structures in the ‘Workspace’
dialog box as shown in figure 1.4.
8. Finally, the ‘Command History’ dialog box shown in figure 1.5 holds a log of all
the commands that you have entered in the ‘Command Window’ since the
installation of the software.
Figure 1.3: Current Folder Dialog Box Figure 1.4: Workspace Dialog Box
9. You can also open the help for any command by typing in ‘help’ or ‘doc’
followed by the name of the command (separated by a space) in the
‘Command Window’. E.g., ‘help sin’ or ‘doc sin’ will show you the help for sine
2. The editor opens docked in the interface, but you can choose to undock it by
pressing ‘ ’ next to the close button and selecting ‘undock <script name>’
option from the dropdown menu. You can also re-dock the editor window by
selecting ‘dock <script name>’ from ‘ ’ in the editor window (see figure 2.2).
Also note that when the editor window is docked in the main interface, the
Command Window is shifted below the docked editor (see figure 2.1).
Figure 2.2: Docking the Editor into the Main Interface of MATLAB
Side Note: Since our work in these laboratories will be restricted to Simscape
toolbox of Simulink, therefore, we will only use MATLAB editor to create
‘Parameter Files’ for our projects when needed (see figure 2.3) where, ‘clc’
command clears Command Window, ‘clear all’ command clears all variables
from Workspace, and ‘close all’ command closes all Figure Windows.
3. You can execute this file by pressing the ‘Run’ button from the ‘Editor’ tab
(whether in main MATLAB interface or undocked editor window) as shown in
figure 2.4.
open the Simulink Start Page by clicking on the ‘ ’ button in the Home tab on
main MATLAB interface.
2. Once in the Simulink Start Page, you need to click on the ‘ ’ option
as seen in the right window in figure 3.1. This opens a blank model ‘untitled.slx’
file as shown in figure 3.2.
3. You can add an image to your model file by clicking the ‘ ’ icon and
placing the image object as shown in figure 3.3. Double-click the image object
to add an image file from PC.
You may use this option to add block or circuit diagrams, schematics and/or
layouts, equations, etc. to be implemented into your Simulink model file for
reference to make the implementation much simpler.
4. You may also create a new file by pressing ‘Ctrl + N’ from keyboard when you
are in the blank model file or clicking the ‘ ’ icon and scrolling to ‘Model…’
to do the same.
5. You can save the model at any time either by entering ‘Ctrl + S’ from your
6. You may also set the simulation time by typing the time in ‘ ’ box. By
default, this time is set to 10 seconds.
7. You may also select the simulation mode by clicking on the dropdown menu ‘
’ and selecting one of the six modes listed in that menu. By default,
this mode is set to ‘Normal’ but for huge simulation models it may also be set to
‘accelerator’ mode to reduce simulation time.
8. Simulink can generate C-code for your model files for implementation on
in the left-hand side of this window while the components of a particular toolbox
are shown to the right of the list of libraries.
2. You may search for any component by entering its name in the search box ‘
’.
3. In our laboratories we will be concerned in major part with the ‘Simulink’ and
‘Simscape’ toolboxes shown in figure 4.2.
4. From Simscape toolbox you can navigate into the ‘Specialized Technology’ in
the ‘Power Systems’ sub-toolbox which we will be using in our laboratories to
create and analyze power systems (see figure 4.3).
5. The ‘powergui’ block ‘ ’ which contains the tools to analyze the power
systems must be placed in all your Simulink model files to execute them and is
located here in the ‘Fundamental Blocks’ toolbox. Double-click this block and
access the help file by clicking on the ‘ ’ button at the bottom of the
opened dialog box.
Figure 5.1: Importing Blocks from Library Directly from Simulink Model Window
Click on ‘ ’ and then click ‘ ’. Connect this block with the ‘Three-
Phase V-I Measurement’ block.
6. Add a second ‘Three-Phase V-I Measurement’ from ‘Measurements’ in
‘Fundamental Blocks’ toolbox and double-click the block. Click on checkbox
next to ‘Use a Label’ for both ‘Voltage measurement’ and ‘Current
measurement’ to check these options. Type ‘Vload’ in the ‘Signal label (use a
From block to collect this signal)’ of the voltage measurement section and
‘Iload’ in the ‘Signal label (use a From block to collect this signal)’ of the current
measurement section. Click on ‘ ’ and then click ‘ ’.
7. Add a ‘Three-Phase Parallel RLC Load’ from ‘Elements’ in ‘Fundamental Blocks’
toolbox. Double click on the added block and enter the following:
Nominal phase-to-phase voltage Vn (Vrms): Vs
Nominal frequency fn (Hz): Fs
Active power P (W): Pload
Inductive reactive Power QL (positive var): Qload
Capacitive reactive power Qc (negative var): 0
Click on ‘ ’ and then click ‘ ’. Connect this block with the ‘Three-
Phase V-I Measurement1’ block.
8. Add a ‘Scope’ from ‘Commonly Used Blocks’ in ‘Simulink’ library. Double click
on the added scope and click on ‘ ’ icon. Enter ‘4’ next to the ‘Number of
9. Add two ‘From’ blocks from ‘Signal Routing’ toolbox in the ‘Simulink’ library.
Right-click the block in the model window, go to ‘Format’ and click on ‘Show
Block Name’ to hide this blocks name. Double click on the first ‘From’ block, type
‘Vload’ in the ‘Goto tag:’ field and click on ‘ ’. You should be able to see
link to the block which is generating this signal next to ‘Goto source:’ field.
Double click on the second ‘From’ block, type ‘Iload’ in the ‘Goto tag:’ field and
click on ‘ ’. You should be able to see link to the block which is generating
this signal next to ‘Goto source:’ field.
10. Connect ‘Vabc’ output from ‘Three-Phase V-I Measurement’ block to first input
of scope block and connect ‘Iabc’ output from ‘Three-Phase V-I Measurement’
block to third input of scope block. Connect the first ‘From’ block labelled
‘Vload’ to the second input of scope block and connect the second ‘From’
block labelled ‘Iload’ to the fourth input of scope block.
11. The complete diagram of implemented system is shown in figure 5.4.
file. Click on ‘ ’ to execute the parameter file. MATLAB may ask you to allow it
to change the current working directory if this file is not located in the
current/default MATLAB working directory by displaying the message shown in
figure 7.1. Click on ‘Change Folder’ button to do allow this.
2. Now go to your Simulink model window and click on ‘ ’ button to execute the
Simulink model.
3. Double-click scope once the execution is done to see the results as shown in
figure 7.2.
4. Click on arrow in the ‘ ’ icon and select ‘ ’ icon. Now click a little above the
peak of the ‘Supply Voltage’ plot and drag the cursor down a little below the
peak of this plot. This will zoom the said plot along y-axis. Repeat this procedure
until you see a plot resembling figure 7.3. This plot shows a peak supply voltage
of 311.63 V and correspondingly the RMS supply voltage is 311.63/√2 V = 220.36
V.
5. Repeat step 4 for the rest of the plots to find the RMS value of supply and load
currents = 3.72/√2 A = 2.63 A and a peak load voltage of 309.4 V with a
corresponding RMS load voltage of 309.4/√2 V = 218.8 V.
6. Change the values of Qload from 0 to 2 kVAR in your parameter file in steps of
0.4 kVAR at a constant active power of 1.5 kW and tabulate the RMS values of
all the corresponding voltages and currents in table 1. Repeat the procedure at
an active power of 3 kW and fill the table 2.
Reactive Power Supply Voltage Supply Current Load Voltage Load Current
(VAR) (V) (A) (V) (A)
0 323.34 3.02 322.42 3.02
3.08 3.08
400 319.3 318
800 315 3.33 313 3.33
1200 311 3.72 309 3.72
1600 308 4.06 305 4.06
2000 304 4.7 301 4.7
Table 1 – Effect of Variation in Reactive Power Demand on System Voltages and Currents at Active Power of 1.5
kW
Reactive Power Supply Voltage Supply Current Load Voltage Load Current
(VAR) (V) (A) (V) (A)
0 319.38 5.95 317.55 5.95
400 315.5 5.93 313.5 5.93
800 311.85 5.99 309 5.99
1200 308 6.16 305 6.16
1600 304 6.3 300 6.3
2000 300 6.69 297 5.69
Table 2 – Effect of Variation in Reactive Power Demand on System Voltages and Currents at Active Power of 3 kW
Post Lab
1. Report your findings from step 6 of Task-1.
2. Compute the load power factor in Task-6.
3. Use the zoomed plots of load voltage and load current in Task-7 to find the angle
between the two quantities. Show all the calculations.
4. Sketch plots of Reactive Power Demand Vs. Load Voltage at active powers of
1.5 kW and 3 kW from tables 1 and 2 in Task-7. Analyze the effect of changing
reactive power on load voltage in the critical analysis portion of your post lab
reports.
Pre-Lab /5
In-Lab /5
Results
Viva
/5
/5
/25
Critical Analysis /5
Comments: