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;
N = 100; % N is number ofr time-measurements
Nt = 3; % Nt is the number of antennas at node B
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
run_measwoduplex;
% alternatively load the measurements from file for testing
% now you should have chanestA2B, fchanestA2B, tchanestA2B, chanestB2A,
% fchanestB2A, tchanestB2A
CHA2B{loc} = chanestA2B; %to check
CHA2B{loc} = chanestA2B; %to check
disp('Please move the antenna to another location and press key when finished')
pause
end
%% calculate full F matrix
for s=1:301
[F, HA]=alterproj(CHB2A,CHA2B, s, N, N_loc, Nt);
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;
% do some beamforming % do some beamforming
signalA2B=zeros(N,4); signalA2B=zeros(N,4);
signalB2A=zeros(N,4); signalB2A=zeros(N,4);
...@@ -44,7 +5,7 @@ signalB2A_prec=zeros(N,4); ...@@ -44,7 +5,7 @@ signalB2A_prec=zeros(N,4);
%%----------Node A to B transmission---------%% %%----------Node A to B transmission---------%%
for i=1:4 for i=1:4
if(indA(ia)==i) if(active_rfA(i))
[Da2b_T, tmps]=genrandpskseq(N,M,amp); [Da2b_T, tmps]=genrandpskseq(N,M,amp);
signalA2B(:,i)=tmps*2; %make sure LSB is 0 (switch=tx) signalA2B(:,i)=tmps*2; %make sure LSB is 0 (switch=tx)
else else
...@@ -66,17 +27,17 @@ for i=0:119; ...@@ -66,17 +27,17 @@ for i=0:119;
fblock=fft(ifblock); fblock=fft(ifblock);
fblock(1,:)=[]; fblock(1,:)=[];
fblock(151:360,:)=[]; fblock(151:360,:)=[];
Da2b_R=vec(fblock); Da2b_R(i+1,:)=vec(fblock);
end end
chanestsA2B=reshape(diag(repmat(Da2b_T,Nantb)'*Da2b_R)/size(Da2b_T,1),301,Nantb); chanestsA2B=reshape(diag(repmat(Da2b_T,1,Nantb)'*Da2b_R)/size(Da2b_T,1),301,Nantb);
%fchanestsA2B(:,:,meas)=[zeros(1,Nantb); chanestsA2B([1:150],:,meas); zeros(210,Nantb); chanestsA2B(151:301,:,meas)]; %fchanestsA2B(:,:,meas)=[zeros(1,Nantb); chanestsA2B([1:150],:,meas); zeros(210,Nantb); chanestsA2B(151:301,:,meas)];
%tchanestsA2B(:,:,meas)=ifft(fchanestsA2B(:,:,meas)); %tchanestsA2B(:,:,meas)=ifft(fchanestsA2B(:,:,meas));
%% calculate beamformer based on chanestA2B %% calculate beamformer based on chanestA2B
for i=1:301 for i=1:301
YA=squeeze(chanestA2B(i,:,:)); YA=chanestsA2B(i,:).';
F=Fs(:,:,i); F=Fs(:,:,i);
Bd(:,i) = conj(F*YA); Bd(:,i) = conj(F*YA)./norm(F*YA);
end end
%% generate normal and beamformed signals %% generate normal and beamformed signals
...@@ -92,13 +53,13 @@ for i=1:size(seqf,1) ...@@ -92,13 +53,13 @@ for i=1:size(seqf,1)
symbol_prec_t=ifft(symbol_prec,512,2); symbol_prec_t=ifft(symbol_prec,512,2);
% Adding cycl. prefix making the block of 640 elements % Adding cycl. prefix making the block of 640 elements
symbol_prec_cp = cat(2,symbol_prec_t(:,end-127:end), symbol_prec_t); 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); tmps_prec(:,[1:640]+(i-1)*640)=floor(amp*symbol_prec_cp);
end end
for i=1:4 for i=1:4
if(indB(ib)==i) if(active_rfB(i))
signalB2A(:,i)=tmps*2; %make sure LSB is 0 (switch=tx) signalB2A(:,i)=floor(tmps/sqrt(3))*2; %make sure LSB is 0 (switch=tx)
signalB2A_prec(:,i)=tmps_prec(i,:)*2; %make sure LSB is 0 (switch=tx) signalB2A_prec(:,i)=tmps_prec(i-1,:)*2; %make sure LSB is 0 (switch=tx)
else else
signalB2A(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx) 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) signalB2A_prec(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
...@@ -106,17 +67,27 @@ for i=1:4 ...@@ -106,17 +67,27 @@ for i=1:4
end end
%% send normal signal %% send normal signal
P_tx = 10*log10(sum(mean(abs(signalB2A(:,2:4)).^2)))
oarf_send_frame(card,signalB2A,n_bit); oarf_send_frame(card,signalB2A,n_bit);
%keyboard %keyboard
sleep(0.01); sleep(0.01);
receivedB2A=oarf_get_frame(card); receivedB2A=oarf_get_frame(card);
sleep(0.01); sleep(0.01);
% measure SNR % measure SNR
P_rx = 10*log10(mean(abs(receivedB2A(:,1)).^2))
%% send beamformed DL signal %% send beamformed DL signal
P_tx_prec = 10*log10(sum(mean(abs(signalB2A_prec(:,2:4)).^2)))
oarf_send_frame(card,signalB2A_prec,n_bit); oarf_send_frame(card,signalB2A_prec,n_bit);
%keyboard %keyboard
sleep(0.01); sleep(0.01);
receivedB2A=oarf_get_frame(card); receivedB2A_prec=oarf_get_frame(card);
sleep(0.01); sleep(0.01);
% measure SNR % measure SNR
P_rx_prec = 10*log10(mean(abs(receivedB2A_prec(:,1)).^2))
figure(10)
bar([P_tx P_tx_prec; P_rx P_rx_prec]);
legend('normal','beamformed')
ylim([0 60])
drawnow
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);
...@@ -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