Commit 047913d2 authored by Florian Kaltenberger's avatar Florian Kaltenberger

debugged beamforming_calibration script and split in 2


git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4180 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent f60f4109
initparams; % do some beamforming
N = 100; % N is number ofr time-measurements signalA2B=zeros(N,4);
Nt = 3; % Nt is the number of antennas at node B signalB2A=zeros(N,4);
N_loc = 3; %check signalB2A_prec=zeros(N,4);
CHA2B = {}; %this should be a cell array
CHB2A = {}; %this should be a cell array %%----------Node A to B transmission---------%%
for i=1:4
% run measurements for all location if(active_rfA(i))
for loc = 1:N_loc [Da2b_T, tmps]=genrandpskseq(N,M,amp);
run_measwoduplex; signalA2B(:,i)=tmps*2; %make sure LSB is 0 (switch=tx)
% alternatively load the measurements from file for testing else
% now you should have chanestA2B, fchanestA2B, tchanestA2B, chanestB2A, signalA2B(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
% fchanestB2A, tchanestB2A end
CHA2B{loc} = chanestA2B; %to check end
CHA2B{loc} = chanestA2B; %to check
disp('Please move the antenna to another location and press key when finished') oarf_send_frame(card,signalA2B,n_bit);
pause %keyboard
end sleep(0.01);
receivedA2B=oarf_get_frame(card);
%% calculate full F matrix %oarf_stop(card); %not good, since it does a reset
for s=1:301 sleep(0.01);
[F, HA]=alterproj(CHB2A,CHA2B, s, N, N_loc, Nt);
Fs{s}=F; %% ------- Do the A to B channel estimation ------- %%
HAs{s}=HA; for i=0:119;
end ifblock=receivedA2B(i*640+[1:640],indB);
ifblock(1:128,:)=[];
%% plot F fblock=fft(ifblock);
figure(1) fblock(1,:)=[];
clf fblock(151:360,:)=[];
hold on; Da2b_R(i+1,:)=vec(fblock);
for s=1:size(Fs,3); end
F=Fs(:,:,s); chanestsA2B=reshape(diag(repmat(Da2b_T,1,Nantb)'*Da2b_R)/size(Da2b_T,1),301,Nantb);
plot(diag(F),'bo') %fchanestsA2B(:,:,meas)=[zeros(1,Nantb); chanestsA2B([1:150],:,meas); zeros(210,Nantb); chanestsA2B(151:301,:,meas)];
plot(diag(F,1),'r+') %tchanestsA2B(:,:,meas)=ifft(fchanestsA2B(:,:,meas));
plot(diag(F,2),'gx')
end %% calculate beamformer based on chanestA2B
%axis([-1 1 -1 1]) for i=1:301
hold off; YA=chanestsA2B(i,:).';
F=Fs(:,:,i);
% do some beamforming Bd(:,i) = conj(F*YA)./norm(F*YA);
signalA2B=zeros(N,4); end
signalB2A=zeros(N,4);
signalB2A_prec=zeros(N,4); %% generate normal and beamformed signals
[seqf, tmps]=genrandpskseq(N,M,amp);
%%----------Node A to B transmission---------%% for i=1:size(seqf,1)
for i=1:4 % precoding
if(indA(ia)==i) for j=1:size(seqf,2)
[Da2b_T, tmps]=genrandpskseq(N,M,amp); symbol_prec(:,j)=Bd(:,j)*seqf(i,j);
signalA2B(:,i)=tmps*2; %make sure LSB is 0 (switch=tx) end
else % insert zero subcarriers
signalA2B(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx) symbol_prec=cat(2,zeros(3,1),symbol_prec(:,1:150),zeros(3,210),symbol_prec(:,151:301));
end % ofdm modulation
end symbol_prec_t=ifft(symbol_prec,512,2);
% Adding cycl. prefix making the block of 640 elements
oarf_send_frame(card,signalA2B,n_bit); symbol_prec_cp = cat(2,symbol_prec_t(:,end-127:end), symbol_prec_t);
%keyboard tmps_prec(:,[1:640]+(i-1)*640)=floor(amp*symbol_prec_cp);
sleep(0.01); end
receivedA2B=oarf_get_frame(card);
%oarf_stop(card); %not good, since it does a reset for i=1:4
sleep(0.01); if(active_rfB(i))
signalB2A(:,i)=floor(tmps/sqrt(3))*2; %make sure LSB is 0 (switch=tx)
%% ------- Do the A to B channel estimation ------- %% signalB2A_prec(:,i)=tmps_prec(i-1,:)*2; %make sure LSB is 0 (switch=tx)
for i=0:119; else
ifblock=receivedA2B(i*640+[1:640],indB); signalB2A(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
ifblock(1:128,:)=[]; signalB2A_prec(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
fblock=fft(ifblock); end
fblock(1,:)=[]; end
fblock(151:360,:)=[];
Da2b_R=vec(fblock); %% send normal signal
end P_tx = 10*log10(sum(mean(abs(signalB2A(:,2:4)).^2)))
chanestsA2B=reshape(diag(repmat(Da2b_T,Nantb)'*Da2b_R)/size(Da2b_T,1),301,Nantb); oarf_send_frame(card,signalB2A,n_bit);
%fchanestsA2B(:,:,meas)=[zeros(1,Nantb); chanestsA2B([1:150],:,meas); zeros(210,Nantb); chanestsA2B(151:301,:,meas)]; %keyboard
%tchanestsA2B(:,:,meas)=ifft(fchanestsA2B(:,:,meas)); sleep(0.01);
receivedB2A=oarf_get_frame(card);
%% calculate beamformer based on chanestA2B sleep(0.01);
for i=1:301 % measure SNR
YA=squeeze(chanestA2B(i,:,:)); P_rx = 10*log10(mean(abs(receivedB2A(:,1)).^2))
F=Fs(:,:,i);
Bd(:,i) = conj(F*YA); %% send beamformed DL signal
end P_tx_prec = 10*log10(sum(mean(abs(signalB2A_prec(:,2:4)).^2)))
oarf_send_frame(card,signalB2A_prec,n_bit);
%% generate normal and beamformed signals %keyboard
[seqf, tmps]=genrandpskseq(N,M,amp); sleep(0.01);
for i=1:size(seqf,1) receivedB2A_prec=oarf_get_frame(card);
% precoding sleep(0.01);
for j=1:size(seqf,2) % measure SNR
symbol_prec(:,j)=Bd(:,j)*seqf(i,j); P_rx_prec = 10*log10(mean(abs(receivedB2A_prec(:,1)).^2))
end
% insert zero subcarriers figure(10)
symbol_prec=cat(2,zeros(3,1),symbol_prec(:,1:150),zeros(3,210),symbol_prec(:,151:301)); bar([P_tx P_tx_prec; P_rx P_rx_prec]);
% ofdm modulation legend('normal','beamformed')
symbol_prec_t=ifft(symbol_prec,512,2); ylim([0 60])
% Adding cycl. prefix making the block of 640 elements drawnow
symbol_prec_cp = cat(2,symbol_prec_t(:,end-127:end), symbol_prec_t);
tmps_prec(:,[1:640]+i*640)=floor(amp*symbol_prec_cp);
end
for i=1:4
if(indB(ib)==i)
signalB2A(:,i)=tmps*2; %make sure LSB is 0 (switch=tx)
signalB2A_prec(:,i)=tmps_prec(i,:)*2; %make sure LSB is 0 (switch=tx)
else
signalB2A(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
signalB2A_prec(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
end
end
%% send normal signal
oarf_send_frame(card,signalB2A,n_bit);
%keyboard
sleep(0.01);
receivedB2A=oarf_get_frame(card);
sleep(0.01);
% measure SNR
%% send beamformed DL signal
oarf_send_frame(card,signalB2A_prec,n_bit);
%keyboard
sleep(0.01);
receivedB2A=oarf_get_frame(card);
sleep(0.01);
% measure SNR
initparams;
N_loc = 3; %check
CHA2B = {}; %this should be a cell array
CHB2A = {}; %this should be a cell array
% run measurements for all location
for loc = 1:N_loc
runmeas_woduplex;
% alternatively load the measurements from file for testing
% now you should have chanestA2B, fchanestA2B, tchanestA2B, chanestB2A,
% fchanestB2A, tchanestB2A
CHA2B{loc} = chanestsA2B; %to check
CHB2A{loc} = chanestsB2A; %to check
disp('Please move the antenna to another location and press key when finished')
pause
end
%% calculate full F matrix
Fs = zeros(Nantb,Nantb,301);
for s=1:301
[F, HA]=alterproj(CHB2A,CHA2B, s, Nantb, N_loc, Nmeas);
Fs(:,:,s)=F;
%HAs{s}=HA;
end
%% plot F
figure(1)
clf
hold on;
for s=1:size(Fs,3);
F=Fs(:,:,s);
plot(diag(F),'bo')
plot(diag(F,1),'r+')
plot(diag(F,2),'gx')
end
%axis([-1 1 -1 1])
hold off;
...@@ -2,19 +2,21 @@ ...@@ -2,19 +2,21 @@
# % Organisation: Eurecom (and Linkoping University) # % Organisation: Eurecom (and Linkoping University)
# % E-mail: mirsad.cirkic@liu.se # % E-mail: mirsad.cirkic@liu.se
addpath('/homes/kaltenbe/Devel/openair/openair4G/trunk/targets/ARCH/EXMIMO/USERSPACE/OCTAVE'); addpath([getenv('OPENAIR_TARGETS') '/ARCH/EXMIMO/USERSPACE/OCTAVE']);
clear all
close all
clear
paramsinitialized=false; paramsinitialized=false;
limeparms; limeparms;
rxgain=0; rx_gain=[0 0 0 0];
txgain=10; tx_gain=[20 20 20 20];
eNB_flag = 0; eNB_flag = 0;
card = 0; card = 0;
Ntrx=4; Ntrx=4;
dual_tx=0; dual_tx=0;
active_rfA=[1 0 0 0]; active_rfA=[1 0 0 0];
active_rfB=[0 1 1 0]; active_rfB=[0 1 1 1];
active_rf=active_rfA+active_rfB; active_rf=active_rfA+active_rfB;
if(active_rfA*active_rfB'!=0) error("The A and B transceive chains must be orthogonal./n") endif if(active_rfA*active_rfB'!=0) error("The A and B transceive chains must be orthogonal./n") endif
...@@ -34,16 +36,17 @@ syncmode = SYNCMODE_FREE; ...@@ -34,16 +36,17 @@ syncmode = SYNCMODE_FREE;
rf_local = [8254744 8255063 8257340 8257340]; %eNB2tx 1.9GHz rf_local = [8254744 8255063 8257340 8257340]; %eNB2tx 1.9GHz
rf_vcocal=rf_vcocal_19G*active_rf; rf_vcocal=rf_vcocal_19G*active_rf;
rffe_rxg_low = 61*active_rf; rffe_rxg_low = 63*active_rf;
rffe_rxg_final = 61*active_rf; rffe_rxg_final = [30 40 30 20];
rffe_band = B19G_TDD*active_rf; rffe_band = B19G_TDD*active_rf;
rf_rxdc = rf_rxdc*active_rf; rf_rxdc = rf_rxdc*active_rf;
freq_rx = fc*active_rf; freq_rx = fc*active_rf;
freq_tx = freq_rx; %+1.92e6; freq_tx = freq_rx; %+1.92e6;
tx_gain = txgain.*active_rf;
rx_gain = rxgain*active_rf; oarf_stop(card);
sleep(0.1);
oarf_config_exmimo(card, freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNB_flag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal_mode); oarf_config_exmimo(card, freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNB_flag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal_mode);
autocal_mode=0*active_rf; % Autocalibration is only needed the first time we conf. exmimo autocal_mode=0*active_rf; % Autocalibration is only needed the first time we conf. exmimo
amp = pow2(14)-1; amp = pow2(14)-1;
......
...@@ -21,7 +21,7 @@ if(paramsinitialized && ~LSBSWITCH_FLAG) ...@@ -21,7 +21,7 @@ if(paramsinitialized && ~LSBSWITCH_FLAG)
if(Niter!=1) if(Niter!=1)
error("We should only use one get_frame at each run.\n"); error("We should only use one get_frame at each run.\n");
endif endif
Nmeas = 100; Nmeas = 10;
# %% ------- Prepare the signals for A2B ---------- %% # %% ------- Prepare the signals for A2B ---------- %%
signalA2B=zeros(N,4); signalA2B=zeros(N,4);
...@@ -54,17 +54,17 @@ if(paramsinitialized && ~LSBSWITCH_FLAG) ...@@ -54,17 +54,17 @@ if(paramsinitialized && ~LSBSWITCH_FLAG)
Db2a_T=[Db2a_T tmpd]; Db2a_T=[Db2a_T tmpd];
if(length(indB)> ib) ib=ib+1; endif if(length(indB)> ib) ib=ib+1; endif
endif endif
endfor endfor
if (!chanest_full) if (!chanest_full)
signalB2A(1:38400,3)=0; signalB2A(1:38400,3)=0;
signalB2A(38401:end,2)=0; signalB2A(38401:end,2)=0;
Db2a_T(1:60,302:end) = 0; Db2a_T(1:60,302:end) = 0;
Db2a_T(61:end,1:301) = 0; Db2a_T(61:end,1:301) = 0;
end end
Da2b_R=zeros(Niter*120,Nantb*301,Nmeas); Da2b_R=zeros(Niter*120,Nantb*301,Nmeas);
Db2a_R=zeros(Niter*120,Nanta*301,Nmeas); Db2a_R=zeros(Niter*120,Nanta*301,Nmeas);
for meas=1:Nmeas for meas=1:Nmeas
# %% ------- Node A to B transmission ------- %% # %% ------- Node A to B transmission ------- %%
...@@ -156,14 +156,16 @@ end ...@@ -156,14 +156,16 @@ end
plot(t,20*log10(abs(tchanests))) plot(t,20*log10(abs(tchanests)))
xlabel('time') xlabel('time')
ylabel('|h|') ylabel('|h|')
legend('A->B1','A->B2','B1->A','B2->A'); legend('A->B1','A->B2','A->B3','B1->A','B2->A','B3->A');
%legend('A->B1','A->B2','B1->A','B2->A');
figure(4) figure(4)
plot(20*log10(abs(fchanests))); plot(20*log10(abs(fchanests)));
ylim([40 100]) ylim([40 100])
xlabel('freq') xlabel('freq')
ylabel('|h|') ylabel('|h|')
legend('A->B1','A->B2','B1->A','B2->A'); legend('A->B1','A->B2','A->B3','B1->A','B2->A','B3->A');
%legend('A->B1','A->B2','B1->A','B2->A');
if (0) if (0)
figure(3) figure(3)
......
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