PID Lab

Choose what the controller regulates: a generic value, pump pressure or water level.
P reacts to the current error. PI also corrects persistent error. PID adds a response to how quickly the measurement changes.
How strongly the controller reacts right away. A larger Kp changes the output more for the same error.
How quickly the correction builds up while the measurement differs from the target. Zero disables it. Used by PI and PID.
How strongly the controller responds to fast changes in the measurement. It can slow a rapid movement. Zero disables it. Used by PID.
The target you want to reach, such as a pressure or level. It takes effect at the scheduled step time, 2 seconds by default.
How many seconds of simulated time pass between controller updates.
Speeds up playback on screen. The sample time and numerical result stay the same.

Ready0 / 30 s

Advanced settings and scenarios
Loads a ready-made setup, such as a run with steady-state error or increased demand.
Process parameters
The sensor reading at the start of the run.
How much the measurement eventually changes for a one percentage point change in the command.
The response time of the process. A larger T makes the measurement change more slowly.
The delay between a command change and the first response from the process.
The command that was in effect before the run. It still affects the measurement while the new command passes through the delay.
Limits and mode
In auto, the controller calculates the output. In manual, you set the command yourself.
Smooths the D response to sharp measurement changes. A larger Tf makes the response smoother.
The lowest command the controller can send, as a percentage.
The highest command the controller can send, as a percentage.
The starting command in manual mode. It must be between Umin and Umax.
Helps the output recover from a limit by restricting how much I can build up toward that limit.

Timing and signals
How many simulated seconds the run lasts. Use a whole number of sample intervals Ts.
The target from the start of the run until the scheduled setpoint step.
When the target changes. Use zero to apply the new target at startup.
The external load at the start of the run. For the pump and tank it is added to the configured flow.
When the external load changes, for example when water demand increases.
The external load after the step. In the water models, a positive number raises the requested flow.

Controls during the run

These fields become available when a run starts.

Switches control during the run. Entering manual mode holds the current command.
The command percentage in manual mode. It takes effect at the next sample.
Changes the target during the run. It takes effect at the next sample.
Changes the external load during the run. For the pump and tank it is added to the flow.

Press Enter or leave the field to confirm a number. The change takes effect at the next sample.

Process diagram
Reference and measurement → error → controller → process. The measurement feeds back to the controller.
Setpoint
—
Measurement
—
Controller output
—

Performance metrics

Overshoot
—
Settling time
—
Steady-state error
—
Mean error over the final samples
—
IAE
—
ISE
—

Metric definitions

IAE = ∫|e| dt and ISE = ∫e² dt over the full run. Measurement is interpolated linearly between samples. Reference is held over each interval.

Overshoot is the peak excursion beyond the target in the direction of the latest reference step, as a percentage of step size. At startup the initial measurement is the baseline. Load or mode changes restart evaluation. Overshoot is undefined for a load change or manual operation.

Settling requires ≥3 s and ≥3 intervals inside ±2% of the step size (or setpoint magnitude), at least ±0.001 units. The check also considers the current command and commands still in transit. The final mean error describes the final samples. Steady-state error requires sufficient observation, low variation and proximity to the model equilibrium.

Compare runs

Up to four complete runs per browser tab. Select runs to overlay their traces.

Models and tuning

Parallel PID and discretisation

eₖ = rₖ − yₖ
Pₖ = Kp·eₖ
ΔIₖ = Ki·Ts·eₖ
Dₖ = (Tf·Dₖ₋₁ − Kd·(yₖ − yₖ₋₁)) / (Tf + Ts)
uₖ = clamp(Pₖ + Iₖ + Dₖ + b, Umin, Umax)

The integrator uses the current error (backward Euler). The derivative on measurement uses a first-order filter discretised by backward Euler. D starts at zero. P omits I and D, PI omits D. Zero Ki or Kd also disables the corresponding term.

With anti-windup enabled, the integral increment is limited to the available output headroom in its direction. In manual and on the first sample back in auto, I = u − P − D. If integration is disabled, the same value becomes the bias b for bumpless transfer.

Process equations and model limits

FOPDT: T·dy/dt = K·u(t−L) + d − y. The controller output is held until the next sample. Each constant input segment uses the exact exponential update. For fractional L the interval is split at the delayed command boundary. The configured prehistory output applies for t < 0.

Pump: T·dp/dt = max(0, Hₘₐₓ·(u/100)² − R·q²) − p, q = max(0, q₀ + d). The update is exponential. The model represents lumped inertia and quadratic losses. Water hammer, cavitation, and pump curves are outside its scope.

Tank: ΔV = (Qin − Qout − Qoverflow)·Ts/3600, h = V/A. Inflow is proportional to valve opening. Outflow is limited by available volume. Excess above A·H is reported as overflow. Displayed flows are interval averages and outlet demand is independent of hydrostatic head.

Scheduled steps take effect at the first sample at or after the programmed time. Steps at the final sample or later are skipped. Live inputs take priority on the same sample. A run supports up to 30,000 intervals.

What to look for when tuning

P moves the output with the error. If a nonzero command is needed at the operating point, proportional-only control without bias leaves an offset. I accumulates error and supplies the command at e ≈ 0. At saturation, accumulated error can delay recovery from the limit.

D opposes rapid movement of the measurement. Its filter limits the response to fast changes. With high gain and dead time, the controller can change output several times before the process responds. Oscillations show up in the trace. Overshoot appears when the measurement crosses and moves beyond the target.

This simulation is intended for engineering analysis and learning. Applying algorithms to real equipment requires separate calculations, testing and safety verification.