Matlab simulation of instantaneous phase calculation for real-time tracking measurement system of optical feedback self-mixing interference displacement based on Hilbert transform

Table of contents

1. Theoretical basis

2. Case background 

3. MATLAB program

Fourth, the simulation conclusion analysis


1. Theoretical basis

       Optical interferometry technology is a measurement technology based on the principle of light wave interference. It is different from other optical imaging measurement technologies. In addition to higher measurement sensitivity and accuracy, it also has the characteristics of non-contact measurement. Cause surface damage , therefore, the application of optical interferometry is very extensive. The Hilbert transform and instantaneous phase theory are a more commonly used method.

      Therefore, the Hilbert transform of the signal can be regarded as the output of the signal after passing through a filter with a unit impulse response of . After the signal undergoes Hilbert transform, its amplitude spectrum, power spectrum and autocorrelation function remain unchanged. The Hilbert transform of the signal is equivalent to a phase shifter. The phase of the positive frequency part of the signal changes by -90°, and the negative frequency Part of the phase change by 90°.

      The analytic signal z(t) can be constructed from the continuous time signal S(t) and its Hilbert transform H(S(t)):    

     From the expression z(t) of the above analytic signal, s(t) The instantaneous phase of , that is, the instantaneous phase is:
                  
       Therefore, the analytic signal can be constructed by performing Hilbert transform on the OFSMI signal, and the instantaneous phase of the OFSMI signal can be obtained by calculating the arc tangent of the analytical signal.

       The main content of the Hilbert transform integer fringe detection algorithm is: after eliminating the DC component of the OFSMI signal, the Hilbert transform is performed to construct an analytical signal, and the instantaneous phase of the package is obtained by calculating the arc tangent of the analytical signal, and the instantaneous phase of the package is detected. All phase abrupt points, and determine the displacement direction of the external reflector, and finally remove the pseudo-stripe points to obtain all integer fringe points. The flow of the Hilbert transform integer fringe detection algorithm is shown in the figure:
 

2. Case background 

       Optical interferometry technology is a measurement technology based on the principle of light wave interference. It is different from other optical imaging measurement technologies. In addition to higher measurement sensitivity and accuracy, it also has the characteristics of non-contact measurement. Cause surface damage, therefore, the application of optical interferometry is very extensive.
       In the research process of traditional optical interferometry, it was found that the external optical feedback of the laser would cause the optical feedback self-mixing interference (OFSMI) effect, which would affect the output characteristics of the laser, resulting in spectral line broadening, optical feedback and optical feedback. Phenomena such as noise and coherence fragmentation can cause serious damage to the laser system, so people always try to eliminate the influence caused by the external optical feedback of the laser at first. With further research, it was found that the OFSMI signal contains the laser's own parameter information and some information about the movement of the external reflector, such as displacement, velocity, acceleration, etc. Therefore, people changed from eliminating the influence of optical feedback to Using optical feedback to obtain relevant information, the research of OFSMI has gradually emerged, and its main applications are in the fields of spectral line narrowing and OFSMI measurement.
       The OFSMI effect refers to the phenomenon that after the laser output light is reflected or scattered by an external reflector, part of the light is fed back to the laser resonator, and the feedback light interferes with the light in the cavity, thereby modulating the output optical power of the laser.
 

3. MATLAB program

%设置相关参数
close all;clc;clear all
 %phi_0=am0+am*sin(2*pi*ft/fs*t1); 
am=19;     %am=4*pi*L/lanbuda0
am0=30;    % am0=4*pi*L0/lanbuda0         
ft=200;    %设置振动频率
fs=40000; %设置采样频率
n=400;    %设置采样点数
alfa=5;    %设置激光器线宽展宽因数
c=0.7;     %设置光反馈强度
[x,g,y]=spain_ofsmi_data(alfa,c,am,am0,ft,fs,n);%%x----fai0, g---自混合信号, y---- fai-f

save ofsmi g; %将g保存到ofsmi.mat文件中
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%画图
figure(1)
subplot(3,1,1);plot(x);title('无光反馈时的外腔相位');ylabel('fai_0(n)/rad');grid on;%axis([-inf inf 290 340]);
subplot(3,1,2);plot(y);title('有光反馈时的外腔相位alfa=3;c=4;');ylabel('fai_f(n)/rad');grid on;
subplot(3,1,3);plot(g);title('SMI信号');xlabel('采样点数n');ylabel('g(n)的振幅');grid on;%legend();

F2    = hilbert(g);
xr    = real(F2);
xi    = imag(F2);
Faif_ = atan2(xi,xr);%公式8

%根据峰值flag的间隔确定flags变量,用来判断m1,m2的取值
flags = [ones(50,1);-1*ones(100,1);ones(100,1);-1*ones(100,1);ones(50,1)];
flags = [0;flags(1:end-1)];

flag2 = zeros(size(Faif_));
for i = 2:length(Faif_)-1
    if i <= 51;
       if g(i)<g(i-1) & g(i)<g(i+1)
          flag2(i)=1;
       end
    end
    if i <= 151 & i>51
       if g(i)<g(i-1) & g(i)<g(i+1) 
          flag2(i)=1;
       end
    end    
    if i <= 251 & i>151
       if g(i)<g(i-1) & g(i)<g(i+1)
          flag2(i)=1;
       end
    end
    if i <= 351 & i>251
       if g(i)<g(i-1) & g(i)<g(i+1)
          flag2(i)=1;
       end
    end
    if i <= 400 & i>351
       if g(i)<g(i-1) & g(i)<g(i+1)
          flag2(i)=1;
       end 
    end  
end
flag2([51,151,251,351])=0;


flag    = zeros(size(Faif_));
for  n = 2:length(Faif_)
     flag(n) = abs([Faif_(n-1)-Faif_(n)]); 
end
[pks,locs]  = findpeaks(flag,'THRESHOLD',0.5);
locs        = locs;
flag3       = zeros(size(Faif_));
flag3(locs) = 1;



 
indx1 = find(flag2==1);
indx2 = find(flag3==1);
indxs = [];
for i = 1:length(indx1)
    if abs(indx1(i)-indx2(i))<=4
       indxs(i) = indx2(i);
    else
       indxs(i) = indx1(i);
    end
end

Flag_=zeros(size(flag2));
Flag_(indxs)=1;
 

figure;
subplot(211);
plot(g);
subplot(212);
plot(flag2,'r');
hold on
plot(flag3,'b');

%依据相位展开原理, 计算真实相位Faif
m1      = 0;
m2      = 1;
Faif(1) = (-1)^m1*abs(Faif_(1))  + 2*pi*m2;


for  n = 2:length(flag3)
     %判决m1和m2,0/1,1/-1,进行分段处理
     if flags(n) ==  1
        m2 = m2+1*Flag_(n); 
        if sign(Faif_(n))==1
           m1=0; 
        else
           m1=1;  
        end
     end
     if flags(n) == -1
        m2 = m2-1*Flag_(n);  
        if sign(Faif_(n))==1
           m1=1; 
        else
           m1=0;  
        end
     end 
     
     
     Faif(n) = (-1)^m1*abs(Faif_(n))  + 2*pi*m2;
end

%步骤三:
fai0 = Faif + c*sin(Faif + atan(alfa));

 
figure;
subplot(311);
plot(g);
ylabel('g(n)的振幅');
subplot(312);
plot(Faif_);
ylabel('Fai_f`');
subplot(313);
plot(fai0);
ylabel('Fai_0');


%计算误差
t1=fai0-mean(fai0);
t2=x-mean(x);
figure;
subplot(211);
plot(t2,'r','linewidth',2);
hold on
plot(t1,'b--','linewidth',2);
legend('真实相位','重构相位');
subplot(212);
plot(t1-t2)
title('error');
axis([0,400,-30,30]);

%%
clear;
 close all;
 %% 生成自混合信号
 am=33;am0=50;ft=200;fs=600000;n=6000  ;  alfa=4;c=0.5;
[x,g,y]=spain_ofsmi_data(alfa,c,am,am0,ft,fs,n);
t1=1:n;
t=t1
%t=t1/fs;
p0=3000;m=0.001;
 p=p0*(1+m*g);
 figure
 plot(t1,p,'k');title('自混合信号');xlabel('采样点数');
 %% 加高斯白噪声
% sur_add=25;%信噪比
% ps=g*g'/n;
sur_add=30;%信噪比
ps=9*g*g'/n;
pn=ps*10^(-sur_add/10);
noise=randn(1,n);
noise=sqrt(pn)*noise;
p=p+noise;
p1=p;
% figure
%   plot(t1,noise);
figure
  plot(t1,p,'k');title('自混合信号');xlabel('采样点数'); 
  figure
subplot(2,1,1);plot(t,p,'k');ylabel('P/uw','fontsize',12);gtext('(a)','fontsize',12);

%% 均值滤波
y1=zeros(1,n)
for i=1:12
y1(i)=p(i);
end
for i=13:n-12
    y1(i)=(p(i-12)+p(i-11)+p(i-10)+p(i-9)+p(i-8)+p(i-7)+p(i-6)+p(i-5)+p(i-4)+p(i-3)+p(i-2)+p(i-1)+p(i)+p(i+1)+p(i+2)+p(i+3)+p(i+4)+p(i+5)+p(i+6)+p(i+7)+p(i+8)+p(i+9)+p(i+10)+p(i+11)+p(i+12))/25;
end
for i=n-11:n
y1(i)=p(i);
end
 p=y1;
% figure
%   plot(t1,p,'k');title('自混合信号');xlabel('采样点数'); axis([-inf inf 2995 3003]);
 
%% 消去直流分量
 dif=diff(p);
dif=[0 dif ];
yuzhi=max(dif)*0.6;
for i=1:length(dif);
    if abs(dif(i))<yuzhi
        dif_th(i)=0;
    else
        dif_th(i)=dif(i);
    end
end
 I=find(dif_th);
 num=length(I);
 z=[1 I n];
setsum=zeros(length(z)-1);
for i=1:length(z)-1
    for j=z(i):z(i+1)
        if j<z(i+1)
        setsum(i)=setsum(i)+p(j);%分段求和
        elseif j==z(i+1)
            if i==1
            for jj=z(i):z(i+1)
        ave(jj)=setsum(i)/(z(i+1)-z(i));
            end
            else
                 for jj=z(i)+1:z(i+1)
        ave(jj)=setsum(i)/(z(i+1)-z(i));
                 end
            end
        end
    end 
end
ave_g=p-ave;
% figure
% subplot(2,1,1);stem(dif);title('SM信号的微分');
% subplot(2,1,2);stem(dif_th);
%  figure
% subplot(2,1,1);plot(t,p,'k');ylabel('P/uw','fontsize',13);xlabel('t/s','fontsize',13);title('(a)','fontsize',13')
%  subplot(2,1,2);plot(t,ave_g,'k');xlabel('t/s','fontsize',13);ylabel('Po/uw','fontsize',13);title('(b)','fontsize',13)
 %% 通过hilbert构造解析形式,检测条纹
F2=hilbert(ave_g);
xr=real(F2);xi=imag(F2);atan=atan2(xi,xr);
freq_ins=diff(atan);
freq_ins=[0 freq_ins ];

for i=1:length(freq_ins);
    if freq_ins(i)>=-3
        freq_ins_th(i)=0;
    else
        freq_ins_th(i)=sign(freq_ins(i));
    end
end
II=find(freq_ins_th);
 no=length(II);
 jiange=(II(6)-II(1))/4/3;
 for i=2:no
     if II(i)<=II(i-1)+jiange;
        freq_ins_th(II(i))=0;
     end
 end

% figure
% subplot(3,1,1);plot(t,atan,'k');title('(a)','fontsize',13');;xlabel('t/s','fontsize',13);ylabel('相位/rad','fontsize',13);
% subplot(3,1,2);plot(t,freq_ins,'k');title('(b)','fontsize',13');;xlabel('t/s','fontsize',13);ylabel('相位微分/rad','fontsize',13);
% subplot(3,1,3);plot(t,freq_ins_th,'k');title('(c)','fontsize',13');;xlabel('t/s','fontsize',13);
%% 确定运动方向
pulsed=-sign(dif);
trans=pulsed.*freq_ins_th;

%% 去掉小数条纹
  xiaoshu=zeros(1,n)
for i=1:num-1
 if sign(dif_th(I(i+1)))~=sign(dif_th(I(i))) 
     mm2=round((I(i+1)-I(i))/3);
      mm1=round((I(i+1)-I(i))/4);
     mm3=round((I(i+1)-I(i))/24*7);
      
    for j=I(i)+mm1:I(i+1)-mm2

         xiaoshu(j)=1;
     end
 else
         xiaoshu(j)=0;
end 
 end
%  figure
%  plot(xiaoshu)
 xiaoshu_y=xiaoshu.*p;
%  figure
%  plot(xiaoshu_y);title('粗糙提取小数条纹');axis([0 6000 2900 3050])
 for i=1:n
    if xiaoshu(i)==1
        xiaoshu1(i)=0;
    else
        xiaoshu1(i)=1;
    end
 end
 trans_x=trans.*xiaoshu1;
 %%
% figure
% subplot(3,1,1);plot(t,p,'k');ylabel('P/uw','fontsize',13);xlabel('t/s','fontsize',13);title('(a)','fontsize',13');
% subplot(3,1,2);plot(t,trans,'k');xlabel('t/s','fontsize',13);title('(b)','fontsize',13');
% subplot(3,1,3);plot(t,trans_x,'k');xlabel('t/s','fontsize',13);title('(c)','fontsize',13');
%% 
subplot(2,1,2);plot(t,trans_x,'k');xlabel('采样点n','fontsize',12);gtext('(b)','fontsize',12);

Fourth, the simulation conclusion analysis

The simulation structure is as follows:

 

 

 

 

 

A23-45 

 

Guess you like

Origin blog.csdn.net/ccsss22/article/details/126695902