Two Tank MPC
Two Tank MPC
Two Tank MPC
Faculty of Technology
TABLE OF CONTENST
Table of contenst .................................................................................................................. 3
1 Introduction ..................................................................................................................... 4
2 Program ........................................................................................................................... 7
2.1 Step 1: Creating a new database .......................................................................................................... 7
2.2 Step 2: Creating MPC- and I/O control modules in an area ............................................................ 7
2.3 Step 3: Activate I/O configuration ....................................................................................................... 9
2.4 Step 4: Connecting I/O to the MPC_LOOP ...................................................................................... 11
2.5 Step 5: Connecting I/O to the rest of the signals .............................................................................. 15
2.6 Step 6: Assigning area to alarm and events and continuous historian ........................................... 17
3 Modelling and validation .............................................................................................. 18
3.1 Step 1: Connecting the Two-Tank process ....................................................................................... 18
3.2 Step 2: Creating the MPC model ....................................................................................................... 18
3.3 Step 3: Verification of the MPC model ............................................................................................. 22
3.4 Step 4: Validation of the MPC controller ......................................................................................... 25
4 Creating the HMI .......................................................................................................... 27
4.1 Step 1: Open a new picture ................................................................................................................ 27
4.2 Step 2: Creating picture interface using dynamos ........................................................................... 28
4.3 Step 6: Creating names and datalinks ............................................................................................... 35
4.4 Step 7: Creating faceplate- and MPC operator interface buttons .................................................. 37
5 Operating the two-tank system .................................................................................... 39
3
Telemark University College
1 INTRODUCTION
In this tutorial you will learn how to:
Create a program to control the level in the lower tank 2 of a Two-Tank system with
MPC using DeltaV Database Administration, -Explorer, -Control Studio and I/O
Configuration.
Create a MPC model for a Two-Tank system and do validation using DeltaV Predict, -
MPC Operate and MPC Simulate.
Create a HMI for a Two-Tank system using DeltaV Operate Configure.
Control and tune the level performance of a Two-Tank system using the MPC controller
in DeltaV Operate Run.
4
Telemark University College
Qp [cm^3/s]
LT1
Overlp
Overlp
HA1
Tank1 y1
LA1
FT
Q2
Q1
LV1
LT2
Overlp
HA2
Tank2 y2
LA2
Q4
Q3 LV2
u[V]
Reservoar
5
Telemark University College
Tank 1:
(1-1)
Tank 2:
(1-2)
Where:
[Area in tank1 = 113,1 cm2]
[Level in tank1]
Qp[The flow to tank1]
Q1[The flow out of tank1]
Q2[The flow out of the solenoid valve]
[Area in tank2 = 113,1cm2]
[The Level in tank2]
Q1[The flow to tank2]
Q3[The flow out of tank2]
Q4[The flow out of the solenoid valve]
6
Telemark University College
2 PROGRAM
In this section you will learn how to create the program used to control the level in the lower
tank 2 of the Two-Tank model using DeltaV Database Administration, -Explorer, -Control
Studio and I/O Configuration.
Now set the database you just made active with the Set Active Database button. This button is
found in the Database Administration window. Select the database you just made and press ok.
Your database is now created and active.
7
Telemark University College
You will find the MPC loop you just added in your TWO_TANK area.
To get a more structured program we want to separate the I/Os into its own control module.
Go to DeltaV Explorer and right click on your area TWO_TANK. Then choose New Control
Module, see Figure 2.3.
8
Telemark University College
Name the Object name I_O, see Figure 2.4, then press OK.
Table 2-1 is an overview over hardware cards with channels connected to the hardware
controller. Right click on the channels, as shown in Figure 2.6, and enable all the channels
presented in the table. When the channels are active they should change color from grey to
yellow.
9
Telemark University College
OUT
P1 C02CH03 PUMP
All I/Os that we need to control the TWO-TANK should now be active.
10
Telemark University College
From Control Studio we see that we have a MPC block. In addition we have one analog in block
and one analog out block, for our case being the controlled variable (CV) for the level in tank 2
and manipulated variable (MV) to the pump respectively. These IO needs to be assigned to the
hardware controller and IO modules. Since the level is measured in percent, then we need to
scale this value into cm. Also, the level transmitter on the tank has a 4mA output signal when the
level is at 100%. Because of this we need to reverse the signal to the controller.
Drag and drop a Scaler block found under the Analog Control tab, see Figure 2.8. Wire a
connection from the AI block to the Scaler block and from the Scaler block to the CNTRL1 on
the MPC block. Mark the Scaler block and double click IN_SCALE in the property section to the
left. Write 0 under 100% scale and 100 under 0% of scale. Press OK. Then, double click
OUT_SCALE, and write 30 under 100% scale. Press OK.
11
Telemark University College
Right click the AI block and choose Assign I/O To Signal Tag. An IO_IN Properties window
will then appear, see Figure 2.9.
12
Telemark University College
Browse Device Tag, double click on CTLR and choose TLR-1-HITC01CH04. This is the fourth
IN on the analog input module (CH04). Press ok until you are back to the MPC loop.
Now, right click the AO block and choose Assign I/O To Signal Tag, and double click
IO_OUT. Browse Device Tag, double click on CTLR and choose TLR-1-HITC02CH03. This is
the third OUT on the analog out module (CH03). Press OK and then close. We have now
connected the I/O to the MPC controller.
In addition, for MPC we will also include constraints (AV) on the level in the lower tank 2, and
disturbance (DV) being the level in tank 1. These are typical variables in a process and often
affect the performance. To include them we need to add these parameters to the MPC block.
Right click the MPC block and choose Extensible Parameters. Then double click on
NOF_DSTRB and add 1 to the Modify Extensible Parameter - NOF_DSTRB, see Figure 2.10.
Click OK and add 1 to the NOF_CONSTR. Again click OK and Yes until you are back to the
MPC loop.
13
Telemark University College
Do the same with the other parameters. For the Constraint parameter, also include CNTRL1
under Related CV, and add a Low limit and High Limit being 10 and 20 cm respectively. When
finished close the property window.
The level in the lower tank 2 is the constrained parameter and then we need to connect the Scaler
block OUT to the CNSTR1 input on the MPC block, see Figure 2.12.
Since the level in the upper tank 1 is the measured disturbance we need to add an AI block from
the IO tab. Then, right click the new AI block and choose Assign I/O To Signal Tag. Browse
Device Tag, double click on CTLR and choose TLR-1-HITC01CH03. This is the third IN on the
analog input module (CH03). Press ok until you are back to the MPC loop.
As for the level transmitter on tank 2, the tank 1 transmitter signal needs to be reversed due to
the 4mA output signal when the level is at 100%. Add a Scaler block from the Analog Control
tab, and double click IN_SCALE in the property section to the left. Write 0 under 100% scale
and 100 under 0% of scale. Press OK. Then, double click OUT_SCALE, and write 30 under
100% scale. Press OK.
When this done connect the AI block and Scaler block to the DSTRB1 input on the MPC block,
as seen in Figure 2.12. By clicking on the default names on the blocks, e.g. AI1, you can change
the name to a preferable tag.
Figure 2.12 Constraint and disturbance parameters connected to the MPC block.
14
Telemark University College
Now, press the button in Control Studio. Then, press yes, and choose CTLR-1-HIT and
click OK. Press yes, and OK until the download is completed.
Close Control Studio. Press yes if you get question about saving.
Figure 2.13 Analog- and Digital signal blocks for the physical model.
We also want to create interlocks for the system to make sure that e.g. a high critical limit level
is respected. Therefore, connect, as seen in Figure 2.13. HA1 output to the LV1 input and HA2
output to the LV2 input. This connection makes sure that whenever a high limit level is reached
for tank 1 or tank 2, then the valves for the respective tanks will open.
15
Telemark University College
Right click on LA2 and choose Assign I/O to Signal Tag, then press browse, double click on
CTLR-1-HIT, mark TLR-1-HITC03CH04 and press OK.
Right click on HA1 and choose Assign I/O to Signal Tag, then press browse, double click on
CTLR-1-HIT, mark TLR-1-HITC03CH01 and press OK.
Right click on HA2 and choose Assign I/O to Signal Tag, then press browse, double click on
CTLR-1-HIT, mark TLR-1-HITC03CH03 and press OK.
Right click on LV1 and choose Assign I/O to Signal Tag, mark IO_OUT, press Modify then
Browse, double click on CTLR-1-HIT, mark TLR-1-HITC04CH01 and press OK.
Right click on LV2 and choose Assign I/O to Signal Tag, mark IO_OUT, press Modify then
Browse, double click on CTLR-1-HIT, mark TLR-1-HITC04CH02 and press OK.
Figure 2.14 shows all the blocks connected to the correct IN and OUT.
Now, press the button in Control Studio. Then, press yes, and choose CTLR-1-HIT and
click OK. Press yes, and OK until the download is completed.
Close Control Studio. Press yes if you get question about saving.
16
Telemark University College
2.6 Step 6: Assigning area to alarm and events and continuous historian
The control modules and I/O is now connected to the hardware module. For alarms and events
and data collecting to work we need to connect this to the history module thats premade in
DeltaV.
Go to Exploring DeltaV, choose your area TWO-TANK under Control Strategies and drag and
drop it down to Alarms And Events, see Figure 2.15. Also, since we need to collect input/output
data to create a model as in section 3, then drag and drop the area to Continuous Historian as
well.
Figure 2.15 Assigning TWO_TANK area to Alarms and Events and Continuous Historian.
The last thing that needs to be done before we start making the user interface is to make sure
everything is downloaded. Right click on Physical network and choose Download physical
network. Whenever there has accrued changes in the physical network this need to be
downloaded again. If minor changes, e.g. setup data, then instead of downloading the whole
physical network there could be more appropriate to right click the physical network and
download Setup Data, see Figure 2.16.
Also, every time you make a change in a program in Control Studio, this needs to be saved and
downloaded again as well.
After the downloading, the program should now be ready.
17
Telemark University College
The model also needs to be connected to 230V and turned on. When turning the power on, make
sure the components inside the model are powered.
18
Telemark University College
Start by going to Options in the application menu and chose Expert. This gives additional
features which we want to use.
19
Telemark University College
From the Figure 3.3, the upper left part is where the model hierarchy is found. On the upper right
is a trending picture which shows the MPC parameters configured, and chosen by double-
clicking the respective parameter under Operation and Trend. The lower left part is for modelling
configuration and the lower middle is for model generation.
Before we start modelling we want to find a preferred operational point, e.g. around 15 cm.
Click Application in the application menu and choose MPC Operate.
A new application appears, and with the physical process connected we have the choice to run
the MPC control either in manual or in auto mode. Since we do not have a model yet only the
manual mode will work.
On the bottom in the MPC Operate application all the MPC parameters are shown.
Start by marking all the parameter check boxes in the bottom of the figure. Click on the
manipulated variable (MV). At the left side a slide-bar for the parameter is then shown. Adjust
the slide-bar so that the level gets steady and about 15 cm, see Figure 3.4.
When you have the operational point steady around 15 cm, go back to the DeltaV Predict
application and set the Test Process parameters Step Size to 5 %, Time to Steady-State to 180 s
and Cycles to 2, as seen in Figure 3.5. Then press the Test button.
20
Telemark University College
The application is now starting to collect input/output data to create the model. For the above
Test Process settings it will take some time to finish this test process. This will be indicated by a
blue progression bar under Test Process.
When the test process is finished this is indicated by the green area layered on the period of data
collection seen on the trend picture and as in Figure 3.6.
21
Telemark University College
22
Telemark University College
To possible improve the model, e.g. remove uncertain data, we may adjust the period of data
collection as seen in Figure 3.6. However, note that doing this may also worsen your model, and
should be done with cautiousness.
If you want to adjust the period of data collection, then click on and adjust the edges of the green
layered area, see Figure 3.9. From the figure the data seems to correlate better within the new
green area.
Figure 3.10 New model verification of the actual measurement vs the predicted.
23
Telemark University College
Once you are satisfied that the model fairly reflects the process dynamics, select Generate Ctlr to
update the MPC configuration for the new model.
When the control is generated from a selected model, control parameters used to generate the
control are displayed and shown in Figure 3.11. Here we can somewhat tune the controller.
Normally only the Penalty On Move (PM) and Penalty On Error (PE) should be adjusted. In
short:
Increase the PM value (in fifty percent increments) for any manipulated variables that are
moving more than the acceptable limits.
Decrease the PM for manipulated variables that are not responsive. It is recommended
that they do not go below the default minimum PM values (the PM min = 3).
Increase or decrease the PE, depending on process control requirements.
We might want to wait to do this kind of tuning since we have not tested the controller yet.
However, normally the default values give a good performance.
Now, press Start to continue, and then Close after the progression bar has finished.
To download the MPC controller click the blue arrow in the DeltaV Predict application as seen
in Figure 3.12.
24
Telemark University College
Start by marking all the parameter check boxes in the bottom of the figure.
Then select AUTO under Mode, and start the simulation by clicking the play button.
Now you can adjust the controlled variable using the slide-bar to the left and see the simulation
performance of the MPC controller. If you want the simulation to go faster you can do so by
adjusting the horizontal slide-bar above the play button. The yellow area in the trend is the
predicted future measurement.
If the performance is satisfactory then you can test it on the Two-Tank, e.g. using the MPC
Operate application in the same manner as in the simulation environment, and see if the response
is similar. The green area in the trend is the predicted future measurement. Figure 3.13 vs Figure
3.14 shows that the controlled variable response is fairly similar. The manipulated variable
deviates some. The reason for this is that in the simulations the disturbance is constant, however,
on the real Two-Tank process the disturbance affects the manipulated variable, which then again
affects the controlled variable. The constant value in the simulation is set w.r.t. the average value
of the earlier collected disturbance data.
25
Telemark University College
Note! If your model or simulations doesnt look to good it could be a good idea doing the test
process again and possible change the test process parameters, e.g. try to vary the period of
testing w.r.t. number of samples.
26
Telemark University College
Press the +sign on the folder Pictures Templates and double click on main. You will then get a
standard template picture, see Figure 4.2.
27
Telemark University College
Mark and delete all the text on the picture so you get a blank picture like the one below, see
Figure 4.3.
28
Telemark University College
A Dynamo box will appear after you have placed your tank, as shown in Figure 4.5Error!
Reference source not found.. Start by entering 30 (cm) in Highest Input Value under Input
Ranges. Press the button, then press Browse DeltaV Control Parameters TWO_TANK
MPC_LOOP_1 MPC1 DSTRB1 CV.
29
Telemark University College
Next we are going to add two solenoid valves, one to each tank. Valves are found in Dynamo
Sets and Valves_DF. Find two suitable valves and place them at the outlet of each tank, see
Figure 4.7.
Double click on the valve you placed next to tank 1. Basic Animation Dialog, as in Figure 4.8,
will appear. Make sure Foreground Color is checked and press the button next to it.
30
Telemark University College
As in Figure 4.9, make sure Exact Match is checked. Delete all the rows and add two new rows.
The color of the valve at value 0 should be gray. At value 1 the valve should be green.
Then press the button, choose Browse DeltaV Control Parameters TWO_TANK, I_O
LV1 OUT_D CV, see Figure 4.10, and press Ok until you return to your picture.
The valve will now change color from gray to green when its open.
Now do the same thing with the valve you placed beside tank 2. The only difference is that you
need to choose LV2 instead of LV1 when you configure the other valve parameter.
31
Telemark University College
We will now find a pump. Choose a suitable pump from the Dynamo Sets, e.g. from Pumps_DF,
and drag and drop it onto the drawing board.
Check the box for Animate Pump Color. Press the button and link it to the I/O exactly the
same way as you did when linking the tanks, except that you will choose MNPLT1 instead of
DSTRB1/CNTRL1.
We can also choose what kind of color the pump will have at different values. Choose green
color for when the pump is running, see Figure 4.11.
Figure 4.11 Linking manipulated variable data to the pump and adding animation color.
The Flow Transmitter can be found under Dynamo Sets and FlowMeters, see Figure 4.12. Find a
suitable flow transmitter and add it to your picture.
32
Telemark University College
Now we need to draw a reservoir tank and add some pipes. The tank can be drawn e.g. using
drawing tools in the toolbar. For the pipes, drag and drop some pipes into the drawing board and
adjust them similar to as seen in see Figure 4.13. The pipes are found in Pipes_DF, under
Dynamo Sets.
Figure 4.13 Adding a reservoir tank and pipes to the picture interface.
33
Telemark University College
Finally, we need to add some alarm indicators. Choose four squares from the toolbar and place
them next to the tanks, see Figure 4.14. These will be the High-High and Low-Low alarms for
tank 1 and tank 2 respectively.
Double click the upper square for tank 1. Similar as for the valves, check Foreground and click
the button beside it in the Basic Animation Dialog. As in Figure 4.15, make sure Exact Match is
checked. Delete all the rows and add two new rows. The color of the alarm at value 0 should be
grey. At value 1 the alarm should be red.
34
Telemark University College
Then press the button, choose Browse DeltaV Control Parameters TWO_TANK, I_O
HA1 OUT_D CV, see Figure 4.15, and press Ok until you return to your picture.
The alarm indicator will now change color from grey to red when its activated.
Do the same with the lower indicator for tank1, except when you Browse DeltaV Control
Parameters, choose LA1 instead of HA1.
Also, do the same for tank 2, except that you now choose HA2 and LA2 instead of HA1 and
LA1 respectively.
Next, we add datalinks connected to the CV, SP, MV, DV and FT1.
Lets start with the CV. Press that you can find in the toolbar. Then press the button.
Browse DeltaV Control Parameters TWO_TANK MPC_LOOP_1 MPC1 CNTRL1
CV. Then press ok until you get back the Datalink box. Here, change Type to Numeric and
press ok. Place the variable next to CV, see Figure 4.17.
35
Telemark University College
Do exactly the same for SP, but choose SP1 instead of CNTRL1, and in Datalink box we need to
choose in-place on the data entry to be allowed to change the variable. Place it next to SP.
For the MV, do exactly the same procedure as we did with SP, except that we choose MNPLT1.
Place the variable next to MV.
For the DV, do exactly the same procedure as when we did with CV, except that we choose
DSTRB. Place the variable next to DV.
The only datalink left is the FT1. From the Browse DeltaV Control Parameters, then choose
TWO_TANK I_O FT1 OUT CV. Place the variable below FT1.
36
Telemark University College
37
Telemark University College
A Dynamo Properties window appears. As for the faceplate press the button and choose
Browse DeltaV Control Parameters. Then choose TWO_TANK MPC_LOOP_1 MPC1
CNTRL1 CV and press OK until you are back to your picture.
You have now made the interface that can be used to control the temperature for the Level Tank.
If you havent already saved your picture then do this now by choosing Save As under File. Save
the picture with yourname.grf.
38
Telemark University College
To open the MPC Operate application just press the Open MPC Operate button you created. You
can then control the Two-Tank as explained in section 3.
Press the Open Faceplate button to open the faceplate. Alternatively you can mark either SP or
MV and then press the faceplate button in upper left corner. Here you have the options to control
the process manually or set it to auto.
You can see the trend of the variables by pressing the button that looks like a graph in the
faceplate. You will then see the CV, SP, MV and DV.
If you press the button with the magnifying glass in the faceplate, a detail window will appear.
Here you can e.g. try to do further tuning changing the SP Filter Time. If your controller f.ex. has
to fast control response, then by increasing the setpoint filter time the response will be relaxed.
Figure 5.2 shows the running model with its associated faceplate and detail window.
.
39
Telemark University College
Figure 5.2 Running the Level Tank system in DeltaV Operate Run with associated faceplate and
detail window.
Further tuning can be done changing the PM and PE by pressing the Generate Ctlr button in the
DeltaV Predict application, and explained in section 3.3. Feel free to experiment and try to find
values that might improve the performance.
In Auto mode, try to set the setpoint to 25- or 5 cm, starting from e.g. an operational area around
15 cm, and see what happens.
You may also want to add water to tank 1 manually as a sudden disturbance change (be careful
not to overfill the system), and see the performance by the controller.
40