PID Control
Three terms for a fast, accurate response
A PID controller is wrapped around the plant G(s) = 1/((s+1)(s+2)) to make it follow the setpoint 1 (dashed line). The gold curve is the closed-loop step response. At first only the proportional gain Kp is on, and you see a steady-state error: the output stalls short of the setpoint. Raise the integral gain Ki and the leftover error accumulates, pushing the output all the way up to the setpoint. But the integral tends to add wobble, so raise the derivative gain Kd to press down on the change ahead of time and tame the oscillation. Tune the three gains for a response that is fast, error-free, and smooth.
Present, past, and future of the error
A PID controller takes a single error e(t), the difference between the setpoint and the output, and combines it three ways into the control input. u = Kp·e + Ki·∫e dt + Kd·de/dt. The proportional term reacts immediately in proportion to the present error: push hard when the error is large, gently when small, the most intuitive term. The integral term accumulates the error over time: even a small error, if it lingers, makes the integral grow and grow until it pushes that error out. The derivative term reacts to how fast the error is changing: if the error is falling quickly, it foresees the coming overshoot and applies the brakes early. The three look, in turn, at the present, the past, and the future of the error.
The limit of P, the accuracy of I, the stability of D
Proportional control alone leaves a steady-state error. Since the control input is u = Kp·e, for the input to hold any value in steady state the error e must be nonzero. This plant has a DC gain of 1/2, so with Kp alone the output stalls at Kp/(2+Kp), always short of the setpoint. The integral term solves this: as long as any error remains the integral keeps accumulating and raising the input, and it stops only when the error is exactly zero. So the integral drives the steady-state error to zero. In return, the integral adds a pole at the origin that delays the phase and tends to make the response wobble. The derivative term does the opposite, advancing the phase to add damping and reduce overshoot. Setting the speed with proportional, erasing the error with integral, and adding stability with derivative is the division of labor in a PID.
Tuning and real-world pitfalls
PID is the standard tool of industrial control, used for temperature, speed, position, flow, everywhere. Choosing the three gains is called tuning, and speed, overshoot, and robustness are interlocked so that raising one hurts another. The classic Ziegler–Nichols method turns off the integral and derivative and raises the proportional gain alone until the system just begins to oscillate steadily, finding the critical gain and the period of that oscillation, which is exactly the stability boundary seen in F1’s Routh and F4’s Nyquist. From there a table sets the three gains. The real world has pitfalls too. The derivative term magnifies fast changes, so it amplifies measurement noise, which is why a low-pass filter is usually placed on the derivative. And if the integral keeps accumulating while the input is stuck at a limit, it builds up an integral windup that overshoots later, which anti-windup prevents.
Back to the first screen
We wrapped a PID controller around the plant G = 1/((s+1)(s+2)) and tuned the three gains. With only the proportional gain, a steady-state error remained: the output stalled short of the setpoint. Raising the integral gain accumulated the leftover error and pulled the output up to exactly the setpoint, but the wobble grew. Raising the derivative gain pressed down on the change ahead of time, settling the oscillation and smoothing the response. Proportional took the speed, integral the accuracy, and derivative the stability, and together they made a response that was fast, error-free, and well damped. The loop we had analyzed with Routh, the root locus, Bode, and Nyquist, we have now shaped to the form we want by designing a controller.
PID shaped the response by adding three terms in the time domain. A compensator does the same thing in the frequency domain, aiming directly at the phase and gain of the Bode plot. The next unit, lead and lag compensation, inserts a small transfer function of one pole and one zero into the loop. A lead compensator lifts the phase near the crossover frequency to raise the phase margin, so like the derivative term it adds damping and speed; a lag compensator raises the gain at low frequencies to improve steady-state accuracy, so like the integral term it reduces error. What the D and I of a PID did, the compensator shows again as the shaping of phase and gain on the Bode plot.