0% found this document useful (0 votes)
26 views35 pages

Session 7

The document introduces Simulink, a program that builds block diagrams and performs simulations. It discusses basic Simulink concepts and blocks, and provides two examples of setting up and running simple simulations of a sine wave and second order system. Step-by-step instructions are given for building each model and interpreting the results.

Uploaded by

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

Session 7

The document introduces Simulink, a program that builds block diagrams and performs simulations. It discusses basic Simulink concepts and blocks, and provides two examples of setting up and running simple simulations of a sine wave and second order system. Step-by-step instructions are given for building each model and interpreting the results.

Uploaded by

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

MATLAB Tutorials

Session VII
Introduction to SIMULINK

Rajeev Madazhy
Email: [email protected]

Dept of Mechanical Engineering


LSU

Department of Mechanical Engineering, LSU Session VII


Last Session….

Engineering Applications using MATLAB….


 Solving non linear differential equations
 Algorithm analysis for four bar linkage problem
 Other mechanical problems

Department of Mechanical Engineering, LSU Session VII


Session VII Outline….

 Introduction to Simulink
 Solving simple problems using Simulink

Department of Mechanical Engineering, LSU Session VII


Simulink…..

 Simulink is a program that runs as a companion to MATLAB


 Simulink provides a graphical user interface (GUI) that is used
in building block diagrams, performing simulations, as well as
analyzing results of dynamic systems.
 In Simulink, models are hierarchical so that you can view a
system at a high level, then double click on blocks by using
the mouse to go down through the design levels.

Department of Mechanical Engineering, LSU Session VII


Getting started…..

Lets get started with a simple example of simulating a sin wave.

To open Simulink open the MATLAB command window first.


Click on the icon which is present in the toolbar in the command
window of MATLAB.
Alternatively you can also enter the command Simulink to open
the graphics library of simulink

Department of Mechanical Engineering, LSU Session VII


Opening Simulink….

Department of Mechanical Engineering, LSU Session VII


Simulink block library….

Department of Mechanical Engineering, LSU Session VII


General list of libraries….

Source type blocks produce input signals.


The Sine Wave block is a source type block

Sink type blocks provide a place for output.


The scope block is a sink type block.

Linear type blocks perform a linear transformation.


The Integrator is a linear type block.

Connection type blocks are involved with forming


vector signals, the Mux block is an example.

Department of Mechanical Engineering, LSU Session VII


Adding a block from the library…..

To open a block library, double click on the associated library icon in


the Simulink block library window. After opening the Sources library,
the Sources library window opens, as shown

Department of Mechanical Engineering, LSU Session VII


Simulink Library Browser….

Department of Mechanical Engineering, LSU Session VII


Adding a block from the library…..

 To add the first block to the diagram, point the mouse at the Sine
Wave block in the Sources library window and press the left button.

 Create a new model window by clicking on to the new icon at the


toolbar.
 Without releasing the left mouse button, drag the mouse to the
new model window and release the mouse button.

Department of Mechanical Engineering, LSU Session VII


Simulink model window….

Department of Mechanical Engineering, LSU Session VII


Pulling the selected blocks….

Pull in the following blocks


for our simulation from the
following libraries.

Block From Library


Sine wave sources
integrator Linear
Mux connections
Scope sinks

Department of Mechanical Engineering, LSU Session VII


Inputs and outputs….

In general the inputs to a block are on the left a > symbol points
into the block. In addition, outputs are generally on to the right, a
> symbol out of the block.

To add a connection, use the mouse to position the pointer over


the output port of the block. During this time the pointer changes
to cross hairs .

Department of Mechanical Engineering, LSU Session VII


Cont…

The completed connection should look like this….

Adding a branch line….This is required when you have an output


which needs to be connected to two separate blocks

Department of Mechanical Engineering, LSU Session VII


Cont…

To complete the connections, add a line from the output of the


integrator block to the input port of the mux block. When you are
done it should look similar to the following.

Labels can be added to lines to further annotate your model.


To create a signal label, double click on a line segment and
type the label at the insertion point.

Department of Mechanical Engineering, LSU Session VII


Final model….

Save the model as


example1.mdl

Department of Mechanical Engineering, LSU Session VII


Giving model parameters…..

The sine wave block


Double click on the sine wave block and examine the data fields.
Sine wave block parameters:

Amplitude = 1
Frequency (rad/sec) = 0.25*2*pi
Phase(rad) = 0
Sample time = 0

Department of Mechanical Engineering, LSU Session VII


Block Parameters of Sine Wave….

Department of Mechanical Engineering, LSU Session VII


Integrator Block….

Integrator block parameters:


External reset = None
Initial Conditions = 0
Limit Output = Not checked
Show saturation point = Not checked
Show state port = Not checked
Absolute tolerance = auto

Department of Mechanical Engineering, LSU Session VII


Block parameters: Integrator

Department of Mechanical Engineering, LSU Session VII


Simulation parameters….

Go to simulation => parameters in the model window toolbar

Enter the following


values

Department of Mechanical Engineering, LSU Session VII


Run the simulation….

To view the results of the simulation, double click on the scope block.

Department of Mechanical Engineering, LSU Session VII


Cont….

To better fit the display in the scope window, click on the ‘Fit View’
button . The scope window should similar to the following.

Department of Mechanical Engineering, LSU Session VII


Example 2….

The next example would be to simulate the dynamics of second order


system.

d2 d
     
2 2
y (t ) 2 n
y (t ) n
y (t ) K n
u (t )
dt 2
dt

Given that:

K  1;  0.5; n  4

Obtain the velocity and displacement response

Department of Mechanical Engineering, LSU Session VII


Building the model….

The same procedure is applied as being shown in the first example.


Pull all the necessary blocks from the library browser.
The blocks required is as follows:
Blocks Number
Integrator 2
Sum 1
Scope 3
Step I/P 1
Gain 3

Department of Mechanical Engineering, LSU Session VII


Final Model….

Department of Mechanical Engineering, LSU Session VII


Gain parameters- 1st Gain block

Similarly give the gains for the second and the third one as
shown in the model window.

Department of Mechanical Engineering, LSU Session VII


Block parameters - Step

Department of Mechanical Engineering, LSU Session VII


Simulation parameters….

Department of Mechanical Engineering, LSU Session VII


Output from Scope1 and Scope2…

Department of Mechanical Engineering, LSU Session VII


Output from Scope3….

Scope3 shows the


displacement response for the
second order system.

Department of Mechanical Engineering, LSU Session VII


References….

MATLAB website (http://www.mathworks.com) has a


comprehensive list of examples and references to SIMULINK.
There are several books which cater to this area. One of the good
references is listed below:

Mastering Simulink 4
James B. Dabney & Thomas L. Harman

ISBN 0-13-017085-2

Department of Mechanical Engineering, LSU Session VII


Looking back….

This completes the MATLAB Tutorial.


Sessions 1 to 7 covered almost all areas of applications of
MATLAB.
Specialized areas of MATLAB are using the toolboxes.
These are a collection of m-files that are specific to the
area of application.

Department of Mechanical Engineering, LSU Session VII


Thank You

Department of Mechanical Engineering, LSU Session VII

You might also like