🏭 Tank Level PID Training Simulator

Process Visualization

TANK (10m × 1m²) 5.0 m 10m 5m 0m
Level
0.0
meters
Setpoint
5.0
meters
Inflow
0.0
L/min
Outflow
0.0
L/min

PID Output Breakdown

P Term
0.0
I Term
0.0
D Term
0.0
Error (SP - PV)
0.0
meters

Simulation Speed

⏩ Time Scale 10x faster

Speed up the simulation to see PID response faster. 1x = real-time, 100x = 100× faster.

Control Mode

Setpoint 50% (5.0m)

PID Tuning Parameters

Kp (Proportional) 20.0
Ki (Integral) 0.5
Kd (Derivative) 2.0

Disturbance (Outflow)

Outflow Disturbance 20 L/min

Simulates a drain valve or process demand. Increase to challenge the controller.

Trend Chart (60 seconds)

Level (PV)
Setpoint (SP)
Output (%)

📚 What is PID Control?

A PID controller continuously calculates an error value as the difference between a desired setpoint (SP) and a measured process variable (PV), then applies a correction based on Proportional, Integral, and Derivative terms.

Output = Kp×e + Ki×∫e dt + Kd×de/dt

Where e = SP - PV (the error)

🔴 P - Proportional (Kp)

The P term produces an output proportional to the current error. Larger error = larger correction.

  • High Kp: Fast response, but may overshoot and oscillate
  • Low Kp: Slow, sluggish response
  • Limitation: P-only control always has steady-state error (offset)
🧪 Exercise 1: P-Only Control
Set Ki=0, Kd=0. Try Kp=5, then Kp=50. Notice how higher Kp reduces steady-state error but causes oscillation.

🟠 I - Integral (Ki)

The I term accumulates error over time. It eliminates steady-state error by adding correction until error reaches zero.

  • High Ki: Eliminates offset quickly, but can cause overshoot and slow oscillation
  • Low Ki: Slow to eliminate offset
  • Danger: "Integral windup" if error persists (we use anti-windup limits)
🧪 Exercise 2: Adding Integral
Set Kp=10, Ki=0, Kd=0. Note the steady-state error. Now add Ki=0.5. Watch the level slowly reach setpoint exactly.

🟣 D - Derivative (Kd)

The D term responds to the rate of change of error. It provides "damping" to reduce overshoot and oscillation.

  • High Kd: Strong damping, may slow response or amplify noise
  • Low Kd: Less damping, more overshoot
  • Note: D is sensitive to noise in real systems
🧪 Exercise 3: Derivative Damping
Set Kp=40, Ki=0.5, Kd=0. Make a step change in setpoint - notice the overshoot. Now add Kd=5. The overshoot should decrease.

⚡ Disturbance Rejection

A good controller rejects disturbances - unexpected changes in the process. The outflow slider simulates a drain valve opening.

🧪 Exercise 4: Disturbance Test
With tuned PID (Kp=20, Ki=0.5, Kd=2), let level stabilize. Then suddenly increase disturbance from 20 to 60 L/min. Watch how the controller compensates.

🎯 Tuning Guidelines

Conservative (slow, no overshoot):

Kp=10, Ki=0.2, Kd=5

Aggressive (fast, some overshoot):

Kp=40, Ki=1.0, Kd=2

Ziegler-Nichols method:

  1. Set Ki=0, Kd=0
  2. Increase Kp until sustained oscillation (Ku)
  3. Measure oscillation period (Tu)
  4. Set: Kp=0.6×Ku, Ki=1.2×Ku/Tu, Kd=0.075×Ku×Tu
🧪 Exercise 5: Compare Tunings
Try both conservative and aggressive settings above. Make a 30% setpoint step change with each. Which reaches setpoint faster? Which has less overshoot?

🔧 Manual Mode

In MANUAL mode, you directly control the inflow valve. The PID is disconnected. Use this to:

  • Understand the process dynamics
  • Perform bump tests for tuning
  • Take over during controller problems
🧪 Exercise 6: Open-Loop Response
Switch to MANUAL. Set disturbance to 30 L/min. Adjust manual inflow until level stabilizes. What inflow balances 30 L/min outflow? (Hint: mass balance!)