Understanding PID Controllers
An interactive, step-by-step guide to Proportional, Integral, and Derivative control.
1. The Proportional (P) Controller
What it does:
The Proportional term looks at the present error (the difference between your target and current state). It applies a corrective force proportional to the size of the error. A bigger error gets a bigger correction. Its main job is to get the system moving towards the target quickly.
The Downside:
A P-only controller usually results in a steady-state error. As the system gets closer to the target, the error becomes smaller, and the corrective force weakens, often leaving a permanent gap between the target and the actual value.
Practical Example: Toilet Float Valve
The float in a toilet tank is a mechanical P-controller. As the water level (and float) rises towards the target, it proportionally closes the valve. It stops just before it's fully closed, leaving the water level slightly below the top of the overflow tube.
P-Only Simulation
2. The Integral (I) Controller
What it does:
The Integral term looks at the accumulation of past errors. If there's a persistent error (like the steady-state error from a P-controller), the integral term will grow over time, adding more and more corrective force until the error is eliminated.
The Downside:
By itself, an I-only controller is slow to react and prone to causing large overshoot and oscillations, as it has to wait for the error to accumulate before it acts strongly.
Practical Example: A Patient Person
Imagine manually filling a leaky bucket to a specific line. At first, you might not add enough water (steady-state error). An integral-like mindset would be to notice you've been below the line for a while and to gradually increase the water flow until the level finally reaches the target, compensating for the leak.
I-Only Simulation
3. The Derivative (D) Controller
What it does:
The Derivative term predicts future error by looking at the error's rate of change. If the error is shrinking rapidly, the D-term reduces the corrective force to prevent overshooting. It acts as a brake or a damper.
The Downside:
A D-only controller doesn't care about the size of the error, only how fast it's changing. It won't act if the error is large but constant. It's also very sensitive to measurement noise, which can cause erratic behavior.
Practical Example: Car Shock Absorbers
A shock absorber is a purely derivative device. It doesn't care how high or low the car is (the error). It only pushes back against the *speed* of the suspension's movement. It dampens oscillations after hitting a bump, preventing the car from bouncing up and down.
D-Only Simulation (Resisting Disturbance)
4. Putting It All Together: The Full PID Controller
Now, combine the P, I, and D terms. Use the Proportional term for a fast response, the Integral to eliminate the final error, and the Derivative to reduce overshoot. Try to reach the target speed of 80 km/h quickly and smoothly.