WEBVTT

00:00:00.058 --> 00:00:02.787
You already know what
a feedback controller does.

00:00:02.984 --> 00:00:05.049
This lecture is about
a different question,

00:00:05.132 --> 00:00:09.324
and it is the question most
of classical control is actually built on.

00:00:09.427 --> 00:00:13.013
Not what a plant does to a step,
but what it does to a sine wave,

00:00:13.096 --> 00:00:14.978
one frequency at a time.

00:00:15.174 --> 00:00:16.834
Answer that for every frequency

00:00:16.834 --> 00:00:20.469
and you have said everything there
is to say about a linear system.

00:00:21.552 --> 00:00:23.155
So here is the setup.

00:00:23.352 --> 00:00:24.581
Take a plant that is linear

00:00:24.664 --> 00:00:29.295
and time invariant, and drive it with
a pure sine wave. Because it is linear,

00:00:29.378 --> 00:00:33.953
whatever comes out is also a sine
wave, at exactly the same frequency.

00:00:34.150 --> 00:00:36.344
Nothing else is possible, so only two

00:00:36.344 --> 00:00:41.685
things can differ between what goes in and
what comes out: the size, and the timing.

00:00:42.900 --> 00:00:46.868
Let me make that concrete with the
simplest plant there is, a single lag,

00:00:46.951 --> 00:00:48.938
one over s plus one.

00:00:49.134 --> 00:00:52.664
Drive it slowly, at a fifth
of a radian per second.

00:00:52.768 --> 00:00:54.763
The grey curve is what we push in,

00:00:54.846 --> 00:00:59.514
the blue curve is what comes back out,
and time runs along the bottom in seconds.

00:01:00.566 --> 00:01:03.572
Honestly, the two waves
are almost the same wave.

00:01:03.655 --> 00:01:06.730
The output stands ninety eight
percent as tall as the input,

00:01:06.813 --> 00:01:09.681
and it trails behind it
by about eleven degrees.

00:01:09.878 --> 00:01:12.918
At this frequency the plant
is barely doing anything at all.

00:01:13.001 --> 00:01:16.427
Ask it to move slowly,
and it simply follows.

00:01:17.339 --> 00:01:19.813
One thing I am quietly assuming here.

00:01:19.917 --> 00:01:22.158
These are steady state pictures.

00:01:22.471 --> 00:01:26.593
Switch the drive on and there
is a transient while the plant settles.

00:01:27.045 --> 00:01:31.225
Frequency response is what is left
after that transient has died away.

00:01:32.022 --> 00:01:35.157
Now speed the drive up
to one radian per second.

00:01:35.354 --> 00:01:38.130
Same plant, same amplitude going in.

00:01:38.326 --> 00:01:39.325
The output has dropped

00:01:39.325 --> 00:01:44.108
to seventy one percent of it, and it
is now a full forty five degrees behind.

00:01:44.305 --> 00:01:46.918
That is an eighth of a cycle of lag.

00:01:47.715 --> 00:01:51.930
And at five radians per second
the plant has more or less given up.

00:01:52.242 --> 00:01:55.375
The output is only two tenths
of the input amplitude now,

00:01:55.458 --> 00:01:59.279
and it lags by seventy nine
degrees, closing in on ninety.

00:01:59.475 --> 00:02:01.659
Notice the pattern that is forming.

00:02:01.856 --> 00:02:03.293
As the frequency climbs,

00:02:03.376 --> 00:02:07.290
the output shrinks, and it
falls further and further behind.

00:02:08.504 --> 00:02:11.243
Both of those numbers come
out of one piece of algebra,

00:02:11.326 --> 00:02:13.079
and you have seen it before.

00:02:13.276 --> 00:02:16.911
Put s equal to j omega
in the transfer function.

00:02:17.107 --> 00:02:21.369
What comes back, for each frequency,
is a single complex number.

00:02:22.072 --> 00:02:24.718
Its magnitude is the amplitude ratio:

00:02:24.801 --> 00:02:27.890
how much taller or shorter
the output is than the input.

00:02:28.086 --> 00:02:29.698
Its argument is the phase shift,

00:02:29.781 --> 00:02:33.323
in degrees, and it
is negative when the output lags.

00:02:33.520 --> 00:02:35.445
Two real numbers per frequency,

00:02:35.528 --> 00:02:38.652
and that pair is the whole
of the frequency response.

00:02:39.449 --> 00:02:42.201
One convention before we plot any of it.

00:02:42.514 --> 00:02:45.080
We do not plot the magnitude directly.

00:02:45.184 --> 00:02:48.784
We plot twenty times
its logarithm, in decibels.

00:02:48.980 --> 00:02:51.138
The reason is pure arithmetic.

00:02:51.221 --> 00:02:55.192
A transfer function is a product
of factors, and taking logarithms turns

00:02:55.192 --> 00:02:58.710
that product into a sum
of curves you can add up by eye.

00:02:59.251 --> 00:03:02.387
And the frequency axis
is logarithmic as well.

00:03:02.699 --> 00:03:07.263
Every unit along it is one decade,
a factor of ten in frequency.

00:03:07.367 --> 00:03:10.130
So the axis we are about
to use runs from a tenth

00:03:10.130 --> 00:03:15.587
of a radian per second on the left to a
hundred on the right, in three even steps.

00:03:16.384 --> 00:03:20.063
So here is the magnitude
of that single lag, in decibels,

00:03:20.146 --> 00:03:22.561
against the logarithm of frequency.

00:03:22.665 --> 00:03:27.168
And here are the three experiments we just
ran, sitting on it as three green dots:

00:03:27.251 --> 00:03:29.678
a fifth, one, and five.

00:03:30.475 --> 00:03:34.945
Flat and unbothered on the left, where
the plant follows whatever it is given.

00:03:35.142 --> 00:03:38.858
Falling away steadily
on the right, where it cannot keep up.

00:03:39.055 --> 00:03:42.596
The table beside it is those same
three readings written out.

00:03:43.393 --> 00:03:47.841
Underneath goes the phase,
in degrees, on the same frequency axis.

00:03:48.037 --> 00:03:52.809
Zero at low frequency, minus ninety at
high frequency, and passing through minus

00:03:52.809 --> 00:03:57.732
forty five right at one radian per second,
which is exactly where the pole is.

00:03:58.529 --> 00:04:01.069
Now look hard at what
those two curves nearly are.

00:04:01.152 --> 00:04:03.740
The magnitude is nearly
two straight lines:

00:04:03.823 --> 00:04:08.549
flat, then falling at twenty decibels
per decade, and they meet at the pole.

00:04:09.163 --> 00:04:13.425
The phase is nearly three straight
lines, hinged a decade either side of it.

00:04:14.222 --> 00:04:16.832
That is not a coincidence
and it is not a drawing trick.

00:04:16.915 --> 00:04:20.851
It falls out of the algebra, and in
the next part we work out exactly where it

00:04:20.851 --> 00:04:25.310
comes from, factor by factor, until
sketching one of these is arithmetic.

00:04:25.793 --> 00:04:27.127
Then we close the loop.

00:04:27.210 --> 00:04:29.599
And I will show you why
one particular frequency,

00:04:29.682 --> 00:04:33.001
the one where the phase reaches
minus one hundred and eighty degrees,

00:04:33.084 --> 00:04:35.894
decides whether the closed
loop is stable at all.

00:04:35.998 --> 00:04:39.967
Gain margin and phase margin are the two
numbers that live at that frequency,

00:04:40.050 --> 00:04:41.339
and by the end you will read both

00:04:41.339 --> 00:04:43.267
of them straight off these curves.

00:04:44.361 --> 00:04:48.844
So why decibels, and why
a logarithmic frequency axis.

00:04:49.040 --> 00:04:53.592
Here is the answer, and it is the only
reason those two conventions exist.

00:04:53.696 --> 00:04:55.829
A transfer function is a product:

00:04:55.913 --> 00:05:00.836
a constant out front, some factors
upstairs, some factors downstairs.

00:05:01.540 --> 00:05:06.580
Take twenty times the logarithm of the
magnitude, and that product becomes a sum.

00:05:06.776 --> 00:05:10.155
Every factor on top adds
its own decibel curve.

00:05:10.352 --> 00:05:12.845
Every factor on the bottom subtracts one.

00:05:12.929 --> 00:05:14.486
Nothing else happens.

00:05:15.190 --> 00:05:18.159
And the angle of a product
is the sum of the angles anyway,

00:05:18.243 --> 00:05:22.760
so the phase adds in exactly the same
pattern, with no logarithm needed.

00:05:23.212 --> 00:05:25.848
Two sums, one for each curve.

00:05:26.389 --> 00:05:31.382
So if I can draw four simple curves, I can
draw any Bode plot by stacking them up.

00:05:31.579 --> 00:05:33.890
Let me take those four one at a time.

00:05:34.686 --> 00:05:39.539
The first one is trivial. A constant
gain K. Its magnitude does not depend

00:05:39.539 --> 00:05:44.637
on frequency at all, so in decibels it
is a horizontal line at twenty log K.

00:05:44.833 --> 00:05:48.515
With K equal to two,
that sits at six decibels.

00:05:48.618 --> 00:05:51.216
And a positive real number has no angle,

00:05:51.300 --> 00:05:54.320
so it contributes nothing
whatsoever to the phase.

00:05:55.116 --> 00:05:58.995
The second one
is an integrator, one over j omega.

00:05:59.191 --> 00:06:01.371
Its magnitude is one over omega,

00:06:01.455 --> 00:06:05.497
so in decibels it is minus
twenty times the logarithm of omega.

00:06:05.693 --> 00:06:09.990
That is a straight line,
exactly, at every frequency.

00:06:10.786 --> 00:06:13.338
And you can read the slope
off it by arithmetic.

00:06:13.422 --> 00:06:18.620
At one radian per second it is zero
decibels. At ten, it is minus twenty.

00:06:18.704 --> 00:06:24.057
At a hundred, minus forty. Every
decade costs twenty decibels, forever.

00:06:25.272 --> 00:06:27.374
Its phase is easier still.

00:06:27.478 --> 00:06:30.973
One over j is minus j,
which points straight down.

00:06:31.170 --> 00:06:35.571
Minus ninety degrees, at every
frequency, with no bend in it anywhere.

00:06:36.367 --> 00:06:39.464
The third block is the one
that actually earns its keep:

00:06:39.548 --> 00:06:44.146
a real pole, written so that it
equals one at zero frequency.

00:06:44.250 --> 00:06:48.140
One over one plus j omega over omega p.

00:06:48.244 --> 00:06:51.437
Take it to its two limits
and everything falls out.

00:06:52.141 --> 00:06:56.051
Well below the corner,
omega over omega p is tiny,

00:06:56.135 --> 00:06:58.725
so the denominator is essentially one.

00:06:59.038 --> 00:07:00.629
The factor is one.

00:07:00.826 --> 00:07:02.948
Zero decibels, and no phase.

00:07:03.032 --> 00:07:04.867
That is the flat piece.

00:07:05.780 --> 00:07:07.066
Well above the corner,

00:07:07.150 --> 00:07:11.423
the one is negligible
and the factor is omega p over j omega.

00:07:11.526 --> 00:07:14.592
That is an integrator again, scaled.

00:07:14.789 --> 00:07:19.910
So it falls at twenty decibels per
decade, and its phase is minus ninety.

00:07:20.521 --> 00:07:22.262
So we have a flat line at zero

00:07:22.262 --> 00:07:26.079
on the left, a falling line
at minus twenty on the right,

00:07:26.163 --> 00:07:31.783
and they cross where omega equals omega
p, which here is two radians per second.

00:07:31.980 --> 00:07:36.253
That crossing is what everybody calls
the corner, or the break frequency.

00:07:37.050 --> 00:07:39.245
Now, how wrong is that sketch.

00:07:39.557 --> 00:07:42.144
Right at the corner
the denominator is one plus j,

00:07:42.228 --> 00:07:47.615
whose magnitude is root two, and twenty
log of root two is minus three decibels.

00:07:47.812 --> 00:07:50.119
Three decibels below
the corner of the sketch,

00:07:50.203 --> 00:07:52.654
and that is the worst it ever gets.

00:07:53.450 --> 00:07:57.058
Half a decade either side of the corner
the error is down to one decibel,

00:07:57.142 --> 00:08:00.066
and a decade out it
is under a quarter of one.

00:08:00.150 --> 00:08:02.550
So the straight lines are not a cartoon.

00:08:02.634 --> 00:08:06.257
They are the truth to within
three decibels, everywhere.

00:08:07.054 --> 00:08:11.571
The phase needs one more rule, and it
is a convention rather than a theorem.

00:08:11.884 --> 00:08:16.861
Zero below a decade under the corner,
minus ninety above a decade over it,

00:08:16.945 --> 00:08:20.928
and a straight ramp of minus forty
five degrees per decade joining them.

00:08:21.632 --> 00:08:26.018
At the corner itself the ramp is halfway
down, at minus forty five degrees,

00:08:26.102 --> 00:08:27.891
and that one is exact:

00:08:28.087 --> 00:08:32.419
one over one plus j has an angle
of minus forty five, precisely.

00:08:32.871 --> 00:08:37.516
The worst error in the ramp is about
six degrees, out near its two hinges.

00:08:38.312 --> 00:08:41.363
And the fourth block is the same
numbers with every sign flipped,

00:08:41.447 --> 00:08:44.269
because a zero is a pole moved upstairs.

00:08:44.466 --> 00:08:47.853
Flat, then rising
at twenty decibels per decade.

00:08:47.937 --> 00:08:51.084
Zero degrees,
then a ramp up to plus ninety.

00:08:51.509 --> 00:08:53.681
That is the whole vocabulary.

00:08:53.878 --> 00:08:57.488
Four shapes, and a Bode plot is what
you get when you add up however many

00:08:57.488 --> 00:08:59.520
of them your plant happens to have.

00:09:00.662 --> 00:09:03.333
Written out as a table, that is it.

00:09:03.529 --> 00:09:08.116
A gain moves the whole magnitude curve
up or down and touches nothing else.

00:09:08.313 --> 00:09:12.687
An integrator tilts it by twenty decibels
per decade and drops the phase by ninety,

00:09:12.771 --> 00:09:14.478
at every frequency.

00:09:15.275 --> 00:09:19.127
A zero puts a bend upward
in the magnitude at its own frequency,

00:09:19.211 --> 00:09:23.623
and hands you ninety degrees
of phase lead spread across two decades.

00:09:23.820 --> 00:09:29.150
A pole does the mirror image: a bend
downward, and ninety degrees of lag.

00:09:29.946 --> 00:09:32.672
And the two error facts
are worth memorising,

00:09:32.756 --> 00:09:36.414
because they are the whole difference
between the sketch and the truth.

00:09:36.610 --> 00:09:41.278
Three decibels at each corner,
and a decade either side for the phase.

00:09:41.730 --> 00:09:43.589
Nothing else is approximate.

00:09:44.292 --> 00:09:46.437
So the straight lines are not magic.

00:09:46.521 --> 00:09:48.902
They are two limits and a hinge.

00:09:49.099 --> 00:09:50.213
Now let me stack them,

00:09:50.213 --> 00:09:53.999
on a plant with a pole, another
pole, and an integrator in it.

00:09:55.145 --> 00:09:58.281
Here is the plant we will carry
for the rest of the lecture.

00:09:58.593 --> 00:10:03.656
Forty, over s times s
plus two times s plus ten.

00:10:03.853 --> 00:10:09.461
Third order, one integrator, two real
poles, and nothing exotic anywhere in it.

00:10:10.165 --> 00:10:13.891
Before we can stack anything we
have to rewrite it, because our four

00:10:13.891 --> 00:10:18.617
building blocks all equal one at low
frequency and these brackets do not.

00:10:19.069 --> 00:10:23.110
So pull a two out of the first
bracket, and a ten out of the second.

00:10:23.651 --> 00:10:28.354
Forty over twenty leaves two, and now
every factor is in the right shape.

00:10:28.458 --> 00:10:29.536
Read them off.

00:10:29.619 --> 00:10:32.499
A gain of two, worth six decibels.

00:10:32.811 --> 00:10:34.194
One integrator.

00:10:34.390 --> 00:10:37.828
A pole at two radians per
second, and a pole at ten.

00:10:38.024 --> 00:10:42.994
Those four items are the entire plant,
and they are the entire Bode plot.

00:10:43.791 --> 00:10:45.405
So let us draw it.

00:10:45.602 --> 00:10:49.292
I will lay the magnitude down
first, one segment at a time,

00:10:49.375 --> 00:10:51.674
and check a number at every break.

00:10:52.471 --> 00:10:57.545
Start at the far left of the magnitude
plot, at a tenth of a radian per second.

00:10:58.160 --> 00:11:03.141
Down there both poles are still asleep,
because we are well below both corners.

00:11:03.453 --> 00:11:07.227
So only the gain and the integrator
are doing anything at all.

00:11:08.024 --> 00:11:10.091
Six decibels from the gain.

00:11:10.195 --> 00:11:13.934
And the integrator is worth plus twenty
down there, because it costs twenty per

00:11:13.934 --> 00:11:17.801
decade and we are one decade
below one radian per second.

00:11:18.114 --> 00:11:19.946
Six plus twenty is twenty six,

00:11:20.029 --> 00:11:23.896
and from there the line comes down
at twenty decibels per decade.

00:11:24.693 --> 00:11:29.477
That segment runs until the first
pole wakes up, at omega equal to two.

00:11:29.673 --> 00:11:31.752
Where has the line got to by then?

00:11:31.949 --> 00:11:36.442
Six from the gain, minus twenty
log of two, which is another six.

00:11:36.639 --> 00:11:39.600
It arrives at exactly zero decibels.

00:11:40.397 --> 00:11:43.578
And past that corner the pole
adds its own twenty per decade

00:11:43.578 --> 00:11:45.413
on top of the integrator's.

00:11:45.610 --> 00:11:48.139
So the slope steepens to minus forty,

00:11:48.222 --> 00:11:51.473
and the second segment falls
twice as fast as the first.

00:11:52.386 --> 00:11:54.242
It runs from two up to ten,

00:11:54.325 --> 00:11:58.435
which is log ten of five,
about seven tenths of a decade.

00:11:58.632 --> 00:12:02.798
At forty decibels a decade,
that is twenty eight decibels lost,

00:12:02.881 --> 00:12:06.121
so we reach the second
corner at minus twenty eight.

00:12:07.034 --> 00:12:11.502
Beyond ten the second pole joins
in as well, so the slope steepens again,

00:12:11.585 --> 00:12:15.974
to minus sixty decibels per
decade, and it never comes back up.

00:12:16.078 --> 00:12:20.885
Three segments, three slopes,
and every number in them was arithmetic.

00:12:21.682 --> 00:12:25.058
Now here is the exact
curve, drawn over the top.

00:12:25.141 --> 00:12:28.949
It hugs the skeleton everywhere,
except that it rounds each corner off

00:12:28.949 --> 00:12:33.049
and sits about three decibels
below it, exactly as we worked out.

00:12:34.263 --> 00:12:37.979
The phase is built the same
way, and it starts lower down.

00:12:38.431 --> 00:12:43.006
The integrator hands us minus ninety
degrees at every frequency, so the phase

00:12:43.006 --> 00:12:48.045
begins at minus ninety on the left and
does not move until the first ramp starts.

00:12:48.842 --> 00:12:53.670
The pole at two begins bending a decade
below itself, at nought point two,

00:12:53.753 --> 00:12:56.610
and finishes a decade above, at twenty.

00:12:56.806 --> 00:13:00.464
So this second piece falls
at forty five degrees per decade.

00:13:01.377 --> 00:13:05.473
But at one radian per second
the pole at ten begins its own ramp,

00:13:05.556 --> 00:13:07.786
and now both are running together.

00:13:08.099 --> 00:13:11.510
Two ramps at forty five each
make ninety degrees per decade,

00:13:11.593 --> 00:13:14.903
so this middle piece
is the steepest part of the whole curve.

00:13:15.700 --> 00:13:20.272
The first ramp finishes at twenty,
and after that only the second is left,

00:13:20.355 --> 00:13:24.779
so we go back to forty five per decade and
settle at minus two hundred and seventy.

00:13:24.976 --> 00:13:28.262
Ninety from the integrator,
and ninety from each pole.

00:13:28.966 --> 00:13:31.855
And there is the exact
phase over the top of that,

00:13:31.938 --> 00:13:34.493
never more than a few
degrees from the hinges.

00:13:34.689 --> 00:13:38.637
Two curves, built out of nothing
but four factors and a ruler.

00:13:39.341 --> 00:13:42.509
Two frequencies on these curves
matter more than all the others,

00:13:42.592 --> 00:13:44.984
and the rest of the lecture is about them.

00:13:45.181 --> 00:13:48.316
The first is where the phase
passes through minus one hundred

00:13:48.316 --> 00:13:49.698
and eighty degrees.

00:13:50.123 --> 00:13:51.912
You can find it exactly.

00:13:52.108 --> 00:13:54.846
Set the phase equal to minus one eighty.

00:13:54.929 --> 00:13:57.122
The integrator
has already spent the ninety,

00:13:57.205 --> 00:14:01.385
so the two arctangents have to add
up to ninety degrees between them.

00:14:02.089 --> 00:14:05.953
Two angles summing to ninety means
their tangents multiply to one,

00:14:06.036 --> 00:14:10.146
and running that through the addition
formula leaves one minus omega squared

00:14:10.146 --> 00:14:12.341
over twenty equal to zero.

00:14:13.138 --> 00:14:16.991
So the phase crosses minus one
eighty at the square root of twenty,

00:14:17.074 --> 00:14:20.128
about four point four
seven radians per second.

00:14:20.441 --> 00:14:23.100
Call it the phase crossover frequency.

00:14:23.297 --> 00:14:25.062
There it is on the curve.

00:14:25.766 --> 00:14:29.886
The second frequency is where the
magnitude passes through zero decibels,

00:14:29.969 --> 00:14:33.104
where the loop neither
amplifies nor attenuates.

00:14:33.301 --> 00:14:35.934
The skeleton puts
that at two radians per second,

00:14:36.017 --> 00:14:38.828
where its two segments straddle the axis.

00:14:39.880 --> 00:14:44.023
The exact curve crosses lower,
at about one point five six,

00:14:44.106 --> 00:14:48.309
and the gap is the three decibel
corner error we already know about.

00:14:48.506 --> 00:14:52.963
Call that one the gain crossover
frequency, and take the exact value,

00:14:53.046 --> 00:14:56.309
because we are about to measure
a stability margin with it.

00:14:57.105 --> 00:15:00.961
Two frequencies, both read
off curves we built by hand.

00:15:01.157 --> 00:15:04.351
Now let us close the loop
and find out what they are worth.

00:15:05.459 --> 00:15:08.719
Close the loop around that plant
with unity negative feedback,

00:15:08.802 --> 00:15:12.936
and the closed loop transfer
function is L over one plus L.

00:15:13.249 --> 00:15:16.791
Everything about stability
is hiding in that denominator.

00:15:17.587 --> 00:15:18.609
The loop is on the edge

00:15:18.609 --> 00:15:22.639
of trouble when the denominator
vanishes at some real frequency.

00:15:22.836 --> 00:15:26.410
That is one plus L
of j omega equal to zero,

00:15:26.493 --> 00:15:30.209
which is L of j omega equal to minus one.

00:15:31.005 --> 00:15:36.196
Now read minus one in polar form, because
that is what a Bode plot shows you.

00:15:36.508 --> 00:15:41.827
Its magnitude is one, and its angle
is minus one hundred and eighty degrees.

00:15:42.023 --> 00:15:45.763
Two conditions, and they
have to hold at the same frequency.

00:15:46.559 --> 00:15:51.076
Let me show you what that actually means
physically, because the algebra hides it.

00:15:51.389 --> 00:15:56.020
Break the loop, and inject a sine
wave at the phase crossover frequency,

00:15:56.103 --> 00:15:58.785
four point four seven radians per second.

00:15:58.982 --> 00:16:00.840
That is the grey wave.

00:16:01.544 --> 00:16:03.112
Send it round the plant.

00:16:03.309 --> 00:16:05.759
What comes back is the blue wave.

00:16:05.956 --> 00:16:10.006
It is one sixth the size,
because we measured that magnitude,

00:16:10.089 --> 00:16:14.815
and it is upside down, because
the phase there is minus one eighty.

00:16:15.128 --> 00:16:18.496
Half a cycle of delay
is exactly an inversion.

00:16:19.199 --> 00:16:21.928
And now the summing junction does its job.

00:16:22.543 --> 00:16:27.246
Negative feedback subtracts,
which flips that wave over one more time.

00:16:27.442 --> 00:16:32.119
So what actually gets added back in is
the green wave, and look where it sits.

00:16:32.202 --> 00:16:34.688
It is in phase with what we injected.

00:16:34.791 --> 00:16:37.381
Perfectly, exactly in phase.

00:16:38.178 --> 00:16:40.907
That is the whole
danger of this frequency.

00:16:41.104 --> 00:16:45.142
Everywhere else the returning signal
partly cancels what is already there.

00:16:45.225 --> 00:16:47.304
Here it reinforces it.

00:16:47.501 --> 00:16:49.986
The only thing saving us is the size.

00:16:50.597 --> 00:16:52.801
It comes back one sixth as tall,

00:16:52.884 --> 00:16:57.065
so each trip round the loop it
shrinks, and the ringing dies away.

00:16:57.261 --> 00:17:00.048
But suppose we multiplied the gain by six.

00:17:00.245 --> 00:17:03.810
Then it would come back
exactly the same size it went in.

00:17:04.723 --> 00:17:08.822
And there it is, landing precisely
on top of the wave we injected.

00:17:09.018 --> 00:17:11.747
At that point the loop no longer needs us.

00:17:12.060 --> 00:17:16.264
It can sustain that oscillation
with no input at all, forever.

00:17:17.061 --> 00:17:21.055
So the factor six is a real
quantity, and it has a name.

00:17:21.368 --> 00:17:23.122
It is the gain margin:

00:17:23.225 --> 00:17:25.002
how much you may multiply the loop gain

00:17:25.002 --> 00:17:28.114
by before the returning
wave comes back full size.

00:17:29.166 --> 00:17:31.779
You read it off the plots in two steps.

00:17:32.231 --> 00:17:36.319
Find the frequency where the phase
curve crosses minus one eighty.

00:17:36.422 --> 00:17:38.966
Drop straight up to the magnitude curve.

00:17:39.162 --> 00:17:43.807
Whatever gap you find between there
and zero decibels is the gain margin.

00:17:44.720 --> 00:17:48.145
Here that gap measures
fifteen point six decibels.

00:17:48.760 --> 00:17:52.067
And fifteen point six
decibels is a factor of six,

00:17:52.150 --> 00:17:55.436
which is exactly the number
we found by hand a moment ago.

00:17:56.233 --> 00:17:59.612
The other margin runs the same
procedure the other way round.

00:18:00.227 --> 00:18:01.862
Start on the magnitude curve,

00:18:01.945 --> 00:18:06.450
at the frequency where it crosses
zero decibels, one point five six.

00:18:06.902 --> 00:18:09.225
Drop down to the phase curve there.

00:18:09.708 --> 00:18:13.062
The phase reads minus one
hundred and thirty seven degrees.

00:18:13.145 --> 00:18:16.661
So we are forty three degrees
short of minus one eighty,

00:18:16.744 --> 00:18:18.881
and that is the phase margin:

00:18:18.985 --> 00:18:22.840
how much extra lag you could pour
into this loop before it sang.

00:18:23.637 --> 00:18:27.304
And that second one is usually
the number engineers care about more,

00:18:27.387 --> 00:18:32.400
because extra lag arrives whether you
asked for it or not. A transport delay,

00:18:32.483 --> 00:18:37.348
a filter you forgot, an actuator
that is slower than the model says.

00:18:37.545 --> 00:18:41.528
All of it eats phase margin,
and none of it touches gain margin.

00:18:42.325 --> 00:18:45.379
Forty three degrees and a factor of six.

00:18:45.691 --> 00:18:47.492
Now let me spend them.

00:18:48.289 --> 00:18:51.294
First, what a gain change
does to these two curves,

00:18:51.377 --> 00:18:53.978
because it is the simplest
thing in the subject.

00:18:54.291 --> 00:18:58.759
Multiplying by a constant adds a constant
number of decibels at every frequency,

00:18:58.842 --> 00:19:01.908
so the magnitude curve
moves bodily upward.

00:19:02.105 --> 00:19:04.265
Its shape does not change at all.

00:19:05.062 --> 00:19:07.277
And a positive constant has no angle,

00:19:07.360 --> 00:19:10.252
so the phase curve
does not move by one degree.

00:19:10.449 --> 00:19:11.541
Watch it.

00:19:11.644 --> 00:19:14.534
It will sit perfectly still
through everything that follows,

00:19:14.617 --> 00:19:18.077
which is why the phase crossover
frequency never moves either.

00:19:19.291 --> 00:19:24.807
Now lift the gain by our whole margin, a
factor of six, fifteen point six decibels.

00:19:25.004 --> 00:19:28.859
Up goes the magnitude curve,
and it keeps its shape exactly.

00:19:29.563 --> 00:19:32.628
And look what has happened
at the phase crossover.

00:19:32.825 --> 00:19:34.357
The point that was fifteen point

00:19:34.357 --> 00:19:38.375
six decibels down is now
sitting exactly on zero.

00:19:38.688 --> 00:19:43.007
The gain crossover and the phase crossover
have arrived at the same frequency.

00:19:43.804 --> 00:19:48.042
Both conditions for minus one now
hold together, and here is what

00:19:48.042 --> 00:19:49.935
that does in the time domain.

00:19:50.131 --> 00:19:54.765
This is the closed loop answering
a step, at the original gain of forty.

00:19:55.217 --> 00:19:59.699
Some overshoot, a couple of swings,
settled inside five seconds.

00:20:00.310 --> 00:20:03.433
And this is the same loop
with the gain multiplied by six,

00:20:03.433 --> 00:20:05.034
at two hundred and forty.

00:20:05.117 --> 00:20:06.578
It never settles.

00:20:06.661 --> 00:20:12.478
It never diverges either. It just rings,
with the same amplitude, indefinitely.

00:20:13.275 --> 00:20:15.316
Measure the period of that ringing.

00:20:15.399 --> 00:20:17.151
It is one point four seconds,

00:20:17.234 --> 00:20:21.287
and two pi over four point
four seven is one point four.

00:20:21.390 --> 00:20:26.323
The loop is oscillating at precisely the
frequency we identified on the phase plot,

00:20:26.406 --> 00:20:28.543
using nothing but arctangents.

00:20:29.339 --> 00:20:33.587
Push a little further, to two hundred
and eighty, which is past the margin,

00:20:33.670 --> 00:20:36.445
and the oscillation
grows instead of holding.

00:20:36.758 --> 00:20:41.077
The closed loop poles have crossed into
the right half plane, and the frequency

00:20:41.077 --> 00:20:45.281
response of the open loop told us
the exact moment it would happen.

00:20:46.193 --> 00:20:48.560
So the margins are not bookkeeping.

00:20:48.643 --> 00:20:52.264
They are the distance,
measured in decibels and in degrees,

00:20:52.347 --> 00:20:56.039
between the loop you have and
a loop that sings on its own.

00:20:56.491 --> 00:20:59.534
What is left is to buy
some of that distance back.

00:21:00.577 --> 00:21:03.294
Everything so far has been diagnosis.

00:21:03.398 --> 00:21:07.869
We took a plant apart, drew its two
curves, and read two margins off them.

00:21:08.065 --> 00:21:12.489
Now let us change those curves on purpose,
with the two simplest tools there are.

00:21:13.193 --> 00:21:17.000
Both of them are one zero
and one pole. That is all.

00:21:17.083 --> 00:21:17.849
And the only thing

00:21:17.849 --> 00:21:21.983
that distinguishes them is which of
the two sits at the lower frequency.

00:21:22.687 --> 00:21:27.726
Put the pole first, below the zero,
and you have a lag compensator.

00:21:27.830 --> 00:21:32.126
At zero frequency the two brackets
are both one, so it does nothing.

00:21:32.323 --> 00:21:37.525
Above the zero, the denominator has grown
more than the numerator, so it attenuates.

00:21:38.437 --> 00:21:43.651
Put the zero first instead, below
the pole, and you have a lead compensator.

00:21:44.103 --> 00:21:46.563
Again it is worth one at zero frequency,

00:21:46.646 --> 00:21:50.582
but now above the pole
the numerator has won, so it amplifies.

00:21:50.686 --> 00:21:55.063
And in between it hands you phase lead,
which is the thing you actually wanted.

00:21:55.860 --> 00:21:59.123
So one of them cuts the high
end and one of them lifts it.

00:21:59.227 --> 00:22:02.456
Let us watch what each
does to a loop we already know.

00:22:03.508 --> 00:22:07.467
Here is our plant again,
in blue, on both plots.

00:22:07.919 --> 00:22:12.109
I have widened the frequency axis down
to a hundredth of a radian per second,

00:22:12.192 --> 00:22:17.057
two decades lower than before, because
that is where a lag compensator lives.

00:22:17.970 --> 00:22:20.850
Now the lag section on its own, in yellow.

00:22:21.046 --> 00:22:24.133
Its pole is at a hundred
and twenty five ten thousandths,

00:22:24.216 --> 00:22:26.388
its zero at five hundredths.

00:22:26.492 --> 00:22:28.800
So it starts flat at zero decibels,

00:22:28.883 --> 00:22:33.029
falls at twenty per decade between
the two, and then goes flat again.

00:22:33.825 --> 00:22:35.567
How far does it fall?

00:22:35.764 --> 00:22:40.699
The ratio of the pole to the zero,
a quarter, which is twelve decibels.

00:22:41.012 --> 00:22:43.764
That is the whole
of what this section is for:

00:22:43.961 --> 00:22:48.501
a twelve decibel cut, delivered
at every frequency above five hundredths.

00:22:49.205 --> 00:22:50.947
And here is its phase.

00:22:51.050 --> 00:22:55.962
It dips down about thirty degrees in the
middle, and comes back to zero afterwards.

00:22:56.159 --> 00:22:59.547
That dip is the price you
pay, and look where it is:

00:22:59.630 --> 00:23:02.475
two decades below anything we care about.

00:23:02.579 --> 00:23:06.294
By the time we reach the interesting
frequencies the section has given all

00:23:06.294 --> 00:23:07.502
of it back.

00:23:08.415 --> 00:23:12.943
Add the yellow to the blue, and the
green curves are the compensated loop.

00:23:13.140 --> 00:23:18.516
Identical to the plant at low frequency,
twelve decibels below it everywhere else.

00:23:19.731 --> 00:23:21.935
So the magnitude curve has dropped,

00:23:22.018 --> 00:23:26.430
and the point where it crosses zero
decibels has slid a long way to the left.

00:23:26.627 --> 00:23:30.946
From one point five six down
to about nought point four nine.

00:23:31.650 --> 00:23:33.508
And that is the whole trick.

00:23:33.612 --> 00:23:37.955
Down at nought point four nine,
the plant had barely started lagging.

00:23:38.152 --> 00:23:41.680
The phase there is about minus
one hundred and eleven degrees,

00:23:41.763 --> 00:23:45.804
so the phase margin is sixty
nine, up from forty three.

00:23:46.600 --> 00:23:51.222
The gain margin improves too, from six to
twenty four, because the whole magnitude

00:23:51.222 --> 00:23:55.030
curve dropped and the phase
crossover frequency hardly moved.

00:23:55.343 --> 00:23:57.318
But notice what it cost.

00:23:57.421 --> 00:24:00.043
The crossover frequency
is the loop's bandwidth,

00:24:00.126 --> 00:24:02.449
and we just divided it by three.

00:24:02.646 --> 00:24:05.387
This loop is safer and it is slower.

00:24:06.184 --> 00:24:08.713
Now clear those away
and try the other one.

00:24:08.796 --> 00:24:13.067
The lead has its zero at one point
two and its pole at seven point two,

00:24:13.150 --> 00:24:17.574
so both of them sit right in the middle
of the action, near the old crossover.

00:24:18.370 --> 00:24:21.784
In yellow again,
its magnitude is flat, then rises

00:24:21.784 --> 00:24:26.600
at twenty decibels per decade between
the zero and the pole, then flat again.

00:24:26.683 --> 00:24:29.619
The ratio of zero to pole is one sixth,

00:24:29.702 --> 00:24:33.023
so it lifts the high end
by about sixteen decibels.

00:24:33.564 --> 00:24:36.200
And here is the part we actually came for.

00:24:36.304 --> 00:24:39.007
Its phase rises to a maximum partway up,

00:24:39.090 --> 00:24:43.747
and for a ratio of one sixth
that maximum is forty six degrees.

00:24:43.850 --> 00:24:47.367
It happens at the geometric
mean of the zero and the pole,

00:24:47.450 --> 00:24:49.470
which is two point nine four.

00:24:50.267 --> 00:24:54.261
So you place the compensator so that its
phase peak lands where the loop is going

00:24:54.261 --> 00:24:56.305
to cross zero decibels.

00:24:56.501 --> 00:25:00.658
Add the two together,
and here are the compensated curves.

00:25:01.455 --> 00:25:05.008
The magnitude has been lifted
at the top end, so crossover moves

00:25:05.008 --> 00:25:09.954
the other way this time, up from one
point five six to two point six five.

00:25:10.151 --> 00:25:13.388
And on an uncompensated
plant that would be bad news,

00:25:13.471 --> 00:25:15.597
because the phase up there is worse.

00:25:16.509 --> 00:25:18.077
But the lead has bumped the phase up

00:25:18.077 --> 00:25:21.270
by forty five degrees
at exactly that frequency.

00:25:21.374 --> 00:25:22.837
So instead of the minus one hundred

00:25:22.837 --> 00:25:26.945
and fifty eight the plant would have given
us, we read minus one hundred and twelve,

00:25:27.028 --> 00:25:29.374
and the phase margin is sixty eight.

00:25:30.286 --> 00:25:34.604
The gain margin is essentially
unchanged, about sixteen decibels,

00:25:34.687 --> 00:25:36.161
because the lead pushed the phase

00:25:36.161 --> 00:25:40.922
crossover frequency out and lifted the
magnitude there by about the same amount.

00:25:41.118 --> 00:25:43.383
Both effects roughly cancel.

00:25:44.087 --> 00:25:45.933
So look at what we bought.

00:25:46.130 --> 00:25:48.323
The same phase margin the lag gave us,

00:25:48.406 --> 00:25:52.572
near enough, but with the crossover
frequency up rather than down.

00:25:52.655 --> 00:25:55.488
This loop is safer and it is faster.

00:25:56.285 --> 00:25:57.900
Side by side, then.

00:25:58.212 --> 00:26:02.483
The lag cuts the high end
of the magnitude curve. The lead lifts it,

00:26:02.566 --> 00:26:06.178
and that single difference drives
everything else about the two of them.

00:26:06.975 --> 00:26:11.013
The lag's own phase contribution
is a nuisance to be parked out of the way,

00:26:11.096 --> 00:26:13.303
two decades below the action.

00:26:13.615 --> 00:26:16.423
The lead's phase
contribution is the entire point,

00:26:16.506 --> 00:26:20.118
and you place it deliberately
on top of the crossover frequency.

00:26:20.462 --> 00:26:23.864
So the lag moves the crossover
down and the lead moves it up.

00:26:24.061 --> 00:26:26.276
Both of them end up
buying you phase margin,

00:26:26.359 --> 00:26:30.177
and they buy it in opposite
currencies: one pays with speed,

00:26:30.260 --> 00:26:34.859
the other pays with amplified high
frequency, which means amplified noise.

00:26:35.238 --> 00:26:40.672
And both are one zero and one pole, the
same two curves we drew by hand earlier.

00:26:40.776 --> 00:26:43.969
Which one you put first
is the whole difference between them.

00:26:44.673 --> 00:26:50.012
That is the arc. A sine wave in gives a
sine wave out, and two numbers record it.

00:26:50.095 --> 00:26:53.983
Those two numbers, plotted
against a logarithmic frequency axis,

00:26:54.066 --> 00:26:58.037
are sums of straight lines you
can draw from the poles and zeros alone.

00:26:58.741 --> 00:27:02.991
Close the loop, and one frequency
on those plots decides everything:

00:27:03.095 --> 00:27:06.587
the one where the phase reaches
minus one hundred and eighty degrees,

00:27:06.670 --> 00:27:10.166
where the returning signal
comes back in step with itself.

00:27:10.362 --> 00:27:14.703
How far the magnitude sits below
unity there is your gain margin,

00:27:14.786 --> 00:27:20.150
and how far the phase sits above minus one
eighty at unity gain is your phase margin.