阅读GNSS软件接收机matlab代码
Posted 者乎之类的
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了阅读GNSS软件接收机matlab代码相关的知识,希望对你有一定的参考价值。
捕获模块
捕获的作用
捕获得到多普勒值和伪码码相位值,就是用作跟踪的初始值。
多普勒值就是一个频率值。伪码相位就是一个采样点序号值。
捕获是只在接收开始时进行,跟踪是一直进行。
本程序中捕获用到11ms数据,用连续2ms数据进行捕获,可以确保这两个连续1ms数据中至少有一个没有数据码的翻转。取其中结果好的一秒的捕获结果的伪码相位值,去掉伪码然后用10ms的数据进行更精确的多普勒估计。
捕获得到的码相位值就是得到这一毫秒数据(5714个数据中)一个伪码周期开始的点的位置(4643)
捕获用的FFT法。 CA码FFT后然后取共轭转置
caCodeFreqDom = conj(fft(caCodesTable(PRN, 😃));
接收信号取FFT : IQfreqDom1 = fft(I1 + j*Q1);
%% Correlate signals ======================================================
%--- Perform DFT of C/A code ------------------------------------------
caCodeFreqDom = conj(fft(caCodesTable(PRN, :)));
%--- Make the correlation for whole frequency band (for all freq. bins)
for frqBinIndex = 1:numberOfFrqBins %载波频率变化,多普勒估计范围
%--- Generate carrier wave frequency grid (0.5kHz step) -----------
frqBins(frqBinIndex) = settings.IF - ...
(settings.acqSearchBand/2) * 1000 + ...
0.5e3 * (frqBinIndex - 1);
%--- Generate local sine and cosine -------------------------------
sinCarr = sin(frqBins(frqBinIndex) * phasePoints);
cosCarr = cos(frqBins(frqBinIndex) * phasePoints);
%--- "Remove carrier" from the signal -----------------------------
I1 = sinCarr .* signal1;
Q1 = cosCarr .* signal1;
I2 = sinCarr .* signal2;
Q2 = cosCarr .* signal2;
% 这里面signal1和signal2是前后两个周期,取两段作相关,哪段结果好用哪段。
%--- Convert the baseband signal to frequency domain --------------
IQfreqDom1 = fft(I1 + j*Q1);
IQfreqDom2 = fft(I2 + j*Q2);
%--- Multiplication in the frequency domain (correlation in time
%domain)
convCodeIQ1 = IQfreqDom1 .* caCodeFreqDom;
convCodeIQ2 = IQfreqDom2 .* caCodeFreqDom;
%--- Perform inverse DFT and store correlation results ------------
acqRes1 = abs(ifft(convCodeIQ1)) .^ 2;
acqRes2 = abs(ifft(convCodeIQ2)) .^ 2;
%--- Check which msec had the greater power and save that, will
%"blend" 1st and 2nd msec but will correct data bit issues
if (max(acqRes1) > max(acqRes2))
results(frqBinIndex, :) = acqRes1;
else
results(frqBinIndex, :) = acqRes2;
end
end % frqBinIndex = 1:numberOfFrqBins
找次大值,如果最大值/次大值超过门限值,说明捕获成功
%% Look for correlation peaks in the results ==============================
% Find the highest peak and compare it to the second highest peak
% The second peak is chosen not closer than 1 chip to the highest peak
%--- Find the correlation peak and the carrier frequency --------------
[peakSize frequencyBinIndex] = max(max(results, [], 2));
%--- Find code phase of the same correlation peak ---------------------
[peakSize codePhase] = max(max(results));
%--- Find 1 chip wide C/A code phase exclude range around the peak ----
samplesPerCodeChip = round(settings.samplingFreq / settings.codeFreqBasis);
excludeRangeIndex1 = codePhase - samplesPerCodeChip;
excludeRangeIndex2 = codePhase + samplesPerCodeChip;
%--- Correct C/A code phase exclude range if the range includes array
%boundaries 这部分就是把最大值部分抠了去,然后找次大值
if excludeRangeIndex1 < 2
codePhaseRange = excludeRangeIndex2 : ...
(samplesPerCode + excludeRangeIndex1);
elseif excludeRangeIndex2 >= samplesPerCode
codePhaseRange = (excludeRangeIndex2 - samplesPerCode) : ...
excludeRangeIndex1;
else
codePhaseRange = [1:excludeRangeIndex1, ...
excludeRangeIndex2 : samplesPerCode];
end
%--- Find the second highest correlation peak in the same freq. bin ---
secondPeakSize = max(results(frequencyBinIndex, codePhaseRange));
%--- Store result -----------------------------------------------------
acqResults.peakMetric(PRN) = peakSize/secondPeakSize;
%acqResults.peakMetric
% If the result is above threshold, then there is a signal ...
if (peakSize/secondPeakSize) > settings.acqThreshold
精确的多普勒频率估计
利用上一步找到的伪码估计进行伪码去除,然后利用10ms的接收信号进行FFT变换估计多普勒频率。
%% Fine resolution frequency search =======================================
%--- Indicate PRN number of the detected signal -------------------
fprintf('%02d ', PRN);
%--- Generate 10msec long C/A codes sequence for given PRN --------
caCode = generateCAcode(PRN);
codeValueIndex = floor((ts * (1:10*samplesPerCode)) / ...
(1/settings.codeFreqBasis));
longCaCode = caCode((rem(codeValueIndex, 1023) + 1));
%--- Remove C/A code modulation from the original signal ----------
% (Using detected C/A code phase)
xCarrier = ...
signal0DC(codePhase:(codePhase + 10*samplesPerCode-1)) ...
.* longCaCode;
%--- Find the next highest power of two and increase by 8x --------
fftNumPts = 8*(2^(nextpow2(length(xCarrier))));
%--- Compute the magnitude of the FFT, find maximum and the
%associated carrier frequency
fftxc = abs(fft(xCarrier, fftNumPts));
uniqFftPts = ceil((fftNumPts + 1) / 2);
[fftMax, fftMaxIndex] = max(fftxc(5 : uniqFftPts-5));
fftFreqBins = (0 : uniqFftPts-1) * settings.samplingFreq/fftNumPts;
%--- Save properties of the detected satellite signal -------------
acqResults.carrFreq(PRN) = fftFreqBins(fftMaxIndex);
acqResults.codePhase(PRN) = codePhase;
2020.3.31补充
以上是关于阅读GNSS软件接收机matlab代码的主要内容,如果未能解决你的问题,请参考以下文章
滤波跟踪基于matlab Huber函数和最大相关熵的抗差滤波算法GNSS导航定位粗差处理含Matlab源码 2129期