$K_p=1.2\,\tau/(K\cdot L),\quad T_i=2L,\quad T_d=0.5L$
Adjust Kp, integral time Ti, and derivative time Td to see closed-loop step response in real time. Compare P-only, PI, and PID control — and discover how each gain affects overshoot, settling time, and IAE.
The core of PID control is the control law, which calculates the command signal $u(t)$ sent to the actuator (like a valve or motor) based on the error $e(t) = SP - PV$, where SP is the Setpoint and PV is the Process Variable.
$$u(t)=K_p\!\left[e(t)+\frac{1}{T_i}\!\int_0^t\!e\,d\tau+T_d\frac{de}{dt}\right]$$$K_p$: Proportional Gain. Scales the current error.
$T_i$: Integral Time (seconds). A smaller Ti means stronger integral action.
$T_d$: Derivative Time (seconds). A larger Td means stronger damping.
The combination of these three terms allows the controller to correct present, past, and future trends of the error.
One classic method for initial tuning is the Ziegler-Nichols step response method. It uses the process's open-loop response, characterized by a delay $L$ and a time constant $\tau$, to suggest starting parameters.
$$K_p=1.2\,\frac{\tau}{K \cdot L},\quad T_i=2L,\quad T_d=0.5L$$These are just starting points. In practice, you use them as a baseline and then fine-tune using a simulator like this one—or carefully on the real system—to achieve the desired balance of speed, overshoot, and stability.
PID control determines the manipulated variable $u$ by combining three actions—proportional (P), integral (I), and derivative (D)—applied to the difference between the setpoint and the current value (the error $e$).
$u(t) = K_p\,e(t) + K_i\!\int_0^t\! e\,d\tau + K_d\,\dfrac{de}{dt}$
| Term | Action | Effect and side effect |
|---|---|---|
| Proportional P ($K_p$) | Proportional to the error | Speeds up the response but leaves a steady-state error; too large causes oscillation |
| Integral I ($K_i$) | Accumulation of the error | Eliminates the steady-state error but induces overshoot |
| Derivative D ($K_d$) | Rate of change of the error | Stabilizes and anticipates the response but is sensitive to noise |
Adjusting each gain (tuning) governs the control performance. In the well-known Ziegler–Nichols method, you switch off I and D, raise $K_p$ until the system sustains oscillation to find the ultimate gain $K_u$ and oscillation period $T_u$, and then set $K_p, K_i, K_d$ from empirical formulas.
In general the basic strategy is: faster rise = increase $K_p$, eliminate steady-state error = increase $K_i$, and suppress overshoot/oscillation = increase $K_d$. However, excessive gains lead to instability, so adjust while watching the response (rise time, overshoot, settling time). In this simulator you can vary each gain and observe how the step response changes.
Chemical Process Control: In a distillation column, temperature must be held precisely to separate chemicals. A PID controller adjusts steam flow to a heater. The integral term (Ti) is crucial here to eliminate any steady-state error, ensuring the final product purity is exactly on spec.
Automotive Cruise Control: Your car's cruise control uses PID to maintain speed on hills. The proportional term (Kp) adjusts throttle based on speed error, the integral term compensates for the hill's grade, and the derivative term (Td) smooths out the response when you suddenly set a new target speed.
CNC Machine & 3D Printer Positioning: The motor controlling the toolhead must move to an exact position quickly and without oscillation. PID tuning is critical here; too much integral can cause overshoot and ruin a part, while derivative helps dampen vibrations for a clean stop.
Drone Flight Stabilization: Drones use PID loops for attitude control (pitch, roll, yaw). The gyroscope provides feedback. The derivative term is especially important to prevent "jerky" movements and provide smooth, stable flight against wind gusts.
First, there is a misconception that "shorter integral time (Ti) is always better." While reducing Ti (strengthening the integral gain) does eliminate steady-state error faster, setting it excessively short can destabilize the system, causing sustained oscillations (including the risk of integral windup). For example, setting Ti to an extremely low value like 0.1 seconds should cause the graph to oscillate back and forth around the setpoint without settling. In practice, the key is to first tune the proportional gain (Kp) to establish the basic response, then adjust Ti within a range that does not induce oscillations.
Next, understand that the derivative action (D) is not a "universal predictive function." While derivative does predict the rate of change, it is extremely sensitive to noise. Real sensor signals always contain noise, and differentiating this noise can amplify it into huge control signals. Therefore, in actual hardware, it's common to set the derivative gain modestly or to use a low-pass filter in conjunction with the derivative action. Note that simulators use ideal signals, making it difficult to appreciate this risk in practice.
Finally, remember that the Ziegler-Nichols method is a "starting point," not an "optimal solution." The parameters obtained from this method tend to be somewhat aggressive (with significant overshoot) and do not necessarily ensure high robustness (strength against disturbances). For instance, after running a simulation with ZN-tuned parameters, fine-tuning—such as slightly lowering Kp and raising Ti to reduce overshoot—is essential. The practical approach is not "set once and forget," but rather to observe the actual response and make adjustments, considering the trade-offs (response speed vs. stability).
For a first-order process with time constant τ=2 s and gain 1, setting SP=1.0, Kp=2.0, Ti=3.0 s, and Td=0.5 s yields rise time tr≈4.1 s, settling time ts≈8.2 s, overshoot 0%, and IAE≈1.5. Increasing Kp to 4.0 shortens the rise time to tr≈2.1 s and the settling time to ts≈3.7 s, with IAE dropping to about 0.75 — for a lag-only plant with no dead time, raising Kp speeds up the response without inducing oscillation.
Standard/formula: standard (non-interacting) PID: u(t) = Kp[e + (1/Ti)∫e dτ + Td·de/dt] (ISA / textbook form). Ziegler–Nichols open-loop (reaction-curve) tuning for a FOPDT plant K·e^(−Ls)/(τs+1): Kp = 1.2τ/(K·L), Ti = 2L, Td = 0.5L.
Assumptions: single-loop SISO; the plant (first-order-plus-dead-time / second-order / integrator) is integrated by forward Euler. The derivative term is filtered (τ_f = Td/8) for noise rejection and the integral is clamped (anti-windup). Verification confirms zero steady-state offset under PI control (0.9999 against a setpoint of 1.0).
Scope & limits: educational continuous-time approximation with fixed step dt=0.02 s; actuator saturation fixed at ±10; no measurement noise, quantization, or discrete-time tuning (e.g. Tustin). ZN gains are a starting point and normally require field trimming.