Contents
P11.1 Gain compensator
G=tf(10,[1 2 10]);
[gm,pm]=margin(G);
disp('Compensator:')
k=pm/65*.98;
disp('Gain/Phase margins:')
[gm,pm]=margin(k*G)
disp('Bode plot:')
margin(K*G), grid
Compensator:
Gain/Phase margins:
gm =
Inf
pm =
65.5967
Bode plot:
P11.2 Phase-lag compensator
disp('Compensator:')
K=k*tf([1 .1],[1 .015])
disp('DC gain:')
dcgain(K*G)
disp('Gain/Phase margins:')
[gm,pm]=margin(K*G)
disp('Bode plot:')
margin(K*G), grid
Compensator:
K =
0.8013 s + 0.08013
------------------
s + 0.015
Continuous-time transfer function.
DC gain:
ans =
5.3417
Gain/Phase margins:
gm =
Inf
pm =
64.2371
Bode plot:
P11.3 PD compensator
G=tf(5*[3 1],[1 2 10 0]);
disp('Compensator:')
K=tf([1 8],1)
disp('Gain/Phase margins:')
[gm,pm]=margin(K*G)
disp('Bode plot:')
margin(K*G), grid
disp('Settling time:')
S=stepinfo(feedback(K*G,1));
S.SettlingTime
Compensator:
K =
s + 8
Continuous-time transfer function.
Gain/Phase margins:
gm =
Inf
pm =
70.6623
Bode plot:
Settling time:
ans =
4.3317
P11.4 Lead-lag compensator - Flexible beam
G=tf(10000,[1 10 10000]);
disp('Compensator:')
K=zpk([-100 -100],[-50, -5000],25)
disp('Bandwidth:')
bandwidth(feedback(K*G,1))
disp('Stability margins:')
[gm,pm]=margin(K*G)
disp('Bode plot:')
margin(K*G), grid
Compensator:
K =
25 (s+100)^2
---------------
(s+50) (s+5000)
Continuous-time zero/pole/gain model.
Bandwidth:
ans =
231.7843
Stability margins:
gm =
Inf
pm =
45.3414
Bode plot:
P11.5 PID compensator - Automobile
G=tf([28 120],[1 7 14]);
disp('Compensator:')
K=zpk([-10 -10],[0, -40],5)
disp('Bandwidth:')
bandwidth(feedback(G*K,1))
disp('Frequency response peak:')
[g,f]=getPeakGain(feedback(K*G,1))
disp('Nichols chart:')
nichols(K*G), grid
Compensator:
K =
5 (s+10)^2
----------
s (s+40)
Continuous-time zero/pole/gain model.
Bandwidth:
ans =
109.1920
Frequency response peak:
g =
1.0104
f =
4.2131
Nichols chart:
P11.6 Lead-lag/PID compensator - Human postural dynamics
G=tf([10],[1 0 -10]);
Klag=tf([1 5],[1 .1]);
wgc=20;
pm=60;
g=evalfr(Klag*G,j*wgc);
th=mod(pm-180-angle(g)*180/pi,360);
wz=sind(th)*abs(g)/(1-cosd(th)*abs(g))*wgc;
wp=sind(th)/(cosd(th)-abs(g))*wgc;
Klead=tf([1/wz 1],[1/wp 1]);
K=Klag*Klead;
disp('Lead-lag compensator:')
zpk(K)
disp('Stability margins:')
[gm,pm]=margin(K*G)
T=feedback(K*G,1);
disp('MATLAB PID design:')
Kpid=pidtune(G,pid(1,1,1,.01))
Tpid=feedback(Kpid*G,1);
disp('Step response:')
step(T,Tpid)
legend('Lead-lag','PID')
Lead-lag compensator:
ans =
155.08 (s+5) (s+0.4861)
-----------------------
(s+75.39) (s+0.1)
Continuous-time zero/pole/gain model.
Stability margins:
gm =
0.1067
pm =
60.0000
MATLAB PID design:
Kpid =
1 s
Kp + Ki * --- + Kd * --------
s Tf*s+1
with Kp = 21.3, Ki = 33.6, Kd = 3.31, Tf = 0.00544
Continuous-time PIDF controller in parallel form.
Step response: