0% found this document useful (0 votes)
14 views25 pages

Chap#4 Simulink Part 1

This document serves as an introduction to Simulink, a graphical programming package that works with MATLAB for modeling and simulating dynamic systems. It covers the Simulink interface, library, running models, simulating linear systems, and user-defined functions. Key features include building models with blocks, configuring simulations, and using various solvers for accurate results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views25 pages

Chap#4 Simulink Part 1

This document serves as an introduction to Simulink, a graphical programming package that works with MATLAB for modeling and simulating dynamic systems. It covers the Simulink interface, library, running models, simulating linear systems, and user-defined functions. Key features include building models with blocks, configuring simulations, and using various solvers for accurate results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

University of M’hamed BOUGARA of Boumerdes

Institute of Electrical and Electronics Engineering


(IGEE ex-INELEC)
Department of Power and Control engineering

EE421 – Computation and Simulation using


MATLAB /Simulink
Chapter 4: Introduction to SIMULINK

Dr. A. AMMAR

01/20/2025 EE421 Dr. AMMAR 1


Outlines:
1. Simulink Interface
2. Simulink Library
3. Running a Simulink model
4. Simulation of Linear Systems
5. User defined function in Simulink

01/20/2025 EE421 Dr. AMMAR 2


1. Simulink interface:
Simulink is the graphical programming package that works in association
with MATLAB and interacts as one combined package. It is employed for modeling,
simulating, and analyzing dynamic systems, control algorithm development, and so
forth.
To launch the package from MATLAB, you just type >> simulink in the Command
Window or using the button in the toolbar. The Simulink
startup window is show in the figure.
History

From the Simulink startup window, you can open existing models (recently worked
ones) from the right-side
01/20/2025 EE421 Dr. AMMAR 3
Or creating a new model by clicking on Blank Model or the other options there.
The Simulink main window, is shown below. Use the button to open the
Simulink library,

01/20/2025 EE421 Dr. AMMAR 4


2. Simulink Library :
The Simulink library browser is shown here:

The Simulink library contains blocks for representing the mathematical models of
commonly occurring components in dynamic systems. The blocks are grouped in
sub-libraries according to function.

01/20/2025 EE421 Dr. AMMAR 5


The standard Simulink sub-libraries are shown in the left pane of Figure.

Building a Simulink model of a system consists of selecting the appropriate blocks


and connecting them in a way that represents the mathematical model.

Inputs, when present, are implemented using blocks from the “Sources” sub-
library which can generate a host of input signals.

01/20/2025 EE421 Dr. AMMAR 6


Simulation output is saved and displayed using various blocks such as “Scopes,” “XY
Graphs,” and “Displays” from the “Sinks” sub-library

The blocks residing in the selected “Continuous” sub-library are shown in the right
pane. The “Integrator” block is selected and the transfer function, 1/s, is used to
designate the integrator.

Sources
01/20/2025 EE421 Dr. AMMAR 7
For arithmetic calculations we use the sub-library Math operations

01/20/2025 EE421 Dr. AMMAR 8


Example:
Let’s take the following simple to demonstrate how to build a Simulink model that
computes addition, multiplication, and subtraction of four different scalar numbers

It’s composed of Constant, Gain, Sum, and Display blocks. The scalars entered in
constant blocks are 13, 22, 3i/2, and 5. When this model is executed, it displays its
computed results in the Display block. Note that all of the blocks employed in this
model are available in the Simulink Library.

01/20/2025 EE421 Dr. AMMAR 9


Example:

Generation of three phase voltages

Example:
Use Simulink to solve the following problem for 0 ≤ t ≤ 13.

01/20/2025 EE421 Dr. AMMAR 10


3. Running a Simulink model

Simulink models implement solutions to algebraic, differential and difference


equations.

It offers a variety of numerical integrators to advance the continuous-time state


vector over an integration step. The user has the option of choosing a particular
solver and step size.

Clicking on the “Model Configuration Parameters” icon located directly


under “Simulation” in the Simulink tool bar leads to a dialog box like the one shown
in Figure where the simulation is configured according to the user’s preferences as
previously described.

01/20/2025 EE421 Dr. AMMAR 11


Fixed-step solvers solve the model at step sizes from the beginning to the end of
the simulation. You can specify the step size or let the solver choose it. Generally,
decreasing the step size increases the accuracy of the results and increases the
time required to simulate the system.

Variable-step solvers vary the step size during the simulation. They reduce the
step size to increase accuracy when the states of a model change rapidly. They
increase the step size to avoid taking unnecessary steps when the states of a model
change slowly.

01/20/2025 EE421 Dr. AMMAR 12


After configuring the simulation, hitting the “Start” icon on the Simulink tool bar
begins the simulation. The simulation terminates when the simulation time reaches
the selected “stop time”.

The simplest way to view simulation output is to select one of the scopes,
double click it, and observe the time history of its input.

The simulation results can also be imported to the MATLAB Workspace several
different ways. Mainly, to workspace bloc or to file

01/20/2025 EE421 Dr. AMMAR 13


01/20/2025 EE421 Dr. AMMAR 14
4. Simulation of Linear Systems

The “Continuous” sub-library is used in general for linear system model


The “Transfer Fcn” and “Zero-Pole” blocks provide alternative
representations for the dynamics of a linear continuous-time component.

For example the Function in represents the RC circuit.

Example
In order to simulate the step response of a
continuous time second order system

01/20/2025 EE421 Dr. AMMAR 15


Subsystems and masks
It is possible to group several blocks to obtain a subsystem. To do this, select with the
mouse the corresponding blocks and then select Create Subsystem.

01/20/2025 EE421 Dr. AMMAR 16


Example of separately excited DC Motor simulation:

The DC machine model is given by


𝑑 𝑖𝑎
𝑈 𝑎=𝑅 𝑎 𝑖 𝑎+ 𝐿𝑎 +𝐾 Φ 𝜔
𝑑𝑡

𝑑𝜔
𝑇 𝑒 − 𝑇 𝐿= 𝐽 + 𝑓 .𝜔
𝑑𝑡
Where the parametes values are given as:
La=0.006H ; Ra=0.6Ω ; KΦ=1; Ua=220V ;
J=0.1SI ; f=0.001SI, TL=5N.m
The Simulink model:

01/20/2025 EE421 Dr. AMMAR 17


Example of DC Motor Control Using PID Controller:

Using the previous developed model in the open loop, a closed-loop speed control using a
PID controller.

PID Tuning Methods:

• PID controller can be tuned using an analytical method.

• PID tuner toolbox can be used

01/20/2025 EE421 Dr. AMMAR 18


PID tuner toolbox

01/20/2025 EE421 Dr. AMMAR 19


5. Signal Routing Library

The Signal Routing library contains blocks that route signals from one point in a
block diagram to another.

• Demux
Separate a vector signal into output signals.
• Mux
Combine several input lines into a vector
line.
• Bus Selector
Output signals selected from an input bus.
• Goto
Pass block input to From blocks.
• From
Accept input from a Goto block.

01/20/2025 EE421 Dr. AMMAR 20


Example:

Goto block’s properties

To find the From block


01/20/2025 EE421 Dr. AMMAR 21
Switches:

Manual Switch
Switch between two inputs.
Multiport Switch
Pass through the input signals corresponding to the discreet value of the first input,
(this bloc work as the switch case command

Switch
Pass through input 1 when input 2 satisfies the selected criterion; otherwise, pass
through input 3

01/20/2025 EE421 Dr. AMMAR 22


Example:
Manual Switch
Double click on the manual switch to switch

Multiport Switch
Must be a discrete natural number according to the number of the inputs.

01/20/2025 EE421 Dr. AMMAR 23


Switch

First choice (if)

The condition
second choice (else)

01/20/2025 EE421 Dr. AMMAR 24


6. User defined function in Simulink
Fcn
The Fcn block applies the specified mathematical expression to its input. The
expression can include one or more of these components:
u is the input to the block. If u is a vector, u(i) represents the i th element of the
vector; u(1) or u alone represents the first element.
MATLAB function

With a MATLAB Function block, you can write a MATLAB® function for use in a
Simulink® model
S-function

S-functions are SIMULINK blocks that can be programmed by the user (in
MATLAB language or in C language). They are used to simulate complex dynamic
systems (with time-varying parameters and/or with nonlinear components, different
sampling rates, etc.).

01/20/2025 EE421 Dr. AMMAR 25

You might also like