Move to matlab folder / tangle / list of sections
This commit is contained in:
		@@ -1,7 +0,0 @@
 | 
			
		||||
load('./mat/test.mat', 't', 'x');
 | 
			
		||||
 | 
			
		||||
figure; plot(t, x)
 | 
			
		||||
 | 
			
		||||
load('./mat/long_test.mat', 't', 'x');
 | 
			
		||||
 | 
			
		||||
figure; plot(t/60/60, 1e9*x)
 | 
			
		||||
							
								
								
									
										152
									
								
								matlab/attocube_asd_noise.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										152
									
								
								matlab/attocube_asd_noise.m
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,152 @@
 | 
			
		||||
%% Clear Workspace and Close figures
 | 
			
		||||
clear; close all; clc;
 | 
			
		||||
 | 
			
		||||
%% Intialize Laplace variable
 | 
			
		||||
s = zpk('s');
 | 
			
		||||
 | 
			
		||||
addpath('./mat/');
 | 
			
		||||
 | 
			
		||||
% Long and Slow measurement
 | 
			
		||||
% The first measurement was made during ~17 hours with a sampling time of $T_s = 0.1\,s$.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
load('long_test_plastic.mat', 'x', 't')
 | 
			
		||||
Ts = 0.1; % [s]
 | 
			
		||||
 | 
			
		||||
figure;
 | 
			
		||||
plot(t/60/60, 1e9*x)
 | 
			
		||||
xlim([0, 17.5]);
 | 
			
		||||
xlabel('Time [h]'); ylabel('Displacement [nm]');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% #+name: fig:long_meas_time_domain_full
 | 
			
		||||
% #+caption: Long measurement time domain data
 | 
			
		||||
% #+RESULTS:
 | 
			
		||||
% [[file:figs/long_meas_time_domain_full.png]]
 | 
			
		||||
 | 
			
		||||
% Let's fit the data with a step response to a first order low pass filter (Figure [[fig:long_meas_time_domain_fit]]).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
f = @(b,x) b(1)*(1 - exp(-x/b(2)));
 | 
			
		||||
 | 
			
		||||
y_cur = x(t < 17.5*60*60);
 | 
			
		||||
t_cur = t(t < 17.5*60*60);
 | 
			
		||||
 | 
			
		||||
nrmrsd = @(b) norm(y_cur - f(b,t_cur)); % Residual Norm Cost Function
 | 
			
		||||
B0 = [400e-9, 2*60*60];                        % Choose Appropriate Initial Estimates
 | 
			
		||||
[B,rnrm] = fminsearch(nrmrsd, B0);     % Estimate Parameters ‘B’
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The corresponding time constant is (in [h]):
 | 
			
		||||
 | 
			
		||||
B(2)/60/60
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% #+RESULTS:
 | 
			
		||||
% : 2.0658
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
figure;
 | 
			
		||||
hold on;
 | 
			
		||||
plot(t_cur/60/60, 1e9*y_cur);
 | 
			
		||||
plot(t_cur/60/60, 1e9*f(B, t_cur));
 | 
			
		||||
hold off;
 | 
			
		||||
xlim([0, 17.5])
 | 
			
		||||
xlabel('Time [h]'); ylabel('Displacement [nm]');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% #+name: fig:long_meas_time_domain_fit
 | 
			
		||||
% #+caption: Fit of the measurement data with a step response of a first order low pass filter
 | 
			
		||||
% #+RESULTS:
 | 
			
		||||
% [[file:figs/long_meas_time_domain_fit.png]]
 | 
			
		||||
 | 
			
		||||
% We can see in Figure [[fig:long_meas_time_domain_full]] that there is a transient period where the measured displacement experiences some drifts.
 | 
			
		||||
% This is probably due to thermal effects.
 | 
			
		||||
% We only select the data between =t1= and =t2=.
 | 
			
		||||
% The obtained displacement is shown in Figure [[fig:long_meas_time_domain_zoom]].
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
t1 = 10.5; t2 = 17.5; % [h]
 | 
			
		||||
 | 
			
		||||
x = x(t > t1*60*60 & t < t2*60*60);
 | 
			
		||||
x = x - mean(x);
 | 
			
		||||
t = t(t > t1*60*60 & t < t2*60*60);
 | 
			
		||||
t = t - t(1);
 | 
			
		||||
 | 
			
		||||
figure;
 | 
			
		||||
plot(t/60/60, 1e9*x);
 | 
			
		||||
xlabel('Time [h]'); ylabel('Measured Displacement [nm]')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% #+name: fig:long_meas_time_domain_zoom
 | 
			
		||||
% #+caption: Kept data (removed slow drifts during the first hours)
 | 
			
		||||
% #+RESULTS:
 | 
			
		||||
% [[file:figs/long_meas_time_domain_zoom.png]]
 | 
			
		||||
 | 
			
		||||
% The Power Spectral Density of the measured displacement is computed
 | 
			
		||||
 | 
			
		||||
win = hann(ceil(length(x)/20));
 | 
			
		||||
[p_1, f_1] = pwelch(x, win, [], [], 1/Ts);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% As a low pass filter was used in the measurement process, we multiply the PSD by the square of the inverse of the filter's norm.
 | 
			
		||||
 | 
			
		||||
G_lpf = 1/(1 + s/2/pi);
 | 
			
		||||
p_1 = p_1./abs(squeeze(freqresp(G_lpf, f_1, 'Hz'))).^2;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% Only frequencies below 2Hz are taken into account (high frequency noise will be measured afterwards).
 | 
			
		||||
 | 
			
		||||
p_1 = p_1(f_1 < 2);
 | 
			
		||||
f_1 = f_1(f_1 < 2);
 | 
			
		||||
 | 
			
		||||
% Short and Fast measurement
 | 
			
		||||
% An second measurement is done in order to estimate the high frequency noise of the interferometer.
 | 
			
		||||
% The measurement is done with a sampling time of $T_s = 0.1\,ms$ and a duration of ~100s.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
load('short_test_plastic.mat')
 | 
			
		||||
Ts = 1e-4; % [s]
 | 
			
		||||
 | 
			
		||||
x = detrend(x, 0);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The time domain measurement is shown in Figure [[fig:short_meas_time_domain]].
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
figure;
 | 
			
		||||
plot(t, 1e9*x)
 | 
			
		||||
xlabel('Time [s]'); ylabel('Displacement [nm]');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% #+name: fig:short_meas_time_domain
 | 
			
		||||
% #+caption: Time domain measurement with the high sampling rate
 | 
			
		||||
% #+RESULTS:
 | 
			
		||||
% [[file:figs/short_meas_time_domain.png]]
 | 
			
		||||
 | 
			
		||||
% The Power Spectral Density of the measured displacement is computed
 | 
			
		||||
 | 
			
		||||
win = hann(ceil(length(x)/20));
 | 
			
		||||
[p_2, f_2] = pwelch(x, win, [], [], 1/Ts);
 | 
			
		||||
 | 
			
		||||
% Obtained Amplitude Spectral Density of the measured displacement
 | 
			
		||||
 | 
			
		||||
% The computed ASD of the two measurements are combined in Figure [[fig:psd_combined]].
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
figure;
 | 
			
		||||
hold on;
 | 
			
		||||
plot(f_1(8:end), sqrt(p_1(8:end)), 'k-');
 | 
			
		||||
plot(f_2(8:end), sqrt(p_2(8:end)), 'k-');
 | 
			
		||||
hold off;
 | 
			
		||||
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
 | 
			
		||||
ylabel('ASD [$m/\sqrt{Hz}$]'); xlabel('Frequency [Hz]');
 | 
			
		||||
							
								
								
									
										131
									
								
								matlab/attocube_non_linearity.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										131
									
								
								matlab/attocube_non_linearity.m
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,131 @@
 | 
			
		||||
%% Clear Workspace and Close figures
 | 
			
		||||
clear; close all; clc;
 | 
			
		||||
 | 
			
		||||
%% Intialize Laplace variable
 | 
			
		||||
s = zpk('s');
 | 
			
		||||
 | 
			
		||||
addpath('./mat/');
 | 
			
		||||
 | 
			
		||||
% Load Data
 | 
			
		||||
% The measurement data are loaded and the offset are removed using the =detrend= command.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
load('int_enc_comp.mat', 'interferometer', 'encoder', 'u', 't');
 | 
			
		||||
Ts = 1e-4; % Sampling Time [s]
 | 
			
		||||
 | 
			
		||||
interferometer = detrend(interferometer, 0);
 | 
			
		||||
encoder = detrend(encoder, 0);
 | 
			
		||||
u = detrend(u, 0);
 | 
			
		||||
 | 
			
		||||
% Time Domain Results
 | 
			
		||||
% One period of the displacement of the mass as measured by the encoder and interferometer are shown in Figure [[fig:int_enc_one_cycle]].
 | 
			
		||||
% It consist of the sinusoidal motion at 0.5Hz with an amplitude of approximately $70\mu m$.
 | 
			
		||||
 | 
			
		||||
% The frequency of the motion is chosen such that no resonance in the system is excited.
 | 
			
		||||
% This should improve the coherence between the measurements made by the encoder and interferometer.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
figure;
 | 
			
		||||
hold on;
 | 
			
		||||
plot(t, encoder,        '-',  'DisplayName', 'Encoder')
 | 
			
		||||
plot(t, interferometer, '--', 'DisplayName', 'Interferometer')
 | 
			
		||||
hold off;
 | 
			
		||||
xlabel('Time [s]'); ylabel('Displacement [m]');
 | 
			
		||||
legend('location', 'southeast');
 | 
			
		||||
xlim([50, 52])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% #+name: fig:int_enc_one_cycle
 | 
			
		||||
% #+caption: One cycle measurement
 | 
			
		||||
% #+RESULTS:
 | 
			
		||||
% [[file:figs/int_enc_one_cycle.png]]
 | 
			
		||||
 | 
			
		||||
% The difference between the two measurements during the same period is shown in Figure [[fig:int_enc_one_cycle_error]].
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
figure;
 | 
			
		||||
hold on;
 | 
			
		||||
plot(t, encoder - interferometer, 'DisplayName', 'Difference')
 | 
			
		||||
hold off;
 | 
			
		||||
xlabel('Time [s]'); ylabel('Displacement [m]');
 | 
			
		||||
legend('location', 'northeast');
 | 
			
		||||
xlim([50, 52])
 | 
			
		||||
 | 
			
		||||
% Difference between Encoder and Interferometer as a function of time
 | 
			
		||||
% The data is filtered using a second order low pass filter with a cut-off frequency $\omega_0$ as defined below.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
w0 = 2*pi*5; % [rad/s]
 | 
			
		||||
xi = 0.7;
 | 
			
		||||
 | 
			
		||||
G_lpf = 1/(1 + 2*xi/w0*s + s^2/w0^2);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% After filtering, the data is "re-shaped" such that we can superimpose all the measured periods as shown in Figure [[fig:int_enc_error_mean_time]].
 | 
			
		||||
% This gives an idea of the measurement error as given by the Attocube during a $70 \mu m$ motion.
 | 
			
		||||
 | 
			
		||||
d_err_mean = reshape(lsim(G_lpf, encoder - interferometer, t), [2/Ts floor(Ts/2*length(encoder))]);
 | 
			
		||||
d_err_mean = d_err_mean - mean(d_err_mean);
 | 
			
		||||
 | 
			
		||||
figure;
 | 
			
		||||
hold on;
 | 
			
		||||
for i_i = 1:size(d_err_mean, 2)
 | 
			
		||||
  plot(t(1:size(d_err_mean, 1)), d_err_mean(:, i_i), 'k-')
 | 
			
		||||
end
 | 
			
		||||
plot(t(1:size(d_err_mean, 1)), mean(d_err_mean, 2), 'r-')
 | 
			
		||||
hold off;
 | 
			
		||||
xlabel('Time [s]'); ylabel('Displacement [m]');
 | 
			
		||||
 | 
			
		||||
% Difference between Encoder and Interferometer as a function of position
 | 
			
		||||
% Figure [[fig:int_enc_error_mean_time]] gives the measurement error as a function of time.
 | 
			
		||||
% We here wish the compute this measurement error as a function of the position (as measured by the encoer).
 | 
			
		||||
 | 
			
		||||
% To do so, all the attocube measurements corresponding to each position measured by the Encoder (resolution of $1nm$) are averaged.
 | 
			
		||||
% Figure [[fig:int_enc_error_mean_position]] is obtained where we clearly see an error with a period comparable to the motion range and a much smaller period corresponding to the non-linear period errors that we wish the estimate.
 | 
			
		||||
 | 
			
		||||
[e_sorted, ~, e_ind] = unique(encoder);
 | 
			
		||||
 | 
			
		||||
i_mean = zeros(length(e_sorted), 1);
 | 
			
		||||
for i = 1:length(e_sorted)
 | 
			
		||||
  i_mean(i) = mean(interferometer(e_ind == i));
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
i_mean_error = (i_mean - e_sorted);
 | 
			
		||||
 | 
			
		||||
figure;
 | 
			
		||||
hold on;
 | 
			
		||||
% plot(encoder, interferometer - encoder, 'k.', 'DisplayName', 'Difference')
 | 
			
		||||
plot(1e6*(e_sorted), 1e9*(i_mean_error))
 | 
			
		||||
hold off;
 | 
			
		||||
xlabel('Encoder Measurement [$\mu m$]'); ylabel('Measrement Error [nm]');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% #+name: fig:int_enc_error_mean_position
 | 
			
		||||
% #+caption: Difference between the two measurement as a function of the measured position by the encoder, averaged for all the cycles
 | 
			
		||||
% #+RESULTS:
 | 
			
		||||
% [[file:figs/int_enc_error_mean_position.png]]
 | 
			
		||||
 | 
			
		||||
% The period of the non-linearity seems to be equal to $765 nm$ which corresponds to half the wavelength of the Laser ($1.53 \mu m$).
 | 
			
		||||
% For the motion range done here, the non-linearity is measured over ~18 periods which permits to do some averaging.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
win_length = 1530/2; % length of the windows (corresponds to 765 nm)
 | 
			
		||||
num_avg = floor(length(e_sorted)/win_length); % number of averaging
 | 
			
		||||
 | 
			
		||||
i_init = ceil((length(e_sorted) - win_length*num_avg)/2); % does not start at the extremity
 | 
			
		||||
 | 
			
		||||
e_sorted_mean_over_period = mean(reshape(i_mean_error(i_init:i_init+win_length*num_avg-1), [win_length num_avg]), 2);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The obtained periodic non-linearity is shown in Figure [[fig:int_non_linearity_period_wavelength]].
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
figure;
 | 
			
		||||
hold on;
 | 
			
		||||
plot(1e-3*(0:win_length-1), 1e9*(e_sorted_mean_over_period))
 | 
			
		||||
hold off;
 | 
			
		||||
xlabel('Displacement [$\mu m$]'); ylabel('Measurement Non-Linearity [nm]');
 | 
			
		||||
							
								
								
									
										73
									
								
								matlab/effect_air_protection.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								matlab/effect_air_protection.m
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,73 @@
 | 
			
		||||
%% Clear Workspace and Close figures
 | 
			
		||||
clear; close all; clc;
 | 
			
		||||
 | 
			
		||||
%% Intialize Laplace variable
 | 
			
		||||
s = zpk('s');
 | 
			
		||||
 | 
			
		||||
addpath('./mat/');
 | 
			
		||||
 | 
			
		||||
% Aluminium Tube and Bubble Sheet
 | 
			
		||||
 | 
			
		||||
load('short_test_plastic.mat');
 | 
			
		||||
Ts = 1e-4; % [s]
 | 
			
		||||
 | 
			
		||||
x = detrend(x, 0);
 | 
			
		||||
 | 
			
		||||
figure;
 | 
			
		||||
plot(t, 1e9*x)
 | 
			
		||||
xlabel('Time [s]'); ylabel('Displacement [nm]');
 | 
			
		||||
 | 
			
		||||
win = hann(ceil(length(x)/10));
 | 
			
		||||
[p_1, f_1] = pwelch(x, win, [], [], 1/Ts);
 | 
			
		||||
 | 
			
		||||
% Only Aluminium Tube
 | 
			
		||||
 | 
			
		||||
load('short_test_alu_tube.mat');
 | 
			
		||||
Ts = 1e-4; % [s]
 | 
			
		||||
 | 
			
		||||
x = detrend(x, 0);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The time domain measurement is shown in Figure [[fig:short_meas_time_domain]].
 | 
			
		||||
 | 
			
		||||
figure;
 | 
			
		||||
plot(t, 1e9*x)
 | 
			
		||||
xlabel('Time [s]'); ylabel('Displacement [nm]');
 | 
			
		||||
 | 
			
		||||
win = hann(ceil(length(x)/10));
 | 
			
		||||
[p_2, f_2] = pwelch(x, win, [], [], 1/Ts);
 | 
			
		||||
 | 
			
		||||
% Nothing
 | 
			
		||||
 | 
			
		||||
load('short_test_without_material.mat');
 | 
			
		||||
Ts = 1e-4; % [s]
 | 
			
		||||
 | 
			
		||||
x = detrend(x, 0);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The time domain measurement is shown in Figure [[fig:short_meas_time_domain]].
 | 
			
		||||
 | 
			
		||||
figure;
 | 
			
		||||
plot(t, 1e9*x)
 | 
			
		||||
xlabel('Time [s]'); ylabel('Displacement [nm]');
 | 
			
		||||
 | 
			
		||||
win = hann(ceil(length(x)/10));
 | 
			
		||||
[p_3, f_3] = pwelch(x, win, [], [], 1/Ts);
 | 
			
		||||
 | 
			
		||||
% Comparison
 | 
			
		||||
 | 
			
		||||
figure;
 | 
			
		||||
hold on;
 | 
			
		||||
plot(f_1(8:end), sqrt(p_1(8:end)), '-', ...
 | 
			
		||||
     'DisplayName', 'Alunimium + Bubble');
 | 
			
		||||
plot(f_2(8:end), sqrt(p_2(8:end)), '-', ...
 | 
			
		||||
     'DisplayName', 'Aluminium');
 | 
			
		||||
plot(f_3(8:end), sqrt(p_3(8:end)), '-', ...
 | 
			
		||||
     'DisplayName', 'nothing');
 | 
			
		||||
hold off;
 | 
			
		||||
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
 | 
			
		||||
ylabel('ASD [$m/\sqrt{Hz}$]'); xlabel('Frequency [Hz]');
 | 
			
		||||
xlim([1e-1, 5e3]);
 | 
			
		||||
legend('location', 'northeast');
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								matlab/mat/int_enc_comp.mat
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								matlab/mat/int_enc_comp.mat
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								matlab/mat/long_test_plastic.mat
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								matlab/mat/long_test_plastic.mat
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								matlab/mat/short_test_alu_tube.mat
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								matlab/mat/short_test_alu_tube.mat
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								matlab/mat/short_test_plastic.mat
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								matlab/mat/short_test_plastic.mat
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								matlab/mat/short_test_without_material.mat
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								matlab/mat/short_test_without_material.mat
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user