Commit 9fb06130 authored by Florian Kaltenberger's avatar Florian Kaltenberger

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5204 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 6572bfe1
close all close all
clear 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 enable_plots=2; %enables figures
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,:));
%% %% preload and init data
v1 = zeros(samples_slot1*slots_per_frame*nframes,nant1); addpath('../../../openair1/PHY/LTE_REFSIG');
v2 = zeros(samples_slot1*slots_per_frame*nframes,nant2); primary_synch; %loads the primary sync signal
for slot=1:slots_per_frame*nframes pss1_t = upsample(primary_synch0_time,4*4);
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); pss2_t = upsample(primary_synch0_time,4*2);
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
%% %load('E:\EMOS\corridor\ofdm_pilots_sync_2048_v7.mat');
figure(1) load('ofdm_pilots_sync_30MHz.mat');
plot(20*log10(abs(fftshift(fft(v1)))))
figure(2)
plot(20*log10(abs(fftshift(fft(v2)))))
filename = 'E:\EMOS\corridor\eNB_data_20140319_133327.EMOS';
%% sync nb_rb1 = 100; %this can be 25, 50, or 100
addpath('../../../openair1/PHY/LTE_REFSIG'); num_carriers1 = 2048/100*nb_rb1;
primary_synch; %loads the primary sync signal 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); nb_rb2 = 50; %this can be 25, 50, or 100
[corr,lag] = xcorr(v2(:,1),pss_t); num_carriers2 = 2048/100*nb_rb2;
figure(3); num_zeros2 = num_carriers2-(12*nb_rb2+1);
plot(lag,abs(corr)); 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 nant1 = 2;
load('E:\EMOS\corridor\ofdm_pilots_sync_30MHz.mat'); nant2 = 2;
ofdm_symbol_length = num_carriers + prefix_length; samples_slot1 = 7680*2;
frame_length = ofdm_symbol_length*num_symbols_frame; samples_slot2 = 7680;
useful_carriers = num_carriers-num_zeros-1; 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 d = dir(filename);
[m,i]=max(abs(corr)); nblocks = floor(d.bytes/(samples_slot_agg*slots_per_frame*nframes*4));
frame_start = lag(i) - prefix_length; PDP1_total = zeros(nblocks*nframes,useful_carriers1);
PDP2_total = zeros(nblocks*nframes,useful_carriers2);
%% ofdm receiver %% main loop
received = v2(frame_start:frame_start+frame_length,1); fid = fopen(filename,'r');
received_f = zeros(num_symbols_frame,useful_carriers); block = 1;
for i=0:num_symbols_frame-1; while ~feof(fid)
ifblock=received(i*ofdm_symbol_length+[1:ofdm_symbol_length]); fprintf(1,'Processing block %d of %d',block,nblocks);
ifblock(1:prefix_length)=[];
fblock=fft(ifblock); %%
received_f(i+1,:) = [fblock(2:useful_carriers/2+1); fblock(end-useful_carriers/2+1:end)]; [v,c]=fread(fid, 2*samples_slot_agg*slots_per_frame*nframes, 'int16',0,'ieee-le');
end if (c==0)
break
end
v0 = double(v(1:2:end,:))+1j*double(v(2:2:end,:));
%% channel estimation v1 = zeros(samples_slot1*slots_per_frame*nframes,nant1);
H=conj(f2).*received_f; v2 = zeros(samples_slot2*slots_per_frame*nframes,nant2);
Ht = ifft(H,[],2); for slot=1:slots_per_frame*nframes
PDP = mean(abs(Ht(2:end,:).^2),1); for a1=1:nant1
figure(3) v1((slot-1)*samples_slot1+1:slot*samples_slot1,a1) = ...
surf(20*log10(abs(Ht))) v0((slot-1)*samples_slot_agg+(a1-1)*samples_slot1+1:...
xlabel('time [OFDM symbol]') (slot-1)*samples_slot_agg+ a1 *samples_slot1,1);
ylabel('delay time [samples]') end
zlabel('power [dB]') for a2=1:nant2
shading interp v2((slot-1)*samples_slot2+1:slot*samples_slot2,a2) = ...
figure(4) v0((slot-1)*samples_slot_agg+nant1*samples_slot1+(a2-1)*samples_slot2+1:...
plot(10*log10(PDP)) (slot-1)*samples_slot_agg+nant1*samples_slot1+ a2 *samples_slot2,1);
xlabel('delay time [samples]') end
ylabel('power [dB]') 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);
...@@ -2,7 +2,7 @@ function [m,ind]=peaksfinder(corr,frame_length) ...@@ -2,7 +2,7 @@ function [m,ind]=peaksfinder(corr,frame_length)
threshold=45000; threshold=max(abs(corr))*0.75;
consecutivePos=[]; consecutivePos=[];
highCorrVal=find(abs(corr)>threshold); highCorrVal=find(abs(corr)>threshold);
num_peak=0; num_peak=0;
......
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