You are on page 1of 21

Heikki Koivo

24

2. DESIGN OF CONTROLLERS USING BODE DIAGRAM


The basic idea in using controllers is to shape and mold the Bode diagram of the open-loop system in such a way that the given specifications are met. When Bode diagrams are used in design, the specifications have to be transformed into phase and gain margins and usually the steady-state error is also given (here also so-called error coefficients are used). In this presentation we concentrate on Bode diagram design exclusively. Other approaches that could be used are Nyquist diagrams, Nichols diagrams and root locus. Essentially the same principle applies: the given representations are shaped so that the given requirements are met. Lately also robustness issues are taken into account in a more careful manner. The most common controllers or compensators are phase-lag, phase-lead and phase-laglead controllers. These have characteristics of more ideal proportional integral (PI), proportional derivative (PD), and proportional integral derivative (PID) controllers, respectively. Although we concentrate on each controller type separately, it is also possible to use, e.g., two phase-lead compensators in series in order to add more phase margin. In practice, so-called tachometer feedback is also quite common. Its design is very similar to phase-lead design. A somewhat different point of view is state-space design, where methods are developed in time domain and using differential equations. Here one could summarize the basic design idea to be pole placement . This means that the closed-loop system poles are placed in such a way that the requirements are met. Closed-loop poles correspond to the eigenvalues of the closed loop system matrix. This is explored more in other textbooks. There are sometimes differing opinions of various techniques of control system design. The strong point of the classical design is that first of the transfer function representation is often easy to obtain by modern spectral analyzers, which sweep through the frequency range and determine the transfer function automatically. Another significant advantage is that you can see graphically the representation of the whole system. This is not the case with state-space form, where you basically only deal with eigenvalues, poles and zeros, i.e., with numbers. Utilization of computer-aided design makes the classical design approaches extremely powerful, although many textbooks have been written in the era when this was not he case. Therefore teaching of these methods in basics courses is easily confusing, without clear objective and exercises are tedious, mostly hand and pencil calculations. In reality the design is carried out with computers, with efficient tools to meet engineering specifications. In engineering the final goal is almost always the design of systems, synthesis, which requires skill and experience. Analysis is part of it, since it is better to be sure beforehand that Tsernobyl does not happen. In both cases efficient tools are used. The rest of these notes show how to use such tools in design of control systems.

Heikki Koivo

25

2.2. Dominant poles


In the subsequent section we will study how a number of basic design specifications can be connected to Bode diagram specifications. This is a crucial step in design. It can also determine the design approach. Basic assumption in design is that even if the original open-loop system is of high order, the closed-loop system behaves like a second-order system:
Y ( s) 2 n = G ( s) = 2 R (s) s + 2 ns + 2 n

(2- 1)

If the system is of high order, then the complex conjugate pair of poles, which is closest to the imaginary axis is called dominant poles. In order this to hold the other poles have to be far from the dominant poles or there must be a zero to approximately cancel out the effect of the pole. An example of this is given in Figure 2.1.

Dominant poles jIm

x o x x

x Re x

Fig.2.1. Dominant poles. Note that if a pole is close to the dominant poles then a zero has to cancel its effect. The design of a servocontrol system is based on this, but the performance has to be checked by simulation, since we are not quite sure how well the assumption will hold. Let us next collect certain facts about second order systems.

Heikki Koivo

26

2.2. Dominant poles - Percent Overshoot (PO) vs. , PM vs.


Consider a unit step response of a second order system. It is possible to calculate exactly maximum percent overshoot as a function of damping ratio . First determine the actual response y(t). Then calculate where the first peak of the response occurs. Subtract one from y(t) in order to get maximum overshoot. Then express it in percentage. After some calculations the following expression is obtained for the magnitude of the first overshoot Mp:

M p = (1 + e

1 2

(2- 2)

and therefore percent overshoot PO

PO = 100e

/ 1 2

(%) .

(2- 3)

Consider a typical example ( n = 2 and = 0.2)


Y ( s) 4 = 2 R ( s) s + 0.4 s + 4

(2- 4)

Use the following MATLAB commands to compute the step response (Fig.2.2): num=[4];den=[1 0.4 4]; gopen=tf(num,den) % transfer function tf- form Transfer function: 4/s^2 + 0.4 s + 4 step(gopen) % % step response calculation

Step Response

1.6 1.4 1.2 Amplitude 1 0.8 0.6 0.4 0.2 0 0 5 10

PO72%

15 Time (sec.)

20

25

30

Fig.2.2. Typical unit step response of a second order system. Here n = 2 and = 0.2. From the figure percent overshoot PO 72%.

Heikki Koivo

27

100 90 80 70 60 50 40 30 20 10 0 0 0.1 0.2 0.3 0.4 0.5 0.6 Damping ratio tseta 0.7 0.8 0.9 1

Fig.2.3. Percent overshoot (PO) as a function of damping ratio . Another useful relationship in design is between phase margin (PM) and the damping coefficient .

Phase margin vs.


PM = tan 1 (2 [ 1 ] ) 4 2 (4 + 1) 2

%Overshoot

(2- 5)

Fig.2.4. Phase margin as a function of . Added phase margin vs. percent overshoot is plotted using the above relationships.

Heikki Koivo

28

Fig.2.5. Added phase margin phimax as a function of percent overshoot (PO).

Exercise: Complete the graphs BANDWIDTH: The bandwidth (BW) of the system is defined to be the frequency at which the overall gain has dropped 3 dB from the level that it was at lower frequencies. For second order systems it is possible to compute the following expression:

BW 2 2 2 2 = (1 2 ) + 2 4 (1 ) n
Similarly for first order systems, it is easy show that
c = 1 c

(2- 6 )

(2- 7)

EXERCISE: One common design specification is settling time ts. This is defined to be the time when the unit step response finally settles to a tolerance of 1% (or 5%). Calculate the exact expression of settling time for a second order system in terms and n. (Answer: Settling time ts 4/n. For higher order systems the predominant time constant is used for the same purpose as n).

Heikki Koivo

29

3. DESIGN OF PHASE-LAG COMPENSATOR


The basic idea in compensators, as the name says, is to compensate or modify the original transfer function in the way that the specifications of the closed loop system are met. Phaselag compensator, which corresponds to PI controller, is appropriate, when speed is not an issue, because it will slow the original response. Transfer function of phase-lag compensators is given by
1 + a1 s , a1 < 1 1 + s

WLag ( s) =

(3- 1)

Gain at high frequencies


W Lag ()
dB

= ( a1 ) dB .

(3- 2)

Upper cut-off frequency


u = 1 a1
(3- 3)

The name of the phase-lag controller follows from the property that phase of the output of Wlag(s) is lagging behind the phase of the input signal. As can be seen from Figure 3.1 the gain decreases at higher frequencies. The gain at higher frequencies is a 1. Since a 1 < 1, this means that W Lag () = ( a1 ) dB is negative, which is clear from Figure
dB

3.1.
Bode Diagrams

0 -5 Phase (deg); Magnitude (dB) -10 -15 -20

-10 -20 -30 -40 -50 10


-1

10

10

10

Frequency (rad/sec)

Fig.3.1. Bode diagram of a typical phase-lag circuit: WLag ( s) = the behavior at break frequencies 1 rad/s and 10 rad/s.

1 + 0.1s . Observe 1+ s

Heikki Koivo

30

Phase-lag compensator is like a PI controller at high frequencies. Let us draw a PI controller, which roughly corresponds to the phase lag circuit in Figure 3.1.
W PI (s) = (1 + 1 ) 0.1s

(3- 4)

or in MATLAB form num=[0.1 1];den=[1 0]; g=tf(num,den); bode(g) The result is displayed in Figure 3.2.
Bode Diagrams

20 10 Phase (deg); Magnitude (dB) 0 -10 -20

-20 -40 -60 -80 10


-1

10

10

10

Frequency (rad/sec)

1 ) . For > 4 rad/s the PI 0.1s controller behaves like the phase-lag compensator of Fig. 3.1.

Fig.3.2. Bode diagram of PI controller W PI (s) = (1 +

Steps in design of phase-lag compensator


STEP 1. Choose gain K to satisfy steady-state requirements. STEP 2. Draw Bode-diagram of KG(s). STEP 3. Determine the new crossover frequency , i.e., the frequency at which the uncompenc

o sated system has phase (-180 +PM), where PM = desired phase margin. Typically o o o o the required phase margin is 45 -60 for electro-mechanical systems and 25 -30 for processes.

Heikki Koivo

31

STEP 4. Determine how much to decrease the gain in dB at the frequency mentioned in step 3 so that it would become the new cross-over frequency c. This determines a .
1

STEP 5. Gain must be decreased at high frequencies without disturbing it at lower frequencies. This is guaranteed by choosing the upper cut-off frequency u to be one decade below c. STEP 6. Check by simulating the unit step response. STEP 7. If requirements are met, stop. Otherwise go back to STEP 1.

EXAMPLE
Open-loop transfer function of a unity feedback system of Fig.3.3 is given by

G (s) =

1 . s(1 + 0.2s)

(3- 5)

Controller
R(s) + WLAG(s)

System
G(s) = 1 s(1 + 02 . s)

Y(s)

Fig.3.3. The block diagram of the overall system. Here WLAG (s) represents the phase-lag controller or compensator and G(s) the open-loop system transfer function. The system has unity feedback, H(s) = 1. Specifications for the system are: Accuracy for a unit ramp input < 2%, i.e. steady-state error < 0.02. Maximum percent overshoot = PO < 20%. Design a phase-lag compensator that satisfies the requirements. HINT: Use MATLAB Help command to familiarize yourself with the following commands, which are useful in design. See APPENDIX for details.

Heikki Koivo

32

FEEDBACK Feedback connection of two systems. ROOTS Find polynomial roots.

SOLUTION: STEP 1. Compute the steady-state for unit ramp input e ss


ess = lim sE (s) = lim s(
s 0

1 ) R( s) s 0 1 + G ( s)

(3- 6)

e ss = lim [s( s 0 1+ < 0.02

1 K s(1 + 0.2s)

)]

1 =K s2

(3- 7)

This implies that K > 1/0.02 = 50, choose K = 50. (3- 8)

Gain is now sufficient. The controller is at this point a P (proportional) controller. STEP 2. From Fig.2.5 percent overshoot PO <20% corresponds to > 48 phase margin, PM. This holds for second order systems and therefore we will make the dominant pole assumption. Draw the Bode diagram of the transfer function KG(s) = 50 /s(1 + 0.2s). REMARK. The numerator now includes gain 50. We will use MATLAB for plotting. Recall that MATLAB requires num/den form so that NUMERATOR: num=[250]; DENOMINATOR: den=[1 5 0]; g=tf(num,den) %Transfer function g Transfer function: 250 --------s^2 + 5 s Next draw the Bode diagram with bode(g).

Heikki Koivo

33

Bode Diagrams

40 20 0 -20

Phase (deg); Magnitude (dB)

-100 -120 -140 -160

10

-1

10

10

10

Frequency (rad/sec)

Fig.3.4.The open-loop transfer function KG(s). Note that the original open-loop transfer function has been multiplied by K = 50, which is a P controller. The steady-state requirement is now satisfied. Plotting is done with bode command. Phase margin can be read from Figure 3.2. Recall that it is obtained from the Bode diagram by first determining the frequency at which the gain curve crosses the 0 dB level. After that read the phase at the same frequency from the phase curve and subtract it from 180 0. A better and a more accurate answer can be obtained with MARGIN(g) command, which draws the whole Bode diagram and also produces directly gain margin Gm, which is not used in the current design, phase margin Pm and the corresponding frequencies. Gain margin, Gm =Inf, Phase margin, Pm = 17.96 (phase margin 18), at frequency Wcp = 15.42 1/s
Bode Diagrams Gm = Inf, Pm=17.964 deg. (at 15.421 rad/sec)

40 20 Phase (deg); Magnitude (dB) 0 -20

-100 -120 -140 -160 -180 10


0

10

Frequency (rad/sec)

Fig.3.5. MARGIN command margin(g) plots Bode diagram, draws also both the gain and phase margin and the corresponding frequencies and computes the exact numbers into the figure. The open-loop system has been compensated with gain K = 50.

Heikki Koivo

34

Phase margin Pm = 18 is not enough, at least 48 is needed. Phase margin relates to overshoot. It is also easy to check the maximum overshoot by simulation, when the open loop has gain K=50. Note that the simulation must be done for closed -loop system. Compute the closed-loop system transfer function using feedback command. Then apply step command. The closed-loop transfer function is obtained by T=feedback(g,1) Transfer function: 250 --------------s^2 + 5 s + 250 The step response is computed by using step(T) For easier reading a grid is drawn together with labels on x- and y-axis. grid xlabel('time in secs');ylabel('Output'); title('Unit step response of closed loop system') The maximum overshoot can now be read from Fig.3.4. to be about 60 %.
Step Response Unit step response of closed loop system 1.6 1.4 1.2 1 Amplitude Output 0.8 0.6 0.4 0.2 0 0 0.5 1 1.5 time(sec.) in secs Time 2 2.5

Fig.3.6. The unit step response of the closed-loop system, when only pure gain compensator K = 50 (P controller) is used. The maximum overshoot PO = 60% is quite large, but the steady-state error for a step (not for a ramp) is zero, since the system includes an integrator. There is clearly too much overshoot! Additional compensating is needed.

Heikki Koivo

35

At this point it is also useful to draw the Bode diagram of the closed-loop system so that it can be later compared with the compensated one: bode(T)

Bandwidth, about 25 rad/s read at 3dB point

Fig.3.7. Bode diagram of the closed-loop system when the compensator is K = 50. Bandwidth is read from the figure (use ginput(1) ) to be about 25 rad/s STEP 3. In designing phase-lag compensator, the first thing is to determine the frequency, at which the phase margin would be sufficient, if the gain is not changed. Read from the Bode diagram of Fig.3.2 at what frequency there is enough phase margin. A handy way to do it is to use crosshair command ginput(1). ginput(1) ans = 4.1786 18.5074

Fig.3.8. Use of crosshair to determine the new crossover frequency, at which the phase margin is sufficient.

Heikki Koivo

36

Or compute more exactly, which is clumsier but more accurate. (Only part of the table is shown) num=[250];den=[1 5 0]; g=tf(num,den) % define KG(s) w=logspace(-1,2);[mag phase w]=bode(g,w); % compute magnitude and phase phi=180.+phase; magdb = 20*log10(mag); %compute phase margin and mag dB [squeeze(magdb) squeeze(phase) squeeze(phi) w] % table of mag in dB, phase, phase margin, frequency Table 2.1. Original magnitude and phase, the new phase margin (if magnitude is fixed to be 0 dB) and the frequency. MagdB phase phi 23.29 -120.51 59.48 2.9471 21.72 -124.16 55.83 3.3932 20.07 -128.00 51.99 3.9069 18.34 -131.97 48.02 4.4984 16.52 -136.01 43.98 5.1795 At 4 rad/s (3.9069 to be exact) the new phase margin is about 520 (51.99640). Let the new crossover frequency be c = 4rad/s. STEP 4. One further piece of information is read from the table. At 4 rad/s the gain is about 20 dB. This must be taken care by the phase lag compensator. Choose a 1 = - 20 dB or a1 = 0.1. STEP 5. Since the upper cut-off frequency u is one decade below the new crossover frequency , c we have c = 4 rad/s = 10x u = 10/ (a1) or = 20 s. STEP 6. This is sufficient accuracy during first design iteration. The design is now checked by simulation. The transfer function of the open-loop compensated system is obtained either by hand calculation (the computations are simple enough) or by product of transfer functions numw=[0.1 0.05]; denw=[1 0.05]; gw=tf(numw,denw) Compensator * Open loop transfer function = W(s)KG(s) or g1=gw*g Transfer function: 25 s + 12.5 ----------------------s^3 + 5.05 s^2 + 0.25 s

Heikki Koivo

37

Let us draw the open-loop compensated Bode diagram, so as to see how the original Bode diagram has changed. bode(g1)
Bode Diagrams

Phase (deg); Magnitude (dB)

50 0 -50 -100 -120 -140 -160 10


-3

10

-2

10

-1

10

10

10

Frequency (rad/sec)

Fig.3.9. Bode diagram of the compensated open loop system. For comparison purposes the Bode diagrams of the uncompensated and compensated open-loop system are drawn in the same Figure. Use the following MATLAB commands: % open-loop transfer function to have more data points w=logspace(-3,2);[mag phase w]=bode(g,w); % Compensated open-loop transfer function numw=[0.1 0.05]; denw=[1 0.05]; gw=tf(numw,denw) % compensator g1=gw*g % compensated open-loop transfer function Transfer function: 25 s + 12.5 ----------------------s^3 + 5.05 s^2 + 0.25 s w=logspace(-3,2);[mag1 phase1 w]=bode(g1,w); % plot in the same figure first magnitude in dB w=logspace(-3,2); [mag phase w]=bode(g,w); [mag1 phase1 w]=bode(g1,w); magdb=squeeze(20*log10(mag)); mag1db=squeeze(20*log10(mag1)); semilogx(w,squeeze(magdb),'k',w,squeeze(mag1db),'k --'); grid xlabel('Frequency (rad/s)'); ylabel('Open and closed loop magnitudes in dB')

Heikki Koivo

38

100 Open and closed loop magnitudes in dB 80 60 40 20 0 -20 -40 -60 -3 10

New crossover frequency c


10
-2

10 10 Frequency (rad/s)

-1

10

10

Fig.3.10. Gain of the uncompensated (solid line, -) and compensated (dashed line, --) open-loop system. Note how the phase-lag compensator decreases the gain at higher frequencies.

Fig.3.11.Phase of the uncompensated (solid line, -) and compensated (dashed line, --) openloop system. Note how the phase-lag compensator decreases the phase at middle frequencies. % Then phase semilogx(w,squeeze(phase),'k',w,squeeze(phase1),'k --'); grid xlabel('w (rad/s)');ylabel('phase, uncompensated (-), compensated(--)') Let us now compute the closed-loop transfer function and then both the Bode diagram and the unit step response. Again in simple cases you could compute the transfer function by hand, but as easily by applying feedback command % closed-loop transfer function T1=feedback(g1,1) Transfer function: 25 s + 12.5 ------------------------------s^3 + 5.05 s^2 + 25.25 s + 12.5

Heikki Koivo

39

Bode diagram of T is shown in Figure 3.12. [magcl,phasecl]=bode(T1)

Fig.3.12. Bode diagram of the compensated closed-loop system. The bandwidth BW 6.8 rad/s is found using crosshair ginput(1), which is less than the 25 rad/s in Fig.3.7. resulting from gain compensation. This is also seen in the unit step response of Fig.3.15, where the response is slower now than without compensation. For comparison the Bode diagrams of the uncompensated and compensated closedloop systems are drawn in the same Figure. Recall how to compute the closed loop-transfer function (uncompensated) % uncompensated closed-loop system T=feedback(g,1); w=logspace(-1,2); [magcl phascl w]=bode(T,w); semilogx(w,20*log10(squeeze(magcl)),'k') % compensated closed-loop system w=logspace(-1,2);[magcl1 phasecl1 w]=bode(T1,w); % both in the same figure semilogx(w,20*log10(squeeze(magcl)),'k',w,20*log10(squeeze(magcl1)),'k --') xlabel('w (rad/s)');ylabel('closed-loop magnitude, uncompensated (-), compensated(--)') grid

Heikki Koivo

40

Fig.3.13. Bode diagram of the uncompensated and the compensated closed-loop magnitude. Note how the bandwidth is decreased, when phase-lag controller is used. This is also seen in the step response. Finally, let us compute the step response of the compensated closed-loop with the command step(T1); grid

Fig.3.14. The compensated closed-loop step-response. The overshoot is still slightly above 20%. This is because the assumption of second order dominant poles does not hold as well as expected.

Heikki Koivo

41

The roots of the closed-loop system are obtained from [numcl dencl]=tfdata(T1,'v'); roots(dencl) ans = -2.2506 + 4.2089i -2.2506 - 4.2089i -0.5487 There are two complex poles, but the third pole clearly has a strong effect on the response. Checking also the zeros: roots(numcl) ans = -0.5000. The zero is quite close to the pole p = -0.5487 and thus cancels most of the effect, but not quite enough. The uncompensated and compensated unit step responses can be drawn in the same Figure by using the following: [numcl dencl]=tfdata(T1,'v'); [numc denc]=tfdata(T,'v'); t=linspace(0,3); y1=step(numc,denc,t); y2=step(numcl,dencl,t); plot(t,y1,'g',t,y2,'b--'); grid xlabel('time');ylabel('Stepresponses, uncomp (-), comp (- -)'); The result is shown in Fig.3.15.

Fig.3.15. The closed loop unit step responses, pure gain compensation (K = 50) (-), and compensation with lag compensator (--). The overshoot is not quite satisfactory. As indicated above this is due to the error in dominant pole assumption.

Heikki Koivo

42

The result is not quite good enough, because the overshoot is almost 30% - maybe a larger requirement for phase margin leading to a smaller value of a 1 and a larger . Calculations are exactly the same as before. EXERCISE: Conclude the design so that also the overshoot requirement is satisfied.

SUMMARY OF PHASE-LAG DESIGN


STEP 1. Choose gain K to satisfy steady-state requirements. STEP 2. Draw Bode-diagram of KG(s). STEP 3. Determine the new crossover frequency . , i.e., the frequency at which the uncompensated c o system has phase (- 180 +PM), PM = desired phase margin . o o o o (PM 45 -60 for electro-mechanical, 25 -30 for processes). STEP 4. Decide how much to decrease the gain in dB at the frequency mentioned in step 3 so that it would become the new cross-over frequency . This determines a .
c 1

STEP 5 Gain must be decreased at high frequencies without disturbing it at lower frequencies. This is guaranteed by choosing the upper cut-off frequency to be one decade below .
c

STEP 6 Check by simulating step response. STEP 7. If requirements are met, stop. Otherwise go back to STEP 1. REMARK: If the system includes feedback dynamics H(s), because of a sensor, then the design is carried out by including it in the Bode diagram. So instead of the open-loop G(s), the design is performed for G(s)H(s). Exactly the same steps are followed. Special care must be taken e.g. in computing steady-state error.

Heikki Koivo

43

APPENDIX FEEDBACK Feedback connection of two systems. SYS = FEEDBACK(SYS1,SYS2) produces the feedback loop u --->O---->[ SYS1 ]----+---> y | | +-----[ SYS2 ]<---+ Negative feedback is assumed and the resulting system SYS maps u to y. To apply positive feedback, use the syntax SYS = FEEDBACK(SYS1,SYS2,+1). SYS = FEEDBACK(SYS1,SYS2,FEEDIN,FEEDOUT,SIGN) builds the more general feedback system +--------+ v --------->| | --------> z | SYS1 | u --->O---->| |----+---> y | +--------+ | | | +-----[ SYS2 ]<---+ The vector FEEDIN contains indices into the input vector of SYS1and specifies which inputs u are involved in the feedback loop. Similarly, FEEDOUT specifies which outputs y of SYS1 are used for feedback. If SIGN=1 then positive feedback is used. If SIGN=-1 or SIGN is omitted, then negative feedback is used. In all cases, the resulting system SYS has the same i nputs and outputs as SYS1). See also STAR, PARALLEL, SERIES, and CONNECT.

ROOTS Find polynomial roots. ROOTS(C) computes the roots of the polynomial whose coefficient sare the elements of the vector C. If C has N+1 components,the polynomial is C(1)*X^N + ... + C(N)*X + C(N+1). See also POLY. TFDATA TFDATA Quick access to transfer function data. [NUM,DEN] = TFDATA(SYS) returns the numerator(s) and denominator(s) of the transfer function SYS. NUM and DEN are cell arrays with as many rows as outputs and as many columns as inputs, and their (I,J) entries specify the transfer function from input J to output I. SYS is first converted to transfer function if necessary. [NUM,DEN,TS,TD] = TFDATA(SYS) returns the sample time TS and input delays TD. For con tinuous systems, TD is a vector with one entry per input channel. For discrete systems, TD is the empty matrix[]. For SISO systems, the convenience syntax [NUM,DEN] = TFDATA(SYS,'v') returns the numerator and denominator as row vectors rather than cell arrays. Other properties of SYS can be accessed with GET or by direct structure-like referencing (e.g., SYS.Ts) See also GET, SSDATA, ZPKDATA. PLOTTING PHASE MARGIN VS. ZETA zeta=0:0.1:1; PO=100*exp(-zeta*pi./sqrt(1-zeta.^2)); PM=atan(2*zeta./sqrt(sqrt(4*zeta.^4+1)-2*zeta.^2)); plot(zeta,PM);

Heikki Koivo

44

You might also like