Commit 847a4203 authored by Florian Kaltenberger's avatar Florian Kaltenberger

moving project CORRIDOR to extras

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7399 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent fd45609d
function La = LanczosKernel(a,x0,samples)
min = floor(x0) - a;
max = ceil(x0) + a;
min(min<1)=1;
max(max>size(samples,2))=size(samples,2);
La=zeros(size(x0,2),1);
for i=1:size(x0,2)
La(i)=sinc((-x0(i)+(min(i):max(i)))).*sinc(((-x0(i)+(min(i):max(i)))/a))*samples(min(i):max(i))';
end
\ No newline at end of file
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)/sqrt(num_carriers);
received_f(j+1,:,:) = [fblock(2:useful_carriers/2+1,:); fblock(end-useful_carriers/2+1:end,:)];
end
\ No newline at end of file
function [sig,sig_length] = OFDM_TX(num_carriers,num_zeros,prefix_length,input)
% OFDM Transmitter - DC removed
% sig is the output signal
% length is the length of the output signal
% num_carriers - number of sub-carriers (power of 2)
% num_zeros - number of zeros minus 1 (DC) in output spectrum (odd)
% prefix_length - length of cyclic prefix
% input - input dimensions (length = number_carriers - num_zeros - 1)
if (length(input) + num_zeros + 1 ~= num_carriers)
fprintf('error in lengths\n');
return;
end
ext_input = [0 input(1:length(input)/2) zeros(1,num_zeros) input((1+length(input)/2) : length(input))];
output_1 = ifft(ext_input);
sig = [output_1((num_carriers - prefix_length + 1) : num_carriers) output_1];
sig_length = length(sig);
function [sig, sig_f] = OFDM_TX_FRAME(num_carriers,num_zeros,prefix_length,num_symbols_frame,preamble_length)
% sig - output signal
% sig_length - output signal length
% num_carriers - number of sub-carriers
% num_zeros - number of zero carriers minus 1 (DC)
% prefix_length - length of cyclic prefix
% num_symbols_frame - number of symbols per OFDM frame
% preamble_length - length of 4-QAM preamble
num_useful_carriers = num_carriers - num_zeros -1;
sig = zeros(1,(num_carriers+prefix_length)*num_symbols_frame);
sig_f = zeros(num_symbols_frame,num_useful_carriers);
for k=1:preamble_length
QAM4_preamble = QAM_MOD(4,floor(256*abs(rand(1,num_useful_carriers/4))));
sig((k-1)*(num_carriers+prefix_length)+1:k*(num_carriers+prefix_length)) = OFDM_TX(num_carriers,num_zeros,prefix_length,QAM4_preamble);
sig_f(k,:) = QAM4_preamble;
end
for k=preamble_length+1:num_symbols_frame
QAM_data = QAM_MOD(256,floor(256*abs(rand(1,num_useful_carriers))));
sig((k-1)*(num_carriers+prefix_length)+1:k*(num_carriers+prefix_length)) = OFDM_TX(num_carriers,num_zeros,prefix_length,QAM_data);
sig_f(k,:) = QAM_data;
end
function [sig, sig_f] = OFDM_TX_FRAME_MIMO(num_carriers,num_zeros,prefix_length,num_symbols_frame,preamble_length,num_ant)
% sig - output signal
% sig_length - output signal length
% num_carriers - number of sub-carriers
% num_zeros - number of zero carriers minus 1 (DC)
% prefix_length - length of cyclic prefix
% num_symbols_frame - number of symbols per OFDM frame
% preamble_length - length of 4-QAM preamble
% numant - number of antennas
num_useful_carriers = num_carriers - num_zeros -1;
if (num_ant ==1)
t_dec = 1;
f_dec = 1;
elseif (num_ant ==2)
t_dec = 1;
f_dec = 2;
elseif (num_ant == 4)
t_dec = 2;
f_dec = 4;
else
error('Only 1, 2 or 4 antennas supported');
end
sig = zeros(num_ant,(num_carriers+prefix_length)*num_symbols_frame);
sig_f = zeros(num_ant,num_symbols_frame,num_useful_carriers);
for a=1:num_ant
for k=(floor((a-1)/2)+1):t_dec:preamble_length
QAM4_preamble = zeros(1,num_useful_carriers);
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_f(a,k,:) = QAM4_preamble;
end
for k=preamble_length+1:num_symbols_frame
QAM_data = QAM_MOD(256,floor(4*abs(rand(1,num_useful_carriers))));
sig(a,(k-1)*(num_carriers+prefix_length)+1:k*(num_carriers+prefix_length)) = OFDM_TX(num_carriers,num_zeros,prefix_length,QAM_data);
sig_f(a,k,:) = QAM_data;
end
end
function [sig,sig_length] = QAM_MOD(size,input)
% sig - output symbols
% size - modulation size (4,16,256)
% input - vector of bytes to be modulated
AM2 = [-1 1];
AM4 = [-3 -1 1 3]; AM4 = 2*AM4/sqrt(AM4*AM4');
AM16 = [-15 -13 -11 -9 -7 -5 -3 -1 1 3 5 7 9 11 13 15]; AM16 = 4*AM16/sqrt(AM16*AM16');
sig = zeros(1,length(input));
sig_length = length(input);
for l=1:length(input)
if (size == 256)
sig(l) = (AM16(1+ floor((input(l)/16))) + sqrt(-1)*AM16(1+rem(input(l),16)))/sqrt(2);
elseif (size == 16)
sig(l) = (AM4(1+rem(floor(input(l)/4),4)) + sqrt(-1)*AM4(1+rem(input(l),4)))/sqrt(2);
elseif (size == 4)
sig(l) = (AM2(1+rem(floor(input(l)/2),2)) + sqrt(-1)*AM2(1+rem(input(l),2)))/sqrt(2);
end
end
This diff is collapsed.
function H_dpss = dpss_smooth(H,V,Dopt,f_start)
alpha = V(f_start:4:end,1:Dopt)'*H.';
H_dpss = V(:,1:Dopt)*alpha;
\ No newline at end of file
close all
clear all
enable_plots=2; %eanbles figures
%% preload and init data
addpath('../../../openair1/PHY/LTE_REFSIG');
primary_synch; %loads the primary sync signal
pss_t = upsample(primary_synch0_time,4);
%load('E:\EMOS\corridor\ofdm_pilots_sync_2048_v7.mat');
load('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;
%filename = 'E:\EMOS\corridor2\eNB_data_20140321_184441.EMOS';
filename = 'D:\711MHz\eNB_data_20140324_113931.EMOS';
samples_slot = 7680/2;
slots_per_frame = 20;
nframes = 100;
nant=3;
d = dir(filename);
nblocks = floor(d.bytes/(samples_slot*slots_per_frame*nframes*nant*4));
PDP_total = zeros(nblocks*nframes,useful_carriers/4);
%% main loop
fid = fopen(filename,'r');
block = 1;
while ~feof(fid)
fprintf(1,'Processing block %d of %d',block,nblocks);
[v,c]=fread(fid, samples_slot*slots_per_frame*nframes*nant*2, 'int16',0,'ieee-le');
if (c==0)
break
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
figure(1)
plot(20*log10(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);
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_start = lag(idx(i))-prefix_length;
% frame_start = lag(i) - prefix_length;
%% ofdm receiver
received_f = OFDM_RX(v2(frame_start:frame_start+frame_length,:),num_carriers,useful_carriers,prefix_length,num_symbols_frame);
%% channel estimation
H=conj(squeeze(f3(1,3:2:end,1:4:end))).*received_f(3:2:end,1:4:end,1);
Ht = ifft(H,[],2);
PDP = mean(abs(Ht).^2,1);
PDP_total((block-1)*nframes+i+1,:) = PDP;
if enable_plots>=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]')
end
end
fprintf(1,'\n');
block = block+1;
end
fclose(fid);
close all
clear all
enable_plots=2; %enables figures
%% 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);
%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';
filename = 'D:\2.6GHz\eNB_data_20140324_171904.EMOS';
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;
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;
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;
d = dir(filename);
nblocks = floor(d.bytes/(samples_slot_agg*slots_per_frame*nframes*4));
PDP1_total = zeros(nblocks*nframes,useful_carriers1/4);
PDP2_total = zeros(nblocks*nframes,useful_carriers2/4);
%% 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');
block = block+1;
if (c==0)
break
end
v0 = double(v(1:2:end,:))+1j*double(v(2:2:end,:));
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(20*log10(abs(fftshift(fft(v1)))))
figure(2)
plot(20*log10(abs(fftshift(fft(v2)))))
end
%% frame start detection
[corr1,lag1] = xcorr(v1(:,1),pss1_t);
[corr2,lag2] = xcorr(v2(:,1),pss2_t);
%[m,idx]=max(abs(corr));
[m1,idx1]=peaksfinder(corr1,frame_length1);
[m2,idx2]=peaksfinder(corr2,frame_length2);
if (enable_plots>=2)
figure(20);
hold off
plot(lag1,abs(corr1));
hold on
plot(lag1(idx1),m1,'ro')
figure(21);
hold off
plot(lag2,abs(corr2));
hold on
plot(lag2(idx2),m2,'ro')
end
%%
for i=1:size(idx1,2)-1; % the last frame is not complite
fprintf(1,'.');
%frame_start2 = lag(i) - prefix_length2;
frame_start1 = lag1(idx1(i))-prefix_length1;
frame_start2 = lag2(idx2(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,3:2:end,1:4:end))).*received_f1(3:2:end,1:4:end,1);
H2=conj(squeeze(f2(1,3:2:end,1:4:end))).*received_f2(3:2:end,1:4:end,1);
H1t = ifft(H1,[],2);
H2t = ifft(H2,[],2);
PDP1 = mean(abs(H1t).^2,1);
PDP2 = mean(abs(H2t).^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');
end
fclose(fid);
This diff is collapsed.
function [MSEsubsp,minind]=findminimumd(sigma2, nM, nD, Sb)
% Changes:
% Author: Thomas Zemen
% Copyright (c) by Forschungszentrum Telekommunikation Wien (ftw.)
for i=1:nD
MSEsubsp(i)=i/nM*sigma2+1/nM*sum(Sb(i+1:nD));
end
[MSEmin,minind]=min(MSEsubsp);
\ No newline at end of file
%addpath('../../../openair1/SIMULATION/LTE_PHY/')
%addpath('../../../openair1/PHY/LTE_ESTIMATION/')
%addpath('../../../openair1/PHY/LTE_REFSIG/')
%addpath('../../../targets/ARCH/EXMIMO/USERSPACE/OCTAVE')
nb_rb = 100; %this can be 25, 50, or 100
num_carriers = 2048/100*nb_rb;
num_zeros = num_carriers-(12*nb_rb+1);
prefix_length = num_carriers/4; %this is extended CP
num_symbols_frame = 120;
preamble_length = 120;
% this generates one LTE frame (10ms) full of OFDM modulated random QPSK
% symbols
[s,f] = OFDM_TX_FRAME(num_carriers,num_zeros,prefix_length,num_symbols_frame,preamble_length);
% scale to conserve energy (Matlabs IFFT does not scale)
s=s*sqrt(num_carriers);
% load the LTE sync sequence, upsample it to the right frequency and insert
% it in the first symbol of the frame
primary_synch;
pss0_up = interp(primary_synch0_time,num_carriers/128);
pss0_up_cp = [pss0_up(num_carriers-prefix_length+1:end) pss0_up];
s(1:num_carriers+prefix_length) = pss0_up_cp;
plot(abs(s))
% save for later use (channel estimation and transmission with the SMBV)
save(sprintf('ofdm_pilots_sync_%d.mat',num_carriers),'-v7','s','f','num_carriers','num_zeros','prefix_length','num_symbols_frame','preamble_length');
mat2wv(s, sprintf('ofdm_pilots_sync_%d.wv',num_carriers), 30.72e6/2048*num_carriers, 1)
%% this script generates the signals for the CORRIDOR channel sounding campaing
addpath('../../../openair1/SIMULATION/LTE_PHY/')
%addpath('../../../openair1/PHY/LTE_ESTIMATION/')
addpath('../../../openair1/PHY/LTE_REFSIG/')
%addpath('../../../targets/ARCH/EXMIMO/USERSPACE/OCTAVE')
rand('seed',42); %make sure seed random numbers are alwyas the same
% load the LTE sync sequence
primary_synch;
nant = 4;
%% this generates one LTE frame (10ms) full of OFDM modulated random QPSK symbols
%% 20MHz carrier
nb_rb = 100; %this can be 25, 50, or 100
num_carriers = 2048/100*nb_rb;
num_zeros = num_carriers-(12*nb_rb+1);
prefix_length = num_carriers/4; %this is extended CP
num_symbols_frame = 120;
preamble_length = 120;
[s1,f1] = OFDM_TX_FRAME_MIMO(num_carriers,num_zeros,prefix_length,num_symbols_frame,preamble_length,nant);
% scale to conserve energy (Matlabs IFFT does not scale)
s1=s1*sqrt(num_carriers);
% upsample PSS to the right frequency and insert it in the first symbol of the frame
pss0_up = interp(primary_synch0_time,num_carriers/128);
pss0_up_cp = [pss0_up(num_carriers-prefix_length+1:end) pss0_up];
s1(:,1:num_carriers+prefix_length) = repmat(pss0_up_cp,nant,1);
%% 10MHz carrier
nb_rb = 50; %this can be 25, 50, or 100
num_carriers = 2048/100*nb_rb;
num_zeros = num_carriers-(12*nb_rb+1);
prefix_length = num_carriers/4; %this is extended CP
[s2,f2] = OFDM_TX_FRAME_MIMO(num_carriers,num_zeros,prefix_length,num_symbols_frame,preamble_length,nant);
% scale to conserve energy (Matlabs IFFT does not scale)
s2=s2*sqrt(num_carriers);
% upsample PSS to the right frequency and insert it in the first symbol of the frame
pss0_up = interp(primary_synch0_time,num_carriers/128);
pss0_up_cp = [pss0_up(num_carriers-prefix_length+1:end) pss0_up];
s2(:,1:num_carriers+prefix_length) = repmat(pss0_up_cp,nant,1);
%% 5MHz carrier
nb_rb = 25; %this can be 25, 50, or 100
num_carriers = 2048/100*nb_rb;
num_zeros = num_carriers-(12*nb_rb+1);
prefix_length = num_carriers/4; %this is extended CP
[s3,f3] = OFDM_TX_FRAME_MIMO(num_carriers,num_zeros,prefix_length,num_symbols_frame,preamble_length,nant);
% scale to conserve energy (Matlabs IFFT does not scale)
s3=s3*sqrt(num_carriers);
% upsample PSS to the right frequency and insert it in the first symbol of the frame
pss0_up = interp(primary_synch0_time,num_carriers/128);
pss0_up_cp = [pss0_up(num_carriers-prefix_length+1:end) pss0_up];
s3(:,1:num_carriers+prefix_length) = repmat(pss0_up_cp,nant,1);
%% combine the 10 and 20 MHz carriers
f1_shift = -5e6;
f2_shift = 10e6;
sample_rate = 30.72e6*2;
s = zeros(nant,sample_rate/100);
for a=1:nant
s1_up = interp(s1(a,:),2);
s1_shift = s1_up .* exp(2*1i*pi*f1_shift*(0:length(s1_up)-1)/sample_rate);
s2_up = interp(s2(a,:),4);
s2_shift = s2_up .* exp(2*1i*pi*f2_shift*(0:length(s2_up)-1)/sample_rate);
s(a,:) = s1_shift + s2_shift/sqrt(2);
end
%%
figure(1)
hold off
plot(linspace(-sample_rate/2,sample_rate/2,length(s)),20*log10(abs(fftshift(fft(s,[],2)))))
%% save for later use (channel estimation and transmission with the SMBV)
save('ofdm_pilots_sync_30MHz.mat','-v7','s1','s2','s3','f1','f2','f3','num_carriers','num_zeros','prefix_length','num_symbols_frame','preamble_length');
s_all = sum(s,1);
s_all(1:5120) = s(1,1:5120);
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);
function p_dpss = init_dpss(p,tau_max)
%% init DPSS
% channel parameters
theta_max = tau_max * p.frame_length*100 / p.useful_carriers; % TS = 1/(p.frame_length*100)
N_sub = floor(theta_max*p.useful_carriers)+1; % number of approximate subspace dimensions
%N_sub = 1;
% DPSS generation
nDmax=min(ceil(N_sub*1.25),p.useful_carriers);
[Udps,Sdps]=dpss(p.useful_carriers,theta_max*p.useful_carriers/2,nDmax);
% the fftshift is needed dependig in which format the frequency response is used
%V=fftshift(diag(exp(-2*pi*1i*theta_max/2*(0:(p.nN-1))))*Udps);
p_dpss.V=diag(exp(-2*pi*1i*theta_max/2*(0:( p.useful_carriers-1))))*Udps;
% compute the optimal subspace dimension based on the expected SNR
p_dpss.SNR=0:30;
for SNR=p_dpss.SNR
% calculate optimum subspace dimension as bias variance tradeoff for a
% given noise variance (assuming pilot symbols with energy one)
sigma2 = 10.^(-SNR/10);
[~,p_dpss.Dopt(SNR+1)]=findminimumd(sigma2, p.useful_carriers,nDmax,1/theta_max*Sdps);
end
% % precompute the filters for DPSS estimation for the required number of
% % basis function
% Dvec = min(Dopt):max(Dopt);
% for ind=1:length(Dvec)
% Dind = Dvec(ind);
%
% for itx=1:p.nant_tx
% % f_start and t_start indicate the start of the pilots in time
% % and frequency according to the specifications (see .doc file).
% % t_start has to be >=2, since the first symbol is the PSS.
% f_start = mod(itx-1,2)*2+1;
% t_start = floor((itx-1)/2)+1;
%
% % filter for DPSS channel estimation
% M = conj(diag(squeeze(transmit_f(itx,t_start,f_start:4:end))) * V(f_start:4:end,1:Dind));
% Mpinv = (M'*M)\M.';
% % to compute the basis coefficients do
% % psi = Mpinv*(symb0(2:6:end));
%
% end
%
% end
function p = init_params(nb_rb,nant_rx,nant_tx)
global symbols_per_slot slots_per_frame;
num_symbols_frame = symbols_per_slot*slots_per_frame;
p.nb_rb = nb_rb;
p.num_carriers = 2048/(100/p.nb_rb);
p.num_zeros = p.num_carriers-(12*p.nb_rb+1);
p.useful_carriers = p.num_carriers-p.num_zeros-1;
p.prefix_length = p.num_carriers/4; %this is extended CP
p.ofdm_symbol_length = p.num_carriers + p.prefix_length;
p.samples_slot = p.ofdm_symbol_length*symbols_per_slot;
p.frame_length = p.ofdm_symbol_length*num_symbols_frame;
p.nant_rx=nant_rx;
p.nant_tx=nant_tx;
This diff is collapsed.
function [m,ind]=peaksfinder(corr,frame_length)
threshold=max(abs(corr))*0.75;
consecutivePos=[];
highCorrVal=find(abs(corr)>threshold);
num_peak=0;
k=1;
consecutivePos(1)=highCorrVal(1);
for i_high=1:size(highCorrVal,1)-1
if highCorrVal(i_high+1)-highCorrVal(i_high)==1
consecutivePos(k+1)=highCorrVal(i_high+1);
k=k+1;
else
num_peak=num_peak+1;
[m(num_peak),temp_idx]=max(abs(corr(min(consecutivePos):max(consecutivePos))));
ind(num_peak)=min(consecutivePos)-1+temp_idx;
consecutivePos=[];
consecutivePos(1)=highCorrVal(i_high+1);
k=1;
end
end
num_peak=num_peak+1;
[m(num_peak),temp_idx]=max(abs(corr(min(consecutivePos):max(consecutivePos))));
ind(num_peak)=min(consecutivePos)-1+temp_idx;
% a bigining for make code which clculate the best peak in respect to whole frlames
% corrMatrix=vec2mat(corr, frame_length);
% corrMatrix(end,:)=[];
% sumCorrMatrix=sum(abs(corrMatrix));
% [Value Pos]=max(sumCorrMatrix);
% this script sends the signals previously generated with generation_ca to
% the cards. We need in total 7 cards configured as follows
% card0 - card3: 20MHz, 1 channel each, s1, freq 2590 MHz
% card4 - card5: 10MHz, 2 channels each, s2, freq 2605 MHz
% card6: 5MHz, 4 channels, s3, freq 771.5 MHz
load('ofdm_pilots_sync_30MHz.mat');
addpath('../../../targets/ARCH/EXMIMO/USERSPACE/OCTAVE')
limeparms;
num_cards = oarf_get_num_detected_cards;
card_select = [1 1 1 1 1 1 1];
% common parameters
rf_local= rf_local*[1 1 1 1];
rf_rxdc = rf_rxdc*[1 1 1 1];
rf_vcocal=rf_vcocal_19G*[1 1 1 1];
tx_gain_all = [10 0 0 0;
10 0 0 0;
15 0 0 0;
12 0 0 0;
1 0 0 0;
0 10 10 0;
9 8 0 0];
%tx_gain_all = [11 0 0 0;
% 8 0 0 0;
% 14 0 0 0;
% 13 0 0 0;
% 5 3 0 0;
% 13 13 0 0;
% 0 0 0 0];
for card=0:min(3,num_cards-1)
disp(card)
% card 0-3: 20MHz
active_rf = [1 0 0 0];
autocal = [1 1 1 1];
resampling_factor = [0 0 0 0];
rf_mode = (RXEN+TXEN+TXLPFNORM+TXLPFEN+TXLPF10+RXLPFNORM+RXLPFEN+RXLPF10+LNA1ON+LNAMax+RFBBNORM)*active_rf;
rf_mode = rf_mode+((DMAMODE_RX+DMAMODE_TX)*active_rf);
freq_rx = 2590e6*active_rf;
freq_tx = freq_rx;
tx_gain = tx_gain_all(card+1,:);
rx_gain = 0*active_rf; %1 1 1 1];
eNBflag = 0;
tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_TESTTX;
%tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_LSB;
if (card==0)
syncmode = SYNCMODE_MASTER;
else
syncmode = SYNCMODE_SLAVE;
end
%syncmode = SYNCMODE_FREE;
rffe_rxg_low = 31*active_rf; %[1 1 1 1];
rffe_rxg_final = 63*active_rf; %[1 1 1 1];
rffe_band = B19G_TDD*active_rf; %[1 1 1 1];
oarf_config_exmimo(card,freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal,resampling_factor);
end
for card=5:min(5,num_cards-1)
disp(card)
% card 5: 10MHz
active_rf = [0 1 1 0];
autocal = [1 1 1 1];
resampling_factor = [1 1 1 1];
rf_mode = (RXEN+TXEN+TXLPFNORM+TXLPFEN+TXLPF5+RXLPFNORM+RXLPFEN+RXLPF5+LNA1ON+LNAMax+RFBBNORM)*active_rf;
rf_mode = rf_mode+((DMAMODE_RX+DMAMODE_TX)*active_rf);
freq_rx = 2605e6*active_rf;
freq_tx = freq_rx;
tx_gain = tx_gain_all(card+1,:);
rx_gain = 0*active_rf; %1 1 1 1];
eNBflag = 0;
tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_TESTTX;
%tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_LSB;
syncmode = SYNCMODE_SLAVE;
%syncmode = SYNCMODE_FREE;
rffe_rxg_low = 31*active_rf; %[1 1 1 1];
rffe_rxg_final = 63*active_rf; %[1 1 1 1];
rffe_band = B19G_TDD*active_rf; %[1 1 1 1];
oarf_config_exmimo(card,freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal,resampling_factor);
end
for card=6:min(6,num_cards-1)
disp(card)
% card 6: 10MHz
active_rf = [1 1 0 0];
autocal = [1 1 1 1];
resampling_factor = [1 1 1 1];
rf_mode = (RXEN+TXEN+TXLPFNORM+TXLPFEN+TXLPF5+RXLPFNORM+RXLPFEN+RXLPF5+LNA1ON+LNAMax+RFBBNORM)*active_rf;
rf_mode = rf_mode+((DMAMODE_RX+DMAMODE_TX)*active_rf);
freq_rx = 2605e6*active_rf;
freq_tx = freq_rx;
tx_gain = tx_gain_all(card+1,:);
rx_gain = 0*active_rf; %1 1 1 1];
eNBflag = 0;
tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_TESTTX;
%tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_LSB;
syncmode = SYNCMODE_SLAVE;
%syncmode = SYNCMODE_FREE;
rffe_rxg_low = 31*active_rf; %[1 1 1 1];
rffe_rxg_final = 63*active_rf; %[1 1 1 1];
rffe_band = B19G_TDD*active_rf; %[1 1 1 1];
oarf_config_exmimo(card,freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal,resampling_factor);
end
for card=4:min(4,num_cards-1)
disp(card)
% card 4: 5MHz
active_rf = [1 1 1 1];
autocal = [1 1 1 1];
resampling_factor = [2 2 2 2];
rf_mode = (RXEN+TXEN+TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAMax+RFBBNORM)*active_rf;
rf_mode = rf_mode+((DMAMODE_RX+DMAMODE_TX)*active_rf);
freq_rx = 771.5e6*active_rf;
freq_tx = freq_rx;
tx_gain = tx_gain_all(card+1,:);
rx_gain = 0*active_rf; %1 1 1 1];
eNBflag = 0;
tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_TESTTX;
%tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_LSB;
syncmode = SYNCMODE_SLAVE;
%syncmode = SYNCMODE_FREE;
rffe_rxg_low = 31*active_rf; %[1 1 1 1];
rffe_rxg_final = 63*active_rf; %[1 1 1 1];
rffe_band = B19G_TDD*active_rf; %[1 1 1 1];
oarf_config_exmimo(card,freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal,resampling_factor);
end
amp = pow2(14)-1;
s1p = 2*floor(amp*(s1./max([real(s1(:)); imag(s1(:))])));
s2p = 2*floor(amp*(s2./max([real(s2(:)); imag(s2(:))])));
s3p = 2*floor(amp*(s3./max([real(s3(:)); imag(s3(:))])));
%for card=min(6,num_cards-1):-1:6
% oarf_send_frame(card,s3p.',16);
%end
%for card=min(5,num_cards-1):-1:4
% oarf_send_frame(card,s2p.',16);
%end
%for card=min(3,num_cards-1):-1:0
% oarf_send_frame(card,s1p.',16);
%end
if card_select(7)
oarf_send_frame(6,s2p(3:4,:).',16);
end
if card_select(6)
oarf_send_frame(5,[zeros(153600,1) (s2p(1:2,:).')],16);
end
if card_select(5)
oarf_send_frame(4,s3p.',16);
end
if card_select(4)
oarf_send_frame(3,s1p(4,:).',16);
end
if card_select(3)
oarf_send_frame(2,s1p(3,:).',16);
end
if card_select(2)
oarf_send_frame(1,s1p(2,:).',16);
end
if card_select(1)
oarf_send_frame(0,s1p(1,:).',16);
end
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