# Daily Archives: May 25, 2012

## Lead Compensator design with Root Locus

The steps to design the Lead Compensator are with root locus are:  1. From given specifications determine the damping ratio and the natural frequency .
2. 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.
3. 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.
4. 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.
5. 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 .
6. a lead compensator has the form 7. Determine open Loop gain K at Sd,by taking equation 8. form the complete transfer function with the lead compensator added in series to the original system
9. 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);
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
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,’*’) Root Locus Of uncompensated system the dominant Pole is not on Root Locus