?? sync_acquisition_tracking_algo2_dab_receiver_nctu.m
字號:
clear all;close all;clc; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Program to generate the parameter h values%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%h=zeros(4,32);h(1,2)=2;h(1,7:8)=1;h(1,9)=2;h(1,13:14)=2;h(1,15:16)=1;h(2,2)=3;h(2,3)=2;h(2,4)=3;h(2,6)=1;h(2,7)=3;h(2,9)=2;h(2,10)=1;h(2,11)=2;h(2,12)=3;h(2,13)=2;h(2,14:15)=3;h(3,4)=2;h(3,6)=2;h(3,7)=1;h(3,8)=3;h(3,9:10)=2;h(3,12:13)=2;h(3,15)=1;h(3,16)=3;h(4,2)=1;h(4,3)=2;h(4,4)=1;h(4,6:7)=3;h(4,8:9)=2;h(4,10)=3;h(4,11)=2;h(4,12)=1;h(4,13)=2;h(4,14)=1;h(4,15)=3;h(4,16)=2;h(1:4,17:32)=h(1:4,1:16);null_symbol_duration=2656;no_of_subcarriers_per_symbol=1536;load ('freq_interleaving_12june.dat');freq_deinterleaving_mod1 = reshape(freq_interleaving_12june,1,1536); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Program to generate the Phase Reference Symbol%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% First af all generate the k', i and n arrays is neededfor k=1:1536 switch k case 1 k_bis=1;i=0;n=1; case 33 k_bis=33;i=1;n=2; case 65 k_bis=65;i=2;n=0; case 97 k_bis=97; i=3; n=1; case 129 k_bis=129; i=0; n=3; case 161 k_bis=161; i=1; n=2; case 193 k_bis=193; i=2; n=2; case 225 k_bis=225; i=3; n=3; case 257 k_bis=257; i=0; n=2; case 289 k_bis=289; i=1; n=1; case 321 k_bis=321; i=2; n=2; case 353 k_bis=353; i=3; n=3; case 385 k_bis=385; i=0; n=1; case 417 k_bis=417; i=1; n=2; case 449 k_bis=449; i=2; n=3; case 481 k_bis=481; i=3; n=3; case 513 k_bis=513; i=0; n=2; case 545 k_bis=545; i=1; n=2; case 577 k_bis=577; i=2; n=2; case 609 k_bis=609; i=3; n=1; case 641 k_bis=641; i=0; n=1; case 673 k_bis=673; i=1; n=3; case 705 k_bis=705; i=2; n=1; case 737 k_bis=737; i=3; n=2; case 769 k_bis=769; i=0; n=3; case 801 k_bis=801; i=3; n=1; case 833 k_bis=833; i=2; n=1; case 865 k_bis=865; i=1; n=1; case 897 k_bis=897; i=0; n=2; case 929 k_bis=929; i=3; n=2; case 961 k_bis=961; i=2; n=1; case 993 k_bis=993; i=1; n=0; case 1025 k_bis=1025; i=0; n=2; case 1057 k_bis=1057; i=3; n=2; case 1089 k_bis=1089; i=2; n=3; case 1121 k_bis=1121; i=1; n=3; case 1153 k_bis=1153; i=0; n=0; case 1185 k_bis=1185; i=3; n=2; case 1217 k_bis=1217; i=2; n=1; case 1249 k_bis=1249; i=1; n=3; case 1281 k_bis=1281; i=0; n=3; case 1313 k_bis=1313; i=3; n=3; case 1345 k_bis=1345; i=2; n=3; case 1377 k_bis=1377; i=1; n=0; case 1409 k_bis=1409; i=0; n=3; case 1441 k_bis=1441; i=3; n=0; case 1473 k_bis=1473; i=2; n=1; case 1505 k_bis=1505; i=1; n=1; end% Now it's time to calculate the phase reference symbol!% First of all the phi(k) phase is needed, so the "h" parameter% has to be determinated. phi(k)=(pi/2)*(h(i+1,k-k_bis+1)+n); z(k)=exp(j*phi(k)); if abs(real(z(k)))<1 Phase_Reference(k)=j*imag(z(k)); else Phase_Reference(k)=real(z(k)); endendphase_ref_beginning= Phase_Reference;% for m=-8:8% for n=0:15% r11_m(m+9,n+1)=phase_ref_beginning(1,n+1)*conj(phase_ref_beginning(1,mod(n+1+m+9,16)));% end% r1_m(1,m+9)=sum(r11_m(m+9,:));% endphase_ref_beginning=[phase_ref_beginning zeros(1,512)];temp=[phase_ref_beginning(769:1536) phase_ref_beginning(1537:2048) phase_ref_beginning(1:768)];phase_ref_beginning=temp;NO_OF_DATA_BITS=768;no_of_fibs_tx_frame=12;no_of_CIFs_tx_frame=4;punctured_data_bits=3072;Tx_carriers_ofdm_symbol=1536;freq_interleaved_bits=2048;useful_symbol_duration=2048;guard_interval=504;%%%%%%%%%%%%Determining auto-correlation of TX PRS%%%%%% %Loading real time data; Assume start of null symbol is unknown DAB_RX_Frame15=load('237_488MHz_IF2MHz_PAT1_80dB_1_updated_frame_cs4.dat'); %2552 samples per symbol; %2506 samples per symbol in the frame for core clock =system clock*4DAB_RX_Frame15=DAB_RX_Frame15.'; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%% Null Symbol detection-Coarse timing estimation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%nn1=length(DAB_RX_Frame15);nn2=mod(nn1,32);nn=nn1/32;%Number of blocksmm=1;for i=1:nn energy(i)=0; for ii=1:32 energy(i)=energy(i)+((DAB_RX_Frame15(mm)*DAB_RX_Frame15(mm))/2); mm=mm+1; endend%%%%%%%%%%%%%%%%Algo 2%%%%%%%%%%%%%%%%%%%start=0;low=0;threshold = 5000;count=0;for i=2:nn if (i==3850) iii=0; end if low==0 if (energy(i)<energy(i-1)) start=1; low=1; threshold=energy(i-1)/10; startpos=i; else start=0; end else if (energy(i)<=threshold && (energy(i)<=energy(i-1) ||( abs(energy(i)-energy(i-1)) <5000) ) ) start=start+1; if ((count <=2) && (count > 0)) startpos=i; end else if (start > 250) count=count+1;%low=0;%startpos=0; start=0;low=0;startpos=0; else start=start+1; end end end end if (start>=332) null_symbol_stop=10624; break; endendif (startpos>=2) if energy(startpos+1) > 500000 Null_start_64=startpos;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -