Chapter6
ナイキストの安定判別
P = tf([0, 1], [1, 1, 1.5, 1])
P =
1
---------------------
s^3 + s^2 + 1.5 s + 1
連続時間の伝達関数です。
pole(P)
-0.1204 + 1.1414i
-0.1204 - 1.1414i
-0.7592 + 0.0000i
[Gm, Pm, wpc, wgc] = margin(P);
plot(t, u, 'LineWidth', 2);
plot(t, y, 'LineWidth', 2);
plot_set(gcf, 't', 'u, y');
set(gcf,'Position',[100 100 700 600])
[x, y] = nyquist(P, logspace(-3,5,1000));
plot(x(:), y(:), 'LineWidth', 2);
plot(x(:), -y(:), '--', 'LineWidth', 2);
scatter(-1, 0, 'filled', 'k');
P = tf([0, 1], [1, 2, 2, 1])
P =
1
---------------------
s^3 + 2 s^2 + 2 s + 1
連続時間の伝達関数です。
pole(P)
-1.0000 + 0.0000i
-0.5000 + 0.8660i
-0.5000 - 0.8660i
[Gm, Pm, wpc, wgc] = margin(P);
plot(t, u, 'LineWidth', 2);
plot(t, y, 'LineWidth', 2);
plot_set(gcf, 't', 'u, y');
set(gcf,'Position',[100 100 700 600])
[x, y] = nyquist(P, logspace(-3,5,1000));
plot(x(:), y(:), 'LineWidth', 2);
plot(x(:), -y(:), '--', 'LineWidth', 2);
scatter(-1, 0, 'filled', 'k');
アームの角度制御(PID制御)
mu = 1.5e-2; % 粘性摩擦係数[kg*m^2/s]
J = 1.0e-2; % 慣性モーメント[kg*m^2]
P = tf( [0,1], [J, mu, M*g*l] );
P制御
K = tf([0, kp(i)], [0, 1]);
[gain, phase, w] = bode(H, logspace(-1,2));
gainLog = 20*log10(gain(:));
semilogx(w, gainLog, 'LineWidth', 2, 'DisplayName','k_P='+string(kp(i)));
semilogx(w, phaseDeg, 'LineWidth', 2, 'DisplayName','k_P='+string(kp(i)));
disp('kp='+string(kp(i)));
[gm, pm, wpc, wgc] = margin(H)
disp('----------------');
end
gm = Inf
pm = 21.1561
wpc = Inf
wgc = 12.0304
gm = Inf
pm = 12.1170
wpc = Inf
wgc = 13.9959
gm = Inf
pm = 7.4192
wpc = Inf
wgc = 17.2170
subplot(2,1,1); bodeplot_set(gcf, '\omega [rad/s]', 'Gain [dB]', 'best');
subplot(2,1,2); bodeplot_set(gcf, '\omega [rad/s]', 'Phase [deg]', 'best');
PI制御
K = tf([kp, ki(i)], [1, 0]);
[gain, phase, w] = bode(H, logspace(-1,2));
gainLog = 20*log10(gain(:));
semilogx(w, gainLog, 'LineWidth', 2, 'DisplayName','k_I='+string(ki(i)));
semilogx(w, phaseDeg, 'LineWidth', 2, 'DisplayName','k_I='+string(ki(i)));
disp('ki='+string(ki(i)));
[gm, pm, wpc, wgc] = margin(H)
disp('----------------');
end
gm = Inf
pm = 7.4192
wpc = Inf
wgc = 17.2170
gm = 0.7397
pm = -0.8651
wpc = 15.6862
wgc = 17.2776
gm = 0.2109
pm = -8.7614
wpc = 11.8443
wgc = 17.4498
subplot(2,1,1); bodeplot_set(gcf, '\omega [rad/s]', 'Gain [dB]', 'best');
subplot(2,1,2); bodeplot_set(gcf, '\omega [rad/s]', 'Phase [deg]', 'best');
K = tf([kp, ki(i)], [1, 0]);
plot(t,y*ref, 'linewidth', 2, 'DisplayName','k_I='+string(ki(i)))
plot_set(gcf, 't', 'y', 'best')
plot(t, ref*ones(1,size(t,2)), 'k');
PID制御
K = tf([kd(i), kp, ki], [1,0]);
[gain, phase, w] = bode(H, logspace(-1,2));
gainLog = 20*log10(gain(:));
semilogx(w, gainLog, 'LineWidth', 2, 'DisplayName','k_D='+string(kd(i)));
semilogx(w, phaseDeg, 'LineWidth', 2, 'DisplayName','k_D='+string(kd(i)));
disp('kd='+string(kd(i)));
[gm, pm, wpc, wgc] = margin(H)
disp('----------------');
end
gm = 0.7397
pm = -0.8651
wpc = 15.6862
wgc = 17.2776
gm = Inf
pm = 45.2117
wpc = NaN
wgc = 18.8037
gm = Inf
pm = 71.2719
wpc = NaN
wgc = 24.7303
subplot(2,1,1); bodeplot_set(gcf, '\omega [rad/s]', 'Gain [dB]', 'best');
subplot(2,1,2); bodeplot_set(gcf, '\omega [rad/s]', 'Phase [deg]', 'best');
K = tf([kd(i), kp, ki], [1,0]);
plot(t,y*ref, 'linewidth', 2, 'DisplayName','k_D='+string(kd(i)))
plot_set(gcf, 't', 'y', 'best')
plot(t, ref*ones(1,size(t,2)), 'k');
開ループ系の比較
Label = ["After", "Before" ];
K = tf([kd(i), kp(i), ki(i)], [1,0]);
[gain, phase, w] = bode(H, logspace(-1,2));
gainLog = 20*log10(gain(:));
semilogx(w, gainLog, 'LineWidth', 2, 'DisplayName', Label(i));
semilogx(w, phaseDeg, 'LineWidth', 2, 'DisplayName',Label(i));
[gm, pm, wpc, wgc] = margin(H)
disp('----------------');
end
gm = Inf
pm = 45.2117
wpc = NaN
wgc = 18.8037
gm = Inf
pm = 12.1170
wpc = Inf
wgc = 13.9959
subplot(2,1,1); bodeplot_set(gcf, '\omega [rad/s]', 'Gain [dB]', 'best');
subplot(2,1,2); bodeplot_set(gcf, '\omega [rad/s]', 'Phase [deg]', 'best');
閉ループ系の比較
K = tf([kd(i), kp(i), ki(i)], [1,0]);
plot(t,y*ref, 'linewidth', 2, 'DisplayName', Label(i))
disp('----------------');
plot_set(gcf, 't', 'y', 'best')
plot(t, ref*ones(1,size(t,2)), 'k');
K = tf([kd(i), kp(i), ki(i)], [1,0]);
[gain, phase, w] = bode(Gyr, logspace(-1,2));
gainLog = 20*log10(gain(:));
semilogx(w, gainLog, 'LineWidth', 2, 'DisplayName', Label(i));
semilogx(w, phaseDeg, 'LineWidth', 2, 'DisplayName',Label(i));
disp('----------------');
subplot(2,1,1); bodeplot_set(gcf, '\omega [rad/s]', 'Gain [dB]', 'best');
subplot(2,1,2); bodeplot_set(gcf, '\omega [rad/s]', 'Phase [deg]', 'best');
位相遅れ・進み補償
位相遅れ
K1 = tf([alpha*T1, alpha], [alpha*T1, 1]);
[gain, phase, w] = bode(K1, logspace(-2,3));
gainLog = 20*log10(gain(:));
semilogx(w, gainLog, 'LineWidth', 2);
semilogx(w, phaseDeg, 'LineWidth', 2);
subplot(2,1,1); bodeplot_set(gcf, '\omega [rad/s]', 'Gain [dB]');
subplot(2,1,2); bodeplot_set(gcf, '\omega [rad/s]', 'Phase [deg]');
omegam = 1/T1/sqrt(alpha)
phim = asin( (1-alpha)/(1+alpha) ) * 180/pi
K1 = tf([alpha*T1, alpha], [alpha*T1, 1]);
[gain, phase, w] = bode(K1, logspace(-2,3));
gainLog = 20*log10(gain(:));
semilogx(w, gainLog, 'LineWidth', 2);
semilogx(w, phaseDeg, 'LineWidth', 2);
subplot(2,1,1); bodeplot_set(gcf, '\omega [rad/s]', 'Gain [dB]');
subplot(2,1,2); bodeplot_set(gcf, '\omega [rad/s]', 'Phase [deg]');
omegam = 1/T1/sqrt(alpha)
phim = asin( (1-alpha)/(1+alpha) ) * 180/pi
位相進み
K2 = tf([T2, 1],[beta*T2, 1])
K2 =
s + 1
---------
0.1 s + 1
連続時間の伝達関数です。
[gain, phase, w] = bode(K2, logspace(-2,3));
gainLog = 20*log10(gain(:));
semilogx(w, gainLog, 'LineWidth', 2);
semilogx(w, phaseDeg, 'LineWidth', 2);
subplot(2,1,1); bodeplot_set(gcf, '\omega [rad/s]', 'Gain [dB]');
subplot(2,1,2); bodeplot_set(gcf, '\omega [rad/s]', 'Phase [deg]');
omegam = 1/T1/sqrt(alpha)
phim = asin( (1-alpha)/(1+alpha) ) * 180/pi
K2 = tf([T2, 1],[beta*T2, 1])
K2 =
s + 1
-----------
1e-05 s + 1
連続時間の伝達関数です。
[gain, phase, w] = bode(K2, logspace(-2,3));
gainLog = 20*log10(gain(:));
semilogx(w, gainLog, 'LineWidth', 2);
semilogx(w, phaseDeg, 'LineWidth', 2);
subplot(2,1,1); bodeplot_set(gcf, '\omega [rad/s]', 'Gain [dB]');
subplot(2,1,2); bodeplot_set(gcf, '\omega [rad/s]', 'Phase [deg]');
omegam = 1/T1/sqrt(alpha)
phim = asin( (1-alpha)/(1+alpha) ) * 180/pi
アームの角度制御(位相遅れ・進み補償)
mu = 1.5e-2; % 粘性摩擦係数[kg*m^2/s]
J = 1.0e-2; % 慣性モーメント[kg*m^2]
P = tf( [0,1], [J, mu, M*g*l] );
[gain, phase, w] = bode(P, logspace(-1,2));
gainLog = 20*log10(gain(:));
semilogx(w, gainLog, 'LineWidth', 2);
semilogx(w, phaseDeg, 'LineWidth', 2);
subplot(2,1,1); bodeplot_set(gcf, '\omega [rad/s]', 'Gain [dB]');
subplot(2,1,2); bodeplot_set(gcf, '\omega [rad/s]', 'Phase [deg]');
制御対象のボード線図. 低周波ゲインが0[dB]なので,このままフィードバック系を構築しても定常偏差が残る.
位相遅れ補償の設計
定常偏差を小さくするために,位相遅れ補償から設計する
低周波ゲインを上げるために,α=20とする.そして,ゲインを上げる周波数は,T1で決めるが,最終的なゲイン交差周波数(ゲイン交差周波数の設計値)の10分の1程度を1/T1にするために,T1=0.25とする(1/T1=40/10=4).
K1 = tf([alpha*T1, alpha], [alpha*T1, 1])
K1 =
5 s + 20
--------
5 s + 1
連続時間の伝達関数です。
[gain, phase, w] = bode(H1, logspace(-1,2));
gainLog = 20*log10(gain(:));
semilogx(w, gainLog, 'LineWidth', 2);
semilogx(w, phaseDeg, 'LineWidth', 2);
subplot(2,1,1); bodeplot_set(gcf, '\omega [rad/s]', 'Gain [dB]');
subplot(2,1,2); bodeplot_set(gcf, '\omega [rad/s]', 'Phase [deg]');
phaseH1at40 = -(180 + atan(imag(S)/real(S))/pi*180)
最終的にゲイン補償によって,ゲイン交差周波数を設計値の40[rad/s]まで上げるが,あげてしまうと,位相余裕が60[dB]を下回る.実際, 40[rad/s]における位相は -176[deg]なので,位相余裕は 4[deg]程度になってしまう.したがって,40[rad/s]での位相を -120[deg] まであげておく.
位相進み補償の設計
位相進み補償の設計
40[rad/s]において位相を進ませる量は 60 - (180-176) = 56[deg]程度とする.
phim = (60- (180 - phaseH1at40 ) ) * pi/180;
beta = (1-sin(phim))/(1+sin(phim));
K2 = tf([T2, 1],[beta*T2, 1])
K2 =
0.1047 s + 1
--------------
0.005971 s + 1
連続時間の伝達関数です。
[gain, phase, w] = bode(H2, logspace(-1,2));
gainLog = 20*log10(gain(:));
semilogx(w, gainLog, 'LineWidth', 2, 'DisplayName', Label(i));
semilogx(w, phaseDeg, 'LineWidth', 2, 'DisplayName',Label(i));
subplot(2,1,1); bodeplot_set(gcf, '\omega [rad/s]', 'Gain [dB]');
subplot(2,1,2); bodeplot_set(gcf, '\omega [rad/s]', 'Phase [deg]');
magH2at40 = sqrt(imag(S)^2 + real(S)^2)
phaseH2at40 = -(180 - atan(imag(S)/real(S))/pi*180)
位相進み補償により,40[rad/s]での位相が -120[deg]となっている. あとは,ゲイン補償により,40[rad/s]のゲインを 0[dB] にすればよい.
ゲイン補償の設計
ゲイン補償の設計
40[rad/s] におけるゲインが -11[dB] 程度なので, 11[dB]分上に移動させる. そのために,k=1/magH2at40 をゲイン補償とする. これにより,40[rad/s]がゲイン交差周波数になり,位相余裕もPM=60[deg]となる.
[gm, pm, wpc, wgc] = margin(H)
gm = Inf
pm = 60.0000
wpc = Inf
wgc = 40.0000
[gain, phase, w] = bode(H, logspace(-1,2));
gainLog = 20*log10(gain(:));
semilogx(w, gainLog, 'LineWidth', 2, 'DisplayName', 'H');
semilogx(w, phaseDeg, 'LineWidth', 2, 'DisplayName', 'H');
[gain, phase, w] = bode(P, logspace(-1,2));
gainLog = 20*log10(gain(:));
semilogx(w, gainLog, 'LineWidth', 2, 'DisplayName', 'P');
semilogx(w, phaseDeg, 'LineWidth', 2, 'DisplayName', 'P');
subplot(2,1,1); bodeplot_set(gcf, '\omega [rad/s]', 'Gain [dB]', 'Best');
subplot(2,1,2); bodeplot_set(gcf, '\omega [rad/s]', 'Phase [deg]', 'Best');
閉ループ系の応答
plot(t,y*ref, 'linewidth', 2, 'DisplayName', 'After')
disp('----------------');
plot(t,y*ref, 'linewidth', 2, 'DisplayName', 'Before')
disp('----------------');
plot_set(gcf, 't', 'y', 'best')
plot(t, ref*ones(1,size(t,2)), 'k');
[gain, phase, w] = bode(Gyr_H, logspace(-1,2));
gainLog = 20*log10(gain(:));
semilogx(w, gainLog, 'LineWidth', 2, 'DisplayName', 'After');
semilogx(w, phaseDeg, 'LineWidth', 2, 'DisplayName', 'After');
disp('----------------');
[gain, phase, w] = bode(Gyr_P, logspace(-1,2));
gainLog = 20*log10(gain(:));
semilogx(w, gainLog, 'LineWidth', 2, 'DisplayName', 'Before');
semilogx(w, phaseDeg, 'LineWidth', 2, 'DisplayName', 'Before');
disp('----------------');
subplot(2,1,1); bodeplot_set(gcf, '\omega [rad/s]', 'Gain [dB]', 'best');
subplot(2,1,2); bodeplot_set(gcf, '\omega [rad/s]', 'Phase [deg]', 'best');