⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fb_detector_corrector.asv

📁 小区初搜为GSM系统中的一个关键过程
💻 ASV
字号:
function  [ peakIndex, qualityMetric, frequencyError ] = FB_detector_corrector(r, Tb, M)

%  This function is intended to detect a frequency correction burst(FB), estimate the frequency error and
%                  the FB burst arrival time!
%
% SYNTAX:   FB_detector_phasedifference(r,LEN,Lburst)
%
% INPUT:          r:      The received complex signal.
%                Tb:      Bit duration (GSM: Tb = 3.692e-6 Sec.)
%                 M:      The length of the correction,and mod(M,4)==0,M=16,32,148.
% 
% wuguangfu, 10th,Aug.,2007
%
%

% initialize parameters
C0 = -j;
Lburst = 148;
peakIndex = 0;
qualityMetric = 0;
frequencyError = 0;
threshold = 0;
count = 0;

scaling = M^2/2;        %%M^2 in theory. 20070815
Lpeak = Lburst-M-1;    %It should be less than 148-M-1.

r = [r zeros(1,M)];               %add r with M 0'guard in the end.
y = zeros(1, length(r));          %y is the output of the correlator!
ynSquare = zeros(1, length(r));   %The last one is used in the judgement before peak_detector!

%The FB corrector!   
for nbits = length(r) :-1: M+2         
    y(nbits-1) = r(nbits) - r(nbits-M) + C0*y(nbits);
    threshold = threshold + abs(r(nbits - 1))^2; %20070815
    ynSquare(nbits - 1) = abs(y(nbits - 1))^2;
end
figure;
plot(ynSquare);           
threshold = scaling*threshold/(length(r)-M); %Threshold is the Threshold37.

for nbits = length(ynSquare)-1 : -1 : M+1    % the direction is from the right to the left.%20070805
    if ynSquare(nbits) > threshold   
        count = count + 1;
        if count > Lpeak & ynSquare(nbits - 1) < threshold    
            
            %The timing estimator!
            peakIndex = nbits - M;               %peakIndex is the beginning of the FB!
            yn_temp = ynSquare(nbits) + ynSquare(nbits +Lpeak);
            for step = 1 : count-Lpeak-1         %peak detector!
                if yn_temp < ynSquare(nbits + step) + ynSquare(nbits + step + Lpeak)
                    yn_temp = ynSquare(nbits + step) + ynSquare(nbits + step + Lpeak);
                    peakIndex = nbits + step - M; %compensating the output with the length of M.
                end                            
            end
            fprintf('\nThe beginning of the FB burst is the %dth of received complex signal r!\n', peakIndex);
            
            %The frequency error estimator(Quality metric)!
            runSum431 = 0;
            qualityMetric = 0;
            qualityMetric1 = 0;
            for step = M : 80    %128 = 132 - 4 from the left to right.
                runSum431 = runSum431 + imag(conj(y(peakIndex + step)) * y(peakIndex + step + 4));
                qualityMetric = qualityMetric + abs(y(peakIndex + step + 4)^2);
                qualityMetric1 = qualityMetric1 + abs(y(peakIndex + step + 4))^2;
            end
            runSum431 = runSum431/80;
            qualityMetric = qualityMetric/80;             %the length number of the y needed to be computed is 128! 
            qualityMetric1 = qualityMetric1/80;  
            frequencyError = runSum431/(4*Tb*qualityMetric)/(2*pi);%frequencyError is Hz
            frequencyError1 = runSum431/(4*Tb*qualityMetric1)/(2*pi);
            break;
        end
    else
        count = 0;   %in order to initialize the parameter of count in the process!
    end
end
if peakIndex == 0
    fprintf('\nWe cannot find the FB burst in the received complex signal r.\n');
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -