OFDM synchronization relying on the preamble and Schmidl and Cox algorithm. function [ r_corrected, Delta_tau_est, Delta_omega_hat ] = OFDM_Synchronization( r, Para ) The function works for SISO systems. Input arguments: r: received signal. Size: vector [1, nFrameSamples]. Para: structure containing the modulation parameters. Outputs arguments: r_corrected: received corrected signal. Size: vector [1, (Para.Ns+Para.PreambleLength)*Para.nSubcarriers(1+Para.CP)] Delta_tau_hat: estimated STO [sampling periods]. Delta_omega_hat: estimated CFO [rad/s].
0001 function [ r_corrected, Delta_tau_hat, Delta_omega_hat ] = OFDM_Synchronization( r, Para ) 0002 % OFDM synchronization relying on the preamble and Schmidl and Cox 0003 % algorithm. 0004 % 0005 % function [ r_corrected, Delta_tau_est, Delta_omega_hat ] = OFDM_Synchronization( r, Para ) 0006 % 0007 % The function works for SISO systems. 0008 % 0009 % Input arguments: 0010 % 0011 % r: received signal. Size: vector [1, nFrameSamples]. 0012 % 0013 % Para: structure containing the modulation parameters. 0014 % 0015 % Outputs arguments: 0016 % 0017 % r_corrected: received corrected signal. Size: vector [1, (Para.Ns+Para.PreambleLength)*Para.nSubcarriers(1+Para.CP)] 0018 % 0019 % Delta_tau_hat: estimated STO [sampling periods]. 0020 % 0021 % Delta_omega_hat: estimated CFO [rad/s]. 0022 % 0023 0024 0025 % This file is part of WaveComBox: www.wavecombox.com and is distributed under the terms of the MIT license. See accompanying LICENSE file. 0026 % Original author: François Rottenberg, May 3, 2018. 0027 % Contributors: 0028 % Change log: 0029 0030 % STO estimation 0031 M=Para.nSubcarriers; 0032 CP=M*Para.CP; 0033 L_OFDM=M+CP; 0034 0035 if Para.N_R==1 && Para.N_T==1 0036 nFrameSamples=length(r(1,:)); 0037 P=zeros(nFrameSamples,1); 0038 R=zeros(nFrameSamples,1); 0039 0040 % P(1)=(r(CP+1+0:CP+1+M-1))*r(CP+1+M:CP+1+M-1)'; 0041 % R(1)=(r(CP+1+M:CP+1+M-1))*r(CP+1+M:CP+1+M-1)'+(r(CP+1:CP+1+M-1))*r(CP+1:CP+1+M-1)'; 0042 % 0043 % for d=2:nFrameSamples-L_OFDM 0044 % P(d)= P(d-1)+conj(r(CP+d+M-1))*r(CP+d+M-1)-conj(r(CP+d-1))*r(CP+d+M-1); 0045 % % P(d)= (r(CP+d+0:CP+d+M-1))*r(CP+d+M:CP+d+M-1)'; 0046 % R(d)=R(d-1)+abs(r(CP+d+M-1))^2-abs(r(CP+d+M-1))^2+abs(r(CP+d+M-1))^2-abs(r(CP+d-1))^2; 0047 % % R(d)=(r(CP+d+M:CP+d+M-1))*r(CP+d+M:CP+d+M-1)'... 0048 % % +(r(CP+d:CP+d+M-1))*r(CP+d:CP+d+M-1)'; 0049 % end 0050 % metric=abs(P./R).^2; 0051 % 0052 % [~,Delta_tau_est]=max(abs(metric)); 0053 % Delta_omega_hat=2/Para.T*angle(P(Delta_tau_est)); 0054 0055 P(1)=conj(r(CP+1+0:1+L_OFDM-1))*r(CP+1+L_OFDM:CP+1+L_OFDM+M-1).'; 0056 R(1)=conj(r(CP+1+L_OFDM:CP+1+L_OFDM+M-1))*r(CP+1+L_OFDM:CP+1+L_OFDM+M-1).'+conj(r(CP+1:CP+1+M-1))*r(CP+1:CP+1+M-1).'; 0057 for d=2:nFrameSamples-2*L_OFDM 0058 P(d)= P(d-1)+conj(r(CP+d+M-1))*r(CP+d+L_OFDM+M-1)-conj(r(CP+d-1))*r(CP+d+L_OFDM-1); 0059 % P(d)= (r(CP+d+0:CP+d+M-1))'*r(CP+d+L_OFDM:CP+d+L_OFDM+M-1); 0060 R(d)=R(d-1)+abs(r(CP+d+L_OFDM+M-1))^2-abs(r(CP+d+L_OFDM-1))^2+abs(r(CP+d+M-1))^2-abs(r(CP+d-1))^2; 0061 % R(d)=(r(CP+d+L_OFDM:CP+d+L_OFDM+M-1))'*r(CP+d+L_OFDM:CP+d+L_OFDM+M-1)... 0062 % +(r(CP+d:CP+d+M-1))'*r(CP+d:CP+d+M-1); 0063 end 0064 metric=abs(P./R).^2; 0065 [~,Delta_tau_hat]=max(abs(metric)); 0066 Delta_omega_hat=1/Para.T*M/L_OFDM*angle(P(Delta_tau_hat)); 0067 % figure 0068 % plot(metric) 0069 % epsilon=Delta_omega*Para.T/2/pi 0070 % epsilon_hat=Delta_omega_hat*Para.T/2/pi 0071 0072 r_corrected=r(Delta_tau_hat:Delta_tau_hat+(Para.Ns+Para.PreambleLength)*L_OFDM-1).*exp(-1j*Delta_omega_hat*Para.T/M*(0:(Para.Ns+Para.PreambleLength)*L_OFDM-1)); 0073 else 0074 error('MIMO not yet implemented') 0075 end 0076 0077 0078 0079 0080 0081 0082 0083 0084 0085 0086 0087 0088 0089 0090 0091 end 0092