S915 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

S9 · Lesson 15 · PID control

What the proportional, integral and derivative terms each do, the ideal and parallel forms, PID as a pair of zeros, filtering the derivative, avoiding derivative kick, and integrator windup with its cures

Somewhere around nine control loops in ten in industry run a PID controller: three terms, acting on the error now, on its accumulated past and on its trend. Thermostats, motor drives, power supplies, chemical plants and quadcopters all use it, because three knobs are enough to make most plants behave and because each knob has a clear physical meaning. This lesson takes the controller apart term by term and covers the practical details that separate a textbook PID from one that works on real hardware.

  • PI control of a first-order plant (DC gain 1, time constant 1 s), C=Kp(1+1Tis), against proportional control alone (dashed).
  • Proportional alone settles short of 1 by 1/(1+Kp). The integral term removes that error, more quickly the smaller Ti is.
  • Too small a Ti and the loop overshoots and rings: the integrator keeps pushing because it remembers the error that built up on the way.

Predict

A PI controller's integral term is Ki∫edt. While the actuator is saturated, the error stays large for several seconds. What happens when the output finally reaches the setpoint?

Name it

The three terms

u=Kp(e+1Ti∫0tedτ+Tddedt)=Kpe+Ki∫e+Kde˙

with Ki=Kp/Ti and Kd=KpTd in the parallel form.

  • P reacts to the present error. Alone, it leaves a steady error on type-0 plants.
  • I reacts to accumulated error and removes steady error (lesson 10), at the cost of phase lag.
  • D reacts to the error's slope, predicting it about Td ahead, which adds damping.

PID as zeros

C(s)=KpTiTds2+Tis+1Tis

a pole at the origin and two zeros, real when Ti≥4Td. A common design puts the zeros on the plant's slow poles.

Practical details

  • Derivative filter: a pure derivative amplifies noise without limit. Use Tds1+Tds/N with N between 5 and 20; the filter pole is at N/Td, and the D term's gain stops rising at KpN.
  • Derivative on measurement: differentiate −y instead of e, so a step in the setpoint doesn't produce an impulse ("derivative kick").
  • Anti-windup: stop integrating while the actuator is saturated (clamping), or feed the difference between the commanded and actual actuator signal back into the integrator through a gain 1/Tt (back-calculation), with Tt around TiTd.
  • Bumpless transfer: when switching from manual to automatic, initialize the integrator so the output doesn't jump.

Worked example

The motor of lesson 2, P=20/(0.016s+1), needs a speed loop with a 2 ms closed-loop time constant and no steady error. Design a PI controller.

Show the solution
  1. Put the integral zero on the plant pole. Ti=16ms
  2. The loop. It becomes a pure integrator: L=Kp⋅200.016s
  3. The closed loop. It's 1/(τcs+1) with τc=0.01620Kp
  4. Gains for 2 ms. Kp=0.01620×0.002=0.4Ki=0.4/0.016=25s−1
  5. Check the response. The step response has no overshoot and settles within 2% in 7.8 ms (3.9τ).
  6. When cancelling is safe. Cancelling a stable, well-known plant pole like this is safe; lesson 4 explains why an unstable one must never be cancelled.

Answer Kp = 0.4 and Ti = 16 ms (Ki = 25 per second), which settles within 2% in 7.8 ms with no overshoot.

Worked example

A plant P=5/((s+1)(s+5)) needs a 0.1 s closed-loop time constant. Design a PID that cancels both poles.

Show the solution
  1. Match the numerator to the plant's poles. TiTds2+Tis+1=(s+1)(s+5)/5=0.2s2+1.2s+1
  2. Read off the times. Ti=1.2sTd=0.2/1.2=0.167s
  3. The loop. L=Kp⋅55×1.2s=Kp1.2s giving τc=1.2/Kp.
  4. Gains for 0.1 s. Kp=12Ki=10Kd=2
  5. The derivative filter. In practice the derivative needs a filter, say N = 10 (a pole at 60 rad/s), which slightly changes the result.

Answer Kp = 12, Ti = 1.2 s and Td = 0.167 s, so Ki = 10 and Kd = 2.

Worked example

A PID with Kp = 2, Td = 0.1 s and a derivative filter with N = 10 acts on the error. The setpoint steps by 1. What does the derivative term do?

Show the solution
  1. High-frequency gain. The filtered derivative KpTds1+Tds/N has high-frequency gain KpN=20.
  2. The kick. A unit step in the error produces an instant kick of 20 in the output, decaying with time constant Td/N=10ms
  3. Why it matters. That spike can saturate the actuator and jolt the mechanism.
  4. The fix. Taking the derivative of the measurement instead of the error removes the kick, since the measurement can't step; disturbances still get the full derivative action.

Answer it kicks the output by 20 at the instant of the step, and the kick decays with a 10 ms time constant.

Check

A PID has Kp = 2 and Ti = 0.05 s. What's its integral gain Ki?

Check

A plant P=2/(τs+1) with τ = 50 ms gets PI control with Ti = τ. What Kp gives a closed-loop time constant of 5 ms?

Check

PI control with Ti = τ = 100 ms and Kp = 1 on a plant with DC gain 4. What's the closed-loop time constant?

Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.

Check

A PID has Ti = 2 s and Td = 0.05 s. Where is its zero nearer the origin?

Write units the way you normally would: 1.5 rad/s and 1500 mrad/s are the same answer.

Check

A derivative term Tds/(1+Tds/N) has Td = 0.1 s and N = 5. Where's the filter pole?

Write units the way you normally would: 1.5 rad/s and 1500 mrad/s are the same answer.

Check

A PI controller (Kp = 1, Ti = 0.2 s) is saturated for 8 s with an error of 10 that it can't act on. Without anti-windup, how much does its integral term grow?

Check

A PID with Kp = 2 and Td = 0.05 s has a derivative filter with N = 20, and its derivative acts on the error. The setpoint steps by 1.

(a)

How big is the derivative term's initial kick?

(b)

With what time constant does it decay?

Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.

Check

A PID in standard form has gain K, integral time T and derivative time D.

Step 1

What is Ki?

Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.

Explain why

Why does a PID's derivative term need a filter?

Practice

Keep practicing

10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.