Commit 996ecbe5 authored by Florian Kaltenberger's avatar Florian Kaltenberger

updated scripts for TX signal generation for CORRIDOR



git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5153 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 324fee0d
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
......@@ -29,13 +29,13 @@ 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((mod(a-1,2)+1):f_dec:num_useful_carriers) = QAM_MOD(4,floor(256*abs(rand(1,num_useful_carriers/4/f_dec))));
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))));
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(256*abs(rand(1,num_useful_carriers))));
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
......
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 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/')
......@@ -7,9 +9,10 @@ rng(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);
......@@ -17,7 +20,7 @@ prefix_length = num_carriers/4; %this is extended CP
num_symbols_frame = 120;
preamble_length = 120;
[s1,f1] = OFDM_TX_FRAME(num_carriers,num_zeros,prefix_length,num_symbols_frame,preamble_length);
[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);
......@@ -26,15 +29,15 @@ s1=s1*sqrt(num_carriers);
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) = pss0_up_cp;
s1(:,1:num_carriers+prefix_length) = repmat(pss0_up_cp,nant,1);
%% and now the other carrier
%% 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(num_carriers,num_zeros,prefix_length,num_symbols_frame,preamble_length);
[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);
......@@ -43,23 +46,43 @@ s2=s2*sqrt(num_carriers);
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) = pss0_up_cp;
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 two carriers
%% combine the 10 and 20 MHz carriers
f1_shift = -5e6;
f2_shift = 10e6;
sample_rate = 30.72e6*2;
s1_up = interp(s1,2);
s1_shift = s1_up .* exp(2*1i*pi*f1_shift*(0:length(s1_up)-1)/sample_rate);
s2_up = interp(s2,4);
s2_shift = s2_up .* exp(2*1i*pi*f2_shift*(0:length(s2_up)-1)/sample_rate);
s = s1_shift + s2_shift/sqrt(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)))))
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','s','f1','f2','num_carriers','num_zeros','prefix_length','num_symbols_frame','preamble_length');
mat2wv(s, 'ofdm_pilots_sync_30MHz.wv', sample_rate, 1);
save('ofdm_pilots_sync_30MHz.mat','-v7','s','f1','f2','f3','num_carriers','num_zeros','prefix_length','num_symbols_frame','preamble_length');
mat2wv(s(1,:), 'ofdm_pilots_sync_30MHz.wv', sample_rate, 1);
% 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
addpath('../../../targets/ARCH/EXMIMO/USERSPACE/OCTAVE')
limeparms;
freq = 2.6e9;
num_cards = oarf_get_num_detected_cards;
......@@ -8,16 +14,15 @@ num_cards = oarf_get_num_detected_cards;
rf_rxdc = rf_rxdc*[1 1 1 1];
rf_vcocal=rf_vcocal_19G*[1 1 1 1];
if (num_cards>0)
% card 0: 20MHz
card = 0;
for card=0:min(3,num_cards-1)
% 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 = (freq-10e6)*active_rf;
freq_rx = 2590e6*active_rf;
freq_tx = freq_rx;
tx_gain = 10*active_rf; %[1 1 1 1];
rx_gain = 0*active_rf; %1 1 1 1];
......@@ -25,10 +30,10 @@ if (num_cards>0)
eNBflag = 0;
tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_TESTTX;
%tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_LSB;
if (num_cards>1)
if (card==0)
syncmode = SYNCMODE_MASTER;
else
syncmode = SYNCMODE_FREE;
syncmode = SYNCMODE_SLAVE;
end
rffe_rxg_low = 31*active_rf; %[1 1 1 1];
rffe_rxg_final = 63*active_rf; %[1 1 1 1];
......@@ -36,16 +41,37 @@ if (num_cards>0)
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
if (num_cards>1)
% card 1: 10MHz
card = 1;
for card=4:min(5,num_cards-1)
% card 4-5: 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 = (freq+5e6)*active_rf;
freq_rx = 2605e6*active_rf;
freq_tx = freq_rx;
tx_gain = 13*active_rf; %[1 1 1 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;
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)
% card 6: 5MHz
active_rf = [1 1 1 1];
autocal = [1 1 1 1];
resampling_factor = [2 2 2 2];
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 = 771.5e6*active_rf;
freq_tx = freq_rx;
tx_gain = 13*active_rf; %[1 1 1 1];
rx_gain = 0*active_rf; %1 1 1 1];
......@@ -62,9 +88,15 @@ 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)])));
if (num_cards>1)
oarf_send_frame(1,repmat(s2p,4,1).',16);
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
oarf_send_frame(0,repmat(s1p,4,1).',16);
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