Commit 0862a82b authored by Florian Kaltenberger's avatar Florian Kaltenberger

updated emos_read scripts and signal generation script

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5207 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent de4208f9
function received_f = OFDM_RX(received,num_carriers,useful_carriers,prefix_length,num_symbols_frame)
nant = size(received,2);
ofdm_symbol_length = num_carriers + prefix_length;
received_f = zeros(num_symbols_frame,useful_carriers,nant);
for j=0:num_symbols_frame-1;
ifblock=received(j*ofdm_symbol_length+(1:ofdm_symbol_length),:);
ifblock(1:prefix_length,:)=[];
fblock=fft(ifblock,[],1);
received_f(j+1,:,:) = [fblock(2:useful_carriers/2+1,:); fblock(end-useful_carriers/2+1:end,:)];
end
\ No newline at end of file
...@@ -18,7 +18,7 @@ elseif (num_ant ==2) ...@@ -18,7 +18,7 @@ elseif (num_ant ==2)
f_dec = 2; f_dec = 2;
elseif (num_ant == 4) elseif (num_ant == 4)
t_dec = 2; t_dec = 2;
f_dec = 2; f_dec = 4;
else else
error('Only 1, 2 or 4 antennas supported'); error('Only 1, 2 or 4 antennas supported');
end end
...@@ -29,7 +29,7 @@ sig_f = zeros(num_ant,num_symbols_frame,num_useful_carriers); ...@@ -29,7 +29,7 @@ sig_f = zeros(num_ant,num_symbols_frame,num_useful_carriers);
for a=1:num_ant for a=1:num_ant
for k=(floor((a-1)/2)+1):t_dec:preamble_length for k=(floor((a-1)/2)+1):t_dec:preamble_length
QAM4_preamble = zeros(1,num_useful_carriers); QAM4_preamble = zeros(1,num_useful_carriers);
QAM4_preamble((mod(a-1,2)+1):f_dec:num_useful_carriers) = QAM_MOD(4,floor(4*abs(rand(1,num_useful_carriers/f_dec)))); QAM4_preamble(2*mod(a-1,2)+1:f_dec:num_useful_carriers) = QAM_MOD(4,floor(4*abs(rand(1,num_useful_carriers/f_dec))));
sig(a,(k-1)*(num_carriers+prefix_length)+1:k*(num_carriers+prefix_length)) = OFDM_TX(num_carriers,num_zeros,prefix_length,QAM4_preamble); sig(a,(k-1)*(num_carriers+prefix_length)+1:k*(num_carriers+prefix_length)) = OFDM_TX(num_carriers,num_zeros,prefix_length,QAM4_preamble);
sig_f(a,k,:) = QAM4_preamble; sig_f(a,k,:) = QAM4_preamble;
end end
......
close all close all
clear all clear all
enable_plots=1; %eanbles figures enable_plots=2; %eanbles figures
%% preload and init data %% preload and init data
addpath('../../../openair1/PHY/LTE_REFSIG'); addpath('../../../openair1/PHY/LTE_REFSIG');
primary_synch; %loads the primary sync signal primary_synch; %loads the primary sync signal
pss_t = upsample(primary_synch0_time,4*4); pss_t = upsample(primary_synch0_time,4);
%load('E:\EMOS\corridor\ofdm_pilots_sync_2048_v7.mat');
load('ofdm_pilots_sync_30MHz.mat');
%load('../LOCALIZATION/ofdm_pilots_sync_2048.mat');
load('E:\EMOS\corridor\ofdm_pilots_sync_2048_v7.mat');
ofdm_symbol_length = num_carriers + prefix_length; ofdm_symbol_length = num_carriers + prefix_length;
frame_length = ofdm_symbol_length*num_symbols_frame; frame_length = ofdm_symbol_length*num_symbols_frame;
useful_carriers = num_carriers-num_zeros-1; useful_carriers = num_carriers-num_zeros-1;
filename = 'E:\EMOS\corridor\eNB_data_20140108_185919.EMOS'; filename = 'E:\EMOS\corridor2\eNB_data_20140321_184441.EMOS';
samples_slot = 7680*2; samples_slot = 7680/2;
slots_per_frame = 20; slots_per_frame = 20;
nframes = 100; nframes = 100;
nant=3;
d = dir(filename); d = dir(filename);
nblocks = floor(d.bytes/(samples_slot*slots_per_frame*nframes*4)); nblocks = floor(d.bytes/(samples_slot*slots_per_frame*nframes*nant*4));
PDP_total = zeros(nblocks*nframes,useful_carriers); PDP_total = zeros(nblocks*nframes,useful_carriers/4);
%% main loop %% main loop
fid = fopen(filename,'r'); fid = fopen(filename,'r');
...@@ -29,42 +31,53 @@ block = 1; ...@@ -29,42 +31,53 @@ block = 1;
while ~feof(fid) while ~feof(fid)
fprintf(1,'Processing block %d of %d',block,nblocks); fprintf(1,'Processing block %d of %d',block,nblocks);
[v,c]=fread(fid, samples_slot*slots_per_frame*nframes*2, 'int16',0,'ieee-le'); [v,c]=fread(fid, samples_slot*slots_per_frame*nframes*nant*2, 'int16',0,'ieee-le');
v2 = double(v(1:2:end))+1j*double(v(2:2:end)); if (c==0)
break
[corr,lag] = xcorr(v2,pss_t); end
v1 = double(v(1:2:end))+1j*double(v(2:2:end));
v2 = zeros(samples_slot*slots_per_frame*nframes,nant);
for slot=1:slots_per_frame*nframes
for a=1:nant
v2((slot-1)*samples_slot+1:slot*samples_slot,a) = ...
v1((slot-1)*samples_slot*nant+(a-1)*samples_slot+1:...
(slot-1)*samples_slot*nant+ a *samples_slot,1);
end
end
if enable_plots>=2 if enable_plots>=2
figure(1) figure(1)
plot(abs(fftshift(fft(v2)))) plot(abs(fftshift(fft(v2))))
end
%% frame start detection
[corr,lag] = xcorr(v2(:,1),pss_t);
%[m,idx]=max(abs(corr));
[m,idx]=peaksfinder(corr,frame_length);
if enable_plots>=2
figure(2); figure(2);
hold off
plot(lag,abs(corr)); plot(lag,abs(corr));
hold on
plot(lag(idx),m,'ro')
end end
%% frame start detection
%[m,i]=max(abs(corr));
[m,idx]=peaksfinder(corr,frame_length);
%%
for i=1:size(idx,2)-1; % the last frame is not complite for i=1:size(idx,2)-1; % the last frame is not complite
fprintf(1,'.'); fprintf(1,'.');
frame_start = lag(idx(i))-prefix_length; frame_start = lag(idx(i))-prefix_length;
% frame_start = lag(i) - prefix_length; % frame_start = lag(i) - prefix_length;
%% ofdm receiver %% ofdm receiver
received = v2(frame_start:frame_start+frame_length); received_f = OFDM_RX(v2(frame_start:frame_start+frame_length,:),num_carriers,useful_carriers,prefix_length,num_symbols_frame);
received_f = zeros(num_symbols_frame,useful_carriers);
for j=0:num_symbols_frame-1;
ifblock=received(j*ofdm_symbol_length+(1:ofdm_symbol_length));
ifblock(1:prefix_length)=[];
fblock=fft(ifblock);
received_f(j+1,:) = [fblock(2:useful_carriers/2+1); fblock(end-useful_carriers/2+1:end)];
end
%% channel estimation %% channel estimation
H=conj(f).*received_f; H=conj(squeeze(f3(1,3:2:end,1:4:end))).*received_f(3:2:end,1:4:end,1);
Ht = ifft(H,[],2); Ht = ifft(H,[],2);
PDP = mean(abs(Ht(2:end,:).^2),1); PDP = mean(abs(Ht).^2,1);
PDP_total((block-1)*nframes+i+1,:) = PDP; PDP_total((block-1)*nframes+i+1,:) = PDP;
if enable_plots>=1 if enable_plots>=1
......
...@@ -40,8 +40,8 @@ slots_per_frame = 20; ...@@ -40,8 +40,8 @@ slots_per_frame = 20;
d = dir(filename); d = dir(filename);
nblocks = floor(d.bytes/(samples_slot_agg*slots_per_frame*nframes*4)); nblocks = floor(d.bytes/(samples_slot_agg*slots_per_frame*nframes*4));
PDP1_total = zeros(nblocks*nframes,useful_carriers1); PDP1_total = zeros(nblocks*nframes,useful_carriers1/2);
PDP2_total = zeros(nblocks*nframes,useful_carriers2); PDP2_total = zeros(nblocks*nframes,useful_carriers2/2);
%% main loop %% main loop
fid = fopen(filename,'r'); fid = fopen(filename,'r');
...@@ -104,12 +104,12 @@ while ~feof(fid) ...@@ -104,12 +104,12 @@ while ~feof(fid)
received_f2 = OFDM_RX(v2(frame_start2:frame_start2+frame_length2,:),num_carriers2,useful_carriers2,prefix_length2,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) % channel estimation (SISO)
H1=conj(squeeze(f1(1,:,:))).*received_f1(:,:,1); H1=conj(squeeze(f1(1,3:2:end,1:2:end))).*received_f1(3:2:end,1:2:end,1);
H2=conj(squeeze(f2(1,:,:))).*received_f2(:,:,1); H2=conj(squeeze(f2(1,3:2:end,1:2:end))).*received_f2(3:2:end,1:2:end,1);
H1t = ifft(H1,[],2); H1t = ifft(H1,[],2);
H2t = ifft(H2,[],2); H2t = ifft(H2,[],2);
PDP1 = mean(abs(H1t(2:end,:).^2),1); PDP1 = mean(abs(H1t).^2,1);
PDP2 = mean(abs(H2t(2:end,:).^2),1); PDP2 = mean(abs(H2t).^2,1);
PDP1_total((block-1)*nframes+i+1,:) = PDP1; PDP1_total((block-1)*nframes+i+1,:) = PDP1;
PDP2_total((block-1)*nframes+i+1,:) = PDP2; PDP2_total((block-1)*nframes+i+1,:) = PDP2;
......
...@@ -89,3 +89,8 @@ save('ofdm_pilots_sync_30MHz.mat','-v7','s1','s2','s3','f1','f2','f3','num_carri ...@@ -89,3 +89,8 @@ save('ofdm_pilots_sync_30MHz.mat','-v7','s1','s2','s3','f1','f2','f3','num_carri
s_all = sum(s,1); s_all = sum(s,1);
s_all(1:5120) = s(1,1:5120); s_all(1:5120) = s(1,1:5120);
mat2wv(s_all, 'ofdm_pilots_sync_30MHz.wv', sample_rate, 1); mat2wv(s_all, 'ofdm_pilots_sync_30MHz.wv', sample_rate, 1);
s_all = sum(s3,1);
s_all(1:640) = s3(1,1:640);
mat2wv(s_all, 'ofdm_pilots_sync_5MHz.wv', 7.68e6, 1);
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