You are on page 1of 13

Laboratory #1 Water Tank Experiments

Deepa Jonnagadla, George Sequeira

The proportional feedback controller (Figure 2) differs


1. Introduction from the first figure because it incorporates feedback as
well as an amplifier. At this point we chose a value for the
Experiment 1a gain to ensure that the starting pump voltage was 10. We
had to change the step voltage for this design due to the
feedback in this particular controller. Once again we
The control system that we worked on for this lab dealt played with the initial water level of the tank to see if that
with calibrating the two sensors for the tanks. To would affect the final water level of the tank.
accomplish this task we first created a Simulink model as
shown below:

Figure 2: Simulink setup for proportional feedback


controller

The last controller that we designed was the PI


Figure 1: Simulink setup for open-loop controller
controller. For this design we added this portion below
(Figure 3) to replace the amplifier in figure 2. For this
We proceeded to configure each part of this simulation controller we played with the values of ki and kp to see
as required and then moved on to the actual calibration how it affected the water level of the tank and other
process. For the calibration process we would pour water aspects of the tank.
into a single tank at a certain mark on the tank then run the
computer to measure the water level from the scope. As
we did this we plotted the results of the scope we were
able to find the voltage required to keep the tank at a
certain level. We did this for various marks on the tank
and then proceeded to follow the same process for the
second tank.
Figure 3: Simulink block diagram of a PI controller
Experiment 1b
Once we designed these controllers we wanted to
In this portion of the lab we designed several investigate how linear they would prove to be. So we
controllers for the two tanks. The types of controllers that would use the step on the open-loop controller and just
we designed were open-loop, proportional feedback, the slightly step up the voltage from the initial voltage to final
PI controller. voltage to see if the reaction of the controller was linear.
The open-loop controller had the same simulink design We did this for several different final water levels.
as the figure shown above (Figure 1). With this design we Next, we replaced the step with a sinusoidal input.
set the voltage of the step to the value that would cause This took the form
the water level to reach the mark of 10. Then we made
sure that no alteration that we caused to the physical water
level in the tank would affect where the water level would
end up.
During this part of the lab we altered the values of ω
and A. The purpose of this was to see how close to linear
the response was to the sin function.
The final part of the lab dealt with both of the tanks.
We designed and built each of the controllers, previously
mentioned, for the upper and lower tank together. In these
systems the water level for the lower tank would have to
achieve the height of 10 and stay there.

2. Results

The following are the results of our laboratory


experiment and the steps needed to replicate them.

2.1. Calibrating the sensors


Figure 5: Tank 2 Calibration
To ensure the quality of the results of our experiment,
we calibrated the sensors as explained in the laboratory
handout. Our goal was to find the voltage related to the We then wanted to relate each level with a tank level.
water level of each tank. We poured water in each tank to So in Matlab we made an array with the values [0, 5, 10,
levels 0,5,10,15,20,25 and graphed the voltage. 15, 20, 25] with the following command.
We saved the data graphed in Simulink by going to >> x = [0 5 10 15 20 25];
File > Save as Mat File. And then opened the files in
Matlab. When opened, the data will be in the workspace. We also needed the voltage at the flat parts so in
Our group had Input 0 in Simulink as tank 1 and Input 1 matlab in plot view (the view we produced Figure 4 and 5
as tank 2. To plot we selected the from) we selected the data cursor tool in the toolbar and
“untitled_Analog_Input_0” and clicked “plot” in the clicked on the most flat part of each corresponding level
workspace toolbar. We did the same to produce the results and saved that in another array. Example:
for tank 2. The graphs produced are shown in Figure 4 >> y = [1 2 3 4 5 6];
and Figure 5. We then plotted the new data in Matlab using the
“plot” command for both tank 1 and 2:
>> plot(x,y);
These were our results.

Figure 6: Tank 1 Calibration (with tank height)


Figure 7: Tank 2 Calibration (with tank height)

Both Figures 8 and 9 show that the tank's sensors are


It is important to see if the sensors are linear. We used close to linear. We believe the following errors could have
linear interpolation from the plot view from each graph made the data not be perfect:
for this step. For Figure 6, in plot view, we selected the • Measuring height by eye sight is not
“Tool” menu item and then clicked on “Basic Fitting.” completely accurate.
Under “Check to display fits on figure,” we selected
linear and below that area we selected “Show equations”
• Some water was leaving since we plugged the
hole with our fingers.
and clicked on the bottom right corner button that is an
arrow. We did this for the data in Figure 7 as well. We • Since not every water level had a “flat” area
then produced the following linear interpolation graphs of voltage we would sometimes choose the
(Figure 8 and 9) with equations: most flat which could be incorrect.

2.2. Determining α

From the laboratory handout, equation (5) describes


the change in height, x, of a tank is written as:

x'(t) = -α*sqrt(x(t)) + β*Vp(t)

As the height of a tank decreases it is due to the “α”. In


order to find this value we must simply record the
draining data of a tank. We followed the directions in the
handout find the drain data for both tanks 1 and 2.
We then produced (Figure 10 and 11) the x(t) vs t
graphs by saving the data to Matlab.

Figure 8: Tank 1 Linear Interpolation


ans =
Tank 1 Drain ( x(t) vs t)
4.5 -0.0002 4.1150
The 1 tells matlab the highest order of the polynomial
4
to find. Our result shows -0.0002 as the slope of the
3.5 graph. Our α is 0.0002. Similarly for tank 2 we do the
same steps:
3
>> y = untitled_Analog_Input_1_;
>> size(y)
x(t) (volts)

2.5

2
ans =
47791 1
1.5 >> x = [1:47791]' ;
1
>> polyfit(x,y,1)
ans =
0.5
-0.0001 4.6055
0
0 0.5 1 1.5 2 2.5
t (seconds) 4
So for tank 2, our α = .0001;
x 10

Figure 10: Tank 1 Drain Graph 2.3. Determining β

To determine β we refer back to equation (5):

Tank 2 Drain (x(t) vs t) x'(t) = -α*sqrt(x(t)) + β*Vp(t)


5

4.5
β is actually the rate at which it fills. So we will isolate
4 this part of the equation by just filling and taking the data
3.5 of x(t) and t. Again we follow the directions in the
3 handout produce (Figure 12 and 13) the x(t) vs t graphs
x(t) (volts)

2.5
by saving the data to Matlab.
2

1.5 Tank 1 Fill (x(t) vs t)


4
1
3.5
0.5
3
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
t (seconds) 4
2.5
x 10

Figure 11: Tank 2 Drain Graph 2


x(t)

1.5
To estimate α our group used the “polyfit” command
in Matlab. When importing data from either the tank 1 1

drain or tank 2. The workspace would fill with an array: 0.5


“untitled_Analog_Input_0” and
0
“untitled_Analog_Input_1” which corresponded to tank 1
and 2 respectively for us. When we drained tank 1 we -0.5
0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000
saved “untitled_Analog_Input_0” as an array y: t
>> y = untitled_Analog_Input_0; Figure 12: Tank 1 Fill Graph
Then we found that the size of it was 47791 and made
an array x counting each point:
>> size(y)
ans =
20045 1
>> x = [1:20045]' ;
We then did used least squares:

>> polyfit(x,y,1)
Tank 2 Fill (x(t) vs t)
2.3. Open Loop Controller
3

We used the guess and check method to see at what


2.5
voltage the water level on the top tank would reach 10 and
stay at that level. We were able to accomplish this by
2
changing the step size in the design. The final value for
the step was 6.5V (Figure 14).
x(t)

1.5

1
OL Tank 1 Steady Response (level 10)
7

0.5
6

0 5
0 2000 4000 6000 8000 10000 12000
t
4

v (volts)
Figure 13: Tank 2 Fill Graph
3

The graphs for both Tank 1 and 2 start out rough.


2
When performing this part of the experiment, we noticed
that the water would sputter in for a bit before and then 1

start a smoother stream. As the lab handout explains, the


0
value for β, is the slope of the plot divided by Vp. We set 0 1 2 3 4
t (seconds)
5 6 7
4
8
x 10
the Vp to a constant 3, so we will be dividing our plots by
3. Figure 14: Tank 1 Steady state response
Just as we did before we will use “polyfit” to get a
least squares estimation. Our code for Tank 1 and 2 are We found that the steady state water level didn’t
below: change if we started the water level in the tank at level 5.
Tank 1: The steady state water level also didn’t change if we
>> y = untitled_Analog_Input_0_; poured additional water into the tank after the level
>> size(y) reached its steady state. If we changed the size of the
ans = orifice without changing the size of the step then the
steady state level will change because the system was
9769 1 calibrated to that step level with respect to the first orifice
>> x = [1:9769]'; size.
>> polyfit(x,y,1)
ans = 2.3. Proportional Feedback Controller

0.0004 -0.5419 We set up the proportional feedback controller as


described in the handout and chose our amplifier to have a
Tank 2: value of 1.5385 causing our initial voltage into the pump
>> y = untitled_Analog_Input_1_; to be 10v. The water level reached a steady state below
>> size(y) that of our open-loop example. This is because of the
ans = feedback that was in the design of the particular
11118 1 controller. The steady- state water level with this design is
>> x = [1:11118]'; 5, which corresponds to the a voltage of 0.9851 v as
>> polyfit(x,y,1) shown below (Figure 15).
ans =
0.0002 -0.1974

From this we conclude that β for Tank 1 = 0.0004/3


and Tank 2 = 0.0002/3 so Tank 1 β = 4/3 * 10^-4 and
Tank 2 β = 2/3 * 10^-4;
Tank 1 (x(t) vs t)
1.2 Tank 1 (Adding water after steady state)
2.2

1
2
X: 3.666e+004
Y: 0.9851
0.8 1.8

0.6 1.6
x(t) volts

x(t) volts
0.4 1.4

1.2
0.2

1
0
0.8
-0.2
0 1 2 3 4 5 6 7 8
t (time) 4 0 1 2 3 4 5 6
x 10
t (time) 4
x 10
Figure 15: Proportional Feedback Steady State
Figure 17: Tank 1 after adding water in steady state
The steady state level voltage did not change if we
started with water in the tank at level 5 (Figure 16). We found that the level does change if you change the
orifice because the amount draining from the tank
increases or decreases (Figure 18).
Tank 1 start level at 5
1.12

Tank 1 (Orifice Change)


1.1 1.6

1.4
1.08
1.2
1.06
x(t) volts

1.04 0.8
x(t) volts

0.6
1.02

0.4
1
0.2

0.98
0 0.5 1 1.5 2 2.5 3 0
t (time) 4
x 10
-0.2
0 1 2 3 4 5 6
Figure 16: Steady state after starting at level 5 t (time) 4
x 10

Figure 18: Tank 1 after changing orifice


Also when we poured some water into the tank after
the level reached its steady-state value there was no
change (Figure 17).
We changed the value of k from 5.07 to 10 and found
that the water level increased (Figure 19).
Tank Signal into Scope
2
Tank 1 (change k)
1.8

1.6 1.5

1.4

1.2 1

x(t) volts
1
x(t) volts

0.8 0.5

0.6

0.4 0

0.2

0 -0.5
0 1000 2000 3000 4000 5000 6000
-0.2 t (time)
0 0.5 1 1.5 2 2.5 3 3.5
t (time) 4
x 10 Figure 21.1: Tank Signal into Scope. ki = 0.1 kp =5.07
Figure 19: Tank 1 after changing k
Tank Error Signal
2.5

The step size that we needed to correct the water level


2
so it reached 10 exactly was (5.5V) and the value for k
that we used for this was 1.8181 (Fig. 20).
1.5
x(t) volts

Tank 1 (change step to 1.8181) 1


2

0.5
1.5

1
x(t) volts

-0.5
0 1000 2000 3000 4000 5000 6000
t (time)
0.5
Figure 21.2: Tank Error Signal. ki = 0.1 kp = 5.07
0

Tank Control Signal


-0.5 12
0 0.5 1 1.5 2 2.5 3 3.5 4
t (time) 4
x 10
10
Figure 20: Tank 1 after changing step
8
2.4. PI Controller
x(t) volts

6
We used a step size of 1.972V and kp was 5.07 and ki
was 0.1. The output, error, and control signal from the
4
amplifier are Figures 21.1, 21.2, 21.3 respectively. For the
rest of this section, this will be the order and assignment
2
for different values of ki and kp.
0
0 1000 2000 3000 4000 5000 6000
t (time)

Figure 21.3: Tank Control Signal. ki = 0.1 kp =5.07


We kept the value of kp at 5.07 and altered the value
of ki with the values of .5, and 1 (Figures 22,23).
Tank Output Signal
3.5
Tank Output Signal
3
3

2.5
2.5

2 2

x(t) volts
1.5 1.5
x(t) volts

1
1

0.5
0.5

0
0
-0.5
0 1000 2000 3000 4000 5000 6000 7000 8000
-0.5 t (time)
0 1000 2000 3000 4000 5000 6000 7000 8000
t (time)
Figure 23.1: Tank Output Signal. ki = 1 kp = 5.07
Figure 22.1: Tank Output Signal. ki = .5 kp = 5.07

Tank Error Signal


Tank Error Signal 2.5
2.5

2
2
1.5

1.5
1
x(t) volts

1
x(t) volts

0.5

0.5 0

0 -0.5

-1
-0.5

-1.5
-1 0 1000 2000 3000 4000 5000 6000 7000 8000
0 1000 2000 3000 4000 5000 6000 7000 8000 t (time)
t (time)
Figure 23.2: Tank Error Signal. ki = 1 kp = 5.07
Figure 22.2: Tank Error Signal. ki = .5 kp =5.07

Tank Control Signal Tank Error Signal


25 2.5

20
1.5

1
15
x(t) volts
x(t) volts

0.5

10 0

-0.5
5
-1

0 -1.5
0 1000 2000 3000 4000 5000 6000 7000 8000 0 1000 2000 3000 4000 5000 6000 7000 8000
t (time) t (time)

Figure 22.3: Tank Control Signal. ki = .5 kp =5.07 Figure 23.3: Tank Control Signal. ki = 1 kp = 5.07
Then we kept the value of ki at .5 and changed the
Tank Output Signal
value of kp with the values 10,2,and 20 (Figs. 24,25,26). 3

2.5
Tank Output Signal
3.5
2

3
1.5

x(t) volts
2.5
1
2
x(t) volts

0.5
1.5

1 0

0.5 -0.5
0 1000 2000 3000 4000 5000 6000 7000 8000
t (time)
0
Figure 25.1: Tank Output Signal. ki = 0.5 kp = 2
-0.5
0 1000 2000 3000 4000 5000 6000 7000
t (time)
Tank Error Signal
Figure 24.1: Tank Output Signal. ki = 0.5 kp = 10 2.5

2
Tank Error Signal
2.5
1.5

2
1
x(t) volts

1.5
0.5
1
x(t) volts

0
0.5

0 -0.5

-0.5 -1
0 1000 2000 3000 4000 5000 6000 7000 8000
t (time)
-1
Figure 25.2: Tank Error Signal. ki = 0.5 kp =2
-1.5
0 1000 2000 3000 4000 5000 6000 7000
t (time)

Figure 24.2: Tank Error Signal. ki =0.5 kp = 10


Tank Control Signal
12

Tank Control Signal


45 10

40
8
35
x(t) volts

30 6
x(t) volts

25
4
20

15 2

10
0
0 1000 2000 3000 4000 5000 6000 7000 8000
5
t (time)

0
0 1000 2000 3000 4000 5000 6000 7000 Figure 25.3: Tank Control Signal. ki = 0.5 kp = 2
t (time)

Figure 24.3: Tank Control Signal. ki = 0.5 kp = 10


We found out that when we increase kp the controller
responds faster and corrects itself faster. Our PI controller
Tank Output Signal
3.5 calculates an "error" value as the difference between the
measured water level of the tank and a our desired level.
3
The controller attempts to minimize the error by adjusting
2.5 the process control inputs.
2
2.5. Linearization
x(t) volts

1.5

0.5

-0.5
0 500 1000 1500 2000 2500 3000
t (time)
3500 4000 4500 5000 where and ;

Figure 26.1: Tank Output Signal. ki = 0.5 kp = 20

The a in this equation is .0002 and the b would be


Tank Error Signal
2.5 (4/3)*10^-4.
2
We also want to test the linearity through experiment as
1.5 instructed in the handout.
The Vpss that we used, to test how linear the open-
1
loop controller is, was 5.7V. Our original value was 6.5V
x(t) volts

0.5 but this changed because the calibration changed slightly


since we did this portion of the experiment on the second
0
day. Then we made the final value of the step equal to the
-0.5 water level at 11, the voltage here was 6V. We show the
response and the step in Figures 27.
-1

-1.5
0 500 1000 1500 2000 2500 3000 3500 4000 4500 5000 Tank Response
t (time) 1.8

Figure 26.2: Tank Error Signal. ki = 0.5 kp = 20 1.6

1.4
step
1.2

Tank Control Signal 1


90
x(t) volts

0.8
80
0.6
70
0.4

60
0.2

50
x(t) volts

40 -0.2
0 2 4 6 8 10 12 14
t (time) 4
30 x 10

20
Figure 27: Tank Response (10 to 11)

10

0
0 500 1000 1500 2000 2500 3000 3500 4000 4500 5000
t (time)

Figure 26.3: Tank Control Signal. ki = 0.5 kp = 20


We set the step time to 75. We repeated this
experiment for final water levels of 12, 9, and 8 and their
Tank Response
respective voltage levels for the final step value were 1.6

6.2V, 5.5V, and 5.3V (Fig. 28, 29, and 30). 1.4

1.2 step

1
Tank Response
2
0.8

x(t) volts
0.6
1.5
0.4
step
0.2
1
x(t) volts

0.5 -0.2
0 2 4 6 8 10 12 14
t (time) 4
x 10

0
Figure 30: Tank Step Response (10 to 8)

-0.5
0 5 10 15
t (time) 4
x 10

Figure 28: Tank Step Response ( 10 to 12) The second test for linearity required the input of the
controller to be sinusoidal instead of the step:

1.6
Tank Response The value that we used for Vpss was 5.7V, A was 1,
and w = 0.3 (Fig. 31) .
1.4

1.2 step

1 Tank Response w= 0.3


1.8
0.8
x(t) volts

1.6
0.6
1.4

0.4 1.2

0.2 1
x(t) volts

0 0.8

-0.2 0.6
0 2 4 6 8 10 12 14
t (time) 4 0.4
x 10

Figure 29: Tank Step Response ( 10 to 9) 0.2

-0.2
0 2 4 6 8 10 12 14
t (time) 4
x 10

Figure 31: Tank Steady State. w = 0.3 A = 1

Then we changed the values for ω from .3 radians/sec


to 1, 2, and 5 radians/sec while keeping the amplitude the
same (Fig. 32,33, 34).
Tank Response w= 1
1.8 We then tried to see if we could find a value of ω that
1.6 changes the steady state response even more. The value
1.4
we used was 10 radians/sec. Then we kept ω at .3 and
double and tripled the value of A (Fig. 35,36).
1.2

1
x(t) volts

Tank Response w = 10
0.8 1.8

0.6 1.6

0.4 1.4

0.2 1.2

0 1

x(t) volts
-0.2 0.8
0 1 2 3 4 5 6 7 8 9
t (time) 4
0.6
x 10

Figure 32: Tank Steady State. w= 1 A =1 0.4

0.2

Tank Response w = 2
-0.2
1.8 0 1 2 3 4 5 6 7 8
t (time) 4
x 10
1.6

1.4
Figure 35: Tank Steady State. w = 10 A =1
1.2
Tank Response w =0.3
1 1.6
x(t) volts

0.8
1.4
0.6
1.2
0.4
1
0.2
0.8
x(t) volts

0
0.6
-0.2
0 1 2 3 4 5 6 7 8 9 10
t (time) 4 0.4
x 10

Figure 33: Tank Steady State. w = 2 A=1 0.2

-0.2
0 1 2 3 4 5 6 7 8
Tank Response w = 5
t (time) 4
1.8 x 10

1.6 Figure 36: Tank Steady State. w = 0.3 A = 3


1.4

1.2
As we increased ω the water tank reached the steady
1 state response more quickly. Without the other two
x(t) volts

0.8 methods one could simply see that Y(t) was not a perfect
0.6 sinusoid. We have a few reasons for this error:
0.4 • signal noise
0.2 • not perfect steady flow from water pump
0 • a sinusoidal signal pump liquid cannot be
-0.2
perfect
0 1 2 3 4 5 6 7 8 9
t (time) 4
x 10

Figure 34: Tank Steady State. w =5 A =1


2.6. Two Tank Experiment

Derivation of nonlinear equations: For our closed-loop PI controller we set the


Amplitude=2.1, Step=2.7, w=10:

Steady State Response (Closed-loop PI)


1.6

We designed and built each of the open-loop, closed- 1.55

loop proportional, and closed-loop PI controllers to make 1.5

the water level in the lower tank hold a steady-state level 1.45
of 10 shown in Figures 37, 38, and 39 respectively.
1.4

x(t) volts
1.35
For our open-loop controller we used a step = 2.7v and
delay of 1 second: 1.3

1.25

Steady State Response ( Open-loop) 1.2


1.6
1.15
1.4
1.1
0 1000 2000 3000 4000 5000 6000 7000 8000 9000
1.2
t (time)
1
Figure 38: Lower Tank Steady State Response. A = 2.1
0.8
Step = 2.7 w = 10
x(t) volts

0.6

0.4 3. Conclusions
0.2

0 We believe that this lab was a good introductory lab


-0.2
for this controls class. We were able to understand the
concepts of what exactly is expected with a control lab
-0.4
0 2000 4000 6000 8000 10000 12000 14000 experiment. What would have been helpful is if we had a
t (time)
better method to figuring out what voltage would keep the
Figure 37: Lower Tank Steady State Response. Step = 2.7. water in the tank at a certain level.
We resorted to using the guess and check method and
we did not think that this was the best method to figuring
For our closed-loop proportional controller we used out these values. Another problem that we had with this
the step= 1.6, ki = 0.1 and kp = 2.4: lab is that lab1b took 2 days to finish. This caused a few
parts of the lab to be rushed being another source of error.
Steady State Response (Closed-loop Proportional)
The problem with this was the value for Vpss changed
3 because another group used our station so the calibration
of the tank changed so we had to redo a part of the
2.5
experiment after finally figuring out why our design was
2
not working correctly. This was slightly time consuming.
With this lab we did not have many difficulties at all. We
1.5 were able to follow the procedures with ease. The results
x(t) volts

that we were able to find were appropriate for the


1 experiment at hand.
0.5

-0.5
0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000
t (time)

Figure 38: Lower Tank Steady State Response. Step= 1.6


ki = 0.1 kp = 2.4

You might also like