Control Theory: Example 3 – Ziegler-Nichols and Tyreus-Luyben Tuning Rules

Edit 21 Jan 2013: added “Example 3” to the title.

Introduction

I’m going to jump right in and imagine that we have a known plant which we wish to control using P, PI, or PID. I’m going to assume that you have some idea what those are. We’ve seen proportional (P) control, where the control signal is proportional to the error. Integral control has a signal which is proportional to the integral of the error, and derivative control a signal which is proportional to the rate of change (the derivative) of the error. Proportional control is always used in conjunction with integral, hence PI. Although derivative control can be used with only proportional, in process control we generally use both integral and proportional with it, hence PID. We’ll talk more about them in subsequent posts, but for now I want to show you two ways to get the required parameters. They may not always be very good values, but they’ll be better than in the ballpark. At the very least, they are good starting values for further investigation.

Oh, I am aware that Mathematica® version 9 has new capabilities for tuning controllers – but let me write about what I know, using version 8.

My plant is a 3rd-order transfer function… as usual, rules are a convenient way to specify things:

con 1 14 1

Bequette – this is Example 5.3 (p. 174) and Example 6.1 (p. 199) from Bequette’s “Process Control: Modeling, Design, and Simulation”, Prentice Hall 2003. He used the Routh criterion to decide that the ultimate gain was 10: that’s on the verge of instability. Let’s take a look – that is, I’m about to show you what the ultimate gain means.

I set a new parameter value for K, namely K = 10, the alleged ultimate gain.

con 1 14 2

The closed loop transfer function (y) is…. and the time-domain response to a unit step function is…

con 1 14 3

Let’s get the control effort transfer function u, too… and the time-domain behavior:

con 1 14 4

Here’s my usual first plot: step function in silver (or whatever it is), system response in black, scaled control effort (c1/K) in gold:

con 1 14 5

OK, we see steady-state oscillations in response to a unit step input. Make K slightly greater, and the oscillations will grow; make K slightly smaller and the oscillations will get smaller. We are on the edge of instability, just as advertised.

I should also show you the actual control effort:

con 1 14 6

We would like to know the period of these output oscillations. It looks like it is slightly above 6… there’s a minimum just before 7, and the next one is just after 13 – look at the previous graph… that’s why I scale the control effort, so the output is not compressed.

We could use calculus to find them…. If we were looking at a paper recording, we might be able to measure them, but in this case we have an explicit equation for the solution, so let’s go ahead and do calculus. Here’s the first derivative of the output… set it to zero.

con 1 14 7

Let’s find solutions near 7 and 13…

con 1 14 8

We could also back up, and instead of finding the ultimate gain by the Routh criterion, we could have found it by simulation. I’ve shown you simulation before, so I won’t do it this time. If, instead of having a math model, you were in the control room playing with parameters, you’d be using the system itself to do a simulation… and the operators would be planning to kill you for bringing the system to the edge of instability.

The bottom line, however, is that we now have two parameters, called the ultimate gain and the ultimate period. There are some simple tuning rules – choices of P, PI, and PID settings – which are based on these two parameters.

But first let me show you the right way to get the ultimate gain and ultimate period, if you have a quantitative model. Everything else in this post is straight-forward, I hope, but this trick is not, at least to me.

We return to our initial system (K = 1):

con 1 14 9

And here’s the open loop Bode plot:

con 1 14 10

The gain margin is 10 – gee, that’s the ultimate gain Bequette found! It occurs at a frequency of 1 radian/second.

Given a frequency f in radians/second, we find the period from P f = 2 pi. This crossover frequency is 1, so the corresponding period is

con 1 14 11

… and that is the ultimate period we computed by finding two consecutive minima.

Don’t ask me why it works, I don’t understand it yet. But I have more than one book telling me it’s not an accident. This, as far as I’m concerned at this point, is the main use of the gain margin. There’s absolutely no reason to simulate the math model and estimate these numbers: they can read off the gain margin. If you have a math model.

Now save these:

con 1 14 12

Now that we have Pu and ku, there are some rules for setting the parameters of P, PI, and PID controllers. But while I have the default K = 1, let’s see how the uncontrolled plant responds to a unit step. I get the closed loop transfer function and then the inverse Laplace transform:

con 1 14 13

Here’s the output and the input (black and silver resp.)

con 1 14 14

Well, except that it’s nowhere near 1 – i.e. we have offset – it had a pretty gentle response, without wild swings.

With a PID controller, we have plant… and controller…

con 1 14 15

We see three parameters: an overall gain kc, and two time constants, \tau_D\ and \tau_I\ . The \tau_D\ is multiplied by s – which says that’s the Laplace transform of a derivative… and the \tau_I\ is coupled with a 1/s – which says that’s the Laplace transform of an integral. What I’m going to show you is two sets of rules for getting from the ultimate gain and the ultimate period to values of kc, \tau_D\ , and \tau_I\ .

The first set of rules is called Ziegler-Nichols; the second is called Tyreus-Luyben.

Let’s go.

Ziegler-Nichols with P, PI, PID

First, let’s try the Ziegler-Nichols rules.

P-only control

To get P-only control, we set \tau_D\ ->0 and \tau_I\ -> \infty\ .

con 1 14 16

Here are the closed loop transfer functions for output and for control… and, since I will want it later, the open loop transfer function, too:

con 1 14 17

The Z-N rule for P-only control is to set kc = .5 ku. (Parts of the following rule are redundant, because I’ve already set \tau_D\ and \tau_I\ , but I like having a complete rule anyway.)

con 1 14 18

and the closed loop for control becomes

con 1 14 19

We get the time-domain responses by taking inverse Laplace transforms…

con 1 14 20

And we plot the input (step function in “silver”), output (black), and scaled control effort (gold):

con 1 14 21

Not only does it take a long time to settle, but there is offset. As for the long settling time… K = 1 got there quickly, K = 10 was on the edge of instability, so K = 5 should have decaying oscillations. OK?

(And if you’re not used to seeing offset with P-only control… remember that the use of transfer functions requires that we use deviation variables: all our initial conditions are zero, in these variables. That is, for example, we’re not using the actual liquid level in a tank – we’re using the deviation from the set point. To hold the system at a value other than zero requires a constant nonzero control effort… so the response is nonzero, but not necessarily 1.)

For the record, here’s the unscaled control effort (gold):

con 1 14 22

Lastly, I want to see the open loop Bode plot, and compute the phase margin:

con 1 14 23

The phase margin is 25° – a little too jittery, as we saw.

PI control

To get PI control, we set \tau_D\ ->0.

con 1 14 24

Here are the closed loop transfer functions for output and for control… and the open loop transfer function for later:

con 1 14 25

Note that kc has changed a little: instead of .5 we have .45 . What this says is that the control modes interact: they should not be set independently of each other…once we add integral control to proportional control, we change the value of the proportional control… and we’ll change both of them again when we add derivative control.

The closed loop transfer function for output becomes.. and we know the ultimate gain ku and ultimate period Pu:

con 1 14 26

The closed loop for control becomes

con 1 14 27

The open loop transfer function becomes

con 1 14 28

The time-domain responses become:

con 1 14 29

And here’s the usual plot, including scaled control effort:

con 1 14 30

It still takes a long time to settle, but the offset is gone.

After all, that’s one of things integral control does for us: it eliminates offset. I should point out that we don’t always care about offset: level control for surge tanks is the best example where we do not care to hold the level at exactly 50%. In fact, to do so would defeat the purpose of a surge tank, and we might as well replace it by a pipe – what goes out is exactly what comes in.

Here’s the unscaled control effort:

con 1 14 31

And here’s the open loop Bode plot:

con 1 14 32

This quantifies what we saw: that the output is more jittery than P-only control.

PID control

To get PID control, we keep all three PID parameters:

con 1 14 33

Here are the closed loop transfer functions for output and for control… and, as usual, the open loop transfer function for later:

con 1 14 34

This time kc is greater than .5, \tau_I\ is smaller than for PI.

The closed loop transfer function for output becomes.. and we know the ultimate gain ku and the ultimate period Pu:

con 1 14 35

and the closed loop transfer function for control becomes

con 1 14 36

The open loop transfer function becomes

con 1 14 37

The time domain responses…

con 1 14 38

… and the usual plot:

con 1 14 39

As usual, here is the unscaled control effort:

con 1 14 40

The open loop Bode plot is

con 1 14 41

That phase margin of 29 is… marginal, at best – go ahead, grimace and hate me; still too jittery.

Let’s take a look at the three output responses:

con 1 14 42

I used panels 3-5 from the following, so orange is P, brown is PI, and yellow is PID. Alternatively, the orange must be P because it has offset, so PID should be yellow.

con 1 14 43

Anyway, we see that P has offset… PI does not, but it takes longer to settle down than P did… PID settles down much faster than the other two, and has no offset, but it still swings wildly at first (that overshoot is just over 40%.)

Tyreus-Luyben with PI, PID

Now I try the Tyreus-Luyben rules. Like the Ziegler–Nichols, they use ultimate gain ku and ultimate period Pu. For P-only control, they are the same.

PI control

To get PI control, we set \tau_D\ ->0.

con 1 14 44

Here are the closed loops for output and for control… and, of course, the open loop transfer function:

con 1 14 45

The T-L rule for PI control is

con 1 14 46

The closed loop for control becomes

con 1 14 47

The open loop becomes

con 1 14 48

The time-domain responses are…

con 1 14 49

Here is the usual plot showing input, output (black), and scaled controller effort:

con 1 14 50

Settles faster, and the offset is gone.

Here’s the unscaled control effort:

con 1 14 51

Here’s the open loop Bode plot:

con 1 14 52

OK, we finally have a phase margin (39°) which is greater than 30°: this choice of parameters is OK by that criterion.

PID control

To get PID control, we need all three PID parameters:

con 1 14 53

The T-L rule for PID control is

con 1 14 54

and the closed loop transfer function for control becomes

con 1 14 55

The open loop transfer function becomes

con 1 14 56

Here are the time-domain responses:

con 1 14 57

Here is the usual plot…

con 1 14 58

Here’s the unscaled controlled effort:

con 1 14 59

Here, as usual, is the open loop Bode plot:

con 1 14 60

Even better than the PI control: a not-too-large phase margin.

Now let’s compare things. Here are the two PI controls:

con 1 14 61

The T-L has significantly less wildness than the Z-N: the overshoot is less and the settling time is less.

Here are the two PID controls:

con 1 14 62

The T-L has significantly less overshoot, but it does take a little longer to get close to its final value. That probably corresponds to a phase margin close to 60°.

I shouldn’t even think of putting all 5 controllers on one graph….

con 1 14 63

…though they look better if I shorten the time, except that it is no longer clear that P-only has offset:

con 1 14 64

Recall the colors in order, orange (3) thru dark gray (7): so, orange, brown, and yellow are Z-N P, PI, and PID; light and dark gray are T-L PI and PID.

con 1 14 65

Summary

Here are the Ziegler-Nichols rules:

con 1 14 66

Here are the alternative Tyreus-Luyben rules:

con 1 14 67

These rules require that we determine the ultimate gain and the ultimate period… and we saw how to get them from the open loop Bode plot, specifically from the gain margin and the frequency at which it occurs.

We saw the effect of these rules on a particular plant, and we also checked the phase margin for each choice of control method and parameters.

As you might expect, I would tend to go with the Tyreus-Luyben rules.

One Response to “Control Theory: Example 3 – Ziegler-Nichols and Tyreus-Luyben Tuning Rules”

  1. prof dr mircea orasanu these must to have a play Says:

    these must to have a play specially in case of in case of POTENTIAL FLOW in hydrodynamics observed prof dr mircea orasanu and prof drd horia orasanu with applications in analytical mechanics and followed that In other words, the motion of the system in a given time interval is such as to maximize or minimize the time integral of the Lagrangian, which is known as the action integral. Thus, the laws of Newtonian dynamics can be summarized in a single statement:
    The motion of a dynamical system in a given time interval is such as to maximize or minimize the action integral.
    (In practice, the action integral is almost always minimized.) This statement is known as Hamilton’s principle, and was first formulated in 1834 by the Irish mathematician William Hamilton.

    Multi-Function Variation
    Suppose that we wish to maximize or minimize the functional
    (707)

    Here, the integrand is now a functional of the independent functions , for . A fairly straightforward extension of the analysis in Section 10.2 yields separate Euler-Lagrange equations,
    (708)

    for , which determine the functions . If does not explicitly depend on the function then the th Euler-Lagrange equation simplifies to
    (709)

    Likewise, if does not explicitly depend on then all Euler-Lagrange equations simplify to
    (710)

    for .


Leave a comment