0% found this document useful (0 votes)
32 views18 pages

Lab 3

This document outlines a laboratory exercise focused on implementing a simple power system using the Simscape toolbox in MATLAB:Simulink. It covers objectives, software requirements, theoretical background on MATLAB, Simulink, and Simscape, as well as detailed pre-lab and in-lab tasks for familiarization and practical implementation. The tasks include using MATLAB commands, creating scripts, accessing libraries, and building a power system model in Simulink.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views18 pages

Lab 3

This document outlines a laboratory exercise focused on implementing a simple power system using the Simscape toolbox in MATLAB:Simulink. It covers objectives, software requirements, theoretical background on MATLAB, Simulink, and Simscape, as well as detailed pre-lab and in-lab tasks for familiarization and practical implementation. The tasks include using MATLAB commands, creating scripts, accessing libraries, and building a power system model in Simulink.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Lab3 – Implementing a Simple Power System Using Simscape Toolbox in MATLAB:Simulink

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

EEE375 – Power Distribution and Utilization Laboratory Manual


Lab3 – Implementing a Simple Power System Using Simscape Toolbox in MATLAB:Simulink

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-theloop (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?

EEE375 – Power Distribution and Utilization Laboratory Manual


Lab3 – Implementing a Simple Power System Using Simscape Toolbox in MATLAB:Simulink

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.

Figure 1.1: MATLAB 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.

Figure 1.2: Setting Working Directory

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:

EEE375 – Power Distribution and Utilization Laboratory Manual


Lab3 – Implementing a Simple Power System Using Simscape Toolbox in MATLAB:Simulink

a = [1 2]
b = [3 4];
c=a+b
d = a – b;
Report
your
observati
ons
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

EEE375 – Power Distribution and Utilization Laboratory Manual


Lab3 – Implementing a Simple Power System Using Simscape Toolbox in MATLAB:Simulink

Figure 1.5: Command History 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 function either in the command window or in a separate window
respectively (see figure 1.6).

Figure 1.6: Use of the ‘help’ and ‘doc’ Commands in MATLAB

Task-2 – Creating MATLAB Scripts


1. Depending upon the version of MATLAB which you are using, there are
several ways by which you can open the MATLAB editor to create programs
or functions (called scripts). You can use the keyboard shortcut ‘Ctrl + N’ to
create this file. Alternatively, you can click/point to the ‘New’ button in the
‘Home’ tab and select ‘Script’ from the dropdown menu as shown in figure
2.1.

EEE375 – Power Distribution and Utilization Laboratory Manual


Lab3 – Implementing a Simple Power System Using Simscape Toolbox in MATLAB:Simulink

Figure 2.1: Opening MATLAB Editor from its Interface

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.

EEE375 – Power Distribution and Utilization Laboratory Manual


Lab3 – Implementing a Simple Power System Using Simscape Toolbox in MATLAB:Simulink

Figure 2.3: An Example ‘Parameter File’

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.

Figure 2.4: Executing Script Files

Task-3 – Opening Simulink from MATLAB and Creating a


Blank Simulink Model File
1. Depending upon the version of MATLAB which you are using, there are
several ways by which you can open the Simulink. The most common
method to open Simulink is by executing ‘simulink’ command from your
MATLAB command window as shown in figure 3.1. This opens the Simulink
Start page. You may also

open the Simulink Start Page by clicking on the ‘ ’ button in the Home
tab on main MATLAB interface.

EEE375 – Power Distribution and Utilization Laboratory Manual


Lab3 – Implementing a Simple Power System Using Simscape Toolbox in MATLAB:Simulink

Figure 3.1: Opening Simulink from MATLAB Command Window

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.

Figure 3.2: Blank Model File in Simulink

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.

EEE375 – Power Distribution and Utilization Laboratory Manual


Lab3 – Implementing a Simple Power System Using Simscape Toolbox in MATLAB:Simulink

Figure 3.3: Adding an Image to a Simulink Model

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

keyboard or by clicking on ‘ ’ icon. Similarly, you can load Simulink files by

clicking on ‘ ’ icon and selecting the relevant option.

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

microprocessors by clicking on ‘ ’ icon. However, several requirements


need to be met before that happens which will be discussed in detail when
needed.
9. Solver information ‘ ’ is displayed in this window at bottom right
corner. This solver can be changed along with other settings by clicking on
this text and selecting ‘ ’ icon. This opens the solver configuration window
as shown in figure 3.4. Various settings can be made in this configuration
panel which will be discussed upon requirement.

EEE375 – Power Distribution and Utilization Laboratory Manual


Lab3 – Implementing a Simple Power System Using Simscape Toolbox in MATLAB:Simulink

Figure 3.4: Solver Configuration Panel

Task-4 – Accessing the Many Libraries of


MATLAB:Simulink
1. Simulink Library Browser can be opened by clicking the ‘ ’ icon at the top
or by selecting ‘ ’ from the ‘View’ menu. This opens
the Simulink Library Browser as shown in figure 4.1. The various toolboxes
are shown
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.

Figure 4.1: Simulink Library Browser

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.

EEE375 – Power Distribution and Utilization Laboratory Manual


Lab3 – Implementing a Simple Power System Using Simscape Toolbox in MATLAB:Simulink

Figure 4.2 Simulink and Simscape Toolboxes

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).

Figure 4.3: Specialized Technology Toolbox

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.

Task-5 - Implementing a Simple Power System in


Simulink using Simscape
1. Open a new Simulink model file ‘untitled.slx’ and save this file by renaming
it as per you first name and registration number e.g.,
‘Asad_FA18BEE111.slx’.
2. Add the ‘powergui’ block from the ‘Fundamental Blocks’ toolbox in the
Simscape library to your Simulink file by right-clicking on the ‘powergui’
block in the right-side of library browser window and selecting the option of

EEE375 – Power Distribution and Utilization Laboratory Manual


Lab3 – Implementing a Simple Power System Using Simscape Toolbox in MATLAB:Simulink

‘ ’. You may also perform the same action by clicking on the blank space in
Simulink file, typing ‘powergui’ and then selecting the appropriate block
from displayed results as shown in figure 5.1. However, this facility may not
be available in the older versions of MATLAB:Simulink.

Figure 5.1: Importing Blocks from Library Directly from Simulink Model Window

3. Add a ‘Three-Phase Source’ from ‘Electric Sources’ in ‘Fundamental Blocks’


toolbox. Double click on the added block and enter the following:
Phase-to-phase voltage (Vrms): Vs
Frequency (Hz): Fs
Base Voltage (Vrms ph-ph): Vs
Click on ‘ ’ and then click ‘ ’.
4. Add a ‘Three-Phase V-I Measurement’ from ‘Measurements’ in ‘Fundamental
Blocks’ toolbox and connect it to the supply as shown in figure 5.2.

Figure 5.2: Connecting the Blocks

5. Add a ‘Three-Phase Series RLC Branch’ from ‘Elements’ in ‘Fundamental


Blocks’ toolbox. Double click on the added block and enter the following:
Branch type: RL (Select from dropdown menu by clicking on ‘
’)
Resistance R (Ohms): r1*len
Inductance L (H): l1*len
Click on ‘ ’ and then click ‘ ’. Connect this block with the
‘ThreePhase 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

EEE375 – Power Distribution and Utilization Laboratory Manual


Lab3 – Implementing a Simple Power System Using Simscape Toolbox in MATLAB:Simulink

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
‘ThreePhase 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 input ports:’ field. Click on ‘ ’ and then click ‘ ’.
Click on ‘Layout…’ in the ‘View’ menu and select a 2 x 2 layout. Right-click
on the top left plot grid and select ‘Configuration Properties…’. Select
‘Active display:’ as ‘1’, type ‘Supply Voltage’ in ‘Title:’ field and Click on ‘
’. Similarly, select ‘Active display:’ as ‘2’, type ‘Load Voltage’ in
‘Title:’ field and Click on ‘ ’. Repeat the process for displays 3 and 4,
type ‘Supply Current’ and ‘Load Current’ in
‘Title:’ field respectively and click ‘ ’ each time. Finally click ‘ ’
to exit the configuration panel. After making all the settings your scope
window should as shown in figure 5.3 (the colour scheme has been changed
for appearance).

Figure 5.3: Scope for Implemented Circuit in Task-5

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

EEE375 – Power Distribution and Utilization Laboratory Manual


Lab3 – Implementing a Simple Power System Using Simscape Toolbox in MATLAB:Simulink

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.

Figure 5.4: Diagram of Implemented Circuit

Task-6 – Creating the Parameter File for Implemented


Model using MATLAB Editor
1. Open MATLAB editor using methods previously described in Task-2.
2. Enter the following commands in the editor and save the file as
‘labtask5_param.m’. Make sure that you place this file in the same directory
as your Simulink model file. This directory will become the MATLAB working
directory in this lab. You can see that we have defined the values for all the
parameters of blocks in our implemented model. clc close all clear all

Vs = 400; % Line-line RMS Supply Voltage (V)


Fs = 50; % Supply frequency (Hz) len = 6;
% Length of power supply cable in km
r1 = 0.05; % Resistance of power supply cable per phase in Ohms
l1 = 3.2e-4; % Inductance of power supply cable per phase in H
Pload = 1.5e3; % Active/Real power of load in Watts
Qload = 1.2e3; % Reactive (Inductive) power of load in VAR

EEE375 – Power Distribution and Utilization Laboratory Manual


Lab3 – Implementing a Simple Power System Using Simscape Toolbox in MATLAB:Simulink

Task-7 – Executing the Implemented Model in Simulink


and Analyzing the Results
1. To successfully execute the Simulink model, we must first execute the
Parameter

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.

Figure 7.1: Change Directory Message in MATLAB

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.

Figure 7.2: Simulation Results of Implemented Model in Simulink

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.

EEE375 – Power Distribution and Utilization Laboratory Manual


Lab3 – Implementing a Simple Power System Using Simscape Toolbox in MATLAB:Simulink

Figure 7.3: Plot of Supply Voltage Zoomed along Y-axis


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
400
800
1200
1600
2000

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
400
800
1200
1600
2000

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.

EEE375 – Power Distribution and Utilization Laboratory Manual


Lab3 – Implementing a Simple Power System Using Simscape Toolbox in MATLAB:Simulink

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.

Critical Analysis / Conclusion (To be filled in by the student)

Lab Assessment (To be filled by the lab-instructor)

Pre-Lab /5

In-Lab /5

Results /5

/25
Viva /5

Critical
/5
Analysis

EEE375 – Power Distribution and Utilization Laboratory Manual


Lab3 – Implementing a Simple Power System Using Simscape Toolbox in MATLAB:Simulink

Comments:

Instructor Name Instructor Signature

EEE375 – Power Distribution and Utilization Laboratory Manual

You might also like