Level Control Exam Kirsten
Big picture: what is this project about? ๐งชโ๏ธ
The system controls the water level in a tank. A pump adds water, an ultrasound sensor measures the level, and a controller adjusts pump voltage/PWM to make the actual water level match a target level.
Think of it like a smart bathtub:
- Target level = how high you want the water.
- Sensor = measures actual water height.
- Controller = decides whether the pump should work harder or slower.
- Pump = adds water.
- Outflow/disturbance = water leaking or draining away.
The report first builds a mathematical model, then designs P and PI controllers, then tests them experimentally with Arduino.
Page 1 โ System introduction and functional block diagram
The project begins with Miniproject B: Level control of liquid in a tank.
Important system parameters:
- Tank cross-sectional area: A = 75 cmยฒ
- Tank height: 15 cm
- Liquid level: L
- Tank volume: Vt
- Inflow: fin
- Pump input: 0โ5 V or PWM 1โ255
The image shows the real physical setup:
- Arduino controls the system.
- Amplifier drives the pump.
- Pump sends water into the tank.
- Ultrasound sensor measures distance to the water surface.
- Outflow pipe/valve can create a disturbance.
Main task: draw a functional block diagram of the level-control system.
Educational point: this is a classic feedback control problem. The system compares a desired level with the measured level, then adjusts pump input to reduce the error.
Page 2 โ Transfer function from inflow to tank level
This page derives the theoretical relationship between inflow and liquid level.
Because liquid is assumed incompressible:
\frac{dV_t}{dt} = F_(t)
The tank volume is:
V_t(t) = A \cdot L(t)
Since the area is constant:
A \frac{dL(t)}{dt} = F_(t)
After Laplace transform with zero initial conditions:
A \cdot s \cdot L(s) = F_(s)
So the transfer function becomes:
G(s) = \frac{L(s)}{F_(s)} = \frac{1}{A s}
Key idea: the tank behaves like an integrator.
That means if water flows into the tank continuously, the level keeps increasing over time.
Page 3 โ Tank transfer function and step response
Using the tank area:
A = 75 \text{ cm}^2
The tank transfer function becomes:
G(s) = \frac{1}{75s}
The step response sketch shows a ramp.
Why? Because a step in inflow means constant inflow. Constant inflow into a tank causes level to increase linearly.
So:
- Step input in flow โ ramp output in height.
- The tank does not naturally settle.
- Without outflow or feedback, the tank keeps filling.
This is important because pure integration can easily cause overflow if uncontrolled.
Page 4 โ Pump-pipe transfer function
This page models the pump and pipe system from voltage input to flow output.
The pump is treated as a first-order system:
G_(s) = \frac{K}{\tau s + 1}
Given values:
- Pump gain: K = 0.5
- Pump time constant: ฯ = 1.2 s
Important note in the report: here V(s) means voltage, not volume.
Educational meaning:
- The pump does not instantly reach its final flow.
- It responds gradually.
- The time constant ฯ describes how fast the pump reacts.
A larger ฯ means a slower pump response.
Page 5 โ Pump step response and combined block diagram
The pump step response shows a typical first-order curve:
- It starts low.
- It rises quickly at first.
- It gradually approaches a final steady value.
Then the report inserts the transfer functions into the block diagram:
- Controller
- Amplifier
- Pump transfer function
- Tank transfer function
- Sensor feedback
- Outflow disturbance
The total open-loop transfer function from pump voltage to tank level is:
G_(s) = Pump(s) \cdot Tank(s)
With no outflow:
G_(s) = \frac{0.5}{(1.2s+1)} \cdot \frac{1}{75s}
which simplifies to something equivalent to:
G_(s) = \frac{0.5}{90s^2 + 75s}
Important meaning: the system contains both:
- A first-order pump delay
- A tank integrator
So the level response is slower at first, then becomes ramp-like.
Page 6 โ Voltage-to-level step response
This page shows the response from pump voltage to tank level.
Two cases are discussed:
No clamp
If there is no limit, the water level continues increasing forever.
That makes sense because the tank is integrating inflow.
With clamp
If the tank height is limited, the level stops once it reaches the maximum allowed level.
This is physically realistic because the tank cannot exceed its actual height unless it overflows.
Important control lesson: mathematical models can predict infinite increase, but real systems have physical limits such as tank height, pump saturation, and overflow.
Page 7 โ Finding parameters from open-loop step response
This page introduces parameter identification using an open-loop step response.
The block diagram uses:
\frac{0.5}{90s^2 + 75s}
The response plot shows the level increasing after a step voltage input.
The goal is to estimate system parameters from experimental or simulated data.
This is important because theoretical values are rarely perfect. Real pumps, tubes, sensors, and leaks behave differently from ideal models.
Page 8 โ Extracting Kฯ, K, and ฯ from step response
The report explains how to estimate:
- Kฯ
- K
- ฯ
You apply a step voltage ฮU to the pump and record the level over time.
Two curves are mentioned:
- The theoretical pure integrator response: a straight ramp.
- The actual measured response: starts slower, then becomes parallel to the ideal ramp.
The delay between these curves helps estimate pump dynamics.
Key interpretations:
- Kฯ comes from the slope of the integrated response.
- K can be found from the gap between theoretical and measured curves.
- ฯ can be found using the 63% rule.
The 63% rule: for a first-order system, the time to reach 63% of the final change is approximately one time constant.
Page 9 โ MATLAB open-loop program
The report asks for a MATLAB program that calculates tank level when a known voltage is added.
Conditions shown:
- Voltage input: 3 V
- Outflow: 0
- Yellow line: measured/calculated tank height
- Blue line: maximum tank height, 15 cm
The plot shows the tank filling over time.
Important lesson: in open loop, the pump is not correcting itself based on level. If voltage is applied too long, the tank can overflow.
Open-loop control is simple, but risky because it does not react to disturbances or measurement error.
Page 10 โ Controller design: P controller
The controller design section starts.
A proportional controller is introduced:
D(s) = K_p
The ultrasound sensor is assumed perfect:
H(s) = 1
The closed-loop transfer function is given in the general feedback form:
T(s) = \frac{G(s)}{1 + G(s)H(s)}
But since the controller is included, the actual loop uses:
\frac{K_pG(s)}{1 + K_pG(s)}
Important idea: closed-loop control compares actual level to reference level and automatically adjusts pump voltage.
Page 11 โ Closed-loop transfer function for P control
For zero outflow, the open-loop plant is:
G(s) = \frac{0.5}{90s^2 + 75s}
With proportional control:
\frac{l}{l_} = \frac{K_pG(s)}{1 + K_pG(s)}
The report simplifies this to:
\frac{l}{l_} = \frac{K_p}{180s^2 + 150s + K_p}
Then it rewrites it in standard second-order form:
\frac{l}{l_} = \frac{K_p/180}{s^2 + \frac{150}{180}s + K_p/180}
Key point: adding P control turns the open-loop integrating system into a closed-loop second-order system.
Page 12 โ P-control simulation for 5 cm reference step
The MATLAB simulation changes the reference level by 5 cm.
The plot shows:
- Blue line: reference height
- Yellow line: actual tank height
The actual level rises and approaches the reference.
The report says there is no stationary error when there is no outflow.
Why? Because the plant already contains an integrator. For a reference step and no disturbance, the closed-loop system can reach the setpoint.
Important distinction:
- P control can remove reference error here because the tank itself has integral behavior.
- But P control struggles with constant disturbances, such as outflow.
Page 13 โ Closed-loop transfer function from outflow disturbance to level
Now the report studies disturbance behavior.
The disturbance is the outflow.
The transfer function from disturbance to level is derived and rewritten in standard form.
The important physical meaning:
- Outflow pulls the water level down.
- The controller responds by increasing pump input.
- But with P control, a constant outflow usually creates a permanent offset.
The report notes that the steady-state error tends toward a value related to:
\frac{1}{K_p}
So larger proportional gain reduces the error, but does not fully remove it.
Page 14 โ P controller with different gains: Kp and 0.1Kp
The report compares P-control disturbance responses.
For outflow = 1:
- With Kp = 1, steady-state error is 2
- With Kp = 0.1, steady-state error is 20
This shows an important rule:
Lower proportional gain means weaker correction.
So when Kp is small:
- The controller reacts gently.
- The response is slower.
- The steady-state error is larger.
Page 15 โ P controller with 10Kp and introduction to PI control
For outflow = 1 and Kp = 10, the steady-state error becomes 0.2.
So increasing Kp reduces the disturbance error.
But there is a tradeoff:
- Higher Kp gives faster response.
- Higher Kp reduces steady-state error.
- Too high Kp can cause overshoot or instability.
Then the report introduces the PI controller:
D(s) = K_c \frac{\tau_I s + 1}{\tau_I s}
A PI controller contains:
- P part: reacts to current error.
- I part: accumulates past error.
The integral part is what removes constant steady-state error.
Page 16 โ PI controller reference-to-level transfer function
The page derives the closed-loop transfer function for PI control from reference to level.
The block diagram includes:
- PI controller
- Amplifier
- Pump transfer function
- Tank transfer function
- Sensor feedback
The controller parameters shown include:
\tau_I = 20\tau
The derived transfer function contains a third-order denominator because the PI controller adds another dynamic element.
Important interpretation:
PI control is more powerful than P control because it can drive steady-state error to zero, but it also increases the system order and can introduce overshoot.
Page 17 โ PI disturbance-to-level transfer function and controller tuning method
The report derives the disturbance-to-level transfer function for the PI-controlled system.
Then it introduces the tuning rules from the slides:
\tau_I = 20\tau
K_c = \frac{0.65}{K_M \tau}
where (K_M) is based on the step-response slope.
This is a practical controller-design method based on measured process behavior.
Educational point: controller tuning often depends on experimental identification, not just theory.
Page 18 โ Calculating PI controller parameters
The page calculates controller parameters from the simulated/theoretical step response.
Given:
- ฯ = 1.2 s
- Slope = 0.0510 / 9.0071 = 0.00566219982
- (K_c = 95.6636438)
- (\tau_I = 20 \cdot 1.2 = 24)
Then the report asks to simulate the PI-controlled system and adjust (K_c) to obtain acceptable overshoot.
Important meaning:
- (K_c) controls how aggressively the PI controller reacts.
- Higher (K_c) usually means faster response but more overshoot.
- Lower (K_c) usually means slower response but less overshoot.
Page 19 โ PI step reference simulations
Two PI simulations are shown:
At (K_c = K_c)
The response reaches the target but overshoots.
At (K_c = 0.49K_c)
The overshoot is reduced.
This shows the classic tuning compromise:
- Strong controller: fast but overshoots.
- Weaker controller: smoother but slower.
The page then moves to step disturbance simulation.
Page 20 โ PI disturbance response and P vs PI comparison
The PI controller is tested with:
- Step outflow disturbance
- Reference = 5 cm
Then P and PI are compared.
The plot shows:
- Orange: P controller
- Yellow: PI controller
- Blue: target/reference
Main conclusion:
- P controller has steady-state error when outflow is nonzero.
- PI controller drives steady-state error to zero.
- (K_c) affects overshoot and responsiveness.
This is one of the most important conclusions in the whole report.
P control can reduce disturbance error, but PI control can eliminate it.
Page 21 โ Experimental part: identifying (K_t)
The experimental section begins.
The goal is to identify parameters from the physical setup.
The report uses a 4-second step from 0 to 4 V.
From the water level data, the slope is used to calculate:
K_t = 0.3487
The graph shows water height increasing over time with a fitted line:
y = 0.3487x + 2.606
with:
R^2 = 0.9656
This means the data is fairly linear, and the fit explains most of the variation.
Important idea: (K_t) describes how strongly voltage input changes the tank level over time.
Page 22 โ Pump transfer function from experiment
The pump transfer function is assumed to be:
\frac{K}{\tau s + 1}
The report estimates:
- (\tau = 0.3s)
- (K = K_t = 0.3487), assuming motor gain = 1
This experimental pump is faster than the theoretical one from earlier, where ฯ was 1.2 s.
Important lesson: real-system identification can differ significantly from theoretical assumptions.
Page 23 โ Experimental P-controller gain
The report determines the proportional controller using the slide method.
The calculated value is:
K_c = K_p = 6.638413578
This is the P-controller gain used for experimental simulations and Arduino implementation.
Interpretation:
- This gain is based on measured behavior.
- It should be more realistic than the earlier theoretical value.
Page 24 โ Experimental closed-loop transfer function
The report plugs the experimental values into the closed-loop P-control model.
It uses:
- (K_p = 6.638413578)
- (K_t = 0.3487)
- (\tau = 0.3s)
The page also shows the closed-loop block diagram.
The purpose is to create a simulation model that better matches the physical setup.
Page 25 โ Experimental P-control simulation with 5 cm reference
The report simulates P control with:
- Reference level: 5 cm
- Outflow: 0 ml/s
The response approaches the target.
The key point is that without outflow, the system reaches the reference level without steady-state error.
Again, this is because the tank dynamics include integration.
Page 26 โ Experimental disturbance transfer function and steady-state error
The report derives the closed-loop transfer function from outflow disturbance to tank level.
For a step disturbance, the system has steady-state error.
Why?
Because a constant outflow continuously removes water. With only P control, the controller needs a nonzero error to generate enough pump voltage to compensate.
That is the key weakness of proportional-only control:
A constant disturbance requires a constant error.
Page 27 โ Experimental P control with Kp and 0.1Kp
The report repeats simulations with:
- (K_p = K_p)
- (K_p = 0.1K_p)
with outflow = 1.
The lower gain gives:
- Slower response
- Larger steady-state error
- Less risk of overshoot
This is the same pattern as the theoretical part, but now using experimental parameters.
Page 28 โ Experimental P control with 10Kp
With:
K_p = 10K_p
and outflow = 1, the response becomes faster and the steady-state error is much smaller.
But the report notes that this can lead to overshoot.
Important control rule:
You cannot simply increase gain forever. Eventually, the system becomes too aggressive, noisy, oscillatory, or unstable.
Page 29 โ Experimental PI transfer function from reference to output
The report begins the PI-control experimental derivation.
It calculates the transfer function from reference to output, assuming zero outflow.
The key point is that PI control adds integral action, which improves steady-state accuracy.
Compared with P control:
- P: simpler, less overshoot risk, but disturbance offset remains.
- PI: removes constant offset, but can overshoot.
Page 30 โ Experimental PI disturbance transfer function
The report derives the transfer function from disturbance to output, assuming outflow = 1.
This is important because real tank systems often have disturbances:
- leakage
- opened drain valve
- pump backflow
- sensor noise
- turbulence
The PI controller should handle constant outflow better than P control because the integral term accumulates error until the offset disappears.
Page 31 โ Experimental PI controller parameters
Using experimental values:
- (\tau = 0.3)
- (K_M = K_t = 0.3487)
The controller gain is calculated:
K_c = \frac{0.65}{0.3487 \cdot 0.3} = 6.213555109
The integral time is:
\tau_I = 20 \cdot 0.3 = 6
So the experimental PI controller uses:
- (K_c = 6.213555109)
- (\tau_I = 6)
Page 32 โ Experimental PI step reference simulation
The PI controller is simulated for a step reference.
Two gains are compared:
(K_c = K_c)
Overshoot:
16.3%
(K_c = 0.55K_c)
Overshoot:
12.9%
Lowering (K_c) reduces overshoot, but likely slows the controller.
Important practical point: controller tuning is about choosing an acceptable balance, not finding a magical perfect number.
Page 33 โ PI simulation with outflow
The report simulates PI control with outflow = 1.
Results:
- At (K_c = K_c), overshoot = 0%
- At (K_c = 0.55K_c), overshoot = 0%
This suggests the disturbance changes the response shape. The controller spends effort compensating for outflow instead of overshooting the target.
The page then moves to step disturbance simulation.
Page 34 โ PI step disturbance simulation
The setup:
- Reference = 1
- Disturbance = step
- (K_c = 0.55K_c)
The purpose is to see how well the PI controller rejects a sudden outflow disturbance.
Expected behavior:
- Level initially changes due to disturbance.
- PI controller reacts.
- Integral action removes the final offset.
Page 35 โ PI controller comparison for disturbance
The report shows PI disturbance simulations at:
- (K_c = 0.55K_c)
- (K_c = K_c)
The higher gain responds faster but may be more aggressive.
The lower gain is smoother but slower.
Again, this illustrates the tuning tradeoff between speed and overshoot/noise sensitivity.
Page 36 โ P controller comparison for disturbance
The report shows P disturbance simulations at:
- (K_p = 0.55K_p)
- (K_p = K_p)
Compared with PI, the P controller cannot fully remove steady-state error from constant outflow.
Important takeaway:
P control can reduce the effect of outflow, but PI control is better when the disturbance is constant.
Page 37 โ Discrete P and PI algorithms for Arduino
The report now moves from continuous transfer functions to discrete controller implementation.
Sampling frequency:
5 \text{ Hz}
So sample time is:
T_s = 200 \text{ ms}
Controller values:
- P controller: K_p = 6.638413578
- PI controller: K_c = 6.213555109
- PI integral time: \tau_I = 6
The controllers were implemented in Arduino IDE 2.3.8.
Important idea: real controllers run digitally, so the continuous formulas must be converted into discrete update equations.
Page 38 โ Arduino P-control test: 10 cm target
The first physical test uses:
- Target height: 10 cm
- Outflow pipe closed
- Initial tank level approximately one-third of max height
Observations:
- At around (t = 0), the measured height jumps randomly.
- This is explained as sensor error.
- Even though the outflow pipe is closed, the pump has backflow.
- This acts like an outflow disturbance.
- The level stays mainly between 8 and 10 cm.
- The controller keeps correcting to reach the target.
Important real-world lesson: even โclosed outflowโ does not mean zero disturbance. Backflow, leakage, sensor noise, and turbulence matter.
Page 39 โ Arduino P-control test: 15 cm target
The second case uses:
- Target height: 15 cm
In the first 60 seconds:
- Water level increases continuously.
- There are corrections along the way.
- Some measurements are inaccurate due to turbulence.
Once the level reaches the setpoint, it stabilizes with behavior similar to the previous 10 cm case.
Important point: ultrasound sensors can be affected by surface turbulence, which causes noisy level readings.
Page 40 โ Arduino PI-control test
The PI controller shows a similar general pattern to the P controller.
However, the report says there is less scattering.
That means more data points are concentrated around the 15 cm level.
Interpretation:
- PI control may hold the level more tightly near the setpoint.
- But sensor noise still affects the data.
Page 41 โ Missing/mostly visual page
The parsed file content skips page 41, so this page likely contains a graph or visual result without easily extracted text.
Based on the surrounding pages, it probably continues the Arduino controller test results, likely comparing P/PI behavior or showing additional measured level data.
The important context is that the experimental section is focused on how well the implemented controllers maintain the target water level despite noise, backflow, and turbulence.
Page 42 โ Adjusting controller gain (K_c)
The report evaluates whether changing (K_c) improves overshoot.
Conclusion:
- The original (K_c) already produced acceptable overshoot.
- Reducing (K_c) to (0.8K_c) did not reduce overshoot.
- It mainly slowed down the controller.
This is an important practical finding.
Sometimes reducing gain does not improve the thing you expected, especially when the real limitation is sensor noise, pump behavior, turbulence, or actuator saturation rather than controller aggressiveness.
Page 43 โ Comparing experimental and simulated results
The report compares simulated performance with actual data.
Simulation settings:
- (K_p) simulation = Arduino (K_p)
- Pump voltage clamped to 0โ5 V
Plot colors:
- Yellow: actual water level
- Blue: target water level
- Orange: pump voltage
The experimental comparison uses measurements taken at 15 cm reference for both P and PI controllers.
Important purpose: check whether the mathematical model predicts the real tank behavior.
Page 44 โ Simulation vs real data differences
The report finds differences between simulation and experiment.
Simulation:
- Shows steady-state error slightly above the set level.
- Has smoother behavior.
- Responds faster.
Actual data:
- Shows slight steady-state error below the set level.
- Has fluctuations.
- Reaches the target more slowly.
Possible reasons:
- Pump leakage/backflow
- Sensor noise
- Water turbulence
- Real pump delay
- Imperfect model
- Voltage/PWM saturation
- Measurement uncertainty
This is a very realistic outcome. Simulations usually look cleaner than real systems.
Page 45 โ Step disturbance experiment
The report repeats the test with a step disturbance, meaning a constant outflow is introduced.
Observations:
- Settling time becomes longer for both P and PI controllers.
- The controller tries to compensate for the outflow.
- Sensor error amplifies the correction behavior.
- A slow increase in water level appears.
Important interpretation:
A disturbance forces the controller to work harder. With noisy measurements, the controller may overcorrect because it cannot perfectly distinguish real level changes from sensor error.
Page 46 โ Missing/mostly visual page
The parsed file jumps from page 45 to page 47, so page 46 likely contains a graph from the step disturbance experiment.
Based on the surrounding text, it probably shows measured water level data under constant outflow for either the P or PI controller.
Main takeaway from this section: real disturbance rejection is messier than simulation due to measurement noise and physical imperfections.
Page 47 โ Varying outflow test
The report introduces a final experiment:
Test for varying outflow
This means the disturbance is not constant. Instead, the outflow changes over time.
This is harder for the controller because the required pump compensation also changes.
In theory:
- P control should show changing error.
- PI control should adapt better, but may lag if the disturbance changes quickly.
Page 48 โ Missing/mostly visual page
The parsed text skips page 48, so this page is likely another graph of the varying-outflow experiment.
It probably shows the measured level response when the disturbance changes.
This visual would support the conclusion on the next page.
Page 49 โ Varying outflow conclusion
The report says that with varying outflow, they expected a more disrupted pattern.
However, the pattern remained similar to previous data.
Interpretation:
- The varying disturbance was probably not strong enough to significantly change the response.
- The large spread of data was more likely caused by sensor sensitivity than controller design.
- The initial โbulgeโ and scattered data are attributed mainly to sensor behavior.
Important conclusion:
The experiment was limited by measurement noise. When sensor noise is large, it becomes difficult to clearly see the effect of controller changes.
Overall conclusions ๐ง
1. The tank behaves like an integrator
A constant inflow causes the water level to rise continuously. This gives the tank transfer function:
G(s)=\frac{1}{As}
Because (A=75):
G(s)=\frac{1}{75s}
2. The pump behaves like a first-order system
The pump does not respond instantly. It has a gain and a time constant:
G_(s)=\frac{K}{\tau s+1}
The theoretical model used:
- (K=0.5)
- (\tau=1.2s)
The experimental model estimated:
- (K_t=0.3487)
- (\tau=0.3s)
3. P control works, but struggles with constant outflow
With no outflow, P control can reach the target level.
With constant outflow, P control has steady-state error.
Increasing (K_p):
- Reduces error
- Speeds response
- Can increase overshoot/noise sensitivity
4. PI control removes steady-state error
PI control adds integral action.
This allows it to eliminate constant disturbance offset.
However, PI control can overshoot if tuned too aggressively.
5. Real experiments are messier than simulation
The experimental results show:
- Sensor noise
- Turbulence
- Pump backflow
- Slower response than simulation
- Scattered measurements
- Differences between modeled and real steady-state behavior
This is normal and very important in control engineering.
6. Sensor quality strongly affected the results
Many experimental issues were linked to ultrasound sensor sensitivity and turbulence.
This means some observed fluctuations were probably not caused by controller design, but by measurement uncertainty.
Simple comparison: P vs PI controller
| Feature | P controller | PI controller |
|---|---|---|
| Uses current error? | Yes | Yes |
| Uses accumulated error? | No | Yes |
| Simple to implement? | Yes | Medium |
| Good with no outflow? | Yes | Yes |
| Constant outflow steady-state error? | Yes | Usually no |
| Overshoot risk | Lower | Higher |
| Sensitive to tuning? | Medium | Higher |
| Best use | Simple level control | Disturbance rejection |
Final takeaway ๐ฏ
This project shows the full control-engineering workflow:
- Build a mathematical model of the tank and pump.
- Derive transfer functions.
- Simulate open-loop and closed-loop behavior.
- Design P and PI controllers.
- Identify real system parameters experimentally.
- Implement controllers on Arduino.
- Compare simulation with real measurements.
- Explain differences using real-world effects like noise, turbulence, and pump backflow.
The most important lesson is:
P control can make the tank level follow a reference, but PI control is better when there is constant outflow because it can remove steady-state error.