4.2.4. Analytical Design of a PID Compensator

This section presents an analytical procedure for PID compensator design. It is based on Section 7.11 of Phillips and Harbor Feedback_ Control Systems, Prentice Hall, 1988[1].

The compensator transfer function is assumed to be

D(s)=KDs2+Kprops+KIs

where Kprop is the proportional gain, KDis the derivative gain and KI is the integral gain. In this procedure we choose the PID gain parameters such that, given a desired location for one of the closed-loop poles s1, the equation

D(s)G(s)H(s)|s=s1=1

is satisfied; that is we are designing a compensator that places a root of the closed-loop characteristic equation at s=s1.

The design proceeds as follows. First we express the desired closed loop pole position

s1=|s1|ejψ

and

G(s1)H(s1)=|G(s1)H(s1)|ejψ

Then the design equations (derived in Appendix B of Phillips and Harbor, 1988) are

Kprop=sin(βψ)|G(s1)H(s1)|sinβ2KIcosβ|s1|
Kprop=sinψ|s1||G(s1)H(s1)|sinβKI|s1|2

Since there are three unknowns and only two relationships that must be satisfied, one of the gains may be chosen to satisfy a different design specification, such as choosing KI to achieve a certain steady-state response. These equations can also be used for PI and P+D controllers by setting the appropriate gain to zero. We now illustrate the design procedure with an example.

4.2.4.1. Example

Definitions (change these to change design)

The plant transfer function is

G(s)=1(s+1)(5s+1)
imatlab_export_fig('print-svg')  % Static svg figures.
Copy to clipboard
G = tf(1,conv([1 1],[5 1]));  
Copy to clipboard

The feedback transfer function is H(s)=1:

H=tf(1,1); 
Copy to clipboard

So G(s)H(s) is:

GH=G*H 
Copy to clipboard
GH =
Copy to clipboard
         1
Copy to clipboard
  ---------------
Copy to clipboard
  5 s^2 + 6 s + 1
Copy to clipboard
Continuous-time transfer function.
Copy to clipboard

The root locus of the uncompensated system is:

clf, sgrid(1/sqrt(2),0.25:0.25:2), hold on, rlocus(GH),hold off 
Copy to clipboard
../../_images/analpid_9_0.svg

From the root locus diagram, it is clear that for ideal damping the natural frequency of the closed-loop poles would be about 0.9 rad/s with a settling time of:

Ts=4.6ζωn=4.65/8=7.36 s

Suppose we wish to half the settling time then we need to double the natural frequency to ωn=2rad/s.

That is:

zeta = 1/sqrt(2); wn=2;  
s1 = -zeta*wn+j*wn*sqrt(1-zeta^2)  
Copy to clipboard
s1 =
  -1.4142 + 1.4142i
Copy to clipboard

The steady state error of the uncompensated type 0 system is:

11+G(s)H(s)|s=0=11+1(5s+1)(s+1)|s=0=12

For the compensated system, which is type 1:

Kv=sD(s)G(s)H(s)|s=0=s(KDss+Kprods+KI)s|s=0=KI

So if we want a steady-state _velocity _error of 20% we need

Ki=20; 
Copy to clipboard

4.2.4.2. Calculations

Having set up your problem, you shouldn?t need to change these commands

Polar form of s1

m_s1=abs(s1),  p_s1 = angle(s1)*180/pi % degrees  
Copy to clipboard
m_s1 =
     2
Copy to clipboard
p_s1 =
   135
Copy to clipboard

Transfer function evaluated at s1is G(s1)H(s1)in polar form:

[numGH,denGH] = tfdata(GH,'v');
GHs1=polyval(numGH,s1)/polyval(denGH,s1)   
Copy to clipboard
GHs1 =
  -0.0397 + 0.0610i
Copy to clipboard

Magnitude:

mGHs1=abs(GHs1) 
Copy to clipboard
mGHs1 =
    0.0728
Copy to clipboard

Phase2:

pGHs1=-angle(GHs1)*180/pi - 90 % degrees
Copy to clipboard
pGHs1 =
 -213.0264
Copy to clipboard

Hence:

beta = p_s1*pi/180; psi = pGHs1*pi/180;  % radians
Copy to clipboard

From (5) and (6)

Kprop = (-sin(beta+psi))/(mGHs1*sin(beta)) - (2*Ki*cos(beta)/m_s1)  
Copy to clipboard
Kprop =
   33.1421
Copy to clipboard
Kd = (sin(psi)/(m_s1*mGHs1*sin(beta))) + Ki/(m_s1^2)  
Copy to clipboard
Kd =
   10.2929
Copy to clipboard

Compensator is therefore given by

D = tf([Kd, Kprop, Ki],[1, 0]) 
Copy to clipboard
D =
Copy to clipboard
  10.29 s^2 + 33.14 s + 20
Copy to clipboard
  ------------------------
Copy to clipboard
             s
Copy to clipboard
Continuous-time transfer function.
Copy to clipboard

4.2.4.3. Evaluation of Design

Open loop transfer function:

Go=D*GH  
Copy to clipboard
Go =
Copy to clipboard
  10.29 s^2 + 33.14 s + 20
Copy to clipboard
  ------------------------
Copy to clipboard
     5 s^3 + 6 s^2 + s
Copy to clipboard
Continuous-time transfer function.
Copy to clipboard

4.2.4.3.1. Root locus:

rlocus(Go)

4.2.4.3.2. Closed-loop transfer function:

DG = D*G  
Gc = feedback(DG,H)  
Copy to clipboard
DG =
Copy to clipboard
  10.29 s^2 + 33.14 s + 20
Copy to clipboard
  ------------------------
Copy to clipboard
     5 s^3 + 6 s^2 + s
Copy to clipboard
Continuous-time transfer function.
Copy to clipboard
Gc =
Copy to clipboard
      10.29 s^2 + 33.14 s + 20
Copy to clipboard
  --------------------------------
Copy to clipboard
  5 s^3 + 16.29 s^2 + 34.14 s + 20
Copy to clipboard
Continuous-time transfer function.
Copy to clipboard

4.2.4.3.3. Step response:

step(Gc) 
Copy to clipboard
../../_images/analpid_36_0.svg

4.2.4.4. Footnotes

[1] The proofs of the formulae given are derived in Appendix B of this text.

[2] You must be careful with angles when using packages like MATLAB, and indeed pocket calculators. It is nearly always beneficial to have a sketch so that you can correct the results. In this case a correction of 90 was needed.

4.2.4.5. Resources

An executable version of this document is available to download as the MATLAB Live Script file analrloc.mlx.