13.2 Transfer Functions & Time Response ended on a trade. Proportional control leaves the error ; cutting it by raising the gain costs damping, and with the engine lag the overshoot grew from at to at . A PID controller adds two new tools: an integral term, which remembers the error and drives it to exactly zero, and a derivative term, which looks at how fast the error is changing and puts damping back. It runs cruise controls, thermostats, drone altitude loops and wind-tunnel speed loops. This lesson builds it on the cruise plant of the last two lessons, shows what each term buys and charges, and ends with a gain that makes the loop unstable.
Transcript
- Welcome to PID control, on the cruise plant of the last two lessons. The controller sees the error e and adds three terms: K p times the error, K i times its integral, and K d times its derivative. As a transfer function that is K p plus K i over s plus K d s. The terms answer three questions: how big is the error now, how long has it been there, and where is it heading. P is fast but leaves an offset. I keeps growing while any error remains, so the controller rests only at zero error. D opposes a speed that is changing quickly, like a damper.
- Now the hill. With P alone at K p equal 4 the step error is 0.2000, and after the hill the error doubles to 0.4000. Add integral action, K i equal 0.5. The hill dip falls from 0.4069 to 0.1850, and the speed climbs back to 1, with an error of 0.0015 at 80 seconds, the slow pole still finishing. The final value theorem explains it: the hill's transfer function has a zero at the origin, which blocks a constant disturbance. At rest the integrator holds u equal 2: it has become the memory of the hill.
- Close the loop and the characteristic polynomial is a cubic: 10 s cubed plus 11 plus K d times s squared, plus 1 plus K p times s, plus K i. The three gains set the three coefficients. Take K p equal 10 and K i equal 1. The PI loop has poles at minus 0.5 plus or minus 0.8660 i, and rings with 16.50 percent overshoot. Adding K d equal 6 raises the s squared coefficient from 11 to 17 and moves the pair to minus 0.7962 plus or minus 0.5428 i, further left and lower. Overshoot falls to 6.21 percent. D buys damping, not speed: settling grows from 8.10 to 14.28 seconds, held by the slow pole at minus 0.1077.
- When the command is clipped the loop is momentarily open, the error stays large, and the integral keeps accumulating a debt the plant never sees. That is integrator windup. Take PI with K p 4 and K i 1 and a limit of 2.5. With no anti-windup the speed overshoots by 36.53 percent and settles at 17.35 seconds. Clamping freezes the integral while the output is saturated and the error would push it deeper. Overshoot falls to 4.43 percent, settling to 13.38 seconds. Anti-windup cannot beat the limit: with the limit at 1.5 the hill needs u equal 2, and both runs end with an error of 0.4925.
- Differentiation amplifies fast changes, and noise is nothing but fast changes. A backward difference of noise of rms sigma has rms about sigma root 2 over delta t, and the D term multiplies it by K d. With sigma 0.01, K d 6 and delta t 0.01 the estimate is 8.485, and the lab measures a jitter of 8.4985 in the command. The cure is a derivative filter. A filter time constant of 0.1 seconds drops the jitter to 0.6513, a factor of thirteen, with almost no change in the response. At 0.5 it is 0.2161, at 1.0 it is 0.1579, but the filter pole comes in from the left, meets the dominant poles, and the derivative gets sluggish.
- For a first guess there is the Ziegler-Nichols reaction-curve rule, quoted from memory. Draw the tangent at the steepest point of the open-loop step, and read an apparent delay L and a time constant T. For this plant the steepest slope is 0.07743 at about 2.555 seconds, so L is 0.6429 and T is 12.9155. The rule gives K p 24.11, K i 18.75 and K d 7.75. The lab then shows poles at minus 0.3752 plus or minus 1.2355 i and minus 1.1247, overshoot 56.74 percent, and a peak command of 24.20. It aims at a loop that rings on purpose, so detune it.
- Hold K p at 4 and raise K i. At 0.5 the overshoot is 5.87 percent, with poles at minus 0.4823 plus or minus 0.3699 i. At 2 it is 46.90 percent and settling takes 26.53 seconds. At 5.5 the pair sits on the imaginary axis at plus or minus 0.7071 i, the overshoot is 101.95 percent and the response never settles. At 6 the pair has crossed to plus 0.0141 plus or minus 0.7291 i, and the response grows. The edge comes from substituting s equal i omega into the polynomial: K i equals 1.1 times 1 plus K p. At K p equal 4 that is 5.5. More integral action removes the offset faster, and then the poles slide right.
- P sets the speed and leaves an offset, I removes it, and D adds damping. The three gains set the coefficients of a cubic whose roots are the closed-loop poles. The costs are windup, noise, and a Ziegler-Nichols command that is far too large. And at K p equal 4, K i equal 6 is unstable. Lesson 13.4 is not yet written. It is meant to take the s equal i omega substitution that found the edge and turn it into the Routh-Hurwitz criterion, a stability test that needs no root finder, and the root locus, a picture of how every pole moves as one gain changes.
The plant and the setup
Every number here comes from one plant: the car of 13.1 Feedback & Block Diagrams with the s engine lag of 13.2 (assumed). With the speed deviation, the command and a hill in the same units,
The reference is a unit step at and the hill of 13.1 () arrives at s (13.1 used s; the integral needs longer to settle first). The lab runs the loop to s with RK4 at s, the controller sampled at that step.
P, I and D
The controller sees the error and forms three terms:
Textbooks also write , with and . The terms answer three questions: how big is the error now (P), how long has it been there (I), and where is it heading (D).
Proportional. Closing the loop with gives the 13.2 polynomial . At the poles are and the step error settles at . A bigger is faster with less error, but the poles climb toward the imaginary axis and the throttle jumps by on a unit step.
Integral. The term keeps growing while any error remains, so the controller rests only when . In transform terms has a pole at , so the loop gain has a free integrator: the loop is type 1 (13.2), and for a step reference . The price is a third closed-loop pole and a more oscillatory transient.
Derivative. The term opposes a speed that is changing quickly, the way a damper opposes a piston. It adds nothing at steady state; in the polynomial below it adds to the coefficient.
The closed-loop poles
Close the loop around with the ideal PID. The loop gain is , and becomes
With the factor cancels and P and PD return to a quadratic. The three gains set the three coefficients: the one, the one, the constant.
The lab’s measurements ( s, unit step at , hill at s): overshoot and settling are read from the true speed before the hill; the errors are ; the dip is how far below the speed falls after the hill; the peak is the largest the PID formula asks for before the hill.
| controller | poles | overshoot | settling | error at 40 s | worst dip | error at 80 s | peak |
|---|---|---|---|---|---|---|---|
| P: | never | ||||||
| PI: | s | ||||||
| PI: | s | ||||||
| PID: | s |
The P row is the loop of 13.2: error , then after the hill. With an integral term both go to zero (the is the slow pole at still finishing). A rough estimate keeps the last two terms, , so the slow pole is near : against the true for , and against for .
Worked example: the PI poles by hand. For , the polynomial is : the roots sum to and multiply to . The lab’s and sum to and multiply to . The pair has and .
The hill and the integral
The hill enters after the engine lag, so the closed-loop transfer function from to is
A constant hill is , so the final value theorem gives whenever and the loop is stable: the factor is a zero of the disturbance path at the origin, which blocks a constant disturbance. With the same calculation gives , the dent of 13.1.
In the lab the dip falls from with P alone to with PI at , and the speed returns to . What does the integrator hold at the end? At rest with gives , so . With the other terms vanish, so the integral state itself is : it has become the memory of the hill.
Derivative action and damping
For , the PI loop has poles and rings: overshoot. Adding raises the coefficient from to and moves the pair to : further left and lower, so the damping ratio rises. Overshoot falls to and the hill dip from to . D buys damping, not speed: settling goes from s to s, because the slow integral pole at holds the tail.
The lab takes the derivative of the measurement: . The error’s derivative differs only when the reference jumps, where it is an infinite spike (the “derivative kick”, from memory of standard practice). The poles are unchanged, since the polynomial only knows about the loop.
Noise and the derivative filter
Differentiation amplifies fast changes, and noise is nothing but fast changes. White noise of rms sampled every gives a backward difference of rms about (two independent samples differ with variance ), and the D term multiplies it by . For , and s the estimate is ; the lab measures an rms jitter of in the PID output over to s. The P term passes only : the lab’s PI at measures . The car barely feels it (speed jitter in every run below), but a real throttle would be shaken to pieces.
The cure is a derivative filter: replace by . The lab implements it on the measurement as , a plain backward difference at . The polynomial becomes , one degree higher, with an extra pole near . For , , :
| (s) | PID output jitter | overshoot | settling | extra poles |
|---|---|---|---|---|
| s | none | |||
| s | ||||
| s | pair at | |||
| s | pair at |
At s the jitter falls by a factor of thirteen with almost no change in the response. The cost grows with : the filter pole comes in from the left ( against the naive ), meets the dominant poles, and the derivative gets sluggish. A rule of thumb (from memory) is between and ; here s, so to s.
Windup and anti-windup
Real actuators saturate. When the command is clipped the loop is momentarily open: the error stays large and the integral keeps accumulating a debt the plant never sees. That is integrator windup. When the car nears the reference the integral state is far too large, and the speed overshoots until the error has been negative long enough to unwind it.
In the lab take PI with , and limit (the step asks for , so it saturates at the start):
| anti-windup | overshoot | settling | worst dip after the hill | error at 80 s |
|---|---|---|---|---|
| off | s | |||
| clamping | s |
Windup costs points of overshoot; the hill is handled identically, since the it needs is within the limit.
Clamping (conditional integration) does not integrate when the output is saturated and the error would drive it deeper in. With the PID output and the clipped one,
The sign test lets the integral keep working in the direction that leads out of saturation.
Anti-windup cannot beat the limit. With the limit at the hill needs and the car cannot hold the speed: both runs end with error at s, near the that predicts. Clamping only guarantees a clean recovery (overshoot against with it off).
Tuning: from intuition to Ziegler-Nichols
A workable order: raise until the loop starts to ring; add just enough to kill the offset in the time you can wait; add to restore damping; then check noise and saturation.
Ziegler-Nichols gives a first guess. The reaction-curve rule (from memory) steps the open-loop plant, draws the tangent at the steepest point, and reads an apparent delay (where the tangent crosses zero) and a time constant for unit static gain. For PID: , , , so and . (The other method needs the ultimate gain at which P control sustains an oscillation. It cannot be used here: has positive coefficients for every , so the P loop never oscillates.)
For this plant the lab finds a steepest slope of at about s, so s and s, hence , s, s, , . The button loads , and : poles and , overshoot , settling s, hill dip , peak command . The recipe aims (from memory) at quarter-amplitude decay, a loop that rings on purpose, and a -fold command is more than a throttle supplies: detune it.
Where PID shows up in the physics
The yaw damper of 12.6 Lateral-Directional Modes was the D term of a heading controller: the yaw rate is the derivative of heading, and feeding it back moved the Dutch roll pole left. A heading autopilot adds P on the heading error and often I, so a steady crosswind leaves no standing error. An altitude hold around 12.5 Trim, Linearization & Longitudinal Modes has the same structure, with elevator rate limits as the saturation that makes anti-windup a safety matter.
More worked examples
The edge of stability, by hand. At the edge a pair sits at . Substituting into , the real part is and the imaginary part is . Both vanish when and . For : and , and has the third pole at .
Concept checks
Playground and exercise
The same loop in plain Python, with every part of the lab: the filtered derivative on the measurement, the clamp, and an RK4 plant step with the command held over each .
Now implement the four building blocks of the lesson: the polynomial, the stability edge, the filtered derivative and the clamped integral.
Problems
The cruise plant with the engine lag is under PI control with . Write the characteristic polynomial for , and find the largest stable and the oscillation frequency there.
Show worked solution
The polynomial is ; a numerical root finder gives and , all in the left half plane. At the edge : the real part and the imaginary part give , so rad/s and , which is . Check: .
With , a hill and a stable PI loop, find the steady-state speed, the steady-state command , and the integral state. If the actuator limit is , find the steady-state speed and error.
Show worked solution
Zero error means . At rest and , so . With the P and D terms vanish, so the integral state is . A limit of is below this: the speed settles where , an error of , whatever the controller does.
A plant with unit static gain has a step response whose tangent at the steepest point crosses zero at s and reaches at with s. Use the reaction-curve rules (from memory: , , ) to find , and . Then explain why the lesson’s cruise plant gives a much larger .
Show worked solution
, s so , s so . The cruise plant has s, much shorter relative to s: , against here, so . The rule says a plant with a short effective delay can be driven hard.
What comes next
The ladder is the warning. At the lab gives overshoot at (poles , ) and at (poles , , settling s). At the pair sits on the imaginary axis at (, never settles), and at it has crossed to and the response grows. More integral action removes the offset faster, and then the poles slide right. The edge came from substituting : the idea behind the Routh-Hurwitz criterion and the root locus of lesson 13.4 (13.4 Stability: Routh–Hurwitz & Root Locus), a stability test that needs no root finder and a picture of how every pole moves as one gain changes.
Key Takeaways
- PID is , : P sets speed and leaves an offset, I removes it by adding a pole at the origin, D adds damping.
- The cruise loop with the engine lag has polynomial . PI at : poles , (). PID at : , ( against for PI at ).
- With the hill gives zero steady-state error (the integral ends at ).
- Windup: with a limit of clamping cuts overshoot from to ; no anti-windup can fix a limit below what the hill needs.
- The derivative amplifies noise by : jitter at , at s; the price is a filter pole near .
- Ziegler-Nichols (from memory) gives , , here: overshoot, peak command .
- Raising at ends in instability at .