You are on page 1of 42

Control Systems Lab

Introduction to SIMULINK

Surrayya Mobeen
Department of Aeronautics and Astronautics
Institute of Space Technology, Islamabad

S.M (IST) CSLab 1 / 17


Outline

1. Introduction

2. Mass Spring System

3. Task

S.M (IST) CSLab 2 / 17


Outline

1. Introduction

2. Mass Spring System

3. Task
Introduction

 Simulink, developed by MathWorks, is a graphical programming environment


for modeling, simulating and analyzing multidomain dynamic systems.

S.M (IST) CSLab 3 / 17


Introduction

 Simulink, developed by MathWorks, is a graphical programming environment


for modeling, simulating and analyzing multidomain dynamic systems.
 Its primary interface is a graphical block diagramming tool and a
customizable set of block libraries.

S.M (IST) CSLab 3 / 17


Introduction

 Simulink, developed by MathWorks, is a graphical programming environment


for modeling, simulating and analyzing multidomain dynamic systems.
 Its primary interface is a graphical block diagramming tool and a
customizable set of block libraries.
 It oers tight integration with the rest of the MATLAB environment and can
either drive MATLAB or be scripted from it.

S.M (IST) CSLab 3 / 17


Introduction

 Simulink, developed by MathWorks, is a graphical programming environment


for modeling, simulating and analyzing multidomain dynamic systems.
 Its primary interface is a graphical block diagramming tool and a
customizable set of block libraries.
 It oers tight integration with the rest of the MATLAB environment and can
either drive MATLAB or be scripted from it.
 Simulink is widely used in automatic control and digital signal processing for
multidomain simulation and Model-Based Design

S.M (IST) CSLab 3 / 17


Outline

1. Introduction

2. Mass Spring System

3. Task
Mass Spring System

 Consider the simple mass spring system shown in the gure below

S.M (IST) CSLab 4 / 17


Mass Spring System

 The dynamic equation of the system is given as:


mẍ = u(t) − bẋ − kx

S.M (IST) CSLab 5 / 17


Mass Spring System

 The dynamic equation of the system is given as:


mẍ = u(t) − bẋ − kx

 As an example, consider m = 10kg, b = 2N sm−1 , k = 5N m−1

S.M (IST) CSLab 5 / 17


Mass Spring System

 The dynamic equation of the system is given as:


mẍ = u(t) − bẋ − kx

 As an example, consider m = 10kg, b = 2N sm−1 , k = 5N m−1


 So the equation becomes:
10ẍ = u(t) − 2ẋ − 5x

S.M (IST) CSLab 5 / 17


Mass Spring System

 The dynamic equation of the system is given as:


mẍ = u(t) − bẋ − kx

 As an example, consider m = 10kg, b = 2N sm−1 , k = 5N m−1


 So the equation becomes:
10ẍ = u(t) − 2ẋ − 5x

 This equation has to be implemented in SIMULINK with a unit step input.

S.M (IST) CSLab 5 / 17


Implementation in SIMULINK

 Start MATLAB and wait for initialization.

S.M (IST) CSLab 6 / 17


Implementation in SIMULINK

 Start MATLAB and wait for initialization.


 Before starting SIMULINK we need to dene the variables m, b and k in the
MATLAB workspace.
m = 10;
b = 2;
k = 5;

S.M (IST) CSLab 6 / 17


Implementation in SIMULINK

 Start MATLAB and wait for initialization.


 Before starting SIMULINK we need to dene the variables m, b and k in the
MATLAB workspace.
m = 10;
b = 2;
k = 5;
 Write Simulink in the command window.

S.M (IST) CSLab 6 / 17


Implementation in SIMULINK

 This opens the Simulink Start Page. Click on Blank Model. This opens the
following window:

S.M (IST) CSLab 7 / 17


Implementation in SIMULINK

 Click on the button highlighted in the above gure. This will open the
Simulink Library Browser.

S.M (IST) CSLab 8 / 17


Implementation in SIMULINK

 In the search bar, write sum. Drag the highlighted block to the blank model
window.

S.M (IST) CSLab 9 / 17


Implementation in SIMULINK
Similarly, drag the following blocks to the model.
 Step

S.M (IST) CSLab 10 / 17


Implementation in SIMULINK
Similarly, drag the following blocks to the model.
 Step
 Integrator

S.M (IST) CSLab 10 / 17


Implementation in SIMULINK
Similarly, drag the following blocks to the model.
 Step
 Integrator
 Gain

S.M (IST) CSLab 10 / 17


Implementation in SIMULINK
Similarly, drag the following blocks to the model.
 Step
 Integrator
 Gain
 Scope

S.M (IST) CSLab 10 / 17


Implementation in SIMULINK

 To duplicate any block, click on the block, press ctrl and while keeping it
pressed, drag the block. This would add an identical block. In the current
case, do this twice for the Gain block and once for the Integrator block. This
would add 1 integrator block and 2 gain blocks.

S.M (IST) CSLab 11 / 17


Implementation in SIMULINK

 To duplicate any block, click on the block, press ctrl and while keeping it
pressed, drag the block. This would add an identical block. In the current
case, do this twice for the Gain block and once for the Integrator block. This
would add 1 integrator block and 2 gain blocks.
 To ip any block select the block and press ctrl+I OR right click on the block
and in the Rotate and Flip tab select Flip Block. Similarly to rotate any
block, press ctrl+R OR right click on the block and in the Rotate and Flip
tab select Clockwise or Counterclockwise. In the current case, ip two Gain
blocks and leave one as it is.

S.M (IST) CSLab 11 / 17


Implementation in SIMULINK

 To arrange the blocks you should understand the equation.


mẍ = u(t) − bẋ − kx

S.M (IST) CSLab 12 / 17


Implementation in SIMULINK

 To arrange the blocks you should understand the equation.


mẍ = u(t) − bẋ − kx

 This means that the result of the Sum block is mẍand there are 3 inputs to
the Sum block i.e u(t) , −bẋ , −kx .

S.M (IST) CSLab 12 / 17


Implementation in SIMULINK

S.M (IST) CSLab 13 / 17


Implementation in SIMULINK
 Double click on the 1st Integrator block. You can give an initial velocity
value by editing the value under the Initial Value section.

S.M (IST) CSLab 14 / 17


Implementation in SIMULINK
 Double click on the 1st Integrator block. You can give an initial velocity
value by editing the value under the Initial Value section.
 Similarly, Double click on the 2nd Integrator block. You can give an initial
position value by editing the value under the Initial Value section.

S.M (IST) CSLab 14 / 17


Implementation in SIMULINK
 Double click on the 1st Integrator block. You can give an initial velocity
value by editing the value under the Initial Value section.
 Similarly, Double click on the 2nd Integrator block. You can give an initial
position value by editing the value under the Initial Value section.
 This completes the implementation.

S.M (IST) CSLab 14 / 17


Implementation in SIMULINK

 The model is ready to be simulated now.

S.M (IST) CSLab 15 / 17


Implementation in SIMULINK

 The model is ready to be simulated now.


 The simulation time can be changed, by editing the time in the model
window as highlighted (green color) in the gure below:

S.M (IST) CSLab 15 / 17


Implementation in SIMULINK

 The model is ready to be simulated now.


 The simulation time can be changed, by editing the time in the model
window as highlighted (green color) in the gure below:

 To run the simulation, press the run button as highlighted (red color) in the
above gure.

S.M (IST) CSLab 15 / 17


Implementation in SIMULINK

 The model is ready to be simulated now.


 The simulation time can be changed, by editing the time in the model
window as highlighted (green color) in the gure below:

 To run the simulation, press the run button as highlighted (red color) in the
above gure.
 To observe the position plot, Double Click on the Scope block.

S.M (IST) CSLab 15 / 17


Outline

1. Introduction

2. Mass Spring System

3. Task
Task 1

1. Consider the following mass-spring damper

S.M (IST) CSLab 16 / 17


Task 1

1. Consider the following mass-spring damper


1.1 Model the system.

S.M (IST) CSLab 16 / 17


Task 1

1. Consider the following mass-spring damper


1.1 Model the system.
1.2 Solve the equation obtained in part (a) in SIMULINK and obtain the position
response with a unit step input for 0≤ t ≤ 50 sec

S.M (IST) CSLab 16 / 17


Task 2

Inititial Conditions:
x1 (0) = x2 (0) = ẋ1 (0) = ẋ2 (0) = 0
m1 = m2 = ( 100N
+ 1)kg
k1 = 7.5N m−1
k2 = 35N m−1
N
b = ( 100 + 0.6)N sm−1

1. Consider the above mass-spring damper where N is the mean/average of the


last two digits of the registration number.

S.M (IST) CSLab 17 / 17


Task 2

Inititial Conditions:
x1 (0) = x2 (0) = ẋ1 (0) = ẋ2 (0) = 0
m1 = m2 = ( 100N
+ 1)kg
k1 = 7.5N m−1
k2 = 35N m−1
N
b = ( 100 + 0.6)N sm−1

1. Consider the above mass-spring damper where N is the mean/average of the


last two digits of the registration number.
1.1 Model the system.

S.M (IST) CSLab 17 / 17


Task 2

Inititial Conditions: x1 (0) = x2 (0) = ẋ1 (0) = ẋ2 (0) = 0


m1 = m2 = ( 100N
+ 1)kg
k1 = 7.5N m−1
k2 = 35N m−1
N
b = ( 100 + 0.6)N sm−1

1. Consider the above mass-spring damper where N is the mean/average of the


last two digits of the registration number.
1.1 Model the system.
1.2 Implement the system in SIMULINK with unit step input at t=0 and obtain
graphs for x1 and x2 with time separately (0 ≤ t ≤ 20).

S.M (IST) CSLab 17 / 17

You might also like