% PD regulator via the root locus technique
% Example 8.8
% Modified february 6, 2004
num=[1 10]
d1=[1 1];d2=[1 2];d3=[1 12];
den=conv(conv(d1,d2),d3)
rlocus(num,den)
% design specifications
osd=0.20; tsd=1.5;
zeta=sqrt(log(osd)^2/(pi^2+log(osd)^2))
zeta=zeta+0.004; % overshoot inversly depends on zeta
% we add a small value to zeta in order to obtain os less than 0.2
wn=3/(zeta*tsd)
% desired operating point
sd=-zeta*wn+j*wn*sqrt(1-zeta^2)
p1=1; p2=2; p3=12; z1=10;
% formula (8.30)
alphac=pi-angle(sd+z1)+angle(sd+p1)+angle(sd+p2)+angle(sd+p3)
adeg=alphac*180/pi; % alphac in degrees
% formula (8.31)
zc=(wn/tan(alphac))*(zeta*tan(alphac)+sqrt(1-zeta^2))
nc=[1 zc]
numc=conv(num,nc)
denc=den
figure (1)
rlocus(num,den)
hold
rlocus(numc,denc)
xlabel('Real axis'); ylabel('Imaginary axis');
print -dps fig8-11.ps
figure (2)
rlocus(num,den)
hold
rlocus(numc,denc)
axis([-3 0 -5 5])
xlabel('Real Axis'); ylabel('Imaginary Axis');
print -dps fig8-12.ps

% Static gain at the desired operationg point
d1=abs(sd+p1); d2=abs(sd+p2); d3=abs(sd+p3);
d4=abs(sd+z1); d5=abs(sd+zc);
Ksd=(d1*d2*d3)/(d4*d5)
% Steady state errors of the original and compensated systems
Kp=Ksd*z1/(p1*p2*p3)
ess=1/(1+Kp)
Kpc=Kp*zc
essc=1/(1+Kpc)
% Step response of the compensated system
[cnumc,cdenc]=feedback(Ksd*numc,denc,1,1,-1)
t=0:0.01:3
yc=step(cnumc,cdenc,t)
figure (3)
plot(t,yc)
xlabel('Time(secs)'); ylabel('Amplitude');
text(0.5,1.1,'ymax=1.0774');text(0.6,0.1,'tpc=0.75');
text(1.4,0.9,'ts=1.125'); text(2.5,0.92,'yssc=0.8927');
print -dps fig8-13.ps
% Transient response parameters of the compensated system
yssc=1-essc
i=300
delt=0.05*yssc
while(abs(yc(i)-yssc))<delt
i=i-1
end
tsc=t(i); % the settling time
[ypc,ipc]=max(yc)
tpc=t(ipc); % the peak time
osc=ypc-yssc; % the oversoot
% Closed-loop eigenvalues of the compensated system
roots(cdenc)
