Commit 65409600 authored by Chiara Di Fronzo's avatar Chiara Di Fronzo

matlab script laserstab

parent bcb1fcdf
%% Laser stabilization script
%Data used here are in Towhaki \labdata\2021\Laserstab
clear all
%% data logging
load('freerunlf19072.csv')%free run lowf 5 ms
load('DataLogMS12807.csv'); %10 ms 30 mins
%load('Datalog1707.csv');
load('DataLog2707us.csv'); %100 us 15 min
load('DataLog27072ms.csv'); %10 ms 5 mins
load('DataLogMS2.csv'); % CL 10ms 15 min lower2 on
load('DataLogUS2.csv'); %CL 100us 15 min
load('DataLogMS1.csv') %CL 10ms 15 min
load('DataLogUS1.csv'); %CL 100 us 15min
%% data unwinding
f1 =freerunlf19072(:,1); %free run 5ms
f2=DataLogMS12807(:,1); %CL 10 ms
%f2=Datalog1707(:,1);
f3=DataLog2707us(:,1); %CL 100 ms
f4=DataLog27072ms(:,1);
f5=DataLogMS2(:,1);
f6=DataLogUS2(:,1);
f7=DataLogMS1(:,1);
f8=DataLogUS1(:,1);
T1= linspace(0, 0.005.*length(f1),length(f1)).'; %free run
[fasd1,freq1]=asdSmooth(f1,0.005); %free run
T2= linspace(0, 100e-6.*length(f2),length(f2)).';
[fasd2,freq2]=asdSmooth(f2,100e-6);
T3= linspace(0, 100e-6.*length(f3),length(f3)).';
[fasd3,freq3]=asdSmooth(f3,100e-6);
T4= linspace(0, 0.01.*length(f4),length(f4)).';
[fasd4,freq4]=asdSmooth(f4,0.01);
T5=linspace(0,0.01.*length(f5),length(f5)).';
[fasd5,freq5]=asdSmooth(f5,0.01);
T6=linspace(0,100e-6.*length(f6),length(f6)).';
[fasd6,freq6]=asdSmooth(f6,100e-6);
T7=linspace(0,0.01.*length(f7),length(f7)).';
[fasd7,freq7]=asdSmooth(f7,0.01);
T8=linspace(0,100e-6.*length(f8),length(f8)).';
[fasd8,freq8]=asdSmooth(f8,100e-6);
%% HoQI noise
lambda = 1064e-9;
FF=(299792458./lambda); % [Hz] Laser frequency
f= logspace(-2,3,1000);
Hnoise= SWG_sensor_noise('hoqi_opt',f); % [m/sqrtHz] HoQI noise
nAdc = SEI_sensor_noise('GS_16bit_ADC',f); % [v/sqrt(Hz)]
vperm = 10/lambda/4;
nHoqi_opt = nAdc/vperm/(pi/2)/4; % Output spectral density, [m/sqrt(Hz)] ADC noise
NoiseFloor=abs(sqrt((Hnoise).^2+(nHoqi_opt).^2));
df01=(NoiseFloor./0.1).*FF; %L=10 cm
dL6D= df01.*0.003./FF; %dL [m/sqrtHz] for 6D, with L=3 mm
df6D= dL6D.*FF./0.003; %df [Hz/sqrtHz] for 6D
%% Data over a fixed range of time (if needed)
% index=find(T2>200,1);
% cut_f2= f2(1:index);
% [fasd2c,freq2c]=asdSmooth(cut_f2,0.01);
%% Closed loop trace computation
load('CL_chain') %dtt Open loop with excitation (on laser1 and filter chain)
fol=CL_chain(:,1); %frequency
mag=CL_chain(:,2); %magnitude
clg=1./(1+mag); %closed loop gain
int=interp1((fol),(clg),(freq1));
CLG=int.*fasd1;
%free run and closed loop traces
figure(1)
loglog(freq1,CLG,freq1,fasd1,f,df6D,'r--')
xlabel('Frequency (Hz)');
ylabel('ASD (Hz/\surd(Hz))');
legend('freerun/(1+G)','free running lasers','expected')
xlim([1e-2 1e2]);
ylim([2e2 2e6]);
%% filter chain
%here there is the filter I use to control the lase
f = logspace(-3,3,1000);
plant = 10^(-49/20); %open loop gain (0,004 measured)
ugf = 104; %ugf
ACfilter = zpkgf([0],[0.01],1/plant,ugf);
uUGFfilter = zpkgf([],[0.1],1,ugf);
lUGFfilter = zpkgf([0.01],[0.1],1,ugf);
lower2 = zpkgf([0.1],[1],1,ugf);
total = ACfilter.*uUGFfilter;
controller= ACfilter.*uUGFfilter.*lUGFfilter;
cl=1/(1+(plant.*controller));
clasd=abs(fresp(cl,freq1));
clfree=fasd1.*clasd; %freerun/(1+G)
%filter Bodeplot
figure(2)
bodePlot(f,controller,cl)
%% HoQI distout CL computation
load('hoqis1007'); %open loop hoqi distout
fd=hoqis1007(:,1); %frequency
hq1=hoqis1007(:,2); %hoqi1 output mag
hq2=hoqis1007(:,4); %hoqi2 output mag
inth1=interp1((fd),(hq1),(freq1));
CLGH1= inth1.*clasd;
inth2=interp1((fd),(hq2),(freq1));
CLGH2= inth2.*clasd;
oldist1=inth1.*1e-9.*FF./0.05;
oldist2=inth2.*1e-9.*FF./0.05;
%power
P1=hoqis1007(:,3); %powerout hoqi1
P2=hoqis1007(:,5); %powerout hoqi2
%%
% figure(22)
% loglog(fd,P2,'r',fd,P1,'b')
% legend('Powerout hoqi2','Powerout hoqi1')
% xlabel('F (Hz)')
% ylabel('Power')
% %% coherence
% load('coh1007');
% fcoh=coh1007(:,1);
% DP1=coh1007(:,2);
% D1D2=coh1007(:,3);
% DP2=coh1007(:,4);
%
% figure(23)
% plot(fcoh,D1D2)
% legend('Hoqi1\_distout/Hoqi2\_distout')
% xlabel('F (Hz)')
% ylabel('Coherence')
%
% figure(24)
% plot(fcoh,DP1,'m')
% legend('Hoqi1\_distout/Hoqi1\_powerout')
% xlabel('F (Hz)')
% ylabel('Coherence')
%
% figure(25)
% plot(fcoh,DP2,'g')
% legend('Hoqi2\_distout/Hoqi2\_powerout')
% xlabel('F (Hz)')
% ylabel('Coherence')
%% HOQI CL measured
%it should give the same result as previous section
load('CL_distout_1507');
fdc=CL_distout_1507(:,1);
hq1c=CL_distout_1507(:,2);
hq2c=CL_distout_1507(:,3);
int1=interp1((fdc),(hq1c),(freq1));
int2=interp1((fdc),(hq2c),(freq1));
dist1=int1.*1e-9.*FF./0.05; %Hz/sqrtHz
dist2=int2.*1e-9.*FF./0.05;
%%
%plot of the hoqis distout closed loop traces measured and computed
figure(3)
loglog(freq1, inth1,'r',freq1,inth2,'b',freq1,CLGH1,'y',freq1,CLGH2,'k',freq1,int1,'g',freq1,int2,'m')
xlabel('Frequency (Hz)');
ylabel('nm/\surd(Hz)');
legend('Open loop HoQI1','Open loop HoQI2','closed loop HoQI1 computed','closed loop HoQI2 computed','closed loop HoQI1 measured','closed loop HoQI2 measured')
xlim([1e-2 100]);
ylim([3e-5 2e-2]);
% %% CL distout time series
% load('CL_distout_time');
%
% t = CL_distout_time(:,1);
% t1=CL_distout_time(:,2);
% t2=CL_distout_time(:,3);
%
% figure(4)
% plot(t,t1)
% xlabel('Time (s))');
% ylabel('nm');
% legend('HoQI1 distout closed loop')
%
% figure(5)
% plot(t,t2)
% xlabel('Time (s))');
% ylabel('nm');
% legend('HoQI2 distout closed loop')
%% main plot
figure(6)
loglog(freq1,fasd1,'b',freq2,fasd2,'c',freq5,fasd5.*1e-30,'r',freq6,fasd6,'g',freq7,fasd7,'m',freq8,fasd8,'y',f,df6D,'k--',freq1,clfree,'k')
xlabel('Frequency (Hz)');
ylabel('ASD (Hz/\surd(Hz))');
legend('free run 5ms','100 us 30 min night','10 ms 15 min lower2 on','100 us 15 min lower2 on','10 ms 15min','100 us 15 min','6D frequency noise expected','freerun/(1+G)')
title('RIO orion lasers beatnote: free running and closed loop')
%xlim([1e-2 1e3]);
ylim([1e2 2e7]);
%% Detrended plot for chosen data
figure(7)
plot(T5,(f5),'r')
xlabel('Time (s)');
ylabel('T domain frequency');
legend('time domain data')
ylim([0e6 80e6])
% xlim([750 900])
%%
% figure(8)
% loglog(freq1,fasd1,'b',freq1,dist1,'r',freq1,dist2,'g',freq5,fasd5,'k',freq1,oldist1,'c',freq1,oldist2,'m')
% legend('freerun','CL hoqi1','CL hoqi2','Laser stab','OL hoqi1','OL hoqi2')
% xlabel('F (Hz)')
% ylabel ('Hz/\surd(Hz)')
% xlim([1e-2 1e2])
% ylim([1e2 1e7])
% %% fringes
% load('fringes2007');
%
% t=fringes2007(:,1);
% cos1=fringes2007(:,2);
% mcos1=fringes2007(:,3);
% sin1=fringes2007(:,4);
% cos2=fringes2007(:,5);
% mcos2=fringes2007(:,6);
% sin2=fringes2007(:,7);
%
% figure(9)
% subplot(2,1,1)
% plot(t,cos1,t,mcos1,t,sin1)
% legend('HoQI1 cosout','HoQI1 mcosout','HoQI1 sinout')
% ylabel('Counts')
% xlim([2 8])
% ylim([-1.5e4 -0.3e4])
% subplot(2,1,2)
% plot(t,cos2,t,mcos2,t,sin2)
% xlim([2 8])
% legend('HoQI2 cosout','HoQI2 mcosout','HoQI2 sinout')
% ylabel('Counts')
% xlabel('Time (s)')
% ylim([-9500 -4500])
%
% %% noise budget
%
% %% mokulab
%
% %load('oltracepersistence1607_Traces.csv')
% load('MokuSpectrumAnalyzerData_20210716_160746_Traces.csv')
%
% % f=oltracepersistence1607_Traces(:,1);
% % db=oltracepersistence1607_Traces(:,2);
%
% f=MokuSpectrumAnalyzerData_20210716_160746_Traces(:,1);
% db=MokuSpectrumAnalyzerData_20210716_160746_Traces(:,2);
%
% figure(10)
% plot(f.*1e-6,db)
% title('Beat note peak')
% xlabel('Frequency (MHz)')
% ylabel('Magnitude (dBm)')
% xlim([0 250])
% ylim([-70 -10])
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment