2019-10-08 11:25:47 +02:00
|
|
|
%% Clear Workspace and Close figures
|
|
|
|
clear; close all; clc;
|
|
|
|
|
|
|
|
%% Intialize Laplace variable
|
|
|
|
s = zpk('s');
|
|
|
|
|
2020-11-12 10:14:52 +01:00
|
|
|
addpath('./mat/');
|
|
|
|
|
2019-10-08 11:25:47 +02:00
|
|
|
freqs = logspace(1, 3, 1000);
|
|
|
|
|
|
|
|
% Load Plant
|
|
|
|
|
|
|
|
load('mat/plant.mat', 'sys', 'Gi', 'Zc', 'Ga', 'Gc', 'Gn', 'Gd');
|
|
|
|
|
|
|
|
% Integral Force Feedback
|
|
|
|
|
|
|
|
bode(sys({'Vch', 'Vcv'}, {'Uch', 'Ucv'}));
|
|
|
|
|
|
|
|
Kppf = blkdiag(-10000/s, tf(0));
|
|
|
|
|
|
|
|
Kppf.InputName = {'Vch', 'Vcv'};
|
|
|
|
Kppf.OutputName = {'Uch', 'Ucv'};
|
|
|
|
|
|
|
|
figure;
|
|
|
|
% Magnitude
|
2020-11-03 11:08:16 +01:00
|
|
|
ax1 = subplot(2,1,1);
|
2019-10-08 11:25:47 +02:00
|
|
|
hold on;
|
|
|
|
plot(freqs, abs(squeeze(freqresp(G, freqs, 'Hz'))), 'k-');
|
|
|
|
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
|
|
|
|
set(gca, 'XTickLabel',[]);
|
|
|
|
ylabel('Magnitude [dB]');
|
|
|
|
hold off;
|
|
|
|
|
|
|
|
% Phase
|
2020-11-03 11:08:16 +01:00
|
|
|
ax2 = subplot(2,1,2);
|
2019-10-08 11:25:47 +02:00
|
|
|
hold on;
|
|
|
|
plot(freqs, 180/pi*angle(squeeze(freqresp(G, freqs, 'Hz'))), 'k-');
|
|
|
|
set(gca,'xscale','log');
|
|
|
|
yticks(-360:90:180);
|
|
|
|
ylim([-360 0]);
|
|
|
|
xlabel('Frequency [Hz]'); ylabel('Phase [deg]');
|
|
|
|
hold off;
|
|
|
|
|
|
|
|
linkaxes([ax1,ax2],'x');
|
|
|
|
xlim([freqs(1), freqs(end)]);
|
|
|
|
|
|
|
|
inputs = {'Uch', 'Ucv', 'Unh', 'Unv'};
|
|
|
|
outputs = {'Ich', 'Icv', 'Rh', 'Rv', 'Vph', 'Vpv'};
|
|
|
|
|
|
|
|
sys_cl = connect(sys, Kppf, inputs, outputs);
|
|
|
|
|
|
|
|
figure; bode(sys_cl({'Vph', 'Vpv'}, {'Uch', 'Ucv'}), sys({'Vph', 'Vpv'}, {'Uch', 'Ucv'}))
|