0% found this document useful (0 votes)
0 views

SimulinkIntro

The document provides a step-by-step introduction to using Simulink for modeling a mass-spring-damper system. It outlines the process of starting Simulink, creating a new model, and building the system using integrators, gain blocks, and sine wave sources. Additionally, it explains how to input parameters, run simulations, and visualize results using a scope.

Uploaded by

ranjitv10
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)
0 views

SimulinkIntro

The document provides a step-by-step introduction to using Simulink for modeling a mass-spring-damper system. It outlines the process of starting Simulink, creating a new model, and building the system using integrators, gain blocks, and sine wave sources. Additionally, it explains how to input parameters, run simulations, and visualize results using a scope.

Uploaded by

ranjitv10
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/ 25

Introduction

to Simulink Prof. Dr. Y. Samim ÜNLÜSOY


Mech. Eng. Dept.,
Prof. Dr. Y. Samim Middle East Technical
ME 513 Vehicle Dynamics 1
Ünlüsoy University, Ankara
SIMULINK
To start Simulink, one has to first
double click on the Matlab icon and
wait for the Matlab window to open.

Then, click on the “Simulink” icon

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 2


“Simulink Library
Browser”

will open.

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 3


Click on the “File” menu item. Select
“New” and then click on “Model”

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 4


A clean window is going to open. New
Simulink model is to be built on this
window.

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 5


Now, let us try to understand the logic behind
Simulink, using a familiar system.

x
m Consider a one degree of freedom
mass-spring-damper system.
c k

z  + cx + kx = cz + kz
mx

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 6


Reorganize the equation of motion
such that the highest derivative term
x is expressed in terms of the rest :
m

c k
c k c k
z 
x = − x − x + z + z
m m m m

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 7


c k c k

x=− x − x + z + z
m m m m SIMULINK
x Now start with the acceleration and
m integrate to get velocity.

c k x 1
z s x
Then integrate velocity to get
Simulink/ displacement.
Continuous/
integrator x 1 x 1 x
s s

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 8


Click on the “integrator”
icon inside “continuous”
selection of the “Simulink
Library Browser” and drag
it into the model window
and leave it there.

Then repeat it for the


second integrator.

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 9


Bring the cursor on the arrowhead of the first
“integrator” icon and drag it to the arrowtail on the
second “integrator” to create the signal line for velocity.

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 10


c k c k

x=− x − x + z + z
m m m m
SIMULINK
x
m It is possible to generate the first
two terms on the right hand side.
c k
x x 1 x
z 1
c s s
x
m c
m k
x
m k
Simulink/ m
Math Operations/
Gain

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 11


c k c k

x=− x − x + z + z
m m m m
SIMULINK
It is now time to generate the last
two terms on the right hand side.
Simulink/
Sources/
Sine wave x x 1 x
1
k s s
z
z k m
c k
m
Sine wave m m
z c
du/dt
m c
z
Simulink/ m
Continuous/
differentiator
Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 12
c k c k

x=− x − x + z + z
m m m m
SIMULINK
Finally sum all the terms and form
the acceleration signal.
Simulink/ x x 1 x
Math Operations/ 1
sum s s
c
m
z k +
-
m +- k
Sine wave m
z c
du/dt
m

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 13


c k c k

x=− x − x + z + z
m m m m
SIMULINK
Simulink/
Sources/ It is possible to provide different
constant inputs using a switch.

Simulink/ x x 1 x
1
Signal Routing/ s
A Manual Switch
s
Constant
c
m
z k +
-
m +- k
Manual m
Switch
z c
du/dt m
Sine wave

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 14


The resulting Simulink model looks like this !

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 15


You can enter parameter values
by clicking on each element.

x x 1 x
1
s s
A

Constant
c
m
z k +
-
m +- k
Manual m
Switch
z c
du/dt m
Sine wave

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 16


A better choice is to write the symbol instead of the
value. The values can be written in an m-script file.
When the m-script file is run, data values will be saved in
the workspace.

x x 1 x
1
s s
A

Constant
c
m
z k +
-
m +- k
Manual m
Switch
z c
du/dt m
Sine wave

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 17


% Data file for sdof.mdl This is the m-script file to
m=310; % [kg] load data to workspace.
C=980; % [N/m/s]
K=15000; % [N/m]
A=0.005; % [m]
f=2; % [Hz] x x 1 x
1
s s
A

Constant
c
m
z k +
-
m +- k
Manual m
Switch
z c
du/dt m
Sine wave

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 18


Now, you would like to Simulink/
observe the variation of Sinks/
some variable, say x, scope
with time. So add an Scope
oscilloscope !
x x 1 x
1
s s
A

Constant
c
m
z k +
-
m +- k
Manual m
Switch
z c
du/dt m
Sine wave

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 19


So, the final form of the Simulink diagram is :

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 20


First run the m-file for data by writing its name on the
Matlab “Command Window” and pressing enter. Check
that the correct data has been stored in workspace.

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 21


Now to run Simulink for 10 seconds,
click on the arrow head.

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 22


To see the variation of x with time,
double click on the scope.

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 23


The scope window will appear
with the plot of x versus time.

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 24


Click on the binoculars
icon to fit graph to frame

Prof. Dr. Y. Samim Ünlüsoy Introduction to Simulink 25

You might also like