SlideShare a Scribd company logo
1 of 15
Download to read offline
© 4 July 2001 – B.W. Bequette
Module 2
Introduction to SIMULINK
Although the standard MATLAB package is useful for linear systems analysis, SIMULINK is far
more useful for control system simulation. SIMULINK enables the rapid construction and
simulation of control block diagrams. The goal of the tutorial is to introduce the use of
SIMULINK for control system simulation. The version available at the time of writing of this
textbook is SIMULINK 4, part of Release 12 (including MATLAB 6) from MATHWORKS. The
version that you are using can be obtained by entering ver in the MATLAB Command Window.
The easiest way to learn how to use SIMULINK is to implement each step of the tutorial, rather
than simply reading it. The basic steps to using SIMULINK are independent of the platform (PC,
MAC, UNIX, LINUX…).
M2.1 Background
M2.2 Open-loop Simulations
M2.3 Closed-loop Simulations
M2.4 Developing Alternative Controller Icons
SIMULINK Tutorial2
M2.1 Background
The first step is to startup MATLAB on the machine you are using. In the Launch Pad window of
the MATLAB desktop, select SIMULINK and then the SIMULINK Library Browser. A number of
options are listed, as shown in Figure M2.1. Notice that Continuous has been highlighted; this
will provide a list of continuous function blocks available. Selecting Continuous will provide the
list of blocks shown in Figure M2.2. The ones that we often use are Transfer Fcn and State-
Space.
Figure M2.1 SIMULINK Library Browser.
3
Figure M2.2 SIMULINK Continuous Blocks.
Selecting the Sources icon yields the library shown in Figure M2.3. The most commonly used
sources are Clock (which is used to generate a time vector), and Step (which generates a step
input).
SIMULINK Tutorial4
Figure M2.3 SIMULINK Sources.
The Sinks icon from Figure M2.1 can be selected to reveal the set of sinks icons shown in
Figure M2.4. The one that we use most often is the To Workspace icon. A variable passed to this
5
icon is written to a vector in the MATLAB workspace. The default data method shoulb be
changed from “structure” to “matrix” in order to save data in an appropriate form for plotting.
Figure M2.4 SIMULINK Sinks.
M2.2 Open-Loop Simulation
You now have enough information to generate an open-loop simulation. The Clock, simout,
step and Transfer function blocks can be dragged to a model (.mdl) workspace, as shown in
Figure M2.5a. Renaming the blocks and variables, and connecting the blocks, results in the
model shown in Figure M2.5b. The transfer function studied is the Van de Vusse reactor
(Module 5).
The s-polynomials in the process transfer function were entered by double-clicking on the
transfer function icon and entering the coefficients for the numerator and denominator
SIMULINK Tutorial6
polynomials. Notice also that the default step (used for the step input change) is to step from a
value of 0 to a value of 1 at t = 1. These default values can be changed by double-clicking the
step icon. The simulation parameters can be changed by going to the Simulation “pull-down”
menu and modifying the stop time (default = 10) or the integration solver method (default
= ode45).
1
s+1
Transfer Fcn
simout
To Workspace2
simout
To Workspace1
simout
To Workspace
Step
Clock
a. Placement of function blocks
t
time
step
input
y
measured output
u
manipulated input
-1.117s+3.1472
s +4.6429s+5.38212
Transfer Fcn
Clock
b. Renaming and connection of blocks
Figure M2.5 Development of an Open-loop Simulation.
The reader should generate simulations and observe the “inverse response” behavior of the
output with respect to a step input change. Use the subplot command to place the process
output (y) on the top plot, and the manipulated input (u) on the bottom plot. Perform this now. If
desired, change the default simulation stop time by selecting the parameters “pull down” menu.
M2.3 Feedback Control Simulation
The Math icon from Figure M2.2 can be selected, resulting in the functions shown in Figure
M2.6. Additional icons can be found by selecting the Simulink Extras icon in Figure M2.1.
Selecting the Additional Linear icon from this group yields the set of icons in Figure M2.7.
The most useful icon here is the PID Controller. Any icon can be “dragged” into the untitled
model workspace. In Figure M2.8 we show the preliminary stage of the construction of a control
block diagram, where icons have been dragged from their respective libraries into the untitled
model workspace.
7
Figure M2.6 SIMULINK Math.
SIMULINK Tutorial8
Figure M2.7 SIMULINK Additional Linear.
The labels (names below each icon) can easily be changed. The default parameters for each icon
are changed by double clicking the icon and entering new parameter values. Also, connections
can be made between the outputs of one icon and inputs of another. Figure M2.8b shows how the
icons from Figure M2.8a have been changed and linked together to form a feedback control
block diagram.
It should be noted that the form of the PID control law used by the SIMULINK PID Controller
icon is not the typical form that we use as process control engineers. The form can be found by
double-clicking the icon to reveal the following controller transfer function representation
gc s( )= P+
I
s
+ Ds
while we normally deal with the following PID structure
9
gc s( )= kc 1+
1
Is
+ Ds


 


so the following values must be entered in the SIMULINK PID Controller
P = kc I = kc I D = kc D
1
s+1
Transfer Fcn
simout
To Workspace3
simout
To Workspace2
simout
To Workspace1
simout
To Workspace
SumStep
Clock
a. Preliminary Block Diagram
t
time
step
setpoint
r
setpoint
y
output
u
manipulated
Sum
-1.117s+3.1472
s +4.6429s+5.38212
Process
PID
PID Controller
Clock
b. Completed Block Diagram, with Name and Parameter Changes
Figure M2.8. Block Diagram for Feedback Control of the Van de Vusse CSTR
The s-polynomials in the process transfer function were entered by double-clicking on the
transfer function and entering the coefficients for the numerator and denominator polynomials.
Notice also that the default step (used for the step setpoint change) is to step from a value of 0 to
SIMULINK Tutorial10
a value of 1 at t = 1. These default values can be changed by double-clicking the step icon. The
simulation parameters can be changed by going to the Simulation “pull-down” menu and
modifying the stop time (default = 10) or the integration solver method (default = ode45).
The controller tuning parameters of kc = 1.89 and τI = 1.23 are used by entering P = 1.89 and I =
1.89/1.23 in the default PID Controller block. The following plot commands were used to
generate Figure M2.9.
» subplot(2,1,1),plot(t,r,'--',t,y)
» xlabel('t (min)')
» ylabel('y (mol/l)')
» subplot(2,1,2),plot(t,u)
» xlabel('t (min)')
» ylabel('u (min^-1)')
Figure M2.9. Measured Output and Manipuated Input Responses to a Unit Step Setpoint
Change.
11
This brief tutorial has gotten you started in the world of SIMULINK-based control block
diagram simulation. You may now easily compare the effect of different tuning parameters, or
different formulations of a PID controller (“ideal” vs. “real”, for example).
Let’s say you generated responses for a set of tuning parameters that we call case 1 for
convenience. You could generate time, input and output vectors for this case by setting:
» t1 = t;
» y1 = y;
» u1 = u;
after running the case 1 values. You could then enter case 2 values, run another simulation, and
create new vectors
» t2 = t;
» y2 = y;
» u2 = u;
then, compare the case 1 and case 2 results by:
» subplot(2,1,1),plot(t1,y1,t2,y2,'--')
» xlabel('t (min)')
» ylabel('y (mol/l)')
» subplot(2,1,2),plot(t1,u1,t2,u2,'--')
» xlabel('t (min)')
» ylabel('u (min^-1)')
which automatically plots case 1 as a solid line and case 2 as a dashed line.
Similarly, you could modify the controller type by placing a transfer function block for the
controller and using a “real PID” transfer function (this only differs when there is derivative
action).
Other Commonly Used Icons
Often you will want to simulate the behavior of systems that have time delays. The Transport
Delay icon can be selected from the Continuous library shown in Figure M2.2. The transport
delay icon is shown in Figure M2.10. Our experience is that simulations can become somewhat
“flaky” if 0 is entered for a transport delay. We recommend that you remove the transport delay
block for simulations where no time-delay is involved.
Transport
Delay
SIMULINK Tutorial12
Figure M2.10. Transport Delay Icon
Manipulated variables are often constrained to between minimum (0 flow, for example) and
maximum (fully open valve) values. A saturation icon from the Nonlinear library can be used
to simulate this behavior. The saturation icon is shown in Figure M2.11.
Saturation
Figure M2.11. Saturation Element
Actuators (valves) and sensors (measurement devices) often have additional dynamic lags that
can be simulated by transfer functions. These can be placed on the block diagram in the same
fashion that a transfer function was used to represent the process earlier.
It should be noted that icons can be “flipped” or “rotated” by selecting the icon and going to the
format “pull-down” menu and selecting Flip Block or Rotate Block. The block diagram of
Figure M2.8 has been extended to include the saturation element and transport delay, as shown
in Figure M2.12.
t
time
step
setpoint
r
setpoint
y
output
u
manipulated
Transport
Delay
Sum Saturation
-1.117s+3.1472
s +4.6429s+5.38212
Process
PID
PID Controller
Clock
Figure M2.12. Block Diagram with Saturation and Time-Delay Elements
The default data method for the “to workspace” blocks (r,t,u,y in Figure M2.12) must be
changed from “structure” to “matrix” in order to save data in an appropriate form for plotting.
13
M2.4 Developing Alternative Controller Icons
It was noted earlier that the default SIMULINK PID controller block uses a different form than
that used by most process engineers. It is easy to generate new PID controller blocks as shown
below. The default PID controller icon is shown in Figure M2.13a. This is “unmasked” to yield
the diagram shown in Figure M2.13b. Again, this has the form
gc s( )= P+
I
s
+ Ds
while we normally prefer the following PID structure
gc s( )= kc 1+
1
Is
+ Ds


 


Of course, the two algorithms are related by
P = kc I = kc I D = kc D
but it would be much less confusing to work with our standard form.
PID
PID Controller
a. Block
1
Out_1
Sum
P
Proportional
I
s
Integral
du/dt
Derivative
D
D
1
In_1
b. Unmasked
Figure M2.13 Default Ideal PID Controller
We have generated a new ideal analog PID, as shown in Figure M2.14a. Notice that there are
two inputs to the controller, the setpoint and the measured output, rather than just the error signal
SIMULINK Tutorial14
that is the input to the default SIMULINK PID controller. Our new implementation is unmasked
in Figure M2.14b to reveal that
gc s( )= kc 1+
1
Is
+ Ds


 


is the algorithm used.
r
y
uPID
Ideal analog PID
a. Block
1
u
taud
taud
kc
kcSum1
Sum
1
s
Integral
du/dt
Derivative
1/taui
1/taui
2
y
1
r
b. Unmasked Block
Figure M2.14 Preferred Implementation of Ideal PID Controller
Summary
SIMULINK is a very powerful block diagram simulation language. Simple simulations,
including the majority of those used as examples in this textbook, can be set-up rapidly (in a
matter of minutes). The goal of this module was to provide enough of an introduction to get you
started on the development of open- and closed-loop simulations. With experience, the
development of these simulations will become second-nature. It is recommended that you
perform the simulations shown in this module, as well as the practice exercises, to rapidly
acquire these simulation skills.
Practice Exercises
1. Compare step responses of the transfer function and state space models for the Van de Vusse
Reactor.
15
a. Transfer function: Perform the open-loop simulation for a step input change from 0 to 1 at t =
1 in Figure M2.5.
b. State space: Replace the transfer function block of Figure M2.5 with a state space block. Enter
the following matrices in the MATLAB command window.
A =
−2.4048 0
0.83333 −2.2381





 B =
7 0.5714
−1.117 0






C = 0 1[ ] D = 0 0[ ]
Show that the resulting step responses of the transfer function and state space models are
identical.
2. Consider the closed-loop SIMULINK diagram for the Van de Vusse reactor (Figure M2.8).
Replace the default PID controller with a “Real PID” controller, as shown below in both the
masked and unmasked versions. How do your results compare with ones obtained using the
default PID controller?
r
y
uReal PID
Real analog PID
1
u
kc
kc
taud.s+1
alpha*taud.s+1
derivative
Sum
taui.s+1
taui.s
Integral2
y
1
r

More Related Content

What's hot

Control system Lab record
Control system Lab record Control system Lab record
Control system Lab record Yuvraj Singh
 
Lecture 8-9 block-diagram_representation_of_control_systems
Lecture 8-9 block-diagram_representation_of_control_systemsLecture 8-9 block-diagram_representation_of_control_systems
Lecture 8-9 block-diagram_representation_of_control_systemsSaifullah Memon
 
EMA3100A Target Motion Simulator User Guide - Chap5-Target Tracking Projects
EMA3100A Target Motion Simulator User Guide - Chap5-Target Tracking ProjectsEMA3100A Target Motion Simulator User Guide - Chap5-Target Tracking Projects
EMA3100A Target Motion Simulator User Guide - Chap5-Target Tracking ProjectsEngin Gul
 
Intro to Matlab programming
Intro to Matlab programmingIntro to Matlab programming
Intro to Matlab programmingAhmed Moawad
 
Implementasi Pemodelan Sistem Ke TeeChart
Implementasi Pemodelan Sistem Ke TeeChartImplementasi Pemodelan Sistem Ke TeeChart
Implementasi Pemodelan Sistem Ke TeeChartLusiana Diyan
 
Simulation and Comparison of P, PI, PID Controllers on MATLAB/ Simulink
Simulation and Comparison of P, PI, PID Controllers on MATLAB/ SimulinkSimulation and Comparison of P, PI, PID Controllers on MATLAB/ Simulink
Simulation and Comparison of P, PI, PID Controllers on MATLAB/ SimulinkHarshKumar649
 
Implementasi Pemodelan Sistem Ke TeeChart 2
Implementasi Pemodelan Sistem Ke TeeChart  2Implementasi Pemodelan Sistem Ke TeeChart  2
Implementasi Pemodelan Sistem Ke TeeChart 2Lusiana Diyan
 
Modelling with uml
Modelling with umlModelling with uml
Modelling with umlNaga Muruga
 
The_Mismatch_Noise_Cancellation_Architecture
The_Mismatch_Noise_Cancellation_ArchitectureThe_Mismatch_Noise_Cancellation_Architecture
The_Mismatch_Noise_Cancellation_ArchitectureShereef Shehata
 
Faster Interleaved Modular Multiplier Based on Sign Detection
Faster Interleaved Modular Multiplier Based on Sign DetectionFaster Interleaved Modular Multiplier Based on Sign Detection
Faster Interleaved Modular Multiplier Based on Sign DetectionVLSICS Design
 
Basics of MATLAB programming
Basics of MATLAB programmingBasics of MATLAB programming
Basics of MATLAB programmingRanjan Pal
 
Matlab simulink simulink modeling tutorial - train system
Matlab  simulink   simulink modeling tutorial - train systemMatlab  simulink   simulink modeling tutorial - train system
Matlab simulink simulink modeling tutorial - train systemuramesh25
 
A simplified method of designing a phase lead compensator to improve the m-s-...
A simplified method of designing a phase lead compensator to improve the m-s-...A simplified method of designing a phase lead compensator to improve the m-s-...
A simplified method of designing a phase lead compensator to improve the m-s-...eSAT Publishing House
 

What's hot (20)

Mmc manual
Mmc manualMmc manual
Mmc manual
 
Control system Lab record
Control system Lab record Control system Lab record
Control system Lab record
 
Matlab booklet
Matlab bookletMatlab booklet
Matlab booklet
 
Lecture 8-9 block-diagram_representation_of_control_systems
Lecture 8-9 block-diagram_representation_of_control_systemsLecture 8-9 block-diagram_representation_of_control_systems
Lecture 8-9 block-diagram_representation_of_control_systems
 
Control chap3
Control chap3Control chap3
Control chap3
 
EMA3100A Target Motion Simulator User Guide - Chap5-Target Tracking Projects
EMA3100A Target Motion Simulator User Guide - Chap5-Target Tracking ProjectsEMA3100A Target Motion Simulator User Guide - Chap5-Target Tracking Projects
EMA3100A Target Motion Simulator User Guide - Chap5-Target Tracking Projects
 
Intro to Matlab programming
Intro to Matlab programmingIntro to Matlab programming
Intro to Matlab programming
 
An Introduction to MATLAB with Worked Examples
An Introduction to MATLAB with Worked ExamplesAn Introduction to MATLAB with Worked Examples
An Introduction to MATLAB with Worked Examples
 
Implementasi Pemodelan Sistem Ke TeeChart
Implementasi Pemodelan Sistem Ke TeeChartImplementasi Pemodelan Sistem Ke TeeChart
Implementasi Pemodelan Sistem Ke TeeChart
 
Simulation and Comparison of P, PI, PID Controllers on MATLAB/ Simulink
Simulation and Comparison of P, PI, PID Controllers on MATLAB/ SimulinkSimulation and Comparison of P, PI, PID Controllers on MATLAB/ Simulink
Simulation and Comparison of P, PI, PID Controllers on MATLAB/ Simulink
 
Implementasi Pemodelan Sistem Ke TeeChart 2
Implementasi Pemodelan Sistem Ke TeeChart  2Implementasi Pemodelan Sistem Ke TeeChart  2
Implementasi Pemodelan Sistem Ke TeeChart 2
 
Fx570 ms 991ms_e
Fx570 ms 991ms_eFx570 ms 991ms_e
Fx570 ms 991ms_e
 
Modelling with uml
Modelling with umlModelling with uml
Modelling with uml
 
The_Mismatch_Noise_Cancellation_Architecture
The_Mismatch_Noise_Cancellation_ArchitectureThe_Mismatch_Noise_Cancellation_Architecture
The_Mismatch_Noise_Cancellation_Architecture
 
Faster Interleaved Modular Multiplier Based on Sign Detection
Faster Interleaved Modular Multiplier Based on Sign DetectionFaster Interleaved Modular Multiplier Based on Sign Detection
Faster Interleaved Modular Multiplier Based on Sign Detection
 
Basics of MATLAB programming
Basics of MATLAB programmingBasics of MATLAB programming
Basics of MATLAB programming
 
Matlab simulink simulink modeling tutorial - train system
Matlab  simulink   simulink modeling tutorial - train systemMatlab  simulink   simulink modeling tutorial - train system
Matlab simulink simulink modeling tutorial - train system
 
OpenVX 1.0 Reference Guide
OpenVX 1.0 Reference GuideOpenVX 1.0 Reference Guide
OpenVX 1.0 Reference Guide
 
Intro to matlab
Intro to matlabIntro to matlab
Intro to matlab
 
A simplified method of designing a phase lead compensator to improve the m-s-...
A simplified method of designing a phase lead compensator to improve the m-s-...A simplified method of designing a phase lead compensator to improve the m-s-...
A simplified method of designing a phase lead compensator to improve the m-s-...
 

Similar to Simulink

PID Tuning using Ziegler Nicholas - MATLAB Approach
PID Tuning using Ziegler Nicholas - MATLAB ApproachPID Tuning using Ziegler Nicholas - MATLAB Approach
PID Tuning using Ziegler Nicholas - MATLAB ApproachWaleed El-Badry
 
Introduction to MATLAB 7 - WIlliam PALM III.ppt
Introduction to MATLAB 7 - WIlliam PALM III.pptIntroduction to MATLAB 7 - WIlliam PALM III.ppt
Introduction to MATLAB 7 - WIlliam PALM III.pptHassenMOuakkad
 
Simulink Presentation.ppt
Simulink Presentation.pptSimulink Presentation.ppt
Simulink Presentation.ppthodeeeeee1
 
Modeling and Simulation of an Active Disturbance Rejection Controller Based o...
Modeling and Simulation of an Active Disturbance Rejection Controller Based o...Modeling and Simulation of an Active Disturbance Rejection Controller Based o...
Modeling and Simulation of an Active Disturbance Rejection Controller Based o...IJRES Journal
 
Real-time PID control of an inverted pendulum
Real-time PID control of an inverted pendulumReal-time PID control of an inverted pendulum
Real-time PID control of an inverted pendulumFrancesco Corucci
 
Addison Wesley - Modern Control Systems Analysis and Design Using Matlab, Bis...
Addison Wesley - Modern Control Systems Analysis and Design Using Matlab, Bis...Addison Wesley - Modern Control Systems Analysis and Design Using Matlab, Bis...
Addison Wesley - Modern Control Systems Analysis and Design Using Matlab, Bis...Gollapalli Sreenivasulu
 
Optimal and pid controller for controlling camera’s position in unmanned aeri...
Optimal and pid controller for controlling camera’s position in unmanned aeri...Optimal and pid controller for controlling camera’s position in unmanned aeri...
Optimal and pid controller for controlling camera’s position in unmanned aeri...Zac Darcy
 
Raymond.Brunkow-Project-EEL-3657-Sp15
Raymond.Brunkow-Project-EEL-3657-Sp15Raymond.Brunkow-Project-EEL-3657-Sp15
Raymond.Brunkow-Project-EEL-3657-Sp15Raymond Brunkow
 
Optimal and Pid Controller for Controlling Camera's Position InUnmanned Aeria...
Optimal and Pid Controller for Controlling Camera's Position InUnmanned Aeria...Optimal and Pid Controller for Controlling Camera's Position InUnmanned Aeria...
Optimal and Pid Controller for Controlling Camera's Position InUnmanned Aeria...Zac Darcy
 
Foundations and methods of stochastic simulation
Foundations and methods of stochastic simulationFoundations and methods of stochastic simulation
Foundations and methods of stochastic simulationSpringer
 
cscript_controller.pdf
cscript_controller.pdfcscript_controller.pdf
cscript_controller.pdfVcTrn1
 
Ece 415 control systems, fall 2021 computer project 1
Ece 415 control systems, fall 2021 computer project  1 Ece 415 control systems, fall 2021 computer project  1
Ece 415 control systems, fall 2021 computer project 1 ronak56
 

Similar to Simulink (20)

CE150--Hongyi Huang
CE150--Hongyi HuangCE150--Hongyi Huang
CE150--Hongyi Huang
 
PID Tuning using Ziegler Nicholas - MATLAB Approach
PID Tuning using Ziegler Nicholas - MATLAB ApproachPID Tuning using Ziegler Nicholas - MATLAB Approach
PID Tuning using Ziegler Nicholas - MATLAB Approach
 
Introduction to MATLAB 7 - WIlliam PALM III.ppt
Introduction to MATLAB 7 - WIlliam PALM III.pptIntroduction to MATLAB 7 - WIlliam PALM III.ppt
Introduction to MATLAB 7 - WIlliam PALM III.ppt
 
Using matlab simulink
Using matlab simulinkUsing matlab simulink
Using matlab simulink
 
ADVANCED WORKSHOP IN MATLAB
ADVANCED WORKSHOP IN MATLABADVANCED WORKSHOP IN MATLAB
ADVANCED WORKSHOP IN MATLAB
 
Simulink Presentation.ppt
Simulink Presentation.pptSimulink Presentation.ppt
Simulink Presentation.ppt
 
Bode
BodeBode
Bode
 
Modeling and Simulation of an Active Disturbance Rejection Controller Based o...
Modeling and Simulation of an Active Disturbance Rejection Controller Based o...Modeling and Simulation of an Active Disturbance Rejection Controller Based o...
Modeling and Simulation of an Active Disturbance Rejection Controller Based o...
 
Real-time PID control of an inverted pendulum
Real-time PID control of an inverted pendulumReal-time PID control of an inverted pendulum
Real-time PID control of an inverted pendulum
 
Addison Wesley - Modern Control Systems Analysis and Design Using Matlab, Bis...
Addison Wesley - Modern Control Systems Analysis and Design Using Matlab, Bis...Addison Wesley - Modern Control Systems Analysis and Design Using Matlab, Bis...
Addison Wesley - Modern Control Systems Analysis and Design Using Matlab, Bis...
 
Optimal and pid controller for controlling camera’s position in unmanned aeri...
Optimal and pid controller for controlling camera’s position in unmanned aeri...Optimal and pid controller for controlling camera’s position in unmanned aeri...
Optimal and pid controller for controlling camera’s position in unmanned aeri...
 
Raymond.Brunkow-Project-EEL-3657-Sp15
Raymond.Brunkow-Project-EEL-3657-Sp15Raymond.Brunkow-Project-EEL-3657-Sp15
Raymond.Brunkow-Project-EEL-3657-Sp15
 
Optimal and Pid Controller for Controlling Camera's Position InUnmanned Aeria...
Optimal and Pid Controller for Controlling Camera's Position InUnmanned Aeria...Optimal and Pid Controller for Controlling Camera's Position InUnmanned Aeria...
Optimal and Pid Controller for Controlling Camera's Position InUnmanned Aeria...
 
Foundations and methods of stochastic simulation
Foundations and methods of stochastic simulationFoundations and methods of stochastic simulation
Foundations and methods of stochastic simulation
 
Simulink
SimulinkSimulink
Simulink
 
Pengenalan Simulink
Pengenalan SimulinkPengenalan Simulink
Pengenalan Simulink
 
cscript_controller.pdf
cscript_controller.pdfcscript_controller.pdf
cscript_controller.pdf
 
E0463137
E0463137E0463137
E0463137
 
493 297
493 297493 297
493 297
 
Ece 415 control systems, fall 2021 computer project 1
Ece 415 control systems, fall 2021 computer project  1 Ece 415 control systems, fall 2021 computer project  1
Ece 415 control systems, fall 2021 computer project 1
 

More from Al Mtdrs

Usulan lengkappenelitian drs al m.t
Usulan lengkappenelitian drs  al m.tUsulan lengkappenelitian drs  al m.t
Usulan lengkappenelitian drs al m.tAl Mtdrs
 
Hexacopter k ucopter
Hexacopter k ucopterHexacopter k ucopter
Hexacopter k ucopterAl Mtdrs
 
Fulltext02
Fulltext02Fulltext02
Fulltext02Al Mtdrs
 
Febrian p aoke
Febrian p aokeFebrian p aoke
Febrian p aokeAl Mtdrs
 
Format laporan tugas besar elda
Format laporan tugas besar eldaFormat laporan tugas besar elda
Format laporan tugas besar eldaAl Mtdrs
 
Smpsproject
SmpsprojectSmpsproject
SmpsprojectAl Mtdrs
 
Tugas besar kiki_febrian_2018310040[1](1) (2)
Tugas besar kiki_febrian_2018310040[1](1) (2)Tugas besar kiki_febrian_2018310040[1](1) (2)
Tugas besar kiki_febrian_2018310040[1](1) (2)Al Mtdrs
 
Potongan b b
Potongan b bPotongan b b
Potongan b bAl Mtdrs
 

More from Al Mtdrs (11)

[000011]
[000011][000011]
[000011]
 
[000008]
[000008][000008]
[000008]
 
[000007]
[000007][000007]
[000007]
 
Usulan lengkappenelitian drs al m.t
Usulan lengkappenelitian drs  al m.tUsulan lengkappenelitian drs  al m.t
Usulan lengkappenelitian drs al m.t
 
Hexacopter k ucopter
Hexacopter k ucopterHexacopter k ucopter
Hexacopter k ucopter
 
Fulltext02
Fulltext02Fulltext02
Fulltext02
 
Febrian p aoke
Febrian p aokeFebrian p aoke
Febrian p aoke
 
Format laporan tugas besar elda
Format laporan tugas besar eldaFormat laporan tugas besar elda
Format laporan tugas besar elda
 
Smpsproject
SmpsprojectSmpsproject
Smpsproject
 
Tugas besar kiki_febrian_2018310040[1](1) (2)
Tugas besar kiki_febrian_2018310040[1](1) (2)Tugas besar kiki_febrian_2018310040[1](1) (2)
Tugas besar kiki_febrian_2018310040[1](1) (2)
 
Potongan b b
Potongan b bPotongan b b
Potongan b b
 

Recently uploaded

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 

Recently uploaded (20)

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 

Simulink

  • 1. © 4 July 2001 – B.W. Bequette Module 2 Introduction to SIMULINK Although the standard MATLAB package is useful for linear systems analysis, SIMULINK is far more useful for control system simulation. SIMULINK enables the rapid construction and simulation of control block diagrams. The goal of the tutorial is to introduce the use of SIMULINK for control system simulation. The version available at the time of writing of this textbook is SIMULINK 4, part of Release 12 (including MATLAB 6) from MATHWORKS. The version that you are using can be obtained by entering ver in the MATLAB Command Window. The easiest way to learn how to use SIMULINK is to implement each step of the tutorial, rather than simply reading it. The basic steps to using SIMULINK are independent of the platform (PC, MAC, UNIX, LINUX…). M2.1 Background M2.2 Open-loop Simulations M2.3 Closed-loop Simulations M2.4 Developing Alternative Controller Icons
  • 2. SIMULINK Tutorial2 M2.1 Background The first step is to startup MATLAB on the machine you are using. In the Launch Pad window of the MATLAB desktop, select SIMULINK and then the SIMULINK Library Browser. A number of options are listed, as shown in Figure M2.1. Notice that Continuous has been highlighted; this will provide a list of continuous function blocks available. Selecting Continuous will provide the list of blocks shown in Figure M2.2. The ones that we often use are Transfer Fcn and State- Space. Figure M2.1 SIMULINK Library Browser.
  • 3. 3 Figure M2.2 SIMULINK Continuous Blocks. Selecting the Sources icon yields the library shown in Figure M2.3. The most commonly used sources are Clock (which is used to generate a time vector), and Step (which generates a step input).
  • 4. SIMULINK Tutorial4 Figure M2.3 SIMULINK Sources. The Sinks icon from Figure M2.1 can be selected to reveal the set of sinks icons shown in Figure M2.4. The one that we use most often is the To Workspace icon. A variable passed to this
  • 5. 5 icon is written to a vector in the MATLAB workspace. The default data method shoulb be changed from “structure” to “matrix” in order to save data in an appropriate form for plotting. Figure M2.4 SIMULINK Sinks. M2.2 Open-Loop Simulation You now have enough information to generate an open-loop simulation. The Clock, simout, step and Transfer function blocks can be dragged to a model (.mdl) workspace, as shown in Figure M2.5a. Renaming the blocks and variables, and connecting the blocks, results in the model shown in Figure M2.5b. The transfer function studied is the Van de Vusse reactor (Module 5). The s-polynomials in the process transfer function were entered by double-clicking on the transfer function icon and entering the coefficients for the numerator and denominator
  • 6. SIMULINK Tutorial6 polynomials. Notice also that the default step (used for the step input change) is to step from a value of 0 to a value of 1 at t = 1. These default values can be changed by double-clicking the step icon. The simulation parameters can be changed by going to the Simulation “pull-down” menu and modifying the stop time (default = 10) or the integration solver method (default = ode45). 1 s+1 Transfer Fcn simout To Workspace2 simout To Workspace1 simout To Workspace Step Clock a. Placement of function blocks t time step input y measured output u manipulated input -1.117s+3.1472 s +4.6429s+5.38212 Transfer Fcn Clock b. Renaming and connection of blocks Figure M2.5 Development of an Open-loop Simulation. The reader should generate simulations and observe the “inverse response” behavior of the output with respect to a step input change. Use the subplot command to place the process output (y) on the top plot, and the manipulated input (u) on the bottom plot. Perform this now. If desired, change the default simulation stop time by selecting the parameters “pull down” menu. M2.3 Feedback Control Simulation The Math icon from Figure M2.2 can be selected, resulting in the functions shown in Figure M2.6. Additional icons can be found by selecting the Simulink Extras icon in Figure M2.1. Selecting the Additional Linear icon from this group yields the set of icons in Figure M2.7. The most useful icon here is the PID Controller. Any icon can be “dragged” into the untitled model workspace. In Figure M2.8 we show the preliminary stage of the construction of a control block diagram, where icons have been dragged from their respective libraries into the untitled model workspace.
  • 8. SIMULINK Tutorial8 Figure M2.7 SIMULINK Additional Linear. The labels (names below each icon) can easily be changed. The default parameters for each icon are changed by double clicking the icon and entering new parameter values. Also, connections can be made between the outputs of one icon and inputs of another. Figure M2.8b shows how the icons from Figure M2.8a have been changed and linked together to form a feedback control block diagram. It should be noted that the form of the PID control law used by the SIMULINK PID Controller icon is not the typical form that we use as process control engineers. The form can be found by double-clicking the icon to reveal the following controller transfer function representation gc s( )= P+ I s + Ds while we normally deal with the following PID structure
  • 9. 9 gc s( )= kc 1+ 1 Is + Ds       so the following values must be entered in the SIMULINK PID Controller P = kc I = kc I D = kc D 1 s+1 Transfer Fcn simout To Workspace3 simout To Workspace2 simout To Workspace1 simout To Workspace SumStep Clock a. Preliminary Block Diagram t time step setpoint r setpoint y output u manipulated Sum -1.117s+3.1472 s +4.6429s+5.38212 Process PID PID Controller Clock b. Completed Block Diagram, with Name and Parameter Changes Figure M2.8. Block Diagram for Feedback Control of the Van de Vusse CSTR The s-polynomials in the process transfer function were entered by double-clicking on the transfer function and entering the coefficients for the numerator and denominator polynomials. Notice also that the default step (used for the step setpoint change) is to step from a value of 0 to
  • 10. SIMULINK Tutorial10 a value of 1 at t = 1. These default values can be changed by double-clicking the step icon. The simulation parameters can be changed by going to the Simulation “pull-down” menu and modifying the stop time (default = 10) or the integration solver method (default = ode45). The controller tuning parameters of kc = 1.89 and τI = 1.23 are used by entering P = 1.89 and I = 1.89/1.23 in the default PID Controller block. The following plot commands were used to generate Figure M2.9. » subplot(2,1,1),plot(t,r,'--',t,y) » xlabel('t (min)') » ylabel('y (mol/l)') » subplot(2,1,2),plot(t,u) » xlabel('t (min)') » ylabel('u (min^-1)') Figure M2.9. Measured Output and Manipuated Input Responses to a Unit Step Setpoint Change.
  • 11. 11 This brief tutorial has gotten you started in the world of SIMULINK-based control block diagram simulation. You may now easily compare the effect of different tuning parameters, or different formulations of a PID controller (“ideal” vs. “real”, for example). Let’s say you generated responses for a set of tuning parameters that we call case 1 for convenience. You could generate time, input and output vectors for this case by setting: » t1 = t; » y1 = y; » u1 = u; after running the case 1 values. You could then enter case 2 values, run another simulation, and create new vectors » t2 = t; » y2 = y; » u2 = u; then, compare the case 1 and case 2 results by: » subplot(2,1,1),plot(t1,y1,t2,y2,'--') » xlabel('t (min)') » ylabel('y (mol/l)') » subplot(2,1,2),plot(t1,u1,t2,u2,'--') » xlabel('t (min)') » ylabel('u (min^-1)') which automatically plots case 1 as a solid line and case 2 as a dashed line. Similarly, you could modify the controller type by placing a transfer function block for the controller and using a “real PID” transfer function (this only differs when there is derivative action). Other Commonly Used Icons Often you will want to simulate the behavior of systems that have time delays. The Transport Delay icon can be selected from the Continuous library shown in Figure M2.2. The transport delay icon is shown in Figure M2.10. Our experience is that simulations can become somewhat “flaky” if 0 is entered for a transport delay. We recommend that you remove the transport delay block for simulations where no time-delay is involved. Transport Delay
  • 12. SIMULINK Tutorial12 Figure M2.10. Transport Delay Icon Manipulated variables are often constrained to between minimum (0 flow, for example) and maximum (fully open valve) values. A saturation icon from the Nonlinear library can be used to simulate this behavior. The saturation icon is shown in Figure M2.11. Saturation Figure M2.11. Saturation Element Actuators (valves) and sensors (measurement devices) often have additional dynamic lags that can be simulated by transfer functions. These can be placed on the block diagram in the same fashion that a transfer function was used to represent the process earlier. It should be noted that icons can be “flipped” or “rotated” by selecting the icon and going to the format “pull-down” menu and selecting Flip Block or Rotate Block. The block diagram of Figure M2.8 has been extended to include the saturation element and transport delay, as shown in Figure M2.12. t time step setpoint r setpoint y output u manipulated Transport Delay Sum Saturation -1.117s+3.1472 s +4.6429s+5.38212 Process PID PID Controller Clock Figure M2.12. Block Diagram with Saturation and Time-Delay Elements The default data method for the “to workspace” blocks (r,t,u,y in Figure M2.12) must be changed from “structure” to “matrix” in order to save data in an appropriate form for plotting.
  • 13. 13 M2.4 Developing Alternative Controller Icons It was noted earlier that the default SIMULINK PID controller block uses a different form than that used by most process engineers. It is easy to generate new PID controller blocks as shown below. The default PID controller icon is shown in Figure M2.13a. This is “unmasked” to yield the diagram shown in Figure M2.13b. Again, this has the form gc s( )= P+ I s + Ds while we normally prefer the following PID structure gc s( )= kc 1+ 1 Is + Ds       Of course, the two algorithms are related by P = kc I = kc I D = kc D but it would be much less confusing to work with our standard form. PID PID Controller a. Block 1 Out_1 Sum P Proportional I s Integral du/dt Derivative D D 1 In_1 b. Unmasked Figure M2.13 Default Ideal PID Controller We have generated a new ideal analog PID, as shown in Figure M2.14a. Notice that there are two inputs to the controller, the setpoint and the measured output, rather than just the error signal
  • 14. SIMULINK Tutorial14 that is the input to the default SIMULINK PID controller. Our new implementation is unmasked in Figure M2.14b to reveal that gc s( )= kc 1+ 1 Is + Ds       is the algorithm used. r y uPID Ideal analog PID a. Block 1 u taud taud kc kcSum1 Sum 1 s Integral du/dt Derivative 1/taui 1/taui 2 y 1 r b. Unmasked Block Figure M2.14 Preferred Implementation of Ideal PID Controller Summary SIMULINK is a very powerful block diagram simulation language. Simple simulations, including the majority of those used as examples in this textbook, can be set-up rapidly (in a matter of minutes). The goal of this module was to provide enough of an introduction to get you started on the development of open- and closed-loop simulations. With experience, the development of these simulations will become second-nature. It is recommended that you perform the simulations shown in this module, as well as the practice exercises, to rapidly acquire these simulation skills. Practice Exercises 1. Compare step responses of the transfer function and state space models for the Van de Vusse Reactor.
  • 15. 15 a. Transfer function: Perform the open-loop simulation for a step input change from 0 to 1 at t = 1 in Figure M2.5. b. State space: Replace the transfer function block of Figure M2.5 with a state space block. Enter the following matrices in the MATLAB command window. A = −2.4048 0 0.83333 −2.2381       B = 7 0.5714 −1.117 0       C = 0 1[ ] D = 0 0[ ] Show that the resulting step responses of the transfer function and state space models are identical. 2. Consider the closed-loop SIMULINK diagram for the Van de Vusse reactor (Figure M2.8). Replace the default PID controller with a “Real PID” controller, as shown below in both the masked and unmasked versions. How do your results compare with ones obtained using the default PID controller? r y uReal PID Real analog PID 1 u kc kc taud.s+1 alpha*taud.s+1 derivative Sum taui.s+1 taui.s Integral2 y 1 r