Thomas Dehaeze
6e3677eb29
Folder name is changed, rework the html templates Change the organisation.
153 lines
5.1 KiB
Matlab
153 lines
5.1 KiB
Matlab
function [Res] = Dual_Spindle_error(dataX, dataY, NbTurn,texte, path)
|
|
L= length(dataX);
|
|
res_per_rev = L/NbTurn;
|
|
P = 0: (res_per_rev * NbTurn)-1;
|
|
Pos = P' * 360/res_per_rev;
|
|
Theta = degtorad(Pos)';
|
|
|
|
x1 = myfit2(Pos, dataX);
|
|
y1 = myfit2(Pos, dataY);
|
|
|
|
%Convert data to frequency domain and scale accordingly
|
|
X2 = 2/(res_per_rev*NbTurn)*fft(x1);
|
|
f2 = (0:L-1)./NbTurn;
|
|
Y2 = 2/(res_per_rev*NbTurn)*fft(y1);
|
|
|
|
|
|
% Separate the fft integers and not-integers
|
|
for i = 1 : length(f2)
|
|
if mod(f2(i), 1) == 0;
|
|
X2dec(i)= 0;
|
|
X2int(i)= X2(i);
|
|
Y2dec(i)= 0;
|
|
Y2int(i)= Y2(i);
|
|
else
|
|
X2dec(i)= X2(i);
|
|
X2int(i)= 0;
|
|
Y2dec(i)= Y2(i);
|
|
Y2int(i)= 0;
|
|
end
|
|
end
|
|
|
|
if mod(length(f2),2) ==1; % Case length(f2) is odd -> the mirror image of the FFT is reflected between 2 harmonique
|
|
for i = length(f2)/2 +1.5: length(f2)
|
|
if mod(f2(i-1), 1) == 0;
|
|
X2dec(i)= 0;
|
|
X2int(i)= X2(i);
|
|
Y2dec(i)= 0;
|
|
Y2int(i)= Y2(i);
|
|
else
|
|
X2dec(i)= X2(i);
|
|
X2int(i)= 0;
|
|
Y2dec(i)= Y2(i);
|
|
Y2int(i)= 0;
|
|
end
|
|
end
|
|
else % Case length(f2) is even -> the mirror image of the FFT is reflected at the Nyquist frequency
|
|
for i = length(f2)/2 +1: length(f2)
|
|
if mod(f2(i), 1) == 0;
|
|
X2dec(i)= 0;
|
|
X2int(i)= X2(i);
|
|
Y2dec(i)= 0;
|
|
Y2int(i)= Y2(i);
|
|
else
|
|
X2dec(i)= X2(i);
|
|
X2int(i)= 0;
|
|
Y2dec(i)= Y2(i);
|
|
Y2int(i)= 0;
|
|
end
|
|
end
|
|
end
|
|
|
|
X2int(1) = 0; %remove the data average/dc component
|
|
X2int(NbTurn+1) = 0; %Remove fondamental/eccentricity
|
|
% X2int(length(f2)) = 0; %remove the data average/dc component
|
|
X2int(length(f2)-NbTurn+1) = 0; %Remove eccentricity
|
|
|
|
Y2int(1) = 0; %remove the data average/dc component
|
|
Y2int(NbTurn+1) = 0; %Remove fondamental/eccentricity
|
|
% Y2int(length(f2)) = 0; %remove the data average/dc component
|
|
Y2int(length(f2)-NbTurn+1) = 0; %Remove eccentricity
|
|
|
|
|
|
% Extract the fondamentale-> exentricity
|
|
for i = 1:length(f2)
|
|
if i == NbTurn+1 || i== length(f2)-NbTurn + 1
|
|
X2fond(i) = X2(i);
|
|
Y2fond(i) = Y2(i);
|
|
else
|
|
X2fond(i) = 0;
|
|
Y2fond(i) = 0;
|
|
end
|
|
end
|
|
|
|
X2tot= X2int + X2dec;
|
|
Y2tot= Y2int + Y2dec;
|
|
|
|
%Convert data to "time" domain and scale accordingly
|
|
Wxint = real((res_per_rev*NbTurn)/2 * ifft(X2int)) ;
|
|
Wxdec = real((res_per_rev*NbTurn)/2 * ifft(X2dec)) ;
|
|
Wxtot = real((res_per_rev*NbTurn)/2 * ifft(X2tot)) ;
|
|
|
|
%Convert data to "time" domain and scale accordingly
|
|
Wyint = real((res_per_rev*NbTurn)/2 * ifft(Y2int)) ;
|
|
Wydec = real((res_per_rev*NbTurn)/2 * ifft(Y2dec)) ;
|
|
Wytot = real((res_per_rev*NbTurn)/2 * ifft(Y2tot)) ;
|
|
|
|
|
|
%%
|
|
fig = figure();
|
|
|
|
% subplot(3, 2, 5); bar(f2(1:50*NbTurn),abs(W2int(1:50*NbTurn)),3) ;
|
|
% axis([0,50,0,max(abs(X2int(1:50*NbTurn)))]);
|
|
% title ('Fourier integer' ); xlabel('UPR'); ylabel ('Microns')
|
|
|
|
% subplot(3, 2, 6); bar(f2(1:50*NbTurn),abs(W2dec(1:50*NbTurn)),2); title (' Fourier non-integer' );
|
|
% axis([0,50,0,max(abs(X2dec(1:50*NbTurn)))]);
|
|
% title ('Fourier non-integer' ); xlabel('UPR'); ylabel ('Microns')
|
|
|
|
% Sensitive pos dir (synchrone+asynchrone)
|
|
Wtot= Wytot.*cos(Theta)+Wxtot.*sin(Theta);
|
|
% Wtot= Wytot+Wxtot; = WTot = real((res_per_rev*NbTurn)/2 * ifft(W2tot)) ;
|
|
|
|
%Sensitive pos dir (synchrone+asynchrone)
|
|
Wint= Wyint.*cos(Theta)+Wxint.*sin(Theta);
|
|
%Sensitive pos dir (synchrone+asynchrone)
|
|
Wdec= Wydec.*cos(Theta)+Wxdec.*sin(Theta);
|
|
|
|
|
|
% total error motion
|
|
Total_Error = max(Wtot)- min(Wtot);
|
|
|
|
%lsc X synchronous
|
|
Synchronous_Error = max(Wint)- min(Wint);
|
|
|
|
%lsc X Asynchronous
|
|
var=reshape(Wxdec,length(Wxdec)/NbTurn,NbTurn);
|
|
for i=1:length(Wxdec)/NbTurn
|
|
Asynch(i) = max(var(i,:)) - min(var(i,:)) ;
|
|
end
|
|
Asynchronous_Error = max(Asynch)- min(Asynch);
|
|
|
|
|
|
% Raw Error Motion without Exentricity (sync +asynch)
|
|
subplot(2, 2, 2) ; polar2(Theta,Wtot, 'b'); title (' Total error' );
|
|
% Residual Synchronous Error Motion without Exentricity (ie fondamental sync err motion)
|
|
subplot(2, 2, 3) ;polar2(Theta,Wint,'b'); title ( 'Residual synchronous error' );
|
|
% Asynchronous Error Motion
|
|
subplot(2, 2, 4) ;polar2(Theta,Wdec, 'b'); title ('Asynchronous error' );
|
|
|
|
|
|
strmin1 = ['Total error = ', num2str(Total_Error*1000), ' nm'];
|
|
strmin2 = ['Residual synchronous error = ', num2str(Synchronous_Error*1000), ' nm' ];
|
|
strmin3 = ['Asynchronous error = ', num2str(Asynchronous_Error*1000), ' nm'];
|
|
dim0=[0.04 0.5 0.3 .3];%x y w h basgauche to hautdroite
|
|
dim1=[0.15 0.65 0.3 .3];
|
|
annotation('textbox',dim0, 'String',{ strmin1 , strmin2, strmin3}, 'FitBoxToText', 'on')
|
|
annotation('textbox',dim1, 'String',texte, 'FitBoxToText', 'on')
|
|
|
|
saveas(fig,fullfile(path,char(texte)),'jpg');
|
|
Res=1;
|
|
close all;
|
|
end
|