0% found this document useful (0 votes)
28 views52 pages

Simulink Lesson 6

This lesson focuses on modeling dynamic systems using SIMULINK software, with intended outcomes including the ability to create subsystems in complex models. It covers the basics of starting SIMULINK, creating models, using solvers, and grouping blocks into subsystems for better organization. The lesson concludes with a summary of key points and a preview of the next lesson, which will include an assessment on numerical methods and modeling.

Uploaded by

navinamulu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views52 pages

Simulink Lesson 6

This lesson focuses on modeling dynamic systems using SIMULINK software, with intended outcomes including the ability to create subsystems in complex models. It covers the basics of starting SIMULINK, creating models, using solvers, and grouping blocks into subsystems for better organization. The lesson concludes with a summary of key points and a preview of the next lesson, which will include an assessment on numerical methods and modeling.

Uploaded by

navinamulu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

COMPUTER APPLICATIONS

BECE4/BEEE4/BEEE4E/BETE4/BAE5
Lesson 6: MODELLING WITH SIMULINK
S. Mafumbi, Staff Associate, Electrical Engineering. Dept
LAST LESSON
In lesson 5, we discussed numerical methods with C++
Any questions??
INTENDED LESSON OUTCOMES
In this lesson, we will discuss the modelling of dynamic
systems using SIMULINK
By the end of this lesson, the student should be able to:
o Model dynamic systems using SIMULINK software; and
o Create subsystems in complex systems modelling.
REFERENCE MATERIALS

o Bakolo, R.S., Ph.D (2022). Computer


Applications lecturer notes. (MUBAS)
o Palm, P.J. (2023). MATLAB for
Engineering Applications. McGraw Hill.
LESSON OUTLINE
o Last lesson
o Intended lesson outcomes
o Reference materials
o Lesson outline
o Introduction
o Creating Simulink Models
o Simulink solvers
o Creating subsystems
LESSON OUTLINE
• Selected Simulink blocks
• Simulink and digital electronics
• Simulink tutorial
• Lesson summary
• Next lesson
INTRODUCTION
• SIMULINK (SIMUlation LINK) is a software package for
modelling, simulating, and analyzing dynamic systems.
• It supports linear and nonlinear systems, modelled in
continuous time, sampled time, or a hybrid of the two.
• SIMULINK turns your computer into a lab for modelling and
analyzing complex systems & processes that are difficult to
model with a simple set of differential equations.
INTRODUCTION
• SIMULINK provides a graphical user interface (GUI) for
building models as block diagrams, using click-drag-drop
mouse operations.
• The Simulink graphical interface enables selection,
positioning, resizing, labelling, interconnection, and
specifying parameters of blocks to describe complicated
systems for simulation.
CREATING SIMULINK MODELS
• To start using Simulink type ‘simulink’ on the MATLAB
command window or click on the MATLAB’s toolbar. The
Start window opens.
• To create a new model, click the Blank Model button on the
Simulink start page. A new blank model window opens.
• Click on the Simulink Library Browser window icon under the
View menu to access simulation blocks.
CREATING SIMULINK MODELS
• Blocks can also be located by typing their name in the search
pane at the top of the Simulink Library Browser.
• To select a block from the Library Browser, double-click on
the appropriate library, and a list of blocks within that library
then appears.
• Click on the block name or icon, hold the mouse button
down, drag the block to the new model window, and release
the button.
CREATING SIMULINK MODELS
• Once all blocks have been placed in the model window,
connect them to achieve the intended block diagram.
• Blocks have a block parameters window that opens when
you double-click on the block. You can change these
parameters.
• Simulation results can be accessed by using the scope block,
we will study this block shortly, but it is possible to produce a
hard copy of a graph using a file menu of the scope.
CREATING SIMULINK MODELS
• It is also possible to use the To Workspace and To File blocks
to write data to the workspace and to a file, respectively
(Students are advised to research on this)
CREATING SIMULINK MODELS
Starting Simulink
CREATING SIMULINK MODELS
Creating New Model
CREATING SIMULINK MODELS
Accessing Modelling Blocks
CREATING SIMULINK MODELS
Basic Simulink Blocks
CREATING SIMULINK MODELS
Basic Simulink Blocks
CREATING SIMULINK MODELS
Basic Simulink Blocks
CREATING SIMULINK MODELS
Example
Construct a Simulink model to solve the equation 𝒚′ = −𝟏𝟎𝒚 + 𝒇 𝒕
where 𝒚 𝟎 = 𝟎 and 𝒇 𝒕 = 𝟏𝟎𝟎𝐬𝐢𝐧(𝟔. 𝟐𝟖𝒕) for 𝟎 ≤ 𝒕 ≤ 𝟐.
CREATING SIMULINK MODELS
Solution
General solution: 𝑦 = ‫ ׬‬−10𝑦 + 𝑓(𝑡), where 𝑓 𝑡 is the input
and 𝑦 is the output
1. Start Simulink and open a new model window
2. Select and place in the new window the Sine Wave block from
the Sources library and set parameters amplitude to 100,
frequency to 6.28, the Bias to 0, the Phase to 0, and the Sample
time to 0.
3. Select the Sum block from the Math Operations library and place
it in the simulation diagram after the sine wave. Double click the
block and change the signs to |+-
CREATING SIMULINK MODELS
Solution
General solution: 𝑦 = ‫ ׬‬−10𝑦 + 𝑓(𝑡), where 𝑓 𝑡 is the input
and 𝑦 is the output
4. Add the integrator block after the sum block and set the initial
condition to 0 (y 0 = 0)
5. Add and rotate a gain block as a feedback with a gain value of 10
6. Add a scope block to display our simulation
7. Connect the blocks to obtain the required model
8. Enter 2 for the stop time in the simulation window
9. Start simulation by clicking on the Run icon on the toolbar
CREATING SIMULINK MODELS
Solution
General solution: 𝑦 = ‫ ׬‬−10𝑦 + 𝑓(𝑡), where 𝑓 𝑡 is the input
and 𝑦 is the output
10. Double-click the scope block to view the response after a bell
sound.
CREATING SIMULINK MODELS
Solution-Model
CREATING SIMULINK MODELS
Solution-Response
CREATING SIMULINK MODELS
Exercise
A. Using suitable simulink blocks come up with Models that would be
used to simulate the following.
dy
1. = −10 y + f (t ) where f (t ) = 2 sin 4t for 0  t  3
dt
dy
2. + 10 x 2 = 2 sin 4t where x is any continuous function and x(0) = 0
dt

3. [ A(t )]2 cos( 2f c t ) for 0  t  3 sec , A(t ) = t for t  0 and f c = 2 Hz

0.5(u 3 + 2) where u is a Sine wave.


BREAK
3min
SIMULINK SOLVERS
• Simulation of a Simulink model entails computing its inputs,
outputs, and states at intervals from the simulation start
time to the simulation end time.
• Simulink uses a solver to perform this task. No one method
for solving a model is suitable for all models. Simulink
therefore provides an assortment of solvers each geared to
solving a specific type of model.
SIMULINK SOLVERS
• The Solver pane allows you to select the solver most suitable
for your model.
SIMULINK SOLVERS
Type of Solvers
1. Fixed-step continuous solvers.
These solvers compute a model's continuous states at
equally spaced time steps from the simulation start time to
the simulation stop time. The solvers use numerical
integration to compute the continuous states of a system
from the state derivatives specified by the model.
Examples include ode1,2,3,4,5 and 8, based on integration
method
SIMULINK SOLVERS
Type of Solvers
2. Fixed-step discrete solver. Simulink provides a fixed-step
solver that performs no integration. It is suitable for use in
solving models that have no continuous states, including
stateless models or models having only discrete states.
SIMULINK SOLVERS
Type of Solvers
3. Variable-step continuous solvers. These solvers decrease
the simulation step-size to increase accuracy when a
system's continuous states are changing rapidly and
increase the step size to save simulation time when a
system's states are changing slowly. Examples include
ode45 (the best for a start and Simulink default, based on
(Runge Kutta), ode23s,133,15s,23t and ode23tb.
SIMULINK SOLVERS
Type of Solvers
4. Variable-Step Discrete Solver. Simulink provides a
variable-step discrete solver that does no integration but
does zero-crossing detection. Suitable for models that have
no continuous states.
CREATING SUBSYSTEMS
Grouping blocks into subsystems helps as a model increases
in size and complexity. Using subsystems has these
advantages:
• It helps reduce the number of blocks displayed in your model
window.
• It allows you to keep functionally related blocks together.
• It enables you to establish a hierarchical block diagram, where a
Subsystem block is on one layer and the blocks that make up the
subsystem are on another.
CREATING SUBSYSTEMS
You can create a subsystem in two ways:

1.Add a Subsystem block to your model, then open that block


and add the blocks it contains to the subsystem window.
2.Add the blocks that make up the subsystem, then group

those blocks into a subsystem.


CREATING SUBSYSTEMS
Method 1
Add a Subsystem block to the model, and then add the
blocks that make up the subsystem.
Copy the Subsystem block from the Subsystems library into
your model.
Open the Subsystem block by double-clicking it. Simulink

opens the subsystem in the current or a new model window,


depending on the model window reuse mode that you
selected.
CREATING SUBSYSTEMS
Method 1
• In the empty subsystem window, create the subsystem as
shown below.
CREATING SUBSYSTEMS
Method 1
Use Inport blocks to represent input from outside the
subsystem and Outport blocks to represent external output.
For example, the subsystem shown above includes a Dot
product block, a gain block, Inport and Outport blocks to
represent input to and output from the subsystem
CREATING SUBSYSTEMS
Method 2
• If your model already contains the blocks you want to
convert to a subsystem, you can create the subsystem by
grouping those blocks:
• Enclose the blocks and connecting lines that you want to
include in the subsystem within a bounding box.
• For example, The Dot product and gain blocks are selected
within a bounding box in the next slide
CREATING SUBSYSTEMS
Method 2

• Choose Create Subsystem from the Edit menu. Simulink replaces the
selected blocks with a Subsystem block as shown below:
CREATING SUBSYSTEMS
Method 2
• Double-clicking the subsystem reveals the following
End of Session
Next Time
Selected Simulink blocks and Simulink tutorial
SELECTED SIMULINK BLOCKS
1. The Fcn – f(u) Block
This is a general expression block used to apply a specified
expression to the input.
The expression must be mathematically well formed (i.e., matched
parentheses, proper number of function arguments, etc.).
Double click the block to change the expression as required.
SELECTED SIMULINK BLOCKS
2. The Math Function Block
Used to perform a mathematical function.
The Math Function block performs numerous common mathematical
functions.
You can select one of these functions from the Function list:
exp, log, 10u, log10,magnitude^2, square, sqrt, pow, reciprocal, mod,
transpose, and many others.
The block output is the result of the function operating on
the input or inputs.
SELECTED SIMULINK BLOCKS
3. The Zero Order Hold Block
The Zero-Order Hold block implements a sample-and-hold
function operating at the specified sampling rate.
The block accepts one input and generates one output,
both of which can be scalar or vector.
This block provides a mechanism for discretizing one or
more signals or resampling the signal at a different rate.
SELECTED SIMULINK BLOCKS
4. The Switch Block - Switch between two inputs.
The Switch block propagates one of two inputs to its output
depending on the value of a second input, called the control input.
If the signal on the control input is greater than or equal to the
Threshold parameter, the block propagates the first input;
otherwise, it propagates the third input. The figure below shows
the use of the block.
SELECTED SIMULINK BLOCKS
A Switch block accepts real- or complex-valued signals of any data
type as switched inputs (inputs 1 and 3). Both switched inputs must
be of the same type. The block output signal has the data type of the
selected input. The data type of the threshold input must be Boolean
or double.
SIMULINK AND DIGITAL ELECTRONICS
Though not the best tool for simulating digital electronics
circuits, SIMULINK offers the electronics engineer a chance to
simulate their digital circuits.
Simulink has all logical operators(AND OR NOT etc) blocks
including JK flip-flop, D-flip-flop and the D-latch. Find these
under ‘Simulink Extras’ in the browser
SIMULINK AND DIGITAL ELECTRONICS
SIMULINK TUTORIAL
Tutorial 1 in word format
Simulink Tutorial 1
‘DC motor speed modeling with SIMULINK’
Simulation:
To simulate the model, add scope and step function blocks. In addition,
enter the following values for the physical parameters on the Model
(on the MATLAB command window)
J= 3.228E-6, b=3.5077E-6, k=0.0274, R=4, and
L=2.75E-6.
LESSON SUMMARY
In this lesson, we have:
o Modelled dynamic systems using SIMULINK software; and
o Created subsystems in complex systems modelling.
Any questions??
NEXT LESSON
In the next lesson, we shall have an assessment covering
numerical methods with MATLAB and C++, and modelling with
SIMULINK.
End of Lesson
THANK YOU

You might also like