Control System Lab 2
Control System Lab 2
Parameters:
House Volume: V
Specific heat: cp
To Central Heating efficiency: Kch
Variables
Ti Central heating input: Qi
Outdoor temperature: To
Indoor temperature: Ti
When we enter a simulation model of a system, we must use some form of representation,
or model, for each of the systems or subsystems. These models may already have been
provided from previous analysis or information from other engineers. However, the
production of a model may require some preliminary analysis. For the house heating
system, we can form a representation using Laplace transforms.
Rate of change of heat content = heat from central heating + heat loss to environment
dQ
dt = Kch Qi + Qe
Q = cp V Ti
Qe = Ke (To-Ti)
22
where Ke is the parameter which represents the energy loss per oC difference in outdoor
and indoor temperature. (This equation shows that if the outdoor temperature is greater
than the indoor temperature, then there is a net heat gain (Qe is positive). Similarly, if To
< Ti, there is a net heat loss , Qe <0. )
dTi
cpV dt = Kch Qi + Ke (To – Ti)
K 1
Ti(s) = Q (s) + T (s)
(τs + 1) i (τs + 1) o
The equation shows how the outdoor temperature is affected by both the heat input due to
the central heating system and the outdoor temperature. This can be shown as a block
diagram:
outdoor
temperature, To
indoor
temperature, Ti
House Model
Heat input, Qi
23
Simulink model of house heating control system
The house model and the control for the heating system can be modelled in Simulink as
follows:
DISTURBANCE
Outdoor Temp
DISPLAY OUTPUT
Set Point
Outdoor Temp
20
Mux
Indoor Temp
This Simulink model of the thermodynamic behaviour of a house can be divided into four
subsystems:
The house is heated by a central heating system or a heater whose output energy is
represented by Qi. As we have seen from our simple house model analysis, we can model
the effect of the heat source on the indoor temperature of the house as a first order system
with system gain of K and a time constant of τ minutes.
24
(ii) The Effect of the Outdoor Temperature on the Indoor Temperature
We model the indoor temperature of the house as the summation of the outdoor effect
(outdoor temperature) and the heat supplied by the heat source. From the house model
analysis, the effect of the outdoor temperature on energy supplied to the building has first
order dynamics, unity system gain and a time constant of τ minutes.
Outdoor
temperature, To
1
τs + 1
Indoor temperature change due
to outdoor environment
We can now connect this block to the indoor temperature block and create a new icon to
represent the combined house model.
Outdoor
temperature, To
1
τs + 1
becomes
+
K +
Heat input, Qi, τs + 1 Indoor
due to heating Temperature Ti HOUSE
system
MODEL
25
B. The Outdoor Temperature
We assume the outdoor temperature has an average value, which is subject to some
variations.
Disturbance model
Average
Outdoor
Temperature
Outdoor
+ temperature, To
+
Outdoor
Temperature
Variation
Daily TempVariation
SIMULINK has the capability to group the sub-blocks of this model into a new block for
better visualisation of the overall structure of the complicated models.
C. The Thermostat
The control of the heating system is performed by a thermostat which produces an on/
off signal depending on the size of the incoming signal. This is represented by a relay.
Set Point
Measured
20 Qi, Heat output
Relay (On/Off)
Heating Control
Thermostat
We usually set a desired temperature (the reference temperature) on the thermostat . This
value is compared with the measured level of indoor temperature. If the indoor
temperature is too low, the error is positive and the thermostat switches on the heater.
When the error reduces below a certain threshold, the thermostat switches off the heater.
26
Note that most thermostats have a sensor to measure the temperature and a knob or dial to
set the reference. For simplicity, we have assumed that the sensor has unity gain and the
reference is as shown in the block diagram.
The overall model brings together the above component models (A,B and C) and has the
following structure:
Outdoor
Temperature, To
Average Outdoor
Temperature (10 0C)
Outdoor
Temperature + +
1
Variation τs + 1
Set point +
K
Heat τs + 1 Indoor
+ Relay
+
Input Temperature Ti
Thermostat (Qi)
These three subsystems (A, B and C) provide the model for the simulation. However we
add the fourth sub system (display output) in order that we can monitor the change in
indoor and outdoor temperatures visually on a plot.
D. Display output
When running a simulation, we usually monitor several variables, such as the indoor and
outdoor temperatures so that we can determine if the simulation model is working. To do
this we use a 'multiplexing' unit which, in this example, receives two signals and
produces a single vector, containing these signals, as the output. This output vector is
used as the input to a scope which can show graphs against time of the input signals.
27
The resulting Simulink diagram looks like:
Disturbance
Outdoor Temp
Outdoor Temp
Set Point
20
Terr Mux
Relay1 House
Mux Scope
Indoor Temp
We will return to this model at the end of this study and examine it in more detail.
The block diagram of the model is shown below. This is the model of a first order system
with a proportional controller of gain Kp.
Controller Process
Setpoint error Y(s)
R(s) + U(s)
Kp K
- τs+1
28
SIMULINK libraries
To construct a SIMULINK simulation for the closed loop system, we use the following
steps.
1. Type SIMULINK in the Matlab command window to display the SIMULINK library
browser. The SIMULINK library browser window looks like this:
3. Double click on Continuous and a number of specific SIMULINK blocks will appear.
29
4. To open a modelling window (called untitled), click on
4. Click on Transfer Fcn, hold the mouse and drag the block onto the modelling window
and release the mouse. The transfer function block will appear on the window.
Example
Each signal and block of the control system can be represented by one of the SIMULINK
blocks. There are many SIMULINK blocks that we can use, but for this example we need
only the blocks shown in the following figure. The libraries where the blocks can be
found have also been shown in the figure.
Controller Process
Setpoint, r(t) error Output, y(t)
+ K
Kp
G( s ) =
τs + 1
Constant
Block in The Scope
Sources block in Sinks
We need to copy all these blocks into the untitled window. Follow these steps to copy the
blocks.
30
1. Open the Sources library to access the Constant block. To open a block library,
double-click on the library menu. SIMULINK displays a list that contains all the
blocks in the library.
2. To copy the Constant block, click over the Constant block, then press and hold down
the mouse button.
3. Now, drag the block into the model window.
4. When the pointer is where you want the block to be in the model window, release the
mouse button. A copy of the Constant block is now in the model window. Close the
‘Sources’ Window.
5. In the same way copy the rest of the blocks in the model window. The model window
should contain these components:
1
1 1
s+1
Constant Gain Scope
Sum Transfer Fcn
Note that a block can be moved from one place in the model window to another using the
same technique that was used to copy the block.
The addition or subtraction operations for the Sum symbol can be changed by double
clicking on the icon. The default values are given as '| + +' which can be changed to '| + -'
to provide the comparator needed in the example for negative feedback. The string
provides the number and entry positions (anticlockwise) for the incoming signals on the
summation icon, with the '|' symbol indicating no entry point. For example, entering the
string '+ | - +' produces the following icon:
Sum
The summation symbol can also be changed to a rectangular shape by choosing the
appropriate option after double clicking on the summation icon.
If we examine the block icons, we can see an angle bracket on the right of the Gain block
or two on the left of the Sum block. The > symbol pointing to a block is an input port; if
the symbol points out of a block, it is an output port. A signal travels out from an output
port and to the input port of another block through a connecting line.
31
•= Position the pointer over the output port on the right side of the Constant block. Note
that the cursor shape changes to cross hairs.
•= Hold down the mouse button and move the cursor to the input port of the Sum block.
•= Release the mouse button. The blocks are connected
1 1
1
Constant s+1
Sum Gain Transfer Fcn Scope
4
1
3
2
•= Starting from the end of line No 1, draw line No 2. Use the same technique.
•= Draw line No.3.
•= Draw line No.4. The feedback loop is now connected.
Model Data
The block diagram of the simulation model is now complete. Before running the model,
we need to enter the model parameters for all blocks. Follow these steps:
32
•= Double-click on the Transfer function, change the numerator polynomial to [0.5].
This is the gain K. Change the denominator to [10 1]. This is for τs+1. Close the
window.
•= Double-click on the Scope block. Change Ymax to 10 and Ymin to 0. Close window.
Simulation
From Simulation menu choose Parameters. Change Stop time to 10. Close the window.
To run the simulation, choose Start from the Simulation menu and run the simulation.
When the simulation is completed, click on the scope. We can now examine how the
system output, y(t), tracks the set point, r(t), in the Scope block.
S3Exercises
Using the block diagram that we have just entered, we will change the controller gains
and notice the effect on the output response.
1. For the controller gains given in the table, measure the time constant and the steady
state error of the closed-loop system.
Controller gain 10 9 7 5 3 1
Time Constant
SS Error
2. Discuss the effect of changing the controller gain on the system output response.
33
3. A pacemaker to regulate the speed of a human heart has a block diagram as shown
below.
Y(s)
Pacemaker Heart Actual heart
R(s) rate
Desired heart rate + K 1
0.05s + 1 s
34
(iii) The overshoot of a second order system is related to the damping by the following
equation
æ − πζ ö
% overshoot = expç
ç
è 1− ζ
2
By changing the value of K in the SIMULINK model, find a value for which the
closed-loop response has a damping factor of 0.35.
(ii) Move the pointer to the white box and click the left mouse button.
(iii) Use backspace to clear 20.
(iv) Type in the new set point, say 18.
(v) Close the window.
(vi) Run the simulation.
35
The thermostat block represents the controller used to control the indoor temperature. To
see how the controller is implemented, double-click on the thermostat block. The heating
control is a relay. The input signal to the relay is the deviation, or error, from the
tempeature setpoint and the output signal is the output energy from the heating system
which works on an on/off switch. Hence the thermostat switches on and off the heating
system dependent on the input and the relay parameters.
b. Double-click on the Relay block and change the limits to ±5. Run the simulation and
comment on the difference with the previous response.
Outdoor Temp
36
15
Avg OutdoorTemp 1
Outdoor Temp
Daily TempVariation
2. Double-click on the Daily Temp Variation to see how the sine wave is generated.
3. Change the value of the frequency of the sine wave by a factor of two. Close the
window.
4. Run the simulation to see the effect of the changes made. Comment.
37
b. Identify the controller, the actuator, and the process. Is there a temperature transducer
in the diagram? If there is, what does it measure? Note that the thermostat effectively
contains a temperature transducer and an on-off controller.
On finishing running the simulation, we close all the models by choosing Close from the
file menu. We can also save the model by choosing Save from the file menu.
38