The steps to design the Lead Compensator are with root locus are:

- From given specifications determine the damping ratio and the natural frequency .
- Find the dominant pole

. If damping ratio alone is given then draw the root locus and draw line from origin at an angle to intersect the root locus, the point of intersection is the dominant pole. - Measure angle contributed by each pole and zero of uncompensated system to the dominant pole as marked in the diagram, the angles are measured in the counter clockwise direction from the positive real axis direction.
- The angle needed to be provided byt the compensator is

This angle if greater than 60 then two compensators each providing half the required angle is made. - as In the figure above draw PC bisection angle APO and draw line PB and PD such that they make angle with respect to PC B is the required pole and D is the required zero.
- a lead compensator has the form

- Determine open Loop gain K at Sd,by taking equation
- form the complete transfer function with the lead compensator added in series to the original system
- plot the new Bode plot and determine phase margin and observe that it is the required phase margin

Now to do this In Matlab let us take a question. I will be solving the question number 1.7 in Advanced Control Systems By Nagoor Kani. In th text book the question has been solved without using matlab you can go through it to understand the steps better.

The question is

the Peak over shot is 12.63% natural frequency of oscillation is 8 rad/sec and velocity error constant should be greater than or equal to 2.5.

Solution:

Calculate the damping ration from the peak over shoot given the equation had been discussed in the previous post.

The code below shows the matlab commands to obtain the design.

clear all close all n=input('Enter the Coefficients of Numerator') d=input('Enter the Coefficients of Denominator') %enter as array [1 11 28 0] 'G(s)' G1=tf(n,d) G2=tf(conv([1 0],n),d); % this is for evaluating the Kv we multiply numerator with s. M=input('Enter peak overshoot: ') z=sqrt(log(M)^2 /(pi^2 + log(M)^2)) % calulate damping ratio wn=input('Enter wn: ') Kv=input('Enter velocity constant: ') Sd=complex((-z*wn),(wn*sqrt(1-z^2))) % forming the dominant pole rlocus(G1) % plotting uncompensated root locus hold on plot(Sd,'*') % mark the dominant pole axis([-20 20 -20 20]) 'Press any key to proceeed' pause close all pzmap(G1) % make pole zero plot. hold on plot(Sd,'*') % mark the dominant pole plot(conj(Sd),'*') axis([-20 20 -20 20]) Po=roots(d) pang=zeros(1,size(Po,1));

% Finding the angle contributions of poles

for i=1:size(Po,1)

pang(i)=abs(atand((abs(imag(Sd))-abs(imag(Po(i,1))))/(abs(real(Sd))-abs(real(Po(i,1))))));

if(real(Po(i,1))>real(Sd))

pang(i)=180-pang(i);

end

end

Zo=roots(n);

zang=zeros(1,size(Zo,1));

% Finding the angle contributions of zeroes

for i=1:size(Zo,1)

zang(i)=abs(atand((abs(imag(Sd))-abs(imag(Zo(i,1))))/(abs(real(Sd))-abs(real(Zo(i,1))))));

if(real(Zo(i,1))>real(Sd))

zang(i)=180-zang(i);

end

end

thetap=sum(pang);

thetaz=sum(zang);

‘Required Phase Lead’

phm=thetap-thetaz-180

phmh=phm;

t=1;

% LOGIC TO CHECK IF PHASE LEAD IS GREATER THAN 60 in some cases it can be 4 times greater than 60 then we have to repeatedly divide it till less than 60

while phmh>60

phmh=phm/(2*t)

t=t+1;

end

t=2*(t-1);

ph1=180-atand(abs(imag(Sd))/abs(real(Sd)));

ph1=ph1/2;

c=(real(Sd))-((imag(Sd))/tand(ph1));

ph=ph1-(phmh);

pol=(real(Sd))-((imag(Sd))/tand(ph))

ph=(ph+phmh);

zer=(real(Sd))-((imag(Sd))/tand(ph))

‘Press any key to proceeed’

pause

‘The lead Compensator’

Gc=tf([1 -zer],[1,-pol])

hold off

‘Open Loop Transfer Function K=1′

if phmh==phm

Go=Gc*G1;

sG=Gc*G2; % For evaluating error constant

else

Go=(Gc^t)*G1

sG=(Gc^t)*G2 % For evaluating error constant

end

sG=minreal(sG); % For evaluating error constant

rlocus(Go)

hold on

plot(Sd,’*’)

axis([-20 20 -20 20])

[K a]=rlocfind(Go)

‘The Velocity Error Constant is’

Kvn=dcgain(K*sG); % For evaluating error constant

if Kvn>=Kv

‘Condition is satisfied’

Kvn

else

‘Improve design’

Kvn

end

‘The Complete transfer open loop function’

Go=Go*K

close all

rlocus(Go)

hold on

plot(Sd,’*’)

very good program……..could you please send me the m.file for this programe, since the second part of program not working …..!!!!?

Please send a mail to my contact ID so that I can reply back

Ziad Qatanani , thanks for your support,…

..

Ziad.Qatanani@dadgroup.com,,,,,,,,,,,,,,,,,,,,,, other question, did you have matlab program to plot and calculate the departure angle of poles in root locus, also can identify (mark in the plote) the root locuse segments as per odd rule.

…thanks in advance.

I tried to use this code for discret time(z plane) but its not working properly. Can help me?

If the angle contributed is more than 60 degree then we consider it is cascade of two lead compensator

But why 60 degree? Why not other angle?