The PID controller
4.6 PID tuning methods
4.6.3 Closed loop single-test tuning methods
Despite the fact that Ziegler-Nichols continuous cycling tuning method is performed in closed loop, the experiment is both tedious and dangerous. The Yuwana-Seborg tuning method de-scribed here, [203], retains the advantages of the ZN tuning method, but avoids many of the the disadvantages. Given the attractions of this closed-loop reaction curve tuning methodology, there have been subsequently many extensions proposed, some of which are summarised in [48,99].
The following development is based on the modifications of [47] with the corrections noted by [193].
The Yuwana-Seborg (YS) tuning technique is based on the assumption that the plant transfer function, while unknown, can be approximated by the first order plus deadtime structure,
Gm(s) = Kme−θms
τms + 1 (4.31)
with three plant parameters, process gain Km, time constant, τm, and deadtime θm.
Surrounding this process with a trial, but known, proportional-only controller Kc, gives a closed loop transfer function between reference r(t) and output y(t) as
Y (s)
R(s) = KcKme−θms
1 + τ s + KcKme−θms (4.32)
A Pad´e approximation can be used to expand the non-polynomial term in the denominator, al-though various people have subsequently modified this aspect of the method such as using a different deadtime polynomial approximation. Using some approximation for the deadtime, we can approximate the closed loop response in Eqn.4.32with
Gcl≈ Ke−θs
τ2s2+ 2ζτ s + 1 (4.33)
and we can extract the model parameters in Eqn.4.33from a single closed loop control step test.
Figure 4.23: Typical response of a stable system to a P-controller.
Suppose we have a trial proportional-only feedback controlled response with a known controller gain Kc. It does not really matter what this gain is so long as the response oscillates sufficiently as shown in Fig.4.23.
If we step change the reference variable setpoint from r0 to r1, we are likely to see an under-damped response such as shown in Fig.4.23. From this response we measure the initial output y0, the first peak yp1, the first trough, ym1and the second peak yp2, and associated times. Under these conditions we expect to see some offset given the proportional-only controlled loop, and that the controller gain should be sufficiently high such that the response exhibits some underdamped (oscillatory) behaviour.
The final value of the output, y∞, is approximately y∞= yp2yp1− y2m
yp1+ yp2− 2ym (4.34)
or alternatively, if the experimental test is of sufficient duration, y∞could simply be just the last value of y collected.
The closed loop gain K is given by
K = y∞
r1− r0 (4.35)
and the overshoot is given by H = 1
and the time constant
τ = (tm− tp1)p 1− ζ2
π . (4.39)
Now that we have fitted a closed loop model, we can compute the ultimate gain, Ku, and ultimate frequency, ωu, by solving the nonlinear expression
− θωu− tan−1 2τζωu
1− τ2ω2u
=−π (4.40)
for ωu, perhaps using an iterative scheme starting with ωu= 0. It follows then that the ultimate gain is Alternatively of course we could try to usemarginto extract Kuand ωu.
At this point, given Ku and ωu, we can tune PID controllers using the ZN scheme directly fol-lowing Table4.4.
Alternatively we can derive the parameters for the assumed open loop plant model, Eqn.4.31, as Km= |y∞− y0| and then subsequently we can tune it either using the ZN strategy given in Listing4.4, or use the internal model controller strategy from Table4.3, or perhaps using ITAE optimal tuning con-stants. The optimal ITAE tuning parameters for P, PI and PID controllers are derived from
Kc= A where the constants A, B, C, D, E, F are given in Table4.5for P, PI and PID controllers. We are now in a position to replace our trial Kcwith the hopefully better controller tuning constants.
Table 4.5: Tuning parameters for P, PI, and PID controllers using an ITAE optimisation criteria where the constants A through E are used in Eqn.4.46.
mode A B C D E F
P 0.49 1.084 – – – –
PI 0.859 0.977 1.484 0.680 – –
PID 1.357 0.947 1.176 0.738 0.381 0.99
Note that the change in setpoint,|r1− r0| must be larger than the actual response |y∞− y0| owing to the offset exhibited by a proportional only controller. If the system does not respond in this manner, then a negative process gain is implied, which in turn implies nonsensical imaginary time constants. Another often overlooked point is that if the controlled process response does not oscillate, then the trial gain Kcis simply not high enough. This gain should be increased, and
the test repeated. If the process never oscillates, no matter how high the gain is, then one can use an infinite gain controller — at least in theory.
Algorithm4.2summarises this single-test closed loop tuning strategy.
Algorithm 4.2 Yuwana-Seborg closed loop PID tuning
Tuning a PID controller using the closed-loop Yuwana-Seborg method is very similar to Algo-rithm4.1, but avoids the trial and error search for the ultimate gain and period.
1. Connect a proportional only controller to the plant.
2. Choose a trial sensible controller gain, Kcand introduce a set point change and record the output.
3. Check that the output is underdamped and shaped similar to Fig.4.23, and if not increase the trial controller gain, Kc, and repeat step2.
4. From the recorded underdamped response, measure the peaks and troughs, and note the demanded setpoint change. You may find Listing4.5helpful here.
5. Compute the parameters of the closed loop plant and solve for the ultimate frequency, Eqn.4.40and gain, Eqn.4.41.
6. Optionally compute the open loop plant model using Eqn.4.43—Eqn.4.45.
7. Compute the P, PI or PID tuning constants using Table4.5or perhaps using the model and the ZN strategy in Listing4.4.
8. Test the closed loop response with the new PID values. If the response is not satisfactory, further manual ‘fine-tuning’ may be necessary.
A MATLAB implementation to compute the tuning constants given response data is given in listings starting on page164.
A consequence of the assumption that the plant is adequately modelled using first-order dy-namics with deadtime, the Yuwana-Seborg tuning scheme is not suitable for highly oscillatory processes, nor plants with inverse response behaviour as illustrated in section4.8.1. Furthermore, a consequence of the low order Pad´e approximation is that the strategy fails for processes with a large relative deadtime. Ways to use this tuning scheme in the presence of excessive measure-ment noise is described in section5.2.1.
An example of a closed loop response tuner
Suppose we are to tune a PID controller for an inverse response process, G(s) = −s + 1
(s + 1)2(2s + 1)
Such processes with right-hand plane zeros are challenging because of the potential instability owing to the initial response heading off into the opposite direction as described further in §4.8.1.
The response to a unit setpoint change is given in the top figure of Fig.4.24. By recording the values of the peaks and troughs, we can estimate the parameters of an approximate model of the
0 5 10 15 20 25 0
0.5 1
tp1 t
m1 t
p2 Trial closed loop step test, K
c= 1
0 5 10 15 20 25
0 0.5 1
Closed loop model
Time (sec)
Amplitude
Actual Fitted
0 5 10 15 20 25 30
0 0.5 1
Open loop model
Time (sec)
Amplitude
Actual fitted
Figure 4.24: A Yuwana-Seborg closed loop step test. The top plot shows the response given a unit change in setpoint with the key points marked. The middle plot compares the estimated with the actual closed loop data, while the bottom plot compares the estimated openloop plant model with the true plant.
closed loop response, Eqn.4.33. A comparison of this model with the actual data is given in the middle plot of Fig.4.24. It is not a perfect fit because the underlying plant is not a pure first order with deadtime, and because Eqn.4.33is only approximate anyway.
Given the closed loop model, we can now extract the open loop model of the plant which is compared with the true plant in the bottom trend of Fig. 4.24. Note how the first-order plus deadtime model, specifically in this case
G =ˆ 1.003
3.128s + 1e−2.24s
approximates within reason the higher order true plant dynamics.
Finally now that we have a plant model, ˆG, we can either use the ITAE optimal or IMC tuning scheme as shown in Fig.4.25.
As evident in Fig.4.25, the ITAE responses are overly oscillatory which tends to be a common failing of PID tuning schemes that are designed to satisfy a performance objective.
In the IMC case, the desired closed loop time constant was set equal to the sum of the dead-time and the open loop dead-time constant, τc = τm+ θm, which as it turns out is perhaps overly conservative in this case. Better performance would be achieved by reducing τc.
0
Figure 4.25: The PI (left) and PID (right) closed loop responses using the ITAE (upper) and IMC (lower) tuning schemes based on the identified model but applied to the actual plant.
Automating the Yuwana-Seborg tuner
Because this is such a useful strategy for PID tuning, it is helpful to have a semi-automated procedure. The first step once you have collected the closed loop data with a trial gain is to identify the values and timing of the peaks and troughs, yp1, ym1and yp2. Listing4.5is a simple routine that attempts to automatically extract these values. As with all small programs of this nature, the identification part can fail, particularly given excessive noise or unusual response curves.
Listing 4.5: Identifies the characteristic points for the Yuwana-Seborg PID tuner from a trial closed loop response
function [yp1,tp1,ym1,tm1,yp2,tp2,yss_est] = ys_ident(t,Y);
%Identify the peaks & troughs from an underdamped closed loop test
3 %Used for Yuwana-Seborg PID tuning
y0 = Y(1); n = length(Y); %start point & total # of points if n < 20
fprintf('Probably need more points\n');
8 end % if
Y = Y*((Y(n) > y0)-0.5)*2; %workout direction, 1 if positive) yss_est = mean(Y(n:-1:n-round(n/50))); %average pt at the end (robust) [yp1,idx] = max(Y); tp1 = t(idx); %1st maximum point & time at occurrence
13 Y = Y(idx:n); t = t(idx:n); %chop off to keep searching [ym1,idx] = min(Y); tm1 = t(idx); %1st minimum point & time Y(1:idx) = []; t(1:idx)=[];
[yp2,idx] = max(Y); tp2 = t(idx); %2nd maximum point & time at occurrence
18 return % end ys_ident.m
Using this peak and trough data, we can compute the parameters in the closed loop model fol-lowing Listing4.6.
Listing 4.6: Compute the closed loop model from peak and trough data yinf = (yp1*yp2 - ym1ˆ2)/(yp1+yp2-2*ym1); %Steady-state output, y∞ 2 K = yinf/A; %Closed loop gain, K, Eqn.4.35& Overshoot, H
H = 1/3*((yp1-yinf)/yinf+(yinf-ym1)/(yp1-yinf)+(yp2-yinf)/(yinf-ym1));
d = 2*tp1 - tm1; %Deadtime, θ, Eqn.4.37 zeta = -log(H)/sqrt(piˆ2+log(H)ˆ2); %shape factor, ζ, Eqn.4.38
7 tau = (tm1-tp1)*sqrt(1-zetaˆ2)/pi; %time constant, τ , Eqn.4.39
Gcl = tf(K,[tauˆ2 2*zeta*tau 1],'iodelay',d); %Closed loop model, Gcl(s), Eqn.4.33
Now that we have the closed loop model, we can compute the ultimate gain, Ku, and ultimate frequency, ωu.
Listing 4.7: Compute the ultimate gain and frequency from the closed loop model parameters.
10 fwu = @(w) pi - d*w - atan2(2*zeta*tau*w,1-tauˆ2*w.ˆ2); % [Gm,Pm,Wcg,Wcp] = margin(Gcl) %Use as a good starting estimate for ωu
wu = fsolve(fwu,Wcg); %Solve nonlinear Eqn.4.40for ωu 15 B= K/sqrt((1-tauˆ2*wuˆ2)ˆ2+(2*tau*zeta*wu)ˆ2);
Kcu = Kc*(1+1/B); %Ultimate gain, Ku, Eqn.4.41
Finally we can now extract the open loop first-order plus deadtime model using Listing4.8.
Listing 4.8: Compute the open loop model, Gm, Eqn.4.31.
Km = yinf/(Kc*(A-yinf)); %Plant gain, Gm, Eqn.4.43 taum = 1/wu*sqrt(Kcuˆ2*Kmˆ2-1); %Plant time constant, τm, Eqn.4.44 dm = 1/wu*(pi - atan(taum*wu)); %Plant delay, θm, Eqn.4.45
20 Gm = tf(Km,[taum 1],'iodelay',dm);%Open loop model estimate, Gm(s), Eqn.4.31
Now that we have an estimate of the plant model, it is trivial to use say the IMC relations to compute reasonable PI or PID tuning constants. We do need however to decide on an appropriate desired closed loop time constant.
Listing 4.9: Compute appropriate PI or PID tuning constants based on a plant model, Gm, using the IMC schemes.
tauc = (tau+dm)/3; %IMC desired closed loop time constant, τc
controller = 'PID'; %Type of desired controller, PI or PID switch controller %See IMC tuning schemes in Table4.3.
25 case 'PI'
Kc = 1/Km*(tau)/(tauc+dm);
taui = taum; rs = 1/taui; %Integral time, τi, and reset, 1/τi.
taud = 0;
case 'PID'
30 Kc = 1/Km*(tau+dm/2)/(tauc+dm/2);
taui = tau+dm/2; rs = 1/taui;
taud = tau*dm/(2*tau+dm);
end % switch
Now all that is left to do is load the controller tuning constants into the PID controller, and set the controller to automatic.