seegongsik
Saved words
SC · Control

PID Control

A PID controller responds to the error in three ways. Proportional (P) reacts to the present error, integral (I) to the accumulated past error, and derivative (D) to the changing trend. Move the three gains and watch the integral erase the steady-state offset that P alone leaves, and the derivative tame the overshoot, until the response is fast, accurate, and smooth.

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.

closed-loop step response (dashed = setpoint)
proportional gain Kp4.0
integral gain Ki0.0
derivative gain Kd0.0
The three gains and the response
Kp = 4.0 · Ki = 0.0 · Kd = 0.0
steady error = 0.33 · overshoot = 0.00
With the integral gain small, the output has stalled short of the setpoint. With the proportional term alone, an error must remain to produce any control input, so the steady-state error cannot reach zero. Raise the integral gain Ki to accumulate the leftover error and pull the output up to the setpoint.
Large error or ringing

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.

Observeu(t) = Kp·e + Ki·∫e dt + Kd·de/dt
PID responds to the error with three terms.
Chooseremoves steady-state offset: the ?
The integral term erases steady-state error.
Fill inadds damping, cuts overshoot: the ?
The derivative term adds damping, reducing overshoot.
On your ownthe D term amplifies ?
Derivative amplifies noise, so it is usually filtered.

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.

A PID controller u = Kp·e (proportional, present error) + Ki·∫e dt (integral, accumulated past) + Kd·de/dt (derivative, trend of change) responds to a single error with three terms. Proportional sets the speed but leaves a steady-state error; integral accumulates until the error is zero, erasing the steady-state error (at the cost of phase lag); derivative reads the change ahead and adds damping, reducing overshoot (at the cost of amplifying noise, needing a filter). Tuning is a trade-off of speed, overshoot, and robustness, and Ziegler–Nichols starts from the critical gain (the stability boundary of F1 and F4). The closed-loop characteristic polynomial is s³+(3+Kd)s²+(2+Kp)s+Ki.
On to the next unit

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.