Commit 223c5a8a authored by Byiringi's avatar Byiringi

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5586 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent ba29e737
...@@ -12,8 +12,8 @@ primary_synch; %loads the primary sync signal ...@@ -12,8 +12,8 @@ primary_synch; %loads the primary sync signal
%load('E:\EMOS\corridor\ofdm_pilots_sync_2048_v7.mat'); %load('E:\EMOS\corridor\ofdm_pilots_sync_2048_v7.mat');
load('ofdm_pilots_sync_30MHz.mat'); load('ofdm_pilots_sync_30MHz.mat');
n_carriers = 1; % use 1 for UHF and 2 for 2.6GHz n_carriers = 2; % use 1 for UHF and 2 for 2.6GHz
n_trials=1;%use 1 for trial1 and 2 for trial2 n_trials=2;%use 1 for trial1 and 2 for trial2
symbols_per_slot = 6; symbols_per_slot = 6;
slots_per_frame = 20; slots_per_frame = 20;
...@@ -36,9 +36,9 @@ switch n_carriers ...@@ -36,9 +36,9 @@ switch n_carriers
pss_t = upsample(primary_synch0_time,4*4); % this assumes we are doing the sync on the first carrier, which is 10MHz pss_t = upsample(primary_synch0_time,4*4); % this assumes we are doing the sync on the first carrier, which is 10MHz
%filename = 'E:\EMOS\corridor\trials1\eNB_data_20140331_UHF_run1.EMOS'; %filename = 'E:\EMOS\corridor\trials1\eNB_data_20140331_UHF_run1.EMOS';
%filename = 'E:/byiringi/emosFiles/trials1/eNB_data_20140331_2.6GHz_run2.EMOS'; %filename = 'E:/byiringi/emosFiles/trials1/eNB_data_20140331_2.6GHz_run1.EMOS';
%filename = 'E:\EMOS\corridor\trials2\eNB_data_20140519_2.6GHz_run2.EMOS'; %filename = 'E:\EMOS\corridor\trials2\eNB_data_20140519_2.6GHz_run2.EMOS';
filename = 'E:/byiringi/emosFiles/trials2/eNB_data_20140519_2.6GHz_run1.EMOS'; filename = 'E:/byiringi/emosFiles/trials2/eNB_data_20140519_2.6GHz_run2.EMOS';
nframes = 50; % frames in one block nframes = 50; % frames in one block
threshold = 3e+4 ; % maybe should change that !!!! threshold = 3e+4 ; % maybe should change that !!!!
...@@ -195,12 +195,21 @@ while ~feof(fid) ...@@ -195,12 +195,21 @@ while ~feof(fid)
if flag1==1 if flag1==1
[corr,lag] = xcorr(v1(:,1),pss_t); [corr,lag] = xcorr(v1(:,1),pss_t);
if(n_carriers==2)
[corrb,lag] = xcorr(v2(:,1),pss_t);
end
%[m,idx]=max(abs(corr)); %[m,idx]=max(abs(corr));
%[m,idx]=peaksfinder(corr,frame_length); %[m,idx]=peaksfinder(corr,frame_length);
tmp = corr(nframes*slots_per_frame*p(1).samples_slot:end); tmp = corr(nframes*slots_per_frame*p(1).samples_slot:end);
tmp2 = reshape(tmp,slots_per_frame*p(1).samples_slot,nframes); tmp2 = reshape(tmp,slots_per_frame*p(1).samples_slot,nframes);
[m,idx] = max(abs(tmp2),[],1); [m,idx] = max(abs(tmp2),[],1);
if(n_carriers==2)
tmp = corrb(nframes*slots_per_frame*p(2).samples_slot:end);
tmp2 = reshape(tmp,slots_per_frame*p(2).samples_slot,nframes);
[m,idx] = max(abs(tmp2),[],1);
end
idx(m < threshold) = []; idx(m < threshold) = [];
if size(idx,2) <= 3 if size(idx,2) <= 3
...@@ -208,6 +217,7 @@ while ~feof(fid) ...@@ -208,6 +217,7 @@ while ~feof(fid)
flag2 = 0 ; flag2 = 0 ;
vStorage1 = []; vStorage1 = [];
vStorage2 = [];
% elseif size(idx,2) == nframes % elseif size(idx,2) == nframes
% %
% flag1 = 0; % flag1 = 0;
...@@ -219,6 +229,9 @@ while ~feof(fid) ...@@ -219,6 +229,9 @@ while ~feof(fid)
end end
frame_offset = round(median(idx)) - p(1).prefix_length; frame_offset = round(median(idx)) - p(1).prefix_length;
if(n_carriers==2)
frame_offset = round(median(idx)) - p(2).prefix_length;
end
if enable_plots>=2 if enable_plots>=2
...@@ -262,8 +275,11 @@ while ~feof(fid) ...@@ -262,8 +275,11 @@ while ~feof(fid)
fprintf(1,'.'); fprintf(1,'.');
frame_start1 = (slots_per_frame*p(1).samples_slot)*(i-1)+frame_offset+1; frame_start1 = (slots_per_frame*p(1).samples_slot)*(i-1)+frame_offset+1;
if n_carriers==2 if n_carriers==2
frame_start2 = (slots_per_frame*p(2).samples_slot)*(i-1)+round(frame_offset/2)+1; % frame_start2 = (slots_per_frame*p(2).samples_slot)*(i-1)+round(frame_offset/2)+1;
frame_start1 = (slots_per_frame*p(1).samples_slot)*(i-1)+2*frame_offset+1;
frame_start2 = (slots_per_frame*p(2).samples_slot)*(i-1)+frame_offset+1;
end end
if i<nframes if i<nframes
...@@ -313,6 +329,7 @@ while ~feof(fid) ...@@ -313,6 +329,7 @@ while ~feof(fid)
PDP = mean(abs(Ht).^2,1); PDP = mean(abs(Ht).^2,1);
PDP_all = squeeze(mean(mean(PDP,3),4)); PDP_all = squeeze(mean(mean(PDP,3),4));
PDD=sum(abs(fftshift(fft(Ht,[],1))).^2,2); PDD=sum(abs(fftshift(fft(Ht,[],1))).^2,2);
if(carrier==1) if(carrier==1)
PDP_totala((block-1)*NFRAMES+i,:,:,:) = PDP; PDP_totala((block-1)*NFRAMES+i,:,:,:) = PDP;
Ha=H; Ha=H;
...@@ -322,21 +339,21 @@ while ~feof(fid) ...@@ -322,21 +339,21 @@ while ~feof(fid)
PDP_totalb((block-1)*NFRAMES+i,:,:,:) = PDP; PDP_totalb((block-1)*NFRAMES+i,:,:,:) = PDP;
Hb=H; Hb=H;
end end
% %
% Hprime=H*exp(2*i*pi*167E-6*f_offset); % Hprime=H*exp(2*i*pi*167E-6*f_offset);
% Htprime = ifft(Hprime,[],2); %impulse response % Htprime = ifft(Hprime,[],2); %impulse response
% PDPprime = mean(abs(Htprime).^2,1); % PDPprime = mean(abs(Htprime).^2,1);
% %
% PDDprime=sum(abs(fftshift(fft(Htprime,[],1))).^2,2); % PDDprime=sum(abs(fftshift(fft(Htprime,[],1))).^2,2);
% if(carrier==1) % if(carrier==1)
% PDP_totala((block-1)*NFRAMES+i,:,:,:) = PDP; % PDP_totala((block-1)*NFRAMES+i,:,:,:) = PDP;
% Ha=H; % Ha=H;
% end % end
% %
% if(carrier==2) % if(carrier==2)
% PDP_totalb((block-1)*NFRAMES+i,:,:,:) = PDP; % PDP_totalb((block-1)*NFRAMES+i,:,:,:) = PDP;
% Hb=H; % Hb=H;
% end % end
if enable_plots>=1 if enable_plots>=1
figure(3+3*(carrier-1)) figure(3+3*(carrier-1))
...@@ -389,6 +406,8 @@ while ~feof(fid) ...@@ -389,6 +406,8 @@ while ~feof(fid)
drawnow drawnow
end end
if(n_carriers==1)
if carrier==1 if carrier==1
% adjust frame offset base on channel estimate to compensate for % adjust frame offset base on channel estimate to compensate for
% timing drift. We try to keep the peak of the impulse response at % timing drift. We try to keep the peak of the impulse response at
...@@ -402,6 +421,26 @@ while ~feof(fid) ...@@ -402,6 +421,26 @@ while ~feof(fid)
frame_offset = frame_offset + round(offset/4); frame_offset = frame_offset + round(offset/4);
end end
end end
end
if(n_carriers==2)
if carrier==2
% adjust frame offset base on channel estimate to compensate for
% timing drift. We try to keep the peak of the impulse response at
% sample prefix_length/8.
[m,idx] = max(fft(ifft(PDP_all),p(carrier).num_carriers));
offset = idx - p(carrier).prefix_length/8;
if offset > p(carrier).prefix_length
offset = offset - p(carrier).num_carriers;
end
if abs(offset) > 5
frame_offset = frame_offset + round(offset/4);
end
end
end
end end
H1a=cat(1,H1a,Ha); H1a=cat(1,H1a,Ha);
...@@ -416,10 +455,11 @@ while ~feof(fid) ...@@ -416,10 +455,11 @@ while ~feof(fid)
Ht1a=ifft(H1a,[],2); Ht1a=ifft(H1a,[],2);
PDD1a=sum(abs(fftshift(fft(Ht1a,[],1))).^2,2); PDD1a=sum(abs(fftshift(fft(Ht1a,[],1))).^2,2);
delayPDD1a=abs(fftshift(fft(Ht1a,[],1))).^2;
if(n_carriers==2) if(n_carriers==2)
Ht1b=ifft(H1b,[],2); Ht1b=ifft(H1b,[],2);
PDD1b=sum(abs(fftshift(fft(Ht1b,[],1))).^2,2); PDD1b=sum(abs(fftshift(fft(Ht1b,[],1))).^2,2);
delayPDD1b=abs(fftshift(fft(Ht1b,[],1))).^2;
end end
if(enable_plots>=2) if(enable_plots>=2)
...@@ -460,10 +500,49 @@ while ~feof(fid) ...@@ -460,10 +500,49 @@ while ~feof(fid)
end end
% figure(20)
% for itx=1:p(1).nant_tx
% for irx=1:p(1).nant_rx
% D=1:300;
% F=-(NFRAMES*num_symbols_frame/2-1)*7.68E6/(2*NFRAMES*num_symbols_frame/2)/1280:7.68E6/(NFRAMES*num_symbols_frame/2)/1280:(NFRAMES*num_symbols_frame/2-1)*7.68E6/(2*NFRAMES*num_symbols_frame/2)/1280;
% if(n_carriers==2)
% F=-(NFRAMES*num_symbols_frame/2-1)*30.72E6/(2*NFRAMES*num_symbols_frame/2)/5120:30.72E6/(NFRAMES*num_symbols_frame/2)/5120:(NFRAMES*num_symbols_frame/2)*30.72E6/(2*NFRAMES*num_symbols_frame/2)/5120;
% end
%
% subplot(p(1).nant_tx,p(1).nant_rx,(itx-1)*p(1).nant_rx + irx);
% % plot(F,10*log10(delayPDD1a(:,180,itx,irx)),F,10*log10(delayPDD1a(:,250,itx,irx)))
% waterfall(plot(10*log10(delayPDD1a(:,:,itx,irx))))
% %ylim([])
% %xlim([])
% % xlabel('F=f-ftx [Hz]')
% % ylabel('power [dB]')
% end
% end
%
% if(n_carriers==2)
% figure(21)
% for itx=1:p(1).nant_tx
% for irx=1:p(1).nant_rx
% D=1:300;
% F=-(NFRAMES*num_symbols_frame/2-1)*15.36E6/(2*NFRAMES*num_symbols_frame/2)/2560:15.36E6/(NFRAMES*num_symbols_frame/2)/2560:(NFRAMES*num_symbols_frame/2)*15.36E6/(2*NFRAMES*num_symbols_frame/2)/2560;
%
% subplot(p(2).nant_tx,p(2).nant_rx,(itx-1)*p(2).nant_rx + irx);
% % plot(F,10*log10(delayPDD1b(:,90,itx,irx)),F,10*log10(delayPDD1b(:,120,itx,irx)))
% waterfall(plot(10*log10(delayPDD1b(:,:,itx,irx))))
% %ylim([])
% %xlim([])
% % xlabel('F=f-ftx [Hz]')
% % ylabel('power [dB]')
% end
% end
% end
PDD_totala(:,block,:,:)=PDD1a; PDD_totala(:,block,:,:)=PDD1a;
if(n_carriers==2) if(n_carriers==2)
PDD_totalb(:,block,:,:)=PDD1b; PDD_totalb(:,block,:,:)=PDD1b;
end end
...@@ -570,8 +649,8 @@ end ...@@ -570,8 +649,8 @@ end
%% %%
if(enable_plots>=2) if(enable_plots>=2)
figure(11) figure(11)
for itx=1:p(1).nant_tx for itx=1:p(1).nant_tx
for irx=1:p(1).nant_rx for irx=1:p(1).nant_rx
T=1:1:block-1; T=1:1:block-1;
F=-(NFRAMES*num_symbols_frame/2-1)*7.68E6/(2*NFRAMES*num_symbols_frame/2)/1280:7.68E6/(NFRAMES*num_symbols_frame/2)/1280:(NFRAMES*num_symbols_frame/2-1)*7.68E6/(2*NFRAMES*num_symbols_frame/2)/1280; F=-(NFRAMES*num_symbols_frame/2-1)*7.68E6/(2*NFRAMES*num_symbols_frame/2)/1280:7.68E6/(NFRAMES*num_symbols_frame/2)/1280:(NFRAMES*num_symbols_frame/2-1)*7.68E6/(2*NFRAMES*num_symbols_frame/2)/1280;
...@@ -587,9 +666,9 @@ for itx=1:p(1).nant_tx ...@@ -587,9 +666,9 @@ for itx=1:p(1).nant_tx
ylabel('F=f-ftx [Hz]') ylabel('F=f-ftx [Hz]')
xlabel('time [s]') xlabel('time [s]')
end end
end end
if(n_carriers==2) if(n_carriers==2)
figure(12) figure(12)
for itx=1:p(2).nant_tx for itx=1:p(2).nant_tx
for irx=1:p(2).nant_rx for irx=1:p(2).nant_rx
...@@ -605,7 +684,7 @@ if(n_carriers==2) ...@@ -605,7 +684,7 @@ if(n_carriers==2)
xlabel('time [s]') xlabel('time [s]')
end end
end end
end end
end end
%% Mean Delay %% Mean Delay
...@@ -717,7 +796,7 @@ figure(17) ...@@ -717,7 +796,7 @@ figure(17)
title(''); title('');
plot(doppler_freq_of_max_a); plot(doppler_freq_of_max_a);
xlabel('time [s]'); xlabel('time [s]');
ylabel('f-ftx [Hz]'); ylabel('f-ftx [Hz]');
if(n_carriers==2) if(n_carriers==2)
figure(18) figure(18)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment