Add script for showing all the possible displacement

This commit is contained in:
Thomas Dehaeze 2018-07-03 15:28:29 +02:00
parent 9a2102b5db
commit 80f3774166
7 changed files with 234 additions and 20 deletions

View File

@ -9,8 +9,24 @@ load('./mat/sim_conf.mat', 'sim_conf');
exp_without_nass.Dmeas.Data(:, 3) = exp_without_nass.Dmeas.Data(:, 3) - exp_without_nass.Dmeas.Data(end, 3);
Fs = ceil((length(exp_without_nass.Dmeas.Time(:))-1)/exp_without_nass.Dmeas.Time(end));
%%
N = length(exp_without_nass.Dmeas.Data(:, 1));
figure;
hold on;
% plot(exp_without_nass.Dmeas.Data(end-6300:end, 1),exp_without_nass.Dmeas.Data(end-6300:end, 2))
plot(exp_without_nass.Dmeas.Data(N-6600:N-6200, 1),exp_without_nass.Dmeas.Data(N-6600:N-6200, 2))
plot(exp_cl.Dmeas.Data(6:end, 1),exp_cl.Dmeas.Data(6:end, 2))
xlim([-1e-6, 1e-6]);
ylim([-1e-6, 1e-6]);
hold off;
xlabel('Displacement - $x$ [m]'); ylabel('Displacement - $y$ [m]');
%% With and without NASS
steady_i = ceil(length(exp_ol.Dmeas.Time)/2);
steady_i = 6;
figure;
hold on;
@ -23,6 +39,99 @@ xlabel('Displacement - $x$ [m]'); ylabel('Displacement - $y$ [m]');
exportFig('exp_w_wo_nass_xy', 'half-short')
%% Video of the simulation
close all;
figure(1);
hold on;
grid;
xlim([-1e-6, 1e-6]);
ylim([-1e-6, 1e-6]);
xlabel('Displacement - $x$ [m]'); ylabel('Displacement - $y$ [m]');
% Set up the movie.
writerObj = VideoWriter('open_loop.avi'); % Name it.
writerObj.FrameRate = 30; % How many frames per second.
open(writerObj);
% Open Loop
N = length(exp_without_nass.Dmeas.Data(:, 1))-6300;
step_i = ceil(Fs/writerObj.FrameRate);
for i=1:step_i:N
% We just use pause but pretend you have some really complicated thing here...
pause(0.01);
figure(1);
plot(exp_without_nass.Dmeas.Data(i:min(i+step_i, N), 1),exp_without_nass.Dmeas.Data(i:min(i+step_i, N), 2), 'color', [0 0.4470 0.7410])
frame = getframe(gcf); % 'gcf' can handle if you zoom in to take a movie.
writeVideo(writerObj, frame);
end
% Close Loop
N = length(exp_cl.Dmeas.Data(:, 1));
step_i = ceil(Fs/writerObj.FrameRate);
first_i = 6;
for i=first_i:step_i:N
% We just use pause but pretend you have some really complicated thing here...
pause(0.01);
figure(1);
plot(exp_cl.Dmeas.Data(i:min(i+step_i, N), 1),exp_cl.Dmeas.Data(i:min(i+step_i, N), 2), 'color', [0.8500 0.3250 0.0980])
frame = getframe(gcf); % 'gcf' can handle if you zoom in to take a movie.
writeVideo(writerObj, frame);
end
hold off
close(writerObj); % Saves the movie.
%% Video of the simulation
close all;
figure(1);
hold on;
xlim([-40, 40]);
ylim([-40, 40]);
yticks([-40 -20 0 20 40])
xticks([-40 -20 0 20 40])
grid on;
xlabel('Displacement - $x$ [nm]'); ylabel('Displacement - $y$ [nm]');
set(gcf, 'pos', [20 20 300 300]);
% Set up the movie.
writerObj = VideoWriter('close_loop_zoom.avi'); % Name it.
writerObj.FrameRate = 30; % How many frames per second.
open(writerObj);
% Open Loop
N = length(exp_without_nass.Dmeas.Data(:, 1))-6300;
step_i = ceil(Fs/writerObj.FrameRate);
for i=1:step_i:N
% We just use pause but pretend you have some really complicated thing here...
pause(0.01);
figure(1);
plot(1e9*exp_without_nass.Dmeas.Data(i:min(i+step_i, N), 1),1e9*exp_without_nass.Dmeas.Data(i:min(i+step_i, N), 2), 'color', [0 0.4470 0.7410])
frame = getframe(gcf); % 'gcf' can handle if you zoom in to take a movie.
writeVideo(writerObj, frame);
end
% Close Loop
N = length(exp_cl.Dmeas.Data(:, 1));
step_i = ceil(Fs/writerObj.FrameRate);
first_i = 6;
for i=first_i:step_i:N
% We just use pause but pretend you have some really complicated thing here...
pause(0.01);
figure(1);
plot(1e9*exp_cl.Dmeas.Data(i:min(i+step_i, N), 1),1e9*exp_cl.Dmeas.Data(i:min(i+step_i, N), 2), 'color', [0.8500 0.3250 0.0980])
frame = getframe(gcf); % 'gcf' can handle if you zoom in to take a movie.
writeVideo(writerObj, frame);
end
hold off
close(writerObj); % Saves the movie.
%%
figure;
hold on;
plot(exp_without_nass.Dmeas.Time(steady_i:end), exp_without_nass.Dmeas.Data(steady_i:end, 2));

Binary file not shown.

Binary file not shown.

View File

@ -3,14 +3,14 @@ clear; close all; clc;
%% Initialize simulation configuration
opts_sim = struct(...
'Tsim', 60 ...
'Tsim', 10 ...
);
initializeSimConf(opts_sim);
%% Initialize Inputs
opts_inputs = struct(...
'ground_motion', true, ...
'ground_motion', false, ...
'rz', true ...
);

103
init_demonstration.m Normal file
View File

@ -0,0 +1,103 @@
%%
clear; close all; clc;
%% Initialize simulation configuration
opts_sim = struct(...
'Tsim', 30 ...
);
initializeSimConf(opts_sim);
%% Initialize Inputs
load('./mat/sim_conf.mat', 'sim_conf')
time_vector = 0:sim_conf.Ts:sim_conf.Tsim;
% Translation Stage
T_ty = 4;
ty = zeros(length(time_vector), 1);
ty(1:T_ty/sim_conf.Ts) = 10e-3*sin(2*pi*(1/2)*time_vector(1:T_ty/sim_conf.Ts));
% Tilt Stage
T_ry = 4;
ry = zeros(length(time_vector), 1);
ry((T_ty)/sim_conf.Ts:(T_ty+T_ry)/sim_conf.Ts) = 2*pi*(3/360)*sin(2*pi*(1/2)*time_vector(T_ty/sim_conf.Ts:(T_ty+T_ry)/sim_conf.Ts));
% Spindle
T_rz = 4;
rz = zeros(length(time_vector), 1);
rz((T_ty+T_ry)/sim_conf.Ts:(T_ty+T_ry+T_rz)/sim_conf.Ts) = 2*pi*0.5*(time_vector((T_ty+T_ry)/sim_conf.Ts:(T_ty+T_ry+T_rz)/sim_conf.Ts)-time_vector((T_ty+T_ry)/sim_conf.Ts));
rz((T_ty+T_ry+T_rz)/sim_conf.Ts:end) = rz((T_ty+T_ry+T_rz)/sim_conf.Ts);
% Micro Hexapod
T_u_hexa = 10;
u_hexa = zeros(length(time_vector), 6);
% Tz
u_hexa((T_ty+T_ry+T_rz)/sim_conf.Ts:(T_ty+T_ry+T_rz+2)/sim_conf.Ts, 3) = 10e-3*sin(2*pi*(1/2)*(time_vector((T_ty+T_ry+T_rz)/sim_conf.Ts:(T_ty+T_ry+T_rz+2)/sim_conf.Ts)));
% Tx-Ty
u_hexa((T_ty+T_ry+T_rz+2)/sim_conf.Ts:(T_ty+T_ry+T_rz+3)/sim_conf.Ts, 1) = 10e-3*(time_vector((T_ty+T_ry+T_rz+2)/sim_conf.Ts:(T_ty+T_ry+T_rz+3)/sim_conf.Ts)-time_vector((T_ty+T_ry+T_rz+2)/sim_conf.Ts));
u_hexa((T_ty+T_ry+T_rz+3)/sim_conf.Ts:(T_ty+T_ry+T_rz+5)/sim_conf.Ts, 1) = 10e-3*cos(2*pi*(1/2)*(time_vector((T_ty+T_ry+T_rz+3)/sim_conf.Ts:(T_ty+T_ry+T_rz+5)/sim_conf.Ts)-time_vector((T_ty+T_ry+T_rz+3)/sim_conf.Ts)));
u_hexa((T_ty+T_ry+T_rz+3)/sim_conf.Ts:(T_ty+T_ry+T_rz+5)/sim_conf.Ts, 2) = 10e-3*sin(2*pi*(1/2)*(time_vector((T_ty+T_ry+T_rz+3)/sim_conf.Ts:(T_ty+T_ry+T_rz+5)/sim_conf.Ts)-time_vector((T_ty+T_ry+T_rz+3)/sim_conf.Ts)));
u_hexa((T_ty+T_ry+T_rz+5)/sim_conf.Ts:(T_ty+T_ry+T_rz+6)/sim_conf.Ts, 1) = 10e-3 - 10e-3*(time_vector((T_ty+T_ry+T_rz+5)/sim_conf.Ts:(T_ty+T_ry+T_rz+6)/sim_conf.Ts)-time_vector((T_ty+T_ry+T_rz+5)/sim_conf.Ts));
% Theta x Theta y
u_hexa((T_ty+T_ry+T_rz+6)/sim_conf.Ts:(T_ty+T_ry+T_rz+7)/sim_conf.Ts, 1) = 2*pi*(3/360)*(time_vector((T_ty+T_ry+T_rz+6)/sim_conf.Ts:(T_ty+T_ry+T_rz+7)/sim_conf.Ts)-time_vector((T_ty+T_ry+T_rz+6)/sim_conf.Ts));
u_hexa((T_ty+T_ry+T_rz+7)/sim_conf.Ts:(T_ty+T_ry+T_rz+9)/sim_conf.Ts, 1) = 2*pi*(3/360)*cos(2*pi*(1/2)*(time_vector((T_ty+T_ry+T_rz+7)/sim_conf.Ts:(T_ty+T_ry+T_rz+9)/sim_conf.Ts)-time_vector((T_ty+T_ry+T_rz+7)/sim_conf.Ts)));
u_hexa((T_ty+T_ry+T_rz+7)/sim_conf.Ts:(T_ty+T_ry+T_rz+9)/sim_conf.Ts, 2) = 2*pi*(3/360)*sin(2*pi*(1/2)*(time_vector((T_ty+T_ry+T_rz+7)/sim_conf.Ts:(T_ty+T_ry+T_rz+9)/sim_conf.Ts)-time_vector((T_ty+T_ry+T_rz+7)/sim_conf.Ts)));
u_hexa((T_ty+T_ry+T_rz+9)/sim_conf.Ts:(T_ty+T_ry+T_rz+10)/sim_conf.Ts, 1) = 2*pi*(3/360) - 2*pi*(3/360)*(time_vector((T_ty+T_ry+T_rz+9)/sim_conf.Ts:(T_ty+T_ry+T_rz+10)/sim_conf.Ts)-time_vector((T_ty+T_ry+T_rz+9)/sim_conf.Ts));
% Gravity Compensator system
T_mass_start = T_ty+T_ry+T_rz+T_u_hexa;
mass = zeros(length(time_vector), 2);
mass((T_mass_start)/sim_conf.Ts:(T_mass_start+2)/sim_conf.Ts, 1) = 2*pi*( 20/360)*(time_vector((T_mass_start)/sim_conf.Ts:(T_mass_start+2)/sim_conf.Ts)-time_vector(T_mass_start/sim_conf.Ts));
mass((T_mass_start)/sim_conf.Ts:(T_mass_start+2)/sim_conf.Ts, 2) = 2*pi*(-10/360)*(time_vector((T_mass_start)/sim_conf.Ts:(T_mass_start+2)/sim_conf.Ts)-time_vector(T_mass_start/sim_conf.Ts));
mass((T_mass_start+2)/sim_conf.Ts:(T_mass_start+3)/sim_conf.Ts, 1) = mass((T_mass_start+2)/sim_conf.Ts, 1);
mass((T_mass_start+2)/sim_conf.Ts:(T_mass_start+3)/sim_conf.Ts, 2) = mass((T_mass_start+2)/sim_conf.Ts, 2);
mass((T_mass_start+3)/sim_conf.Ts:(T_mass_start+5)/sim_conf.Ts, 1) = mass((T_mass_start+2)/sim_conf.Ts, 1)-2*pi*( 20/360)*(time_vector((T_mass_start+3)/sim_conf.Ts:(T_mass_start+5)/sim_conf.Ts)-time_vector((T_mass_start+3)/sim_conf.Ts));
mass((T_mass_start+3)/sim_conf.Ts:(T_mass_start+5)/sim_conf.Ts, 2) = mass((T_mass_start+2)/sim_conf.Ts, 2)-2*pi*(-10/360)*(time_vector((T_mass_start+3)/sim_conf.Ts:(T_mass_start+5)/sim_conf.Ts)-time_vector((T_mass_start+3)/sim_conf.Ts));
% opts_inputs = struct(...
% 'ty', ty, ...
% 'ry', ry, ...
% 'rz', rz, ...
% 'u_hexa', u_hexa, ...
% 'mass', mass ...
% );
% initializeInputs(opts_inputs);
initializeInputs();
%% Initialize SolidWorks Data
initializeSmiData();
%% Initialize Ground
initializeGround();
%% Initialize Granite
initializeGranite();
%% Initialize Translation stage
initializeTy();
%% Initialize Tilt Stage
initializeRy();
%% Initialize Spindle
initializeRz();
%% Initialize Hexapod Symétrie
initializeMicroHexapod();
%% Initialize Center of Gravity compensation
initializeAxisc();
%% Initialize NASS
opts_nano_hexapod = struct('actuator', 'lorentz');
initializeNanoHexapod(opts_nano_hexapod);
%% Initialize Sample
opts_sample = struct('mass', 20);
initializeSample(opts_sample);

View File

@ -4,7 +4,7 @@ function [inputs] = initializeInputs(opts_param)
'ground_motion', false, ...
'ty', false, ...
'ry', false, ...
'rz', false, ...
'rz', false, ... % If numerical value, rpm speed of the spindle
'u_hexa', false, ...
'mass', false, ...
'n_hexa', false ...
@ -27,13 +27,13 @@ function [inputs] = initializeInputs(opts_param)
inputs = struct();
%% Ground motion
if opts.ground_motion == true
if islogical(opts.ground_motion) && opts.ground_motion == true
load('./mat/weight_Wxg.mat', 'Wxg');
ground_motion = 1/sqrt(2)*100*random('norm', 0, 1, length(time_vector), 3);
ground_motion(:, 1) = lsim(Wxg, ground_motion(:, 1), time_vector);
ground_motion(:, 2) = lsim(Wxg, ground_motion(:, 2), time_vector);
ground_motion(:, 3) = lsim(Wxg, ground_motion(:, 3), time_vector);
elseif opts.ground_motion == false
elseif islogical(opts.ground_motion) && opts.ground_motion == false
ground_motion = zeros(length(time_vector), 3);
else
ground_motion = opts.ground_motion;
@ -42,9 +42,9 @@ function [inputs] = initializeInputs(opts_param)
inputs.ground_motion = timeseries(ground_motion, time_vector);
%% Translation stage [m]
if opts.ty == true
if islogical(opts.ty) && opts.ty == true
ty = zeros(length(time_vector), 1);
elseif opts.ty == false
elseif islogical(opts.ty) && opts.ty == false
ty = zeros(length(time_vector), 1);
else
ty = opts.ty;
@ -53,9 +53,9 @@ function [inputs] = initializeInputs(opts_param)
inputs.ty = timeseries(ty, time_vector);
%% Tilt Stage [rad]
if opts.ry == true
if islogical(opts.ry) && opts.ry == true
ry = 3*(2*pi/360)*sin(2*pi*0.2*time_vector);
elseif opts.ry == false
elseif islogical(opts.ry) && opts.ry == false
ry = zeros(length(time_vector), 1);
else
ry = opts.ry;
@ -64,10 +64,12 @@ function [inputs] = initializeInputs(opts_param)
inputs.ry = timeseries(ry, time_vector);
%% Spindle [rad]
if opts.rz == true
if islogical(opts.rz) && opts.rz == true
rz = 2*pi*0.5*time_vector;
elseif opts.rz == true
elseif islogical(opts.rz) && opts.rz == false
rz = zeros(length(time_vector), 1);
elseif isnumeric(opts.rz) && length(opts.rz) == 1
rz = 2*pi*(opts.rz/60)*time_vector;
else
rz = opts.rz;
end
@ -75,9 +77,9 @@ function [inputs] = initializeInputs(opts_param)
inputs.rz = timeseries(rz, time_vector);
%% Micro Hexapod
if opts.setpoint == true
if islogical(opts.u_hexa) && opts.setpoint == true
u_hexa = zeros(length(time_vector), 6);
elseif opts.setpoint == false
elseif islogical(opts.u_hexa) && opts.setpoint == false
u_hexa = zeros(length(time_vector), 6);
else
u_hexa = opts.u_hexa;
@ -86,9 +88,9 @@ function [inputs] = initializeInputs(opts_param)
inputs.micro_hexapod = timeseries(u_hexa, time_vector);
%% Center of gravity compensation
if opts.setpoint == true
if islogical(opts.mass) && opts.setpoint == true
mass = zeros(length(time_vector), 2);
elseif opts.setpoint == false
elseif islogical(opts.mass) && opts.setpoint == false
mass = zeros(length(time_vector), 2);
else
mass = opts.mass;
@ -97,9 +99,9 @@ function [inputs] = initializeInputs(opts_param)
inputs.axisc = timeseries(mass, time_vector);
%% Nano Hexapod
if opts.setpoint == true
if islogical(opts.n_hexa) && opts.setpoint == true
n_hexa = zeros(length(time_vector), 6);
elseif opts.setpoint == false
elseif islogical(opts.n_hexa) && opts.setpoint == false
n_hexa = zeros(length(time_vector), 6);
else
n_hexa = opts.n_hexa;
@ -108,10 +110,10 @@ function [inputs] = initializeInputs(opts_param)
inputs.nano_hexapod = timeseries(n_hexa, time_vector);
%% Set point [m, rad]
if opts.setpoint == true
if islogical(opts.setpoint) && opts.setpoint == true
setpoint = zeros(length(time_vector), 6);
setpoint(ceil(10/sim_conf.Ts):end, 2) = 1e-6; % Step of 1 micro-meter in y direction
elseif opts.setpoint == false
elseif islogical(opts.setpoint) && opts.setpoint == false
setpoint = zeros(length(time_vector), 6);
else
setpoint = opts.setpoint;

View File

@ -4,7 +4,7 @@ function [] = initializeSample(opts_param)
'height', 300,...
'mass', 50,...
'offset', 0,...
'color', [0.9 0.1 0.1] ...
'color', [0.45, 0.45, 0.45] ...
);
%% Populate opts with input parameters