%plot inline -f "svg"
pkg load control
the input data:
T0 = tf([1e4, 1e9], [1, 2e3, 1e8])
fc = 10e3
finalpm = 90
set the crossover frequency, $f_C$, this is our second input
wc = 2 * pi * fc;
set the required value of $k$
k = 1 / abs(T0(wc))
T1 = k * T0
determine the phase margin, pm
Twc = T1(wc);
aTwc = abs(Twc)
pm = 180 + 180 / pi * angle(Twc)
lead compensator, the third input variable, desired phase margin, finalpm
philead = finalpm + 6 - pm;
pl = pi / 180 * philead;
t = tan(pl);
p = t + sqrt(1 + t^2);
Hlead = 1 / p * tf([p / wc, 1], [1 / (p * wc), 1])
connect the lead compensator, we get $T_2$
T2 = series(Hlead, T1)
lag compensator
wl = wc / 10;
Hlag = parallel(1, tf([wl], [1 0]))
connect the lag compensator
T3 = series(Hlag, T2)
open loop transfer function Bode plot:
bode(T3)
closed loop transfer function:
H3 = feedback(T3)
closed loop poles:
pzmap(H3)
legend('location', 'northwest')
closed loop step response
step(H3)
closed loop Bode plot:
bode(H3)
compressed open loop Nyquist plot:
dodato_nestabilnih_polova = pypass(T3);