From 9fb061300a1b18bb74b740ea6d4110154ad77878 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger <florian.kaltenberger@eurecom.fr> Date: Wed, 19 Mar 2014 15:39:14 +0000 Subject: [PATCH] git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5204 818b1a75-f10b-46b9-bf7c-635c3b92a50f --- targets/PROJECTS/CORRIDOR/emos_read_ca.m | 197 +++++++++++++++-------- targets/PROJECTS/CORRIDOR/peaksfinder.m | 2 +- 2 files changed, 135 insertions(+), 64 deletions(-) diff --git a/targets/PROJECTS/CORRIDOR/emos_read_ca.m b/targets/PROJECTS/CORRIDOR/emos_read_ca.m index 4a20f2013f..d48e21a43a 100644 --- a/targets/PROJECTS/CORRIDOR/emos_read_ca.m +++ b/targets/PROJECTS/CORRIDOR/emos_read_ca.m @@ -1,77 +1,148 @@ close all clear all -nant1 = 1; -nant2 = 2; -samples_slot1 = 7680*2; -samples_slot2 = 7680; -samples_slot_agg = nant1*samples_slot1 + nant2*samples_slot2; -nframes = 10; -slots_per_frame = 20; -%% read data -fid = fopen('E:\EMOS\corridor\eNB_data_20140311_173205.EMOS','r'); -[v,c]=fread(fid, 2*samples_slot_agg*slots_per_frame*nframes, 'int16',0,'ieee-le'); -fclose(fid); -v0 = double(v(1:2:end,:))+1j*double(v(2:2:end,:)); +enable_plots=2; %enables figures -%% -v1 = zeros(samples_slot1*slots_per_frame*nframes,nant1); -v2 = zeros(samples_slot1*slots_per_frame*nframes,nant2); -for slot=1:slots_per_frame*nframes - v1((slot-1)*samples_slot1+1:slot*samples_slot1,1) = v0((slot-1)*samples_slot_agg+1:slot*samples_slot_agg-samples_slot2*nant2,1); - v2((slot-1)*samples_slot2+1:slot*samples_slot2,1) = v0((slot-1)*samples_slot_agg+samples_slot1+1:slot*samples_slot_agg-samples_slot2,1); - v2((slot-1)*samples_slot2+1:slot*samples_slot2,2) = v0((slot-1)*samples_slot_agg+samples_slot1+samples_slot2+1:slot*samples_slot_agg,1); -end +%% preload and init data +addpath('../../../openair1/PHY/LTE_REFSIG'); +primary_synch; %loads the primary sync signal +pss1_t = upsample(primary_synch0_time,4*4); +pss2_t = upsample(primary_synch0_time,4*2); -%% -figure(1) -plot(20*log10(abs(fftshift(fft(v1))))) -figure(2) -plot(20*log10(abs(fftshift(fft(v2))))) +%load('E:\EMOS\corridor\ofdm_pilots_sync_2048_v7.mat'); +load('ofdm_pilots_sync_30MHz.mat'); +filename = 'E:\EMOS\corridor\eNB_data_20140319_133327.EMOS'; -%% sync -addpath('../../../openair1/PHY/LTE_REFSIG'); -primary_synch; %loads the primary sync signal +nb_rb1 = 100; %this can be 25, 50, or 100 +num_carriers1 = 2048/100*nb_rb1; +num_zeros1 = num_carriers1-(12*nb_rb1+1); +prefix_length1 = num_carriers1/4; %this is extended CP +ofdm_symbol_length1 = num_carriers1 + prefix_length1; +frame_length1 = ofdm_symbol_length1*num_symbols_frame; +useful_carriers1 = num_carriers1-num_zeros1-1; -pss_t = upsample(primary_synch0_time,4*2); -[corr,lag] = xcorr(v2(:,1),pss_t); -figure(3); -plot(lag,abs(corr)); +nb_rb2 = 50; %this can be 25, 50, or 100 +num_carriers2 = 2048/100*nb_rb2; +num_zeros2 = num_carriers2-(12*nb_rb2+1); +prefix_length2 = num_carriers2/4; %this is extended CP +ofdm_symbol_length2 = num_carriers2 + prefix_length2; +frame_length2 = ofdm_symbol_length2*num_symbols_frame; +useful_carriers2 = num_carriers2-num_zeros2-1; -%% frame start detection -load('E:\EMOS\corridor\ofdm_pilots_sync_30MHz.mat'); -ofdm_symbol_length = num_carriers + prefix_length; -frame_length = ofdm_symbol_length*num_symbols_frame; -useful_carriers = num_carriers-num_zeros-1; +nant1 = 2; +nant2 = 2; +samples_slot1 = 7680*2; +samples_slot2 = 7680; +samples_slot_agg = nant1*samples_slot1 + nant2*samples_slot2; +nframes = 50; +slots_per_frame = 20; -% TODO: do a proper peak detection. for now just take the max -[m,i]=max(abs(corr)); -frame_start = lag(i) - prefix_length; +d = dir(filename); +nblocks = floor(d.bytes/(samples_slot_agg*slots_per_frame*nframes*4)); +PDP1_total = zeros(nblocks*nframes,useful_carriers1); +PDP2_total = zeros(nblocks*nframes,useful_carriers2); -%% ofdm receiver -received = v2(frame_start:frame_start+frame_length,1); -received_f = zeros(num_symbols_frame,useful_carriers); -for i=0:num_symbols_frame-1; - ifblock=received(i*ofdm_symbol_length+[1:ofdm_symbol_length]); - ifblock(1:prefix_length)=[]; - fblock=fft(ifblock); - received_f(i+1,:) = [fblock(2:useful_carriers/2+1); fblock(end-useful_carriers/2+1:end)]; -end +%% main loop +fid = fopen(filename,'r'); +block = 1; +while ~feof(fid) + fprintf(1,'Processing block %d of %d',block,nblocks); + + %% + [v,c]=fread(fid, 2*samples_slot_agg*slots_per_frame*nframes, 'int16',0,'ieee-le'); + if (c==0) + break + end + v0 = double(v(1:2:end,:))+1j*double(v(2:2:end,:)); -%% channel estimation -H=conj(f2).*received_f; -Ht = ifft(H,[],2); -PDP = mean(abs(Ht(2:end,:).^2),1); -figure(3) -surf(20*log10(abs(Ht))) -xlabel('time [OFDM symbol]') -ylabel('delay time [samples]') -zlabel('power [dB]') -shading interp -figure(4) -plot(10*log10(PDP)) -xlabel('delay time [samples]') -ylabel('power [dB]') + v1 = zeros(samples_slot1*slots_per_frame*nframes,nant1); + v2 = zeros(samples_slot2*slots_per_frame*nframes,nant2); + for slot=1:slots_per_frame*nframes + for a1=1:nant1 + v1((slot-1)*samples_slot1+1:slot*samples_slot1,a1) = ... + v0((slot-1)*samples_slot_agg+(a1-1)*samples_slot1+1:... + (slot-1)*samples_slot_agg+ a1 *samples_slot1,1); + end + for a2=1:nant2 + v2((slot-1)*samples_slot2+1:slot*samples_slot2,a2) = ... + v0((slot-1)*samples_slot_agg+nant1*samples_slot1+(a2-1)*samples_slot2+1:... + (slot-1)*samples_slot_agg+nant1*samples_slot1+ a2 *samples_slot2,1); + end + end + + if enable_plots>=2 + figure(1) + plot(abs(fftshift(fft(v1)))) + + figure(2) + plot(abs(fftshift(fft(v2)))) + end + + %% frame start detection + [corr,lag] = xcorr(v2(:,1),pss2_t); + %[m,idx]=max(abs(corr)); + [m,idx]=peaksfinder(corr,frame_length2); + if (enable_plots>=2) + figure(20); + hold off + plot(lag,abs(corr)); + hold on + plot(lag(idx),m,'ro') + end + + %% + for i=1:size(idx,2)-1; % the last frame is not complite + fprintf(1,'.'); + %frame_start2 = lag(i) - prefix_length2; + frame_start2 = lag(idx(i))-prefix_length2; + frame_start1 = frame_start2*2; + + % ofdm receiver + received_f1 = OFDM_RX(v1(frame_start1:frame_start1+frame_length1,:),num_carriers1,useful_carriers1,prefix_length1,num_symbols_frame); + received_f2 = OFDM_RX(v2(frame_start2:frame_start2+frame_length2,:),num_carriers2,useful_carriers2,prefix_length2,num_symbols_frame); + + % channel estimation (SISO) + H1=conj(squeeze(f1(1,:,:))).*received_f1(:,:,1); + H2=conj(squeeze(f2(1,:,:))).*received_f2(:,:,1); + H1t = ifft(H1,[],2); + H2t = ifft(H2,[],2); + PDP1 = mean(abs(H1t(2:end,:).^2),1); + PDP2 = mean(abs(H2t(2:end,:).^2),1); + PDP1_total((block-1)*nframes+i+1,:) = PDP1; + PDP2_total((block-1)*nframes+i+1,:) = PDP2; + + if enable_plots>=1 + figure(3) + surf((abs(H1t))) + xlabel('time [OFDM symbol]') + ylabel('delay time [samples]') + zlabel('power [dB]') + title('H1t') + shading interp + figure(4) + plot(10*log10(PDP1)) + xlabel('delay time [samples]') + ylabel('power [dB]') + title('PDP1') + figure(30) + surf((abs(H2t))) + xlabel('time [OFDM symbol]') + ylabel('delay time [samples]') + zlabel('power [dB]') + title('H2t') + shading interp + figure(40) + plot(10*log10(PDP2)) + xlabel('delay time [samples]') + ylabel('power [dB]') + title('PDP2') + end + + end + fprintf(1,'\n'); + block = block+1; +end +fclose(fid); diff --git a/targets/PROJECTS/CORRIDOR/peaksfinder.m b/targets/PROJECTS/CORRIDOR/peaksfinder.m index 80139405e7..5d9c0961d7 100644 --- a/targets/PROJECTS/CORRIDOR/peaksfinder.m +++ b/targets/PROJECTS/CORRIDOR/peaksfinder.m @@ -2,7 +2,7 @@ function [m,ind]=peaksfinder(corr,frame_length) -threshold=45000; +threshold=max(abs(corr))*0.75; consecutivePos=[]; highCorrVal=find(abs(corr)>threshold); num_peak=0; -- GitLab