Title: INTRODUCTION TO SIMULINK by Yasmin Hanum Md Thayoob
1INTRODUCTION TO SIMULINKbyYasmin Hanum Md
ThayoobAidil Azwin Zainul Abidin
2TABLE OF CONTENTS
- What Is Simulink?
- Starting Simulink
- Simulink Windows
- Simulink Library
- Creating A New Model
- Entering Simulink Commands
- Connecting Blocks
- Modeling In Simulink
- Example 1
- Example 2
- Creating Subsystems
- Simulation Parameters
- Running A Simulation
- Getting Output
- Using Scope
- Further Considerations
- Ending A Simulink Session
- Case Study
- References
3What Is Simulink
- Simulink is a graphical method of modeling and
simulating a mathematical equation or a system in
Matlab. - Simulink is not a stand alone program which means
that it could not be run without running Matlab. - Whatever variable defined in Matlab can be used
in Simulink.
4Starting Simulink
- To start Simulink, you must first start MATLAB.
Consult your MATLAB documentation for more
information. You can then start Simulink in two
ways - Click the Simulink icon on the MATLAB toolbar.
- Enter the simulink command at the MATLAB prompt.
- On Microsoft Windows platforms, starting Simulink
displays the Simulink Library Browser
5Simulink Windows
- Simulink uses separate windows to display
- a block library browser
- a block library
- a model
- graphical (scope) simulation output
- These windows are not MATLAB figure windows and
cannot be manipulated using HandleGraphics
commands.
6Simulink Library
- The Library Browser displays a tree-structured
view of the Simulink block libraries installed on
your system. You can build models by copying
blocks from the Library Browser into a model
window.
7Sources and Sinks
8Continuous and Discrete Systems
- All dynamic systems can be analyzed as continuous
or discrete time systems. Simulink allows you to
represent these systems using transfer functions,
integration blocks, delay blocks etc.
9Simulink Extras
- Figure 5 contains some advanced linear blocks,
available in the Simulink Extras ibrary. They
contain certain advanced blocks, such as a PID
control block, transfer functions with initial
conditions, etc.
10Non-linear operators
11Functions and Tables
12Math Block (Mathematical tools)
13Signals Systems Block (Signals and data
transfer)
- In complicated block diagrams, there may arise
the need to transfer data from one portion to
another portion of the block. They may be in
different subsystems. That signal could be dumped
into a GOTO block, which is used to send signals
from one subsystem to another. - Multiplexing helps us remove clutter due to
excessive connectors, and makes matrix
(column/row) visualization easier.
14Subsystems Block
15Creating a New Model
- Click the New button on the Simulink Library
Browsers toolbar (Windows only) or choose New
from the library windows File menu and select
Model. You can move the window as you do other
windows. - You can build models by copying blocks from the
Library Browser into a model window (this
procedure is described later in the modeling
example ).
16Simulink opens a new model window as below.
17Entering Simulink Commands
- You run Simulink and work with your model by
entering commands. You can enter commands by - Selecting items from the Simulink menu bar
- Selecting items from a context-sensitive
Simulink menu (Windows only) - Clicking buttons on the Simulink toolbar (Windows
only) - Entering commands in the MATLAB command window
18- Using Context-Sensitive Menus to Enter Commands
- Simulink displays a context-sensitive menu when
you click the right mouse button over a model or
block library window. The contents of the menu
depend on whether a block is selected. If a block
is selected, the menu displays commands that
apply only to the selected block. If no block is
selected, themenu displays commands that apply to
a model or library as a whole.
19Connecting Blocks
- To connect blocks, left-click and drag the mouse
from the output of one block to the input of
another block. The figure below shows the steps
involved.
20Modeling In SimulinkExample 1 Modeling
Equations
- Converting Celsius to Fahrenheit
- To model the equation that converts Celsius
temperature to Fahrenheit - TF 9/5(TC) 32
- First, consider the blocks needed to build the
model - A Ramp block to input the temperature signal,
from the Sources library - A Constant block to define a constant of 32,
also from the Sources library - A Gain block to multiply the input signal by
9/5, from the Math library - A Sum block to add the two quantities, also
from the Math library - A Scope block to display the output, from the
Sinks library -
21 - Next, gather the blocks into your model window.
- Assign parameter values to the Gain and Constant
blocks by opening - (double-clicking) each block and entering
the appropriate value. Then, click the Close
button to apply the value and close the dialog
box. - Now, connect the blocks.
22- The Ramp block inputs Celsius temperature. Open
that block and change the Initial output
parameter to 0. - The Gain block multiplies that temperature by the
constant 9/5. The Sum block adds the value 32 to
the result and outputs the Fahrenheit
temperature. - Open the Scope block to view the output. Now,
choose Start from the Simulation menu to run the
simulation. The simulation runs for 10 seconds.
23Example 2 Modeling A Simple Continuous System
- To model the differential equation
- x' (t) 2x (t) u (t)
- where u(t) is a square wave with an amplitude of
1 and a frequency of 1 rad/sec. The Integrator
block integrates its input x' to produce x. Other
blocks needed in this model include a Gain block
and a Sum block. To generate a square wave, use a
Signal Generator block and select the Square Wave
form but change the default units to radians/sec.
- Again, view the output using a Scope block.
Gather the blocks and define the gain.
24- An important concept in this model is the loop
that includes the Sum block, the Integrator
block, and the Gain block. In this equation, x is
the output of the Integrator block. It is also
the input to the blocks that compute x', on which
it is based. This relationship is implemented
using a loop.
25The Scope displays x at each time step. For a
simulation lasting 10 seconds, the output looks
like this
26The equation you modeled in this example can also
be expressed as a transfer function. The model
uses the Transfer Fcn block, which accepts u as
input and outputs x. So, the block implements
x/u. If you substitute sx for x' in the above
equation, you get sx -2x u Solving
for x gives x u /(s 2) or, x / u 1
/ ( s 2)
27The Transfer Fcn block uses parameters to specify
the numerator and denominator coefficients. In
this case, the numerator is 1 and the denominator
is s2. Specify both terms as vectors of
coefficients of successively decreasing powers of
s. In this case the numerator is 1 (or just 1)
and the denominator is 1 2. The model now
becomes quite simple.
- The results of this simulation are identical to
those of the previous model.
28Creating Sub System
- 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.
29 Before - After
- Check with model browser in Simulink window
- Label subsytem Ports
30Simulation Parameters
- You can set the simulation parameters for each
simulation such as run time or solver option
31Simulation Parameters (Continue)
Solver type
Step Size
- Setting simulation time
- Setting solver
32Running A Simulation
- A simulation can be run using 3 ways
- Clicking the start word on the simulation tab
- Clicking the play button on the window
- Pressing CtrlT.
33When a simulation is running, the status bar
displays the status of the simulation, including
the current simulation time and the name of the
current solver. You can display or hide the
status bar by selecting or clearing the Status
Bar option on the Simulink View menu.
34Getting Output
- You can save scope data into workspace (you can
do this with save to workspace block in sinks
catagory) - You can view more than one signal in scope either
on the same axis or in the separate axis. - Data can also be exported to the workspace using
the scope.
Parameters
35Using Scope
- Setting the number of axes for the scope (Figure
1) - Saving the data to workspace (Figure 2)
36Further Considerations
- This lecture cant possibly look upon all the
blocks. - Another way is to get help concerning the
block. - This can be done by double clicking on the block.
A window will appear where a help button is
available. - Click on that button to know what is the
potential of the block.
37Ending A Simulink Session
- Terminate a Simulink session by closing all
Simulink windows. - Terminate a MATLAB session by choosing the
command below from the File menu - Exit MATLAB
38References
- SIMULINK Model-Based and System-Based Design
- Matlab Documentation, The MathWorks.
- www.mathworks.com
- http//sts.bwk.tue.n1/7y530/readers/.5CSimuLinkTu
torial.pdf - http//www.eng.warwick.ac.uk/staff/msl/progs/simul
inklab1.pdf - http//www.engin.umich.edu/group/ctm/working/mac/s
imulink_basics/