Вы находитесь на странице: 1из 4

CHEE 319

Introduction to the MATLAB SIMULINK Program


Using Simulink to perform open-loop simulations
MATLAB, which stands for MATrix LABoratory, is a technical computing environment for high-
performance numeric computation and visualization. SIMULINK is a part of MATLAB that can
be used to simulate dynamic systems. To facilitate model denition, SIMULINK adds a new
class of windows called block diagram windows. In these windows, models are created and edited
primarily by mouse- driven commands. Part of mastering SIMULINK is to become familiar with
manipulating model components within these windows. The purpose of this tutorial is to introduce
you to SIMULINK and give you experience simulating dynamic systems.
Launching SIMULINK
In this tutorial, you will use SIMULINK to generate an open-loop set-point and load response for
a linear process. In the second part of the tutorial, you will generate the closed-loop set-point and
load responses.
Open MATLAB. Start Simulink by typing simulink in the Matlab command prompt >>.
Once the simulink library window block opens, you will create a new Model.
To create a model, click on File in the simulink block, followed by new and then Model. A
blank page opens. You are now ready to build a Simulink model. Save the empty model
by choosing Save from the File menu in the untitled window. Name the model, examplesim.
From this point on, the model will be referred to as examplesim.
This tutorial is part 1 of two tutorials. In the rst part, you will build a model of the open-loop
system for a nonlinear process and determine the response of the system to sinusoidal, step and
ramp inputs. We make use of the Dierential Equation Editor (DEE) to perform the simulations.
1
Problem Statement
In class, we developed a dynamic model of the gravity tank. A schematic diagram of the process
is shown below.
The dynamics of the process are given by:
dh
dt
=
F
o
A

A
p
v
A
(1)
dv
dt
=
hg
L

K
f
v
2
A
p
L
(2)
where A and A
p
are the cross-sectional areas of the tank and the outlet pipe, g (=9.8 m/sec
2
) is
2
the gravitation constant, L is the length of the outlet pipe, h is the height of liquid in the tank,
v is the average velocity of the uid in the outlet pipe, K
f
is the pipe friction constant, is the
density of the uid and F
o
is the inlet owrate of uid to the tank. It is assumed that the tank
and the outlet pipe are cylindrical.
The tank has a radius R of 2 m. The inner radius of the pipe, r, is 0.125 m. The outlet pipe is 10
m in length. The density of the uid is 1000 kg/m
3
. The friction constant is 4.0.
We will now simulate the dynamic behavior of the nonlinear process using the SIMULINK dier-
ential equation editor (DEE). You can input the dierential equation as they are formulated using
the DEE.
To invoke the DEE editor, type DEE at the MATLAB command prompt. This will open the
DEE window.
Click and drag the DEE icon to your untitled SIMULINK worksheet.
Double Click on the DEE to invoke the entry window. You must enter the number of in-
puts, the dierential equations, the initial conditions and the output functions that you are
interested in.
For this case, there is 1 input, the inlet ow. To enter the system of equations, you must use
the DDE syntax. The variables that you are solving for are given as entries in the array x.
Let h=x(1) and v=x(2). The input variable, F
o
, is given as the rst entry in the array u, i.e.,
u(1). All other variables of the system must be set to their numerical values.
To solve the system, you must supply the initial conditions. Let h(0)=3 and v(0)=4.
Finally, enter the output functions that you are interested in, i.e., x(1) and x(2). Once you
close the DEE editor window you will see that the DEE block has one input F
o
and two
outputs h and v.
Copy a Step Input block from the Sources menu, place the block to the left of DEE editor
window and connect it to the input. The Step Input block generates a step function. The
step time (time at which the step occurs), initial value, and nal value of the function can be
specied.
Copy two (2) To Workspace blocks to the right of the DEE block and connect the outputs
of the DEE block to the two (s) new To Workspace blocks. Double-click on the new blocks
and set the Variable name to h and v, respectively. The model developed to this point is a
model of the open-loop system. To facilitate the analysis, you can choose to change the Save
format of the output variables by selecting the ARRAY in the save format item of the menu.
Now we are ready to simulate the open-loop response of the system. To select the integration
technique and parameters to be used during simulations, pull down the Simulation menu and
3
choose Parameters. A dialog box is opened showing all the simulation parameters that can
be modied. Set the Stop Time to 500 and the Max Step Size to 1. Because the system
is easy to integrate numerically , SIMULINK can and will take integration step sizes equal
to the default value. If this occurs, the appearance of the response will not be smooth. By
setting Max Step Size to 1, the outputs u and v will be output to the workspace each time
interval and the simulated response will be smoother. Start the simulation by selecting Start
from Simulation menu. The resulting h, v and t variables in the workspace will be for the
open-loop unit set-point response.
Once a simulation has been completed, the resulting data can be manipulated and analyzed
using MATLAB. Select the MATLAB command window and type
>> plot(t,h)
to view the response. Theplot command opens a MATLAB Figure window and generates a
plot inside the window. To add x and y axis labels and a title type xlabel(Time) ylabel(h)
title(Step Response (Open-Loop)). Repeat this for the variable v.
Perform the following steps. i) Assuming an inlet ow of 0.45 m
3
/sec, nd the steady-state values
for the height of liquid in the tank and the outlet pipe uid velocity. Report the steady-state
value and show the resulting plots of h and v. ii) Starting for this steady-state, perform a 0.25
m
3
/sec step increase and a 0.25 m
3
/sec step decrease in inlet owrate. Report the two new sets of
steady-state values. Generate a rst plot showing both step responses for the level and a second
showing the step responses for the velocity. Briey comment on the extent of nonlinearity of this
process.
4

Вам также может понравиться