MATLAB Simulink: (For Old Versions of MATLAB)

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

MATLAB Simulink Tutorial For Power Electronics

MATLAB Simulink
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:

➢ Math and computation.


➢ Algorithm development.
➢ Modeling, simulation, and prototyping.
➢ Data analysis, exploration, and visualization.
➢ Scientific and engineering graphics.
➢ Application development, including Graphical User Interface building.

The name MATLAB stands for Matrix Laboratory. MATLAB was originally written to provide
easy access to matrix software developed by the LINPACK and EISPACK projects, which
together represent the state-of-the-art in software for matrix computation. [1]

In Power electronics lab, we are concern with simulation of different power conversion circuits,
let’s discuss about environment in MATLAB where we can easily simulate any circuit named
Simulink.

➢ For simulations of Power Electronics in MATLAB Simulink, the library path is:
MATLAB→ Simulink→ Simscape→ SimPowerSystems→ Power Electronics.
(For old versions of MATLAB)

MATLAB→ Simulink→ Simscape→ Electrical→ Specialized Power Systems.


(For latest versions of MATLAB)

SIMULINK PRODUCT DESCRIPTION:

Simulink is a block diagram environment for multi-domain simulation and Model-Based Design.
It supports system-level design, simulation, automatic code generation, and continuous test and
verification of embedded systems. Simulink provides a graphical editor, customizable block
libraries, and solvers for modeling and simulating dynamic systems. It is integrated with
MATLAB, enabling you to incorporate MATLAB algorithms into models and export simulation
results to MATLAB for further analysis.

P a g e 1 | 12
MATLAB Simulink Tutorial For Power Electronics

KEY FEATURES:

➢ Graphical editor for building and managing hierarchical block diagrams.


➢ Libraries of predefined blocks for modeling continuous-time and discrete-time systems.
➢ Simulation engine with fixed-step and variable-step ODE solvers.
➢ Scopes and data displays for viewing simulation results.
➢ Project and data management tools for managing model files and data.

➢ Model analysis tools for refining model architecture and increasing simulation speed.
➢ MATLAB Function block for importing MATLAB algorithms into models.
➢ Legacy Code Tool for importing C and C++ code into models. [2]

SIMSCAPE:

Simscape is one of the tool box in Simulink’s library. Simscape contains the tools
which are required for simulation of physical systems. Simscape includes blocks from the electrical
domain, as well as other physical domains (mechanical, hydraulic, pneumatic, thermal etc).

SIMPOWERSYSTEMS:

SimPowerSystems only works in the electrical domain. The mechanical


characteristics in SimPowerSystems tend to be represented by Simulink inputs (e.g. rotational
speed or mechanical power input into an electrical machine). More importantly, SimPowerSystems
is designed and optimized for three-phase systems, whereas Simscape (and SimElectronics)
components are single-phase only.

SimPowerSystems has some single-phase components as well. You do get some overlap between
SimPowerSystems and Simscape/SimElectronics for basic components, such as resistor, capacitor,
inductor, etc. SimPowerSystems is really aimed at power generation, power distribution and power
transmission, looking at things like power quality. Simscape and SimElectronics are more
designed for modelling electro-mechanical systems, analog electronics, semi-conductors, etc.

BLOCK LIBRARIES:

For detail study of all block libraries in Simulink, check the official link of
Mathworks for help given below.

https://www.mathworks.com/help/simulink/referencelist.html?type=block

P a g e 2 | 12
MATLAB Simulink Tutorial For Power Electronics

Circuit Modeling Using Simulink:


STEP 1: In order to use Simulink, you must first start MATLAB.
Double click on desktop icon (MATLAB_version).
Command Window opens, which is use to enter data, run MATLAB
functions and other M-files, and display results.

Figure (1): Command Window

STEP 2: With MATLAB running, there are different ways to start Simulink.

i. Type ‘Simulink’ at the MATLAB prompt (Command Window) and press the Enter key.
ii. Go to Home→ Click on the ‘New’ icon→ Select the new Simulink model.
iii. Go to Home→ Click on the ‘Simulink Library’.

P a g e 3 | 12
MATLAB Simulink Tutorial For Power Electronics

Figure (2): Opens Simulink Model

STEP 3: On clicking Simulink Library, Simulink Library Browser Window opens.

Figure (3): Simulink Library Browser


P a g e 4 | 12
MATLAB Simulink Tutorial For Power Electronics

➢ To open new model, click on New Model Template or File→ New→ Model (Cntrl+N).

Figure (4): Path to Open New Model

➢ To save your model, file menu (Untitled)→ Save as→ Enter a name for your model (In the
File name text box)→ Click Save. The model is saved with the file extension.slx.

Figure (5): Path to Save New Simulink Model


P a g e 5 | 12
MATLAB Simulink Tutorial For Power Electronics

➢ To browse through the block libraries, select a MathWorks product and then a functional
area in the left pane. To search all of the available block libraries, enter a search term.

➢ Get detailed information about a block. Right-click a block, and then select Help for the
<block name>. The Help browser opens with the reference page for the block.

➢ View block parameters. Right-click a block, and then select Block Parameters. The block
parameters dialog box opens.

➢ Access the Simscape Electrical Block Libraries in both old and new version of MATLAB
shown in figures below.

Figure (6): Path to Access Simscape Library

P a g e 6 | 12
MATLAB Simulink Tutorial For Power Electronics

Figure (7): Path to Access Simscape Library

STEP 4: Now Add blocks to model. You build models by dragging blocks from the Simulink
Library Browser window to the Simulink Editor or single-clicking your model and entering a
search term.

To build the simple model, begin by copying blocks from the Simulink Library Browser to the
Simulink Editor.

Note that you need the ‘POWERGUI’ Block to simulate any Simulink model containing
Simscape Electrical Specialized Power Systems blocks. It stores the equivalent Simulink circuit
that represents the state-space equations of the model. When using one Powergui block in a model:

➢ Place the Powergui block in the top-level diagram for optimal performance.
➢ Make sure that the block uses the name Powergui.

P a g e 7 | 12
MATLAB Simulink Tutorial For Power Electronics

Figure (8): Gathering Blocks in Simulink Model

STEP 5: Running a simulation once model completed. Running a Simulink model is a two-step
process. First Simulation parameters such as the solver used to solve the model; the start and stop
time for the simulation; the maximum step size etc. are specified. Then the simulation is started.
The simulation can be paused or stopped while it running.

Once model is completed, its simulation can be stored by:

➢ Selecting ‘Start Simulation’ from simulation menu to run the simulation.

➢ Clicking a run icon on the tool bar.

Make sure that the model window is the active window before starting a simulation. Simulink
starts the simulation at the start time specified and continues till the simulation reaches the final
time step specified in the solver option. Completion of simulation will be indicated by a beeping
sound. Progress of the simulation is shown at the bottom of the model window.

P a g e 8 | 12
MATLAB Simulink Tutorial For Power Electronics

Figure (9): Running a Simulation

STEP 6: Viewing output to observe simulation result. To view the output of the model, double
click on ‘Scope’ block. If you not set the “Scope Parameter” of scope then click on the auto-scale
icon to view the output response.

Figure (10): Simulation Result


P a g e 9 | 12
MATLAB Simulink Tutorial For Power Electronics

EXAMPLE:

To build the simple model, begin by copying blocks from the Simulink Library
Browser to the Simulink Editor.

➢ In the left pane of Simulink Library Browser, select the Sources library.
➢ From the right pane, select the Sine Wave block.

Figure (11): Selecting Sine Wave Block from Simulink Library

➢ Drag the Sine Wave block to the Simulink Editor. A copy of the Sine Wave block appears
in your model with a text box for entering the value of the Amplitude parameter. In the text
box enter 2.

➢ Add a Scope block using this alternative procedure:

➢ Double-click within the block diagram.


o After the search icon appears, type scope, and then from the list, select Scope from
the Simulink/Sinks library.
o Add the following blocks to your model using one of the approaches you used to
add the Sine Wave and Scope blocks.

P a g e 10 | 12
MATLAB Simulink Tutorial For Power Electronics

Figure (12): Selecting Scope Block from Simulink Library

➢ Before you connect the blocks in your model, arrange the block inputs and outputs to make
signal connections as straightforward as possible.

➢ Move the Scope:


o Click and drag the block.
o Select the block, and then press the arrow keys on your keyboard.
o Move the blocks until your model looks similar to the following figure.
o Connect scope with the sine wave.
o Configure the sine wave.
o Select the desired amplitude.

Figure (13): Configuring the Circuit


P a g e 11 | 12
MATLAB Simulink Tutorial For Power Electronics

➢ After you define the configuration parameters, you are ready to simulate your model.

➢ After simulating a model, you can view the simulation results in a Scope window.

Figure (14): Sine Waveform

That’s all enough for an introduction to MATLAB Simulink. Now you can simulate any circuit
easily using Simulink.

P a g e 12 | 12

You might also like