debugged beamforming_calibration script and split in 2
git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4180 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
+93
-122
@@ -1,122 +1,93 @@
|
||||
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
|
||||
signalA2B=zeros(N,4);
|
||||
signalB2A=zeros(N,4);
|
||||
signalB2A_prec=zeros(N,4);
|
||||
|
||||
%%----------Node A to B transmission---------%%
|
||||
for i=1:4
|
||||
if(indA(ia)==i)
|
||||
[Da2b_T, tmps]=genrandpskseq(N,M,amp);
|
||||
signalA2B(:,i)=tmps*2; %make sure LSB is 0 (switch=tx)
|
||||
else
|
||||
signalA2B(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
|
||||
end
|
||||
end
|
||||
|
||||
oarf_send_frame(card,signalA2B,n_bit);
|
||||
%keyboard
|
||||
sleep(0.01);
|
||||
receivedA2B=oarf_get_frame(card);
|
||||
%oarf_stop(card); %not good, since it does a reset
|
||||
sleep(0.01);
|
||||
|
||||
%% ------- Do the A to B channel estimation ------- %%
|
||||
for i=0:119;
|
||||
ifblock=receivedA2B(i*640+[1:640],indB);
|
||||
ifblock(1:128,:)=[];
|
||||
fblock=fft(ifblock);
|
||||
fblock(1,:)=[];
|
||||
fblock(151:360,:)=[];
|
||||
Da2b_R=vec(fblock);
|
||||
end
|
||||
chanestsA2B=reshape(diag(repmat(Da2b_T,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)];
|
||||
%tchanestsA2B(:,:,meas)=ifft(fchanestsA2B(:,:,meas));
|
||||
|
||||
%% calculate beamformer based on chanestA2B
|
||||
for i=1:301
|
||||
YA=squeeze(chanestA2B(i,:,:));
|
||||
F=Fs(:,:,i);
|
||||
Bd(:,i) = conj(F*YA);
|
||||
end
|
||||
|
||||
%% generate normal and beamformed signals
|
||||
[seqf, tmps]=genrandpskseq(N,M,amp);
|
||||
for i=1:size(seqf,1)
|
||||
% precoding
|
||||
for j=1:size(seqf,2)
|
||||
symbol_prec(:,j)=Bd(:,j)*seqf(i,j);
|
||||
end
|
||||
% insert zero subcarriers
|
||||
symbol_prec=cat(2,zeros(3,1),symbol_prec(:,1:150),zeros(3,210),symbol_prec(:,151:301));
|
||||
% ofdm modulation
|
||||
symbol_prec_t=ifft(symbol_prec,512,2);
|
||||
% Adding cycl. prefix making the block of 640 elements
|
||||
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
|
||||
% do some beamforming
|
||||
signalA2B=zeros(N,4);
|
||||
signalB2A=zeros(N,4);
|
||||
signalB2A_prec=zeros(N,4);
|
||||
|
||||
%%----------Node A to B transmission---------%%
|
||||
for i=1:4
|
||||
if(active_rfA(i))
|
||||
[Da2b_T, tmps]=genrandpskseq(N,M,amp);
|
||||
signalA2B(:,i)=tmps*2; %make sure LSB is 0 (switch=tx)
|
||||
else
|
||||
signalA2B(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
|
||||
end
|
||||
end
|
||||
|
||||
oarf_send_frame(card,signalA2B,n_bit);
|
||||
%keyboard
|
||||
sleep(0.01);
|
||||
receivedA2B=oarf_get_frame(card);
|
||||
%oarf_stop(card); %not good, since it does a reset
|
||||
sleep(0.01);
|
||||
|
||||
%% ------- Do the A to B channel estimation ------- %%
|
||||
for i=0:119;
|
||||
ifblock=receivedA2B(i*640+[1:640],indB);
|
||||
ifblock(1:128,:)=[];
|
||||
fblock=fft(ifblock);
|
||||
fblock(1,:)=[];
|
||||
fblock(151:360,:)=[];
|
||||
Da2b_R(i+1,:)=vec(fblock);
|
||||
end
|
||||
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)];
|
||||
%tchanestsA2B(:,:,meas)=ifft(fchanestsA2B(:,:,meas));
|
||||
|
||||
%% calculate beamformer based on chanestA2B
|
||||
for i=1:301
|
||||
YA=chanestsA2B(i,:).';
|
||||
F=Fs(:,:,i);
|
||||
Bd(:,i) = conj(F*YA)./norm(F*YA);
|
||||
end
|
||||
|
||||
%% generate normal and beamformed signals
|
||||
[seqf, tmps]=genrandpskseq(N,M,amp);
|
||||
for i=1:size(seqf,1)
|
||||
% precoding
|
||||
for j=1:size(seqf,2)
|
||||
symbol_prec(:,j)=Bd(:,j)*seqf(i,j);
|
||||
end
|
||||
% insert zero subcarriers
|
||||
symbol_prec=cat(2,zeros(3,1),symbol_prec(:,1:150),zeros(3,210),symbol_prec(:,151:301));
|
||||
% ofdm modulation
|
||||
symbol_prec_t=ifft(symbol_prec,512,2);
|
||||
% Adding cycl. prefix making the block of 640 elements
|
||||
symbol_prec_cp = cat(2,symbol_prec_t(:,end-127:end), symbol_prec_t);
|
||||
tmps_prec(:,[1:640]+(i-1)*640)=floor(amp*symbol_prec_cp);
|
||||
end
|
||||
|
||||
for i=1:4
|
||||
if(active_rfB(i))
|
||||
signalB2A(:,i)=floor(tmps/sqrt(3))*2; %make sure LSB is 0 (switch=tx)
|
||||
signalB2A_prec(:,i)=tmps_prec(i-1,:)*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
|
||||
P_tx = 10*log10(sum(mean(abs(signalB2A(:,2:4)).^2)))
|
||||
oarf_send_frame(card,signalB2A,n_bit);
|
||||
%keyboard
|
||||
sleep(0.01);
|
||||
receivedB2A=oarf_get_frame(card);
|
||||
sleep(0.01);
|
||||
% measure SNR
|
||||
P_rx = 10*log10(mean(abs(receivedB2A(:,1)).^2))
|
||||
|
||||
%% 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);
|
||||
%keyboard
|
||||
sleep(0.01);
|
||||
receivedB2A_prec=oarf_get_frame(card);
|
||||
sleep(0.01);
|
||||
% 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
|
||||
@@ -0,0 +1,38 @@
|
||||
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 @@
|
||||
# % Organisation: Eurecom (and Linkoping University)
|
||||
# % 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;
|
||||
limeparms;
|
||||
rxgain=0;
|
||||
txgain=10;
|
||||
rx_gain=[0 0 0 0];
|
||||
tx_gain=[20 20 20 20];
|
||||
eNB_flag = 0;
|
||||
card = 0;
|
||||
Ntrx=4;
|
||||
dual_tx=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;
|
||||
|
||||
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;
|
||||
rf_local = [8254744 8255063 8257340 8257340]; %eNB2tx 1.9GHz
|
||||
rf_vcocal=rf_vcocal_19G*active_rf;
|
||||
|
||||
rffe_rxg_low = 61*active_rf;
|
||||
rffe_rxg_final = 61*active_rf;
|
||||
rffe_rxg_low = 63*active_rf;
|
||||
rffe_rxg_final = [30 40 30 20];
|
||||
rffe_band = B19G_TDD*active_rf;
|
||||
|
||||
rf_rxdc = rf_rxdc*active_rf;
|
||||
|
||||
freq_rx = fc*active_rf;
|
||||
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);
|
||||
autocal_mode=0*active_rf; % Autocalibration is only needed the first time we conf. exmimo
|
||||
amp = pow2(14)-1;
|
||||
|
||||
@@ -21,7 +21,7 @@ if(paramsinitialized && ~LSBSWITCH_FLAG)
|
||||
if(Niter!=1)
|
||||
error("We should only use one get_frame at each run.\n");
|
||||
endif
|
||||
Nmeas = 100;
|
||||
Nmeas = 10;
|
||||
|
||||
# %% ------- Prepare the signals for A2B ---------- %%
|
||||
signalA2B=zeros(N,4);
|
||||
@@ -54,17 +54,17 @@ if(paramsinitialized && ~LSBSWITCH_FLAG)
|
||||
Db2a_T=[Db2a_T tmpd];
|
||||
if(length(indB)> ib) ib=ib+1; endif
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
||||
if (!chanest_full)
|
||||
if (!chanest_full)
|
||||
signalB2A(1:38400,3)=0;
|
||||
signalB2A(38401:end,2)=0;
|
||||
Db2a_T(1:60,302:end) = 0;
|
||||
Db2a_T(61:end,1:301) = 0;
|
||||
end
|
||||
end
|
||||
|
||||
Da2b_R=zeros(Niter*120,Nantb*301,Nmeas);
|
||||
Db2a_R=zeros(Niter*120,Nanta*301,Nmeas);
|
||||
Da2b_R=zeros(Niter*120,Nantb*301,Nmeas);
|
||||
Db2a_R=zeros(Niter*120,Nanta*301,Nmeas);
|
||||
|
||||
for meas=1:Nmeas
|
||||
# %% ------- Node A to B transmission ------- %%
|
||||
@@ -156,14 +156,16 @@ end
|
||||
plot(t,20*log10(abs(tchanests)))
|
||||
xlabel('time')
|
||||
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)
|
||||
plot(20*log10(abs(fchanests)));
|
||||
ylim([40 100])
|
||||
xlabel('freq')
|
||||
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)
|
||||
figure(3)
|
||||
|
||||
Reference in New Issue
Block a user