Huge Change
- Add may folders - Add IFF and HAC-LAC scripts
This commit is contained in:
90
control/control_cl_ol_plots.m
Normal file
90
control/control_cl_ol_plots.m
Normal file
@@ -0,0 +1,90 @@
|
||||
%%
|
||||
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
|
11
control/control_cl_sim.m
Normal file
11
control/control_cl_sim.m
Normal file
@@ -0,0 +1,11 @@
|
||||
%%
|
||||
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');
|
34
control/control_cl_tf.m
Normal file
34
control/control_cl_tf.m
Normal file
@@ -0,0 +1,34 @@
|
||||
%%
|
||||
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/controller.mat', 'K');
|
||||
Gd_cl_light_vc = identifyPlant();
|
||||
|
||||
initializeNanoHexapod(struct('actuator', 'piezo'));
|
||||
K = K_light_pz; %#ok
|
||||
save('./mat/controller.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/controller.mat', 'K');
|
||||
G_cl_heavy_vc = identifyPlant();
|
||||
|
||||
initializeNanoHexapod(struct('actuator', 'piezo'));
|
||||
K = K_heavy_pz;
|
||||
save('./mat/controller.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');
|
41
control/control_cl_tf_comp.m
Normal file
41
control/control_cl_tf_comp.m
Normal file
@@ -0,0 +1,41 @@
|
||||
%%
|
||||
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
|
17
control/control_generate.m
Normal file
17
control/control_generate.m
Normal file
@@ -0,0 +1,17 @@
|
||||
%%
|
||||
clear; close all; clc;
|
||||
|
||||
%% Load Plant
|
||||
load('./mat/G.mat', 'G_light_vc', 'G_light_pz', 'G_heavy_vc', 'G_heavy_pz');
|
||||
|
||||
%%
|
||||
fs = 10;
|
||||
|
||||
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');
|
25
control/control_main.m
Normal file
25
control/control_main.m
Normal file
@@ -0,0 +1,25 @@
|
||||
%%
|
||||
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
|
87
control/control_ol_psd.m
Normal file
87
control/control_ol_psd.m
Normal file
@@ -0,0 +1,87 @@
|
||||
%%
|
||||
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
|
11
control/control_ol_sim.m
Normal file
11
control/control_ol_sim.m
Normal file
@@ -0,0 +1,11 @@
|
||||
%%
|
||||
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');
|
Reference in New Issue
Block a user