0001 function [ r_corrected, Delta_tau_hat, Delta_omega_hat ] = FBMC_OQAM_Synchronization( r, d_TR, Para )
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 M=Para.nSubcarriers/2;
0039 set_K=Para.PreamblePilotSubcarriers;
0040 nFrameSamples=length(r(1,:));
0041 Para.Ns=Para.Ns+Para.PreambleLength;
0042 if nFrameSamples>(2*(Para.Ns+6)+2*Para.kappa-1)/2*2*M
0043 Para.Ns=Para.Ns+6;
0044 end
0045
0046
0047 if Para.N_R==1 && Para.N_T==1
0048 z = Demodulator( r, Para );
0049 xi=zeros(2*Para.Ns,1);
0050 for l_test=1:2*Para.Ns-2
0051 xi(l_test)=2*abs(z(set_K,l_test)'*z(set_K,l_test+2) )/sum (abs(z(set_K,l_test)).^2+abs(z(set_K,l_test+2)).^2);
0052 end
0053 [~,l_hat]=max(xi);
0054
0055 epsilon_hat_coarse=1/2/pi*angle( z(set_K,l_hat)'*z(set_K,l_hat+2) );
0056 r_CFO_corrected=r.*exp(-1j*2*pi*epsilon_hat_coarse/Para.nSubcarriers*(0:nFrameSamples-1));
0057 epsilon_hat=epsilon_hat_coarse;
0058 for l=1:2
0059 z = Demodulator( r_CFO_corrected, Para );
0060 epsilon_hat_fine=1/2/pi*angle( z(set_K,l_hat)'*z(set_K,l_hat+2) );
0061 epsilon_hat=epsilon_hat+epsilon_hat_fine;
0062 r_CFO_corrected=r.*exp(-1j*2*pi*epsilon_hat/Para.nSubcarriers*(0:nFrameSamples-1));
0063 end
0064 z = Demodulator( r_CFO_corrected, Para );
0065
0066
0067 tau_hat_CFE=1/4/pi*angle(sum(z(set_K,l_hat).*conj(circshift(z(set_K,l_hat),-1) )./d_TR(set_K)./circshift(d_TR(set_K),-1) ) ...
0068 + sum(z(set_K,l_hat+2).*conj(circshift(z(set_K,l_hat+2),-1) )./d_TR(set_K)./circshift(d_TR(set_K),-1)) );
0069
0070 L_tau_hat_CFE=floor(tau_hat_CFE*2*M);
0071 Delta_tau_hat=(l_hat-1)*M+L_tau_hat_CFE;
0072 Delta_omega_hat=2*pi*1/Para.T*epsilon_hat;
0073
0074 r_corrected=r_CFO_corrected(Delta_tau_hat+1:end);
0075 else
0076
0077 z = Demodulator( r, Para );
0078 xi=zeros(2*Para.Ns,1);
0079 for l_test=1:2*Para.Ns-2
0080 for index_N_R=1:Para.N_R
0081 z_0=squeeze(z(index_N_R,set_K,l_test)).';
0082 z_2=squeeze(z(index_N_R,set_K,l_test+2)).';
0083 xi(l_test)=xi(l_test)+2*(z_0'*z_2 )/sum (abs(z_0).^2+abs(z_2).^2);
0084 end
0085 xi(l_test)=abs(xi(l_test));
0086 end
0087 [~,l_hat]=max(xi);
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104 temp=0;
0105 for index_N_R=1:Para.N_R
0106 z_0=squeeze(z(index_N_R,set_K,l_hat)).';
0107 z_2=squeeze(z(index_N_R,set_K,l_hat+2)).';
0108 temp=temp+z_0'*z_2;
0109 end
0110 epsilon_hat_coarse=1/2/pi*angle( temp );
0111 r_CFO_corrected=r;
0112 for index_N_R=1:Para.N_R
0113 r_CFO_corrected(index_N_R,:)=r(index_N_R,:).*exp(-1j*2*pi*epsilon_hat_coarse/Para.nSubcarriers*(0:nFrameSamples-1));
0114 end
0115 epsilon_hat=epsilon_hat_coarse;
0116 for l=1:2
0117 z = Demodulator( r_CFO_corrected, Para );
0118 temp=0;
0119 for index_N_R=1:Para.N_R
0120 z_0=squeeze(z(index_N_R,set_K,l_hat)).';
0121 z_2=squeeze(z(index_N_R,set_K,l_hat+2)).';
0122 temp=temp+z_0'*z_2;
0123 end
0124 epsilon_hat_fine=1/2/pi*angle( temp );
0125 epsilon_hat=epsilon_hat+epsilon_hat_fine;
0126 for index_N_R=1:Para.N_R
0127 r_CFO_corrected(index_N_R,:)=r(index_N_R,:).*exp(-1j*2*pi*epsilon_hat/Para.nSubcarriers*(0:nFrameSamples-1));
0128 end
0129 end
0130 z = Demodulator( r_CFO_corrected, Para );
0131
0132
0133 temp=0;
0134 for index_N_R=1:Para.N_R
0135 temp=temp+sum((z(index_N_R,set_K,l_hat).'.*conj(circshift(z(index_N_R,set_K,l_hat).',-1) ))./d_TR(set_K)./circshift(d_TR(set_K),-1) ) ...
0136 + sum((z(index_N_R,set_K,l_hat+2).'.*conj(circshift(z(index_N_R,set_K,l_hat+2).',-1) ))./d_TR(set_K)./circshift(d_TR(set_K),-1)) ;
0137 end
0138 tau_hat_CFE=1/4/pi*angle(temp);
0139
0140 L_tau_hat_CFE=floor(tau_hat_CFE*2*M);
0141 Delta_tau_hat=(l_hat-1)*M+L_tau_hat_CFE;
0142 Delta_omega_hat=2*pi*1/Para.T*epsilon_hat;
0143
0144 r_corrected=r_CFO_corrected(:,Delta_tau_hat+1:end);
0145
0146 end
0147
0148
0149 end
0150