Advertisement

m基于matlab的GPS卫星信号捕获和数据解析仿真

阅读量:

目录

1.算法描述

2.仿真效果预览

3.MATLAB核心程序

4.完整MATLAB


1.算法描述

GPS(全球定位系统)是一种全天时、全方位覆盖的高精度自动运行的卫星导航定位系统,在有适当接收设备的情况下向全球范围内的用户提供精确无差地测定物体运动的三维坐标和速度参数。经过长期运行已形成一个多功能综合服务系统。

卫星信号捕捉技术是现代定位接收机的关键组成环节,在实际应用中通常会结合多种处理方法以提高检测效率与精度。其中一种典型的技术方案是将传统GPS定位系统中的工作流程进行优化设计,在接收机内部引入多跳距差分相位观测器来实现高精度的位置估计功能。具体而言,在接收机内部构建了一个包含多个差分环路以及自适应滤波器组的新系统架构,在这种架构下可以通过灵活配置各跳距差分相位观测器的工作模式来实现对不同频率偏移情况的有效补偿。这种创新性设计不仅能够显著提升系统的抗干扰能力,在复杂环境下的性能表现也得到了明显改善

为了实现对GPS信号的追踪与解码,必须首先捕获该信号。接收并传输所获取的关于该GPS信号的关键参数至追踪流程后,通过追踪流程即可推导出卫星发送的数据信息。由于 GPS 卫星正处在一个高速运行的状态下,其发射出的电磁波频率会发生多普勒效应的变化。关于载波频率与 C/A 码之间的多普勒频移关系及其相关特性将在后续章节中进行详细阐述。

GPS卫星发送的信号通常主要包含三个组成部分:载波、伪码信号与导航信息。其中包含了伪码信号与导航信息的部分采用了BPSK技术进行调制处理。

为了实现目标完成对GPS信号的跟踪与解码,首要任务是捕获到相应的GPS信号.将获取的数据进行传递并利用这些数据可以顺利地完成对卫星导航信息的获取.传统的GPS捕获方式包括:串行搜索捕获,滑动相关法,循环相关法以及PMF算法等.

GPS卫星系统采用两个工作频段:f_{\text{L1}}f_{\text{LO}}(注:此处可能有笔误应为f_{\text{LO}}或其他符号?根据上下文推测应为f_{\text{LO}}或其他相关符号)。这些载波信号在L频段上实现调制以减少电磁环境中的干扰问题;由于L频带的工作负荷较低且占用资源相对较少,在全球范围内提供观测服务非常高效;此外,在L频带中采用扩频技术可显著提高系统的抗干扰能力并支持宽band传输;该频带范围内的微弱大气扰动以及电离效应较小的特点使得接收设备设计更加简洁经济

2.仿真效果预览

matlab2022a仿真结果如下:

3.MATLAB核心程序

复制代码
 clc;

    
 clear;
    
 close all;
    
 warning off;
    
 addpath(genpath(pwd));
    
  
    
 rng('default')
    
 %%
    
 %11111111111111111111111111111111111111111111111111111111111
    
 isnoise         = 0;%1:add noise;0 good signal
    
 %nosie awgn
    
 SNR             = -19;
    
  
    
 %Q1
    
 satellite       = [1,12,14,22];
    
 satellitenumber = length(satellite);
    
 fs              = 16.368e6; %sampling freq
    
 IF              = 4.092e6;%centered
    
 fIFD            = IF + 5e3 - 10e3*rand(1,satellitenumber);%no more than 5 KHz in absolute value
    
 Fai             = 2*pi*rand(1,satellitenumber);%random values
    
 Ai              = 0.7+0.3*rand(1,satellitenumber);%random between 1 and 0.7 for different satellites
    
 taoi            = floor(4e5*rand(1,satellitenumber)) + 2e5; %random between 1 and 
    
 Dur             = 20;%bit duration,20ms
    
 Len             = 50;%data bit length,1s
    
 %
    
 CHIP_TIME       = 977.5e-9;    % chip time in seconds 
    
 ts              = 1/fs;
    
 n               = fs/1000; 
    
 nn              = [0:n-1]; 
    
 millisecond     = 1000;
    
  
    
 x_bound         = (ts/2)/CHIP_TIME;  % Maximum offset 
    
 d_samp          = 6; % sample offset between correlators 
    
 d               = (d_samp*ts)/CHIP_TIME;  
    
 msSamp          = 16368;
    
  
    
  
    
 for i = 1:satellitenumber
    
     i
    
     %C
    
     %1ms with 16 samples
    
     code0   = digitizg(fs/1000,fs,0,satellite(i));
    
     %20ms
    
     code1   = [code0,code0,code0,code0,code0,code0,code0,code0,code0,code0,code0,code0,code0,code0,code0,code0,code0,code0,code0,code0];
    
     %len
    
     CA      = [];
    
     for j = 1:Len
    
     CA = [CA,code1];
    
     end
    
     %D
    
     Di0       = 2*double(rand(1,Len)>=0.5)-1;
    
     %output the data
    
     for j = 1:Len
    
     Dout2{i}(Dur*(j-1)+1:Dur*j) = Di0(j);
    
     end
    
     
    
     for j = 1:length(Dout2{i})
    
     Di2(length(code0)*(j-1)+1:length(code0)*j) = Dout2{i}(j);
    
     end
    
     %S
    
     signal0 = Ai(i).*CA.*Di2;
    
     %16times
    
     %delay taoi/61
    
     delays  = floor(taoi(i)/61);
    
     signal3 = [zeros(1,delays),signal0(1:end-delays)];
    
     
    
     %carrier
    
     t       = 0:1/fs:(length(signal3)-1)/fs;
    
     carrier{i} = cos(2*pi*fIFD(i)*t+Fai(i));
    
     Si0{i}     = signal3.*carrier{i};
    
 end
    
 %noise awgn
    
 if isnoise==0
    
    Si_ = Si0;
    
 else
    
    for i = 1:satellitenumber
    
    Si_{i} = awgn(Si0{i},SNR,'measured');
    
    end
    
 end
    
  
    
 %combine
    
 Si= Si_{1}; 
    
 for i = 1:satellitenumber-1
    
     Si = Si + Si_{i+1}; 
    
 end
    
  
    
  
    
 figure;
    
 subplot(221);
    
 stem(Dout2{1});
    
 title('data bits of satelite 1');
    
 axis([0,1000,-2,2]);
    
 subplot(222);
    
 stem(Dout2{2});
    
 title('data bits of satelite 12');
    
 axis([0,1000,-2,2]);
    
 subplot(223);
    
 stem(Dout2{3});
    
 title('data bits of satelite 14');
    
 axis([0,1000,-2,2]);
    
 subplot(224);
    
 stem(Dout2{4});
    
 title('data bits of satelite 22');
    
 axis([0,1000,-2,2]);
    
  
    
 ttt = 0:1000/(length(Si)-1):1000;
    
 figure;
    
 plot(ttt,Si);
    
 title('Combined Si');
    
  
    
 figure;
    
 plot(ttt(10000:10200),Si(10000:10200));
    
 title('Combined Si local');
    
  
    
 %%
    
 %22222222222222222222222222222222222222222222222222
    
 %fine frequency estimation
    
 segment=5;
    
 for a=1:satellitenumber
    
     for b=1:segment
    
     output               = acquisition(Si',satellite(a),b);
    
     correlation(:,a,b)   = output{1};
    
     correlationpeak(:,a) = output{2};
    
     frequency(:,a,b)     = output{3};
    
     finefrequency(a,b)   = output{4};                
    
     end
    
     finefrequencyaverage(a)  = mean(finefrequency(a,:));
    
 end
    
 finefrequencyaverage
    
 fIFD
    
 err = finefrequencyaverage-fIFD
    
 X=[fIFD;finefrequencyaverage]';
    
 figure;
    
 bar(X);
    
 axis([0,5,4.0e6,4.2e6]);
    
 legend('Blue:real frequency','Red:fine frequency estimation');
    
 xlabel('4 different satellite');
    
 ylabel('frequency est');
    
  
    
  
    
  
    
  
    
 %code phase
    
 segment=5;
    
 for a=1:satellitenumber
    
     Data = [Si]';
    
     for b=1:segment
    
     output               = acquisition(Data,satellite(a),b);
    
     correlation(:,a,b)   = output{1};
    
     correlationpeak(:,a) = output{2};
    
     frequency(:,a,b)     = output{3};
    
     finefrequency(a,b)   = output{4};                
    
     end
    
     finefrequencyaverage(a)  = mean(finefrequency(a,:));
    
 end
    
  
    
 figure;
    
 codephases = [];
    
 for a=1:satellitenumber
    
     Pdata = correlation(:,a,1);
    
     subplot(4,1,a);
    
     plot(Pdata);
    
     [V,I] = max(Pdata);
    
     hold on
    
     plot(I,V,'r*');
    
     xlabel('times');
    
     ylabel('correlation');
    
     title(['satellite',num2str(satellite(a))]);
    
     codephases = [codephases,I];
    
 end
    
 %code phase of 4 
    
 codephases
    
 taois=codephases*61 
    
 taoi
    
 %%
    
 %3 
    
 for a=1:satellitenumber
    
     a
    
     Data = [Si]';
    
     for c=1:millisecond
    
     %BASS method.
    
     %use the same C/A code from BASS to correlate all 1 ms segments one at a time
    
     cacode(:,a)           = digitizg(n,fs,0,satellite(a)); 
    
     %fine frequency
    
     lc(:,a)               = exp(sqrt(-1)*2*pi*finefrequencyaverage(a)*ts*nn);
    
     lsi(:,a)              = cacode(:,a).*lc(:,a);
    
     lcf(:,a)              = fft(lsi(:,a));
    
     xf                    = fft(Data((c-1)*n+1:c*n));
    
     f(:,a)                = ifft(exp(-sqrt(-1)*2*pi*finefrequencyaverage(a)*ts*(c-1))*xf.* conj(lcf(:,a))); 
    
     [amp(c,a),ccn(c,a)]   = max(abs(f(:,a)));        
    
     codephase(c,a)        = angle((f(ccn(c,a),a)));
    
     correlationphase(c,a) = angle((lsi(ccn(c,a),a)));
    
     end
    
     ccnmax(a)   = max(ccn(:,a));
    
     tmps        = find(ccn(:,a)==ccnmax(a));
    
     location(a) = tmps(1);
    
 end
    
  
    
 figure
    
 for a=1:satellitenumber
    
     subplot(4,1,a);stem(codephase(:,a));title('Correlation result');
    
 end
    
 figure
    
 for a=1:satellitenumber
    
     subplot(4,1,a);stem(correlationphase(:,a));title('Correlation Phase');
    
 end
    
 figure
    
 for a=1:satellitenumber
    
     subplot(4,1,a);stem(amp(:,a));title('Correlation Magnitude');
    
 end
    
  
    
  
    
 %Fine time estimate
    
 for a=1:satellitenumber
    
     for tt = 1:millisecond
    
     cacode(:,a)      = digitizg(n,fs,0,satellite(a)); 
    
     ffreq            = finefrequencyaverage(a);
    
     code_phase       = ccn(c,a);
    
     local_carrier    = exp(1i*2*pi*ffreq*ts*nn); 
    
     Data_carrier_off = [Data((tt-1)*n+1:tt*n)]'.*local_carrier; 
    
     
    
     input_ms_tt      = Data_carrier_off;    
    
     corrs            = ifft(fft(input_ms_tt).* [conj(fft(cacode(:,a)))]'); 
    
  
    
     early            = corrs(code_phase - d_samp);
    
     late             = corrs(code_phase + d_samp); 
    
     r(tt,a)            = abs(late)/abs(early); 
    
     x(tt,a)            = ((1-r(tt,a))*(1-d))/(1+r(tt,a));  
    
     if mod(tt,10) == 0 
    
        xx(tt/10,a) = mean(x(tt-9:tt,a));  % Average the past 10 fine time estimates 
    
     end  
    
     end
    
 end
    
  
    
 figure; 
    
 for i=1:satellitenumber
    
 subplot(4,1,i);
    
 stem(xx(:,i)*CHIP_TIME); 
    
 title('Averaged Fine Time Estimates for 10ms segments of data'); 
    
 xlabel('10ms'); 
    
 ylabel('Fine time Est (s)'); 
    
 end
    
  
    
 figure;
    
 for i=1:satellitenumber
    
 subplot(4,1,i);
    
 stem(x(:,i)*CHIP_TIME); 
    
 title('Fine Time Estimates for 1 ms segments of data'); 
    
 xlabel('1ms '); 
    
 %xlim([0,13]); 
    
 ylabel('Fine time Est (s)'); 
    
 end
    
 %%
    
 %456together
    
 %phase transitions
    
 for sj=1:satellitenumber
    
     tmps = find(amp(:,sj)>0);
    
     start(sj) = tmps(1);
    
     fprintf(['The initial data bits boundary from satellite ',num2str(satellite(sj)),' is : ',num2str(start(sj)),'ms\n\n']);
    
     Recive_bits(:,sj) = Dout2{sj}(1)*ones(Len*Dur,1);
    
 end
    
 for sj=1:satellitenumber
    
     %enhance the special point
    
     corrd = [amp(:,sj)].*[amp(:,sj)].*[amp(:,sj)].*[amp(:,sj)];
    
     corrd = corrd-min(corrd);
    
     %find the transitions position
    
     Count1=0;Count2=0;
    
     for j = 3:length(corrd)-2
    
     if corrd(j)>2*corrd(j-1) & corrd(j)>2*corrd(j+1) & corrd(j)>2*corrd(j-2) & corrd(j)>2*corrd(j+2) 
    
        Count1=Count1+1; 
    
     end
    
     if corrd(j)<0.4*corrd(j-1) & corrd(j)<0.4*corrd(j+1) & corrd(j)<0.4*corrd(j-2) & corrd(j)<0.4*corrd(j+2) 
    
        Count2=Count2+1; 
    
     end        
    
     end
    
     
    
     if Count1 < Count2
    
    threshold = 0.4*mean(corrd);
    
    Pos      = find(corrd<=threshold);
    
     else
    
    threshold = 1.5*mean(corrd);
    
    Pos      = find(corrd>=threshold);
    
     end
    
     
    
     if isempty(Pos)==1
    
    if sj == 1 ;disp('satellite 1  failed.....'); end
    
    if sj == 12;disp('satellite 12 failed.....'); end
    
    if sj == 14;disp('satellite 14 failed.....'); end
    
    if sj == 22;disp('satellite 22 failed.....'); end
    
     else
    
     if Pos(1)==1
    
         for j = 3:length(Pos);
    
             Recive_bits(Pos(j-1)+1:Pos(j),sj) = -1*Recive_bits(Pos(j-1),sj);%transitions
    
         end
    
     else
    
         for j = 2:length(Pos);
    
             Recive_bits(Pos(j-1)+1:Pos(j),sj) = -1*Recive_bits(Pos(j-1),sj);%transitions
    
         end
    
     end
    
     Recive_bits(Pos(end)+1:end,sj) = -1*Recive_bits(Pos(end),sj);
    
     end
    
 end
    
  
    
  
    
 figure;
    
 subplot(221);
    
 stem(Recive_bits(:,1));title('The data bits of satellite 1');
    
 axis([0,1000,-2,2]);
    
 subplot(222);
    
 stem(Recive_bits(:,2));title('The data bits of satellite 12');
    
 axis([0,1000,-2,2]);
    
 subplot(223);
    
 stem(Recive_bits(:,3));title('The data bits of satellite 14');
    
 axis([0,1000,-2,2]);
    
 subplot(224);
    
 stem(Recive_bits(:,4));title('The data bits of satellite 22');
    
 axis([0,1000,-2,2]);
    
 01-155m

4.完整MATLAB

V

全部评论 (0)

还没有任何评论哟~