Removed old matlab files about control

This commit is contained in:
Thomas Dehaeze 2019-12-11 15:01:38 +01:00
parent ae148d1248
commit 897681e195
8 changed files with 0 additions and 360 deletions

View File

@ -1,90 +0,0 @@
%%
clear; close all; clc;
%% Load Configuration file
load('./mat/config.mat', 'save_fig', 'freqs');
%% Load Simulation Results
sim_light_vc_ol = load('./mat/sim_light_vc_ol.mat', 'time', 'Dx', 'Dy', 'Dz', 'Rx', 'Ry', 'Rz', 'K');
sim_light_vc_cl = load('./mat/sim_light_vc_cl.mat', 'time', 'Dx', 'Dy', 'Dz', 'Rx', 'Ry', 'Rz', 'K');
sim_light_pz_ol = load('./mat/sim_light_pz_ol.mat', 'time', 'Dx', 'Dy', 'Dz', 'Rx', 'Ry', 'Rz', 'K');
sim_light_pz_cl = load('./mat/sim_light_pz_cl.mat', 'time', 'Dx', 'Dy', 'Dz', 'Rx', 'Ry', 'Rz', 'K');
%% Start after few seconds
T_init = 1;
%% Plot X against Y in OL - Piezo and Voice Coil
figure;
hold on;
plot(1e9*sim_light_vc_ol.Dx, 1e9*sim_light_vc_ol.Dy);
plot(1e9*sim_light_pz_ol.Dx, 1e9*sim_light_pz_ol.Dy);
hold off;
xlabel('X Displacement [nm]'); ylabel('Y Displacement [nm]');
xlim([-1000 1000]); ylim([-1000 1000]);
xticks(-1000:200:1000); yticks(-1000:200:1000);
legend({'VC - Light - OL', 'PZ - Light - OL'});
if save_fig; exportFig('xy_ol_vc_pz', 'normal-normal', struct('path', 'control')); end
%% Plot X against Y in CL - Piezo and Voice Coil
figure;
hold on;
plot(1e9*sim_light_vc_cl.Dx, 1e9*sim_light_vc_cl.Dy);
plot(1e9*sim_light_pz_cl.Dx, 1e9*sim_light_pz_cl.Dy);
hold off;
xlabel('X Displacement [nm]'); ylabel('Y Displacement [nm]');
xlim([-500 500]); ylim([-500 500]);
xticks(-500:100:500); yticks(-500:100:500);
legend({'VC - Light - CL', 'PZ - Light - CL'});
if save_fig; exportFig('xy_cl_vc_pz', 'normal-normal', struct('path', 'control')); end
%% Compute the RMS Values
i_init = find(sim_light_vc_ol.time > T_init, 1);
rms_light_vc_ol = rms(sqrt(sim_light_vc_ol.Dx(i_init:end).^2+sim_light_vc_ol.Dy(i_init:end).^2));
rms_light_pz_ol = rms(sqrt(sim_light_pz_ol.Dx(i_init:end).^2+sim_light_pz_ol.Dy(i_init:end).^2));
rms_light_vc_cl = rms(sqrt(sim_light_vc_cl.Dx(i_init:end).^2+sim_light_vc_cl.Dy(i_init:end).^2));
rms_light_pz_cl = rms(sqrt(sim_light_pz_cl.Dx(i_init:end).^2+sim_light_pz_cl.Dy(i_init:end).^2));
fprintf(' \t OL \t CL [nm RMS]\n');
fprintf('PZ \t %.0f \t %.0f \n', 1e9*rms_light_pz_ol, 1e9*rms_light_pz_cl);
fprintf('VC \t %.0f \t %.0f \n\n', 1e9*rms_light_vc_ol, 1e9*rms_light_vc_cl);
%% Compute the PSD
sim_light_vc_ol.psd = computePsdDispl(sim_light_vc_ol, 1, 2);
sim_light_pz_ol.psd = computePsdDispl(sim_light_pz_ol, 1, 2);
sim_light_vc_cl.psd = computePsdDispl(sim_light_vc_cl, 1, 2);
sim_light_pz_cl.psd = computePsdDispl(sim_light_pz_cl, 1, 2);
%% PSD Open Loop and Close Loop for the X direction
figure;
hold on;
plot(sim_light_vc_ol.psd.f, sim_light_vc_ol.psd.dx, 'DisplayName', 'VC - $T_x$ - OL');
plot(sim_light_pz_ol.psd.f, sim_light_pz_ol.psd.dx, 'DisplayName', 'PZ - $T_x$ - OL');
set(gca,'ColorOrderIndex',1);
plot(sim_light_vc_cl.psd.f, sim_light_vc_cl.psd.dx, '--', 'DisplayName', 'VC - $T_x$ - CL');
plot(sim_light_pz_cl.psd.f, sim_light_pz_cl.psd.dx, '--', 'DisplayName', 'PZ - $T_x$ - CL');
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude [$m^2/Hz$]'); xlabel('Frequency [Hz]');
xlim([sim_light_vc_ol.psd.f(1), sim_light_vc_ol.psd.f(end)])
hold off;
legend('Location', 'southwest');
if save_fig; exportFig('psd_ol_cl_pz_vc_light_tx', 'normal-normal', struct('path', 'control')); end
%% PSD Open Loop and Close Loop for the Z direction
figure;
hold on;
plot(sim_light_vc_ol.psd.f, sim_light_vc_ol.psd.dz, 'DisplayName', 'VC - $T_z$ - OL');
plot(sim_light_pz_ol.psd.f, sim_light_pz_ol.psd.dz, 'DisplayName', 'PZ - $T_z$ - OL');
set(gca,'ColorOrderIndex',1);
plot(sim_light_vc_cl.psd.f, sim_light_vc_cl.psd.dz, '--', 'DisplayName', 'VC - $T_z$ - CL');
plot(sim_light_pz_cl.psd.f, sim_light_pz_cl.psd.dz, '--', 'DisplayName', 'PZ - $T_z$ - CL');
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude [$m^2/Hz$]'); xlabel('Frequency [Hz]');
xlim([sim_light_vc_ol.psd.f(1), sim_light_vc_ol.psd.f(end)])
hold off;
legend('Location', 'southwest');
if save_fig; exportFig('psd_ol_cl_pz_vc_light_tz', 'normal-normal', struct('path', 'control')); end

View File

@ -1,15 +0,0 @@
%%
clear; close all; clc;
%% Initialize Simulation and Inputs
initializeExperiment('tomography', 'light');
%% Run Close Loop Simulations
runSimulation('vc', 'light', 'cl', 'none');
runSimulation('pz', 'light', 'cl', 'none');
% runSimulation('vc', 'heavy', 'cl', 'none');
% runSimulation('pz', 'heavy', 'cl', 'none');
%%
opts_inputs = struct('Dw', true);
initializeInputs(opts_inputs);

View File

@ -1,34 +0,0 @@
%%
clear; close all; clc;
%% Load Controllers
load('./mat/K_fb.mat', 'K_light_vc', 'K_light_pz', 'K_heavy_vc', 'K_heavy_pz');
%% Closed Loop - Light Sample
initializeSample(struct('mass', 1));
initializeNanoHexapod(struct('actuator', 'lorentz'));
K = K_light_vc; %#ok
save('./mat/controllers.mat', 'K');
Gd_cl_light_vc = identifyPlant();
initializeNanoHexapod(struct('actuator', 'piezo'));
K = K_light_pz; %#ok
save('./mat/controllers.mat', 'K');
Gd_cl_light_pz = identifyPlant();
%% Closed Loop - Heavy Sample
initializeSample(struct('mass', 50));
initializeNanoHexapod(struct('actuator', 'lorentz'));
K = K_heavy_vc; %#ok
save('./mat/controllers.mat', 'K');
G_cl_heavy_vc = identifyPlant();
initializeNanoHexapod(struct('actuator', 'piezo'));
K = K_heavy_pz;
save('./mat/controllers.mat', 'K');
G_cl_heavy_pz = identifyPlant();
%% Save the identified transfer functions
save('./mat/G_cl.mat', 'G_cl_light_vc', 'G_cl_light_pz', 'G_cl_heavy_vc', 'G_cl_heavy_pz');

View File

@ -1,41 +0,0 @@
%%
clear; close all; clc;
%% Load System and Damped System
load('./mat/G.mat', 'G_light_vc', 'G_light_pz', 'G_heavy_vc', 'G_heavy_pz');
load('./mat/G_cl.mat', 'G_cl_light_vc', 'G_cl_light_pz', 'G_cl_heavy_vc', 'G_cl_heavy_pz');
%% Load Configuration file
load('./mat/config.mat', 'save_fig', 'freqs');
%% From xw to d
figure;
hold on;
plot(freqs, abs(squeeze(freqresp(G_light_vc.G_gm('Dx', 'Dgx'), freqs, 'Hz'))), '-', 'DisplayName', 'Light VC - OL');
plot(freqs, abs(squeeze(freqresp(G_light_pz.G_gm('Dx', 'Dgx'), freqs, 'Hz'))), '-', 'DisplayName', 'Light PZ - OL');
set(gca,'ColorOrderIndex',1);
plot(freqs, abs(squeeze(freqresp(G_cl_light_vc.G_gm('Dx', 'Dgx'), freqs, 'Hz'))), '--', 'DisplayName', 'Light VC - CL');
plot(freqs, abs(squeeze(freqresp(G_cl_light_pz.G_gm('Dx', 'Dgx'), freqs, 'Hz'))), '--', 'DisplayName', 'Light PZ - CL');
hold off;
xlim([freqs(1) freqs(end)]);
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude [m/m]'); xlabel('Frequency [Hz]');
legend('Location', 'southwest');
if save_fig; exportFig('damping_comp_xw', 'normal-normal', struct('path', 'active_damping')); end
%% From fi to d
figure;
hold on;
plot(freqs, abs(squeeze(freqresp(G_light_vc.G_fs('Dx', 'Fsx'), freqs, 'Hz'))), '-', 'DisplayName', 'Light VC - OL');
plot(freqs, abs(squeeze(freqresp(G_light_pz.G_fs('Dx', 'Fsx'), freqs, 'Hz'))), '-', 'DisplayName', 'Light PZ - OL');
set(gca,'ColorOrderIndex',1);
plot(freqs, abs(squeeze(freqresp(G_cl_light_vc.G_fs('Dx', 'Fsx'), freqs, 'Hz'))), '--', 'DisplayName', 'Light VC - CL');
plot(freqs, abs(squeeze(freqresp(G_cl_light_pz.G_fs('Dx', 'Fsx'), freqs, 'Hz'))), '--', 'DisplayName', 'Light PZ - CL');
hold off;
xlim([freqs(1) freqs(end)]);
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude [m/N]'); xlabel('Frequency [Hz]');
legend('Location', 'southwest');
if save_fig; exportFig('damping_comp_fi', 'normal-normal', struct('path', 'active_damping')); end

View File

@ -1,57 +0,0 @@
%%
clear; close all; clc;
%% Load Plant
load('./mat/G.mat', 'G_light_vc', 'G_light_pz', 'G_heavy_vc', 'G_heavy_pz');
%%
s = tf('s');
%%
% bodeFig({minreal(G_light_vc.G_cart(1, 1))}, struct('phase', true));
%%
% sisotool(minreal(G_light_vc.G_cart(6, 6)))
K_light_vc = tf(zeros(6));
K_light_vc(1, 1) = 3.4802e06*(s+0.6983)*(s+131.6)/((s+5.306e-06)*(s+577.4));
K_light_vc(2, 2) = 5.3292e06*(s+0.6722)*(s+58.23)/((s+3.628e-06)*(s+734.6));
K_light_vc(3, 3) = 2.1727e06*(s+66.94)*(s+3.522)/((s+530.6)*(s+0.0006859));
K_light_vc(4, 4) = 6.4807e06*(s+2.095)*(s+111.1)/((s+0.0001246)*(s+577.4));
K_light_vc(5, 5) = 2.5184e06*(s+5.582)*(s+48.76)/((s+0.01558)*(s+453.8));
K_light_vc(6, 6) = 1.022e06*(s+6.152)*(s+40.15)/((s+0.001945)*(s+589.7));
%%
i = 6;
bodeFig({-G_light_vc.G_plant(i, i)*K_light_vc(i, i)}, struct('phase', true))
%%
% sisotool(minreal(G_light_pz.G_plant(1, 1)))
K_light_pz = tf(zeros(6));
% K_light_pz(1, 1) = 3.4802e06*(s+0.6983)*(s+131.6)/((s+5.306e-06)*(s+577.4));
% K_light_pz(2, 2) = 5.3292e06*(s+0.6722)*(s+58.23)/((s+3.628e-06)*(s+734.6));
% K_light_pz(3, 3) = 2.1727e06*(s+66.94)*(s+3.522)/((s+530.6)*(s+0.0006859));
% K_light_pz(4, 4) = 6.4807e06*(s+2.095)*(s+111.1)/((s+0.0001246)*(s+577.4));
% K_light_pz(5, 5) = 2.5184e06*(s+5.582)*(s+48.76)/((s+0.01558)*(s+453.8));
% K_light_pz(6, 6) = 1.022e06*(s+6.152)*(s+40.15)/((s+0.001945)*(s+589.7));
%%
K_heavy_vc = tf(zeros(6));
K_heavy_pz = tf(zeros(6));
%%
save('./mat/K_fb.mat', 'K_light_vc', 'K_light_pz', 'K_heavy_vc', 'K_heavy_pz');
%% Automatic generation of controllers
% fs = 100;
%
% K_light_vc = generateDiagPidControl(G_light_vc.G_cart, fs);
% K_light_pz = generateDiagPidControl(G_light_pz.G_cart, fs);
%
% K_heavy_vc = generateDiagPidControl(G_heavy_vc.G_cart, fs);
% K_heavy_pz = generateDiagPidControl(G_heavy_pz.G_cart, fs);
%% Save the MIMO control
% save('./mat/K_fb.mat', 'K_light_vc', 'K_light_pz', 'K_heavy_vc', 'K_heavy_pz');

View File

@ -1,25 +0,0 @@
%%
clear; close all; clc;
%% Generate Control Laws for the Undamped System
run control_generate.m
%% Run the simulation and save results
% Run open loop simulations
run control_ol_sim.m
% Run closed loop simulations
run control_cl_sim.m
% Compute PSD in open loop
run control_ol_psd.m
% Plots to compare OL and CL for PZ and VC
run control_cl_ol_plots.m
%% Identify the Closed Loop Transfer Functions
% Compute the closed loop transfer functions
run control_cl_tf.m
% Compare OL and CL transfer functions
run control_cl_tf_comp.m

View File

@ -1,87 +0,0 @@
%%
clear; close all; clc;
%% Load Configuration file
load('./mat/config.mat', 'save_fig', 'freqs');
%% Load Simulation Results
sim_light_vc_ol = load('./mat/sim_light_vc_ol.mat', 'time', 'Dx', 'Dy', 'Dz', 'Rx', 'Ry', 'Rz', 'K');
sim_light_pz_ol = load('./mat/sim_light_pz_ol.mat', 'time', 'Dx', 'Dy', 'Dz', 'Rx', 'Ry', 'Rz', 'K');
sim_heavy_vc_ol = load('./mat/sim_heavy_vc_ol.mat', 'time', 'Dx', 'Dy', 'Dz', 'Rx', 'Ry', 'Rz', 'K');
sim_heavy_pz_ol = load('./mat/sim_heavy_pz_ol.mat', 'time', 'Dx', 'Dy', 'Dz', 'Rx', 'Ry', 'Rz', 'K');
%%
sim_light_vc_ol.psd = computePsdDispl(sim_light_vc_ol, 1, 2);
sim_light_pz_ol.psd = computePsdDispl(sim_light_pz_ol, 1, 2);
sim_heavy_vc_ol.psd = computePsdDispl(sim_heavy_vc_ol, 1, 2);
sim_heavy_pz_ol.psd = computePsdDispl(sim_heavy_pz_ol, 1, 2);
%% PSD Plot of translations
figure;
hold on;
plot(sim_light_vc_ol.psd.f, sim_light_vc_ol.psd.dx);
plot(sim_light_vc_ol.psd.f, sim_light_vc_ol.psd.dy);
plot(sim_light_vc_ol.psd.f, sim_light_vc_ol.psd.dz);
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude [$m^2/Hz$]'); xlabel('Frequency [Hz]');
hold off;
legend({'PSD $Tx$', 'PSD $Tz$', 'PSD $Tz$'})
if save_fig; exportFig('psd_ol_vc_light_trans', 'normal-normal', struct('path', 'control')); end
%% PSD Plot of rotations
figure;
hold on;
plot(sim_light_vc_ol.psd.f, sim_light_vc_ol.psd.rx);
plot(sim_light_vc_ol.psd.f, sim_light_vc_ol.psd.ry);
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude [$rad^2/Hz$]'); xlabel('Frequency [Hz]');
hold off;
legend({'PSD $Rx$', 'PSD $Rz$'})
if save_fig; exportFig('psd_ol_vc_light_rot', 'normal-normal', struct('path', 'control')); end
%% PSD Plot of translations
figure;
hold on;
plot(sim_light_pz_ol.psd.f, sim_light_pz_ol.psd.dx);
plot(sim_light_pz_ol.psd.f, sim_light_pz_ol.psd.dy);
plot(sim_light_pz_ol.psd.f, sim_light_pz_ol.psd.dz);
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude [$m^2/Hz$]'); xlabel('Frequency [Hz]');
hold off;
legend({'PSD $Tx$', 'PSD $Tz$', 'PSD $Tz$'})
if save_fig; exportFig('psd_ol_pz_light_trans', 'normal-normal', struct('path', 'control')); end
%% PSD Plot of rotations
figure;
hold on;
plot(sim_light_pz_ol.psd.f, sim_light_pz_ol.psd.rx);
plot(sim_light_pz_ol.psd.f, sim_light_pz_ol.psd.ry);
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude [$rad^2/Hz$]'); xlabel('Frequency [Hz]');
hold off;
legend({'PSD $Rx$', 'PSD $Rz$'})
if save_fig; exportFig('psd_ol_pz_light_rot', 'normal-normal', struct('path', 'control')); end
%% PSD Plot of translations
figure;
hold on;
plot(sim_light_vc_ol.psd.f, sim_light_vc_ol.psd.dx);
plot(sim_light_vc_ol.psd.f, sim_light_vc_ol.psd.dy);
plot(sim_light_vc_ol.psd.f, sim_light_vc_ol.psd.dz);
set(gca,'ColorOrderIndex',1);
plot(sim_light_pz_ol.psd.f, sim_light_pz_ol.psd.dx, '--');
plot(sim_light_pz_ol.psd.f, sim_light_pz_ol.psd.dy, '--');
plot(sim_light_pz_ol.psd.f, sim_light_pz_ol.psd.dz, '--');
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude [$m^2/Hz$]'); xlabel('Frequency [Hz]');
xlim([sim_light_vc_ol.psd.f(1), sim_light_vc_ol.psd.f(end)])
hold off;
legend({'PSD $Tx$ - VC', 'PSD $Tz$ - VC', 'PSD $Tz$ - VC', 'PSD $Tx$ - PZ', 'PSD $Tz$ - PZ', 'PSD $Tz$ - PZ'})
if save_fig; exportFig('psd_ol_pz_vc_light_trans', 'wide-tall', struct('path', 'control')); end

View File

@ -1,11 +0,0 @@
%%
clear; close all; clc;
%% Initialize Simulation and Inputs
initializeExperiment('tomography', 'light');
%% Run Open Loop Simulations
runSimulation('vc', 'light', 'ol', 'none');
runSimulation('pz', 'light', 'ol', 'none');
% runSimulation('vc', 'heavy', 'ol', 'none');
% runSimulation('pz', 'heavy', 'ol', 'none');