载波同步方法:导频、平方变换(bpsk)、同相正交锁相环…
位同步:位同步频率可以由载波频率得到,(前面载波频率已经跟踪上了,只进行一个简单的分频就可以了)
或者异步通信,不需要位同步,因为异步通信一般通信速率较低,如RS232中。异步通信最高速率115.2kbps.
帧同步:同步头、巴克码
同步头,这里就有漏捕、误捕的问题。
比如7位巴克码同步头中出现一位错误,相关值就由7变为5.如果判决门限设置为7,那么就会出现漏捕。
解决办法:降低判决门限。如设置为5.
如果信息码元中出现与同步头一样的结构,那么就会出现误捕。
解决办法:判断两同步头之间间隔是否位一帧长度。
下面以GPS接收机帧同步代码为例说明。
function [firstSubFrame, activeChnList] = findPreambles(trackResults, ...
settings)
% findPreambles finds the first preamble occurrence in the bit stream of
% each channel. The preamble is verified by check of the spacing between
% preambles (6sec) and parity checking of the first two words in a
% subframe. At the same time function returns list of channels, that are in
% tracking state and with valid preambles in the nav data stream.
%
%[firstSubFrame, activeChnList] = findPreambles(trackResults, settings)
%
% Inputs:
% trackResults - output from the tracking function
% settings - Receiver settings.
%
% Outputs:
% firstSubframe - the array contains positions of the first
% preamble in each channel. The position is ms count
% since start of tracking. Corresponding value will
% be set to 0 if no valid preambles were detected in
% the channel.
% activeChnList - list of channels containing valid preambles
%--------------------------------------------------------------------------
% SoftGNSS v3.0
%
% Copyright (C) Darius Plausinaitis, Peter Rinder and Nicolaj Bertelsen
% Written by Darius Plausinaitis, Peter Rinder and Nicolaj Bertelsen
%--------------------------------------------------------------------------
%
%This program is free software; you can redistribute it and/or
%modify it under the terms of the GNU General Public License
%as published by the Free Software Foundation; either version 2
%of the License, or (at your option) any later version.
%
%This program is distributed in the hope that it will be useful,
%but WITHOUT ANY WARRANTY; without even the implied warranty of
%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%GNU General Public License for more details.
%
%You should have received a copy of the GNU General Public License
%along with this program; if not, write to the Free Software
%Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
%USA.
%--------------------------------------------------------------------------
% CVS record:
% $Id: findPreambles.m,v 1.1.2.10 2006/08/14 11:38:22 dpl Exp $
% Preamble search can be delayed to a later point in the tracking results
% to avoid noise due to tracking loop transients
searchStartOffset = 0;
% searchStartOffset 这个量一直没用到,一直是0
%--- Initialize the firstSubFrame array -----------------------------------
firstSubFrame = zeros(1, settings.numberOfChannels);
%--- Generate the preamble pattern ----------------------------------------
preamble_bits = [1 -1 -1 -1 1 -1 1 1];
% "Upsample" the preamble - make 20 vales per one bit. The preamble must be
% found with precision of a sample.
preamble_ms = kron(preamble_bits, ones(1, 20));
%--- Make a list of channels excluding not tracking channels --------------
activeChnList = find([trackResults.status] ~= '-');
%=== For all tracking channels ...
for channelNr = activeChnList
%% Correlate tracking output with preamble ================================
% Read output from tracking. It contains the navigation bits. The start
% of record is skiped here to avoid tracking loop transients.
bits = trackResults(channelNr).I_P(1 + searchStartOffset : end);
%trackResults(channelNr).I_P共37000ms(37000个)数据,20个数据位一个导航信息位数据
% Now threshold the output and convert it to -1 and +1
bits(bits > 0) = 1;
bits(bits <= 0) = -1;
% Correlate tracking output with the preamble
tlmXcorrResult = xcorr(bits, preamble_ms);
%% Find all starting points off all preamble like patterns ================
clear index
clear index2
xcorrLength = (length(tlmXcorrResult) + 1) /2;
%--- Find at what index/ms the preambles start ------------------------
index = find(...
abs(tlmXcorrResult(xcorrLength : xcorrLength * 2 - 1)) > 153)' + ...
searchStartOffset;
%相关值最大为8*20=160;错开一位时,相关值为160-8=152。
%% Analyze detected preamble like patterns ================================
for i = 1:size(index) % For each occurrence
%--- Find distances in time between this occurrence and the rest of
%preambles like patterns. If the distance is 6000 milliseconds (one
%subframe), the do further verifications by validating the parities
%of two GPS words
index2 = index - index(i);
if (~isempty(find(index2 == 6000)))
%相隔6000个点(6000ms=6s一个子帧周期)又出现相关值,说明这是接收到的第一个子帧起点了。
%=== Re-read bit vales for preamble verification ==============
% Preamble occurrence is verified by checking the parity of
% the first two words in the subframe. Now it is assumed that
% bit boundaries a known. Therefore the bit values over 20ms are
% combined to increase receiver performance for noisy signals.
% in Total 62 bits mast be read :
% 2 bits from previous subframe are needed for parity checking;
% 60 bits for the first two 30bit words (TLM and HOW words).
% The index is pointing at the start of TLM word.
bits = trackResults(channelNr).I_P(index(i)-40 : ...
index(i) + 20 * 60 -1)';
%--- Combine the 20 values of each bit ------------------------
bits = reshape(bits, 20, (size(bits, 1) / 20));
bits = sum(bits);
% Now threshold and make it -1 and +1
bits(bits > 0) = 1;
bits(bits <= 0) = -1;
%--- Check the parity of the TLM and HOW words ----------------
if (navPartyChk(bits(1:32)) ~= 0) && ...
(navPartyChk(bits(31:62)) ~= 0)
% Parity was OK. Record the preamble start position. Skip
% the rest of preamble pattern checking for this channel
% and process next channel.
firstSubFrame(channelNr) = index(i);
break;
end % if parity is OK ...
end % if (~isempty(find(index2 == 6000)))
end % for i = 1:size(index)
% Exclude channel from the active channel list if no valid preamble was
% detected
if firstSubFrame(channelNr) == 0
% Exclude channel from further processing. It does not contain any
% valid preamble and therefore nothing more can be done for it.
activeChnList = setdiff(activeChnList, channelNr);
disp(['Could not find valid preambles in channel ', ...
num2str(channelNr),'!']);
end
end % for channelNr = activeChnList
代码中89行,判决门限设置为153,102行判断同步头前后间隔是否位一帧长度。