updated octave code for reciprocity measurements
git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4603 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
@@ -35,7 +35,7 @@ for k=1:Ns
|
|||||||
sndgroup=(k-1)*301+[151:301]; # The second group of OFDM carriers
|
sndgroup=(k-1)*301+[151:301]; # The second group of OFDM carriers
|
||||||
for i=0:119
|
for i=0:119
|
||||||
fblock=[0 carrierdata(i+1,frstgroup) zeros(1,210) carrierdata(i+1,sndgroup)];
|
fblock=[0 carrierdata(i+1,frstgroup) zeros(1,210) carrierdata(i+1,sndgroup)];
|
||||||
ifblock=ifft(fblock,512);
|
ifblock=ifft(fblock,512)*sqrt(512);
|
||||||
block = [ifblock(end-127:end) ifblock]; # Cycl. prefix
|
block = [ifblock(end-127:end) ifblock]; # Cycl. prefix
|
||||||
s([1:640]+i*640,k)=floor(amp*block);
|
s([1:640]+i*640,k)=floor(amp*block);
|
||||||
endfor
|
endfor
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ for i=0:(N/640-1)
|
|||||||
carrierdata(i+1,j)=datablock(j);
|
carrierdata(i+1,j)=datablock(j);
|
||||||
end
|
end
|
||||||
fblock=[0 datablock(1:150) zeros(1,210) datablock(151:301)];
|
fblock=[0 datablock(1:150) zeros(1,210) datablock(151:301)];
|
||||||
ifblock=ifft(fblock,512);
|
ifblock=ifft(fblock,512)*sqrt(512);;
|
||||||
% Adding cycl. prefix making the block of 640 elements
|
% Adding cycl. prefix making the block of 640 elements
|
||||||
block = [ifblock(end-127:end) ifblock];
|
block = [ifblock(end-127:end) ifblock];
|
||||||
s([1:640]+i*640)=floor(amp*block);
|
s([1:640]+i*640)=floor(amp*block);
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ eNB_flag = 0;
|
|||||||
card = 0;
|
card = 0;
|
||||||
Ntrx=4;
|
Ntrx=4;
|
||||||
dual_tx=0;
|
dual_tx=0;
|
||||||
active_rfA=[1 1 0 0];
|
active_rfA=[0 0 1 0];
|
||||||
active_rfB=[0 0 1 1];
|
active_rfB=[1 1 0 0];
|
||||||
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
|
||||||
|
|
||||||
@@ -36,8 +36,8 @@ 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 = 63*active_rf;
|
rffe_rxg_low = 31*active_rf;
|
||||||
rffe_rxg_final = [30 30 30 30];
|
rffe_rxg_final = 63*active_rf;
|
||||||
rffe_band = B19G_TDD*active_rf;
|
rffe_band = B19G_TDD*active_rf;
|
||||||
|
|
||||||
rf_rxdc = rf_rxdc*active_rf;
|
rf_rxdc = rf_rxdc*active_rf;
|
||||||
@@ -49,7 +49,7 @@ oarf_stop(card);
|
|||||||
sleep(0.1);
|
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(12.5)-1;
|
||||||
n_bit = 16;
|
n_bit = 16;
|
||||||
|
|
||||||
chanest_full = 1;
|
chanest_full = 1;
|
||||||
|
|||||||
@@ -143,13 +143,30 @@ if(paramsinitialized)
|
|||||||
%end
|
%end
|
||||||
fchanestsB2A(:,:,meas) = [zeros(1,Nantb); chanestsB2A([1:150],:,meas); zeros(210,Nantb); chanestsB2A(151:301,:,meas)];
|
fchanestsB2A(:,:,meas) = [zeros(1,Nantb); chanestsB2A([1:150],:,meas); zeros(210,Nantb); chanestsB2A(151:301,:,meas)];
|
||||||
tchanestsB2A(:,:,meas)=ifft(fchanestsB2A(:,:,meas));
|
tchanestsB2A(:,:,meas)=ifft(fchanestsB2A(:,:,meas));
|
||||||
|
end % Nmeas
|
||||||
|
|
||||||
|
%% estimate the noise
|
||||||
|
no_signal=repmat(1+1j,76800,4);
|
||||||
|
oarf_send_frame(card,no_signal,n_bit);
|
||||||
|
sleep(0.01);
|
||||||
|
noise_received=oarf_get_frame(card);
|
||||||
|
% estimate noise in frequency domain
|
||||||
|
noise_f = zeros(120,301,4);
|
||||||
|
for i=0:119;
|
||||||
|
ifblock=noise_received(i*640+[1:640],:);
|
||||||
|
ifblock(1:128,:)=[];
|
||||||
|
fblock=fft(ifblock);
|
||||||
|
fblock(1,:)=[];
|
||||||
|
fblock(151:360,:)=[];
|
||||||
|
noise_f(i+1,:,:)=fblock;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
%% -- Some plotting code -- %% (you can uncomment what you see fit)
|
%% -- Some plotting code -- %% (you can uncomment what you see fit)
|
||||||
received = [receivedB2A(:,indA) receivedA2B(:,indB)];
|
received = [receivedA2B(:,indB) receivedB2A(:,indA)];
|
||||||
phases = phasesB2A;
|
phases = phasesB2A;
|
||||||
tchanests = [tchanestsA2B(:,:,end), tchanestsB2A(:,:,end)];
|
tchanests = [tchanestsA2B(:,:,end), tchanestsB2A(:,:,end)];
|
||||||
fchanests = [fchanestsA2B(:,:,end), fchanestsB2A(:,:,end)];
|
fchanests = [chanestsA2B(:,:,end), chanestsB2A(:,:,end)];
|
||||||
|
|
||||||
clf
|
clf
|
||||||
figure(1)
|
figure(1)
|
||||||
@@ -164,16 +181,25 @@ if(paramsinitialized)
|
|||||||
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','A->B3','B1->A','B2->A','B3->A');
|
if Nantb==3
|
||||||
%legend('A->B1','A->B2','B1->A','B2->A');
|
legend('A->B1','A->B2','A->B3','B1->A','B2->A','B3->A');
|
||||||
|
else
|
||||||
|
legend('A->B1','A->B2','B1->A','B2->A');
|
||||||
|
end
|
||||||
|
|
||||||
figure(3)
|
figure(3)
|
||||||
plot(20*log10(abs(fchanests)));
|
plot(20*log10(abs(fchanests)));
|
||||||
|
hold on
|
||||||
|
plot(squeeze(10*log10(mean(abs(noise_f(:,:,[indB indA])).^2,1))),'.');
|
||||||
|
hold off
|
||||||
ylim([40 100])
|
ylim([40 100])
|
||||||
xlabel('freq')
|
xlabel('freq')
|
||||||
ylabel('|h|')
|
ylabel('|h|')
|
||||||
legend('A->B1','A->B2','A->B3','B1->A','B2->A','B3->A');
|
if Nantb==3
|
||||||
%legend('A->B1','A->B2','B1->A','B2->A');
|
legend('A->B1','A->B2','A->B3','B1->A','B2->A','B3->A','Noise B1','Noise B2','Noise B3','Noise A');
|
||||||
|
else
|
||||||
|
legend('A->B1','A->B2','B1->A','B2->A','Noise B1','Noise B2','Noise A');
|
||||||
|
end
|
||||||
|
|
||||||
if (0)
|
if (0)
|
||||||
figure(4)
|
figure(4)
|
||||||
@@ -219,7 +245,8 @@ if(paramsinitialized)
|
|||||||
end
|
end
|
||||||
axis([-2 2 -2 2])
|
axis([-2 2 -2 2])
|
||||||
|
|
||||||
disp(squeeze(mean(Fhatloc,2)));
|
%disp(squeeze(mean(Fhatloc,2)));
|
||||||
|
drawnow;
|
||||||
|
|
||||||
else
|
else
|
||||||
error('You have to run init.params.m first!')
|
error('You have to run init.params.m first!')
|
||||||
|
|||||||
@@ -105,10 +105,26 @@ if(paramsinitialized)
|
|||||||
Db2a_R((meas-1)*120+i+1,:)=fblock.';
|
Db2a_R((meas-1)*120+i+1,:)=fblock.';
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
%% estimate the noise
|
||||||
|
no_signal=repmat(1+1j,76800,4);
|
||||||
|
oarf_send_frame(card,no_signal,n_bit);
|
||||||
|
sleep(0.01);
|
||||||
|
noise_received=oarf_get_frame(card);
|
||||||
|
% estimate noise in frequency domain
|
||||||
|
noise_f = zeros(120,301,4);
|
||||||
|
for i=0:119;
|
||||||
|
ifblock=noise_received(i*640+[1:640],:);
|
||||||
|
ifblock(1:128,:)=[];
|
||||||
|
fblock=fft(ifblock);
|
||||||
|
fblock(1,:)=[];
|
||||||
|
fblock(151:360,:)=[];
|
||||||
|
noise_f(i+1,:,:)=fblock;
|
||||||
|
end
|
||||||
|
|
||||||
%% ------- Do the A to B channel estimation ------- %%
|
%% ------- Do the A to B channel estimation ------- %%
|
||||||
HA2B=repmat(conj(Da2b_T),1,Nantb).*Da2b_R;
|
HA2B=repmat(conj(Da2b_T),1,Nantb).*Da2b_R;
|
||||||
phasesA2B=unwrap(angle(HA2B));
|
phasesA2B=mod(angle(HA2B),2*pi);
|
||||||
if(mean(var(phasesA2B))>0.5)
|
if(mean(var(phasesA2B))>0.5)
|
||||||
disp('The phases of your estimates from A to B are a bit high (larger than 0.5 rad.), something is wrong.');
|
disp('The phases of your estimates from A to B are a bit high (larger than 0.5 rad.), something is wrong.');
|
||||||
end
|
end
|
||||||
@@ -118,20 +134,27 @@ if(paramsinitialized)
|
|||||||
tchanestsA2B=ifft(fchanestsA2B);
|
tchanestsA2B=ifft(fchanestsA2B);
|
||||||
|
|
||||||
%% ------- Do the B to A channel estimation ------- %%
|
%% ------- Do the B to A channel estimation ------- %%
|
||||||
HB2A=conj(Db2a_T.*repmat(Db2a_R,1,Nantb));
|
|
||||||
phasesB2A=unwrap(angle(HB2A));
|
|
||||||
%if(mean(var(phasesB2A))>0.5)
|
|
||||||
% disp('The phases of your estimates from B to A are a bit high (larger than 0.5 rad.), something is wrong.');
|
|
||||||
%end
|
|
||||||
|
|
||||||
if (chanest_full)
|
if (chanest_full)
|
||||||
chanestsB2A=zeros(301,Nantb);
|
HB2A=zeros(120*Nmeas/10,301,Nantb);
|
||||||
inds=repmat([1:Nantb]',1,301);
|
for t=1:120*Nmeas/10
|
||||||
for ci=1:301;
|
for ci=1:301;
|
||||||
data=Db2a_T(:,ci+[0:Nantb-1]*301);
|
data=Db2a_T((t-1)*10+1:t*10,ci+[0:Nantb-1]*301);
|
||||||
rec=Db2a_R(:,ci);
|
rec=Db2a_R((t-1)*10+1:t*10,ci);
|
||||||
chanestsB2A(ci,:)=(inv(data'*data)*data'*rec).';
|
HB2A(t,ci,:)=(inv(data'*data)*data'*rec).';
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
phasesB2A=mod(angle(HB2A),2*pi);
|
||||||
|
phasesB2A=reshape(phasesB2A,[],301*Nantb);
|
||||||
|
if(mean(var(phasesB2A))>0.5)
|
||||||
|
disp('The phases of your estimates from B to A are a bit high (larger than 0.5 rad.), something is wrong.');
|
||||||
|
end
|
||||||
|
|
||||||
|
chanestsB2A=zeros(301,Nantb);
|
||||||
|
for ci=1:301;
|
||||||
|
data=Db2a_T(:,ci+[0:Nantb-1]*301);
|
||||||
|
rec=Db2a_R(:,ci);
|
||||||
|
chanestsB2A(ci,:)=(inv(data'*data)*data'*rec).';
|
||||||
|
end
|
||||||
else
|
else
|
||||||
chanestsB2A=reshape(diag(Db2a_T'*repmat(Db2a_R,1,Nantb)/(Nmeas*60)),301,Nantb);
|
chanestsB2A=reshape(diag(Db2a_T'*repmat(Db2a_R,1,Nantb)/(Nmeas*60)),301,Nantb);
|
||||||
end
|
end
|
||||||
@@ -144,10 +167,10 @@ if(paramsinitialized)
|
|||||||
tchanestsB2A=ifft(fchanestsB2A);
|
tchanestsB2A=ifft(fchanestsB2A);
|
||||||
|
|
||||||
%% -- Some plotting code -- %% (you can uncomment what you see fit)
|
%% -- Some plotting code -- %% (you can uncomment what you see fit)
|
||||||
received = [receivedB2A(:,indA) receivedA2B(:,indB)];
|
received = [receivedA2B(:,indB) receivedB2A(:,indA)];
|
||||||
phases = phasesB2A;
|
phases = phasesB2A;
|
||||||
tchanests = [tchanestsA2B(:,:,end), tchanestsB2A(:,:,end)];
|
tchanests = [tchanestsA2B(:,:,end), tchanestsB2A(:,:,end)];
|
||||||
fchanests = [fchanestsA2B(:,:,end), fchanestsB2A(:,:,end)];
|
fchanests = [chanestsA2B(:,:,end), chanestsB2A(:,:,end)];
|
||||||
|
|
||||||
clf
|
clf
|
||||||
figure(1)
|
figure(1)
|
||||||
@@ -162,17 +185,26 @@ if(paramsinitialized)
|
|||||||
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','A->B3','B1->A','B2->A','B3->A');
|
if Nantb==3
|
||||||
%legend('A->B1','A->B2','B1->A','B2->A');
|
legend('A->B1','A->B2','A->B3','B1->A','B2->A','B3->A');
|
||||||
|
else
|
||||||
|
legend('A->B1','A->B2','B1->A','B2->A');
|
||||||
|
end
|
||||||
|
|
||||||
figure(3)
|
figure(3)
|
||||||
plot(20*log10(abs(fchanests)));
|
plot(20*log10(abs(fchanests)));
|
||||||
|
hold on
|
||||||
|
plot(squeeze(10*log10(mean(abs(noise_f(:,:,[indB indA])).^2,1))),'.');
|
||||||
|
hold off
|
||||||
ylim([40 100])
|
ylim([40 100])
|
||||||
xlabel('freq')
|
xlabel('freq')
|
||||||
ylabel('|h|')
|
ylabel('|h|')
|
||||||
legend('A->B1','A->B2','A->B3','B1->A','B2->A','B3->A');
|
if Nantb==3
|
||||||
%legend('A->B1','A->B2','B1->A','B2->A');
|
legend('A->B1','A->B2','A->B3','B1->A','B2->A','B3->A','Noise B1','Noise B2','Noise B3','Noise A');
|
||||||
|
else
|
||||||
|
legend('A->B1','A->B2','B1->A','B2->A','Noise B1','Noise B2','Noise A');
|
||||||
|
end
|
||||||
|
|
||||||
if (0)
|
if (0)
|
||||||
figure(4)
|
figure(4)
|
||||||
wndw = 50;
|
wndw = 50;
|
||||||
@@ -214,7 +246,8 @@ if(paramsinitialized)
|
|||||||
end
|
end
|
||||||
axis([-2 2 -2 2])
|
axis([-2 2 -2 2])
|
||||||
|
|
||||||
disp(squeeze(mean(Fhatloc,1)));
|
%disp(squeeze(mean(Fhatloc,1)));
|
||||||
|
drawnow
|
||||||
|
|
||||||
else
|
else
|
||||||
error('You have to run init.params.m first!')
|
error('You have to run init.params.m first!')
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ if(paramsinitialized)
|
|||||||
if(indA(ia)==i)
|
if(indA(ia)==i)
|
||||||
[tmpd, tmps]=genrandpskseq(N,M,amp);
|
[tmpd, 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)
|
||||||
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)
|
||||||
Da2b_T = [Da2b_T tmpd];
|
Da2b_T = [Da2b_T tmpd];
|
||||||
if(length(indA)> ia) ia=ia+1; end
|
if(length(indA)> ia) ia=ia+1; end
|
||||||
end
|
end
|
||||||
@@ -52,7 +52,7 @@ if(paramsinitialized)
|
|||||||
if(indB(ib)==i)
|
if(indB(ib)==i)
|
||||||
[tmpd, tmps]=genrandpskseq(N,M,amp);
|
[tmpd, tmps]=genrandpskseq(N,M,amp);
|
||||||
signalB2A(:,i)=tmps*2; %make sure LSB is 0 (switch=tx)
|
signalB2A(:,i)=tmps*2; %make sure LSB is 0 (switch=tx)
|
||||||
signalA2B(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
|
%signalA2B(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
|
||||||
Db2a_T=[Db2a_T tmpd];
|
Db2a_T=[Db2a_T tmpd];
|
||||||
if(length(indB)> ib) ib=ib+1; end
|
if(length(indB)> ib) ib=ib+1; end
|
||||||
end
|
end
|
||||||
@@ -144,13 +144,15 @@ if(paramsinitialized)
|
|||||||
fchanests = [fchanestsA2B(:,:,end), fchanestsB2A(:,:,end)];
|
fchanests = [fchanestsA2B(:,:,end), fchanestsB2A(:,:,end)];
|
||||||
|
|
||||||
clf
|
clf
|
||||||
|
if (0)
|
||||||
figure(1)
|
figure(1)
|
||||||
for i=1:size(received,2);
|
for i=1:size(received,2);
|
||||||
subplot(220+i);
|
subplot(220+i);
|
||||||
plot(20*log10(abs(fftshift(fft(received(:,i))))));
|
plot(20*log10(abs(fftshift(fft(received(:,i))))));
|
||||||
ylim([20 140])
|
ylim([20 140])
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
figure(2)
|
figure(2)
|
||||||
t=[0:512-1]/512*1e-2;
|
t=[0:512-1]/512*1e-2;
|
||||||
plot(t,20*log10(abs(tchanests)))
|
plot(t,20*log10(abs(tchanests)))
|
||||||
@@ -191,7 +193,34 @@ if(paramsinitialized)
|
|||||||
ylabel('phase variance')
|
ylabel('phase variance')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
figure(4);
|
||||||
|
for t=1
|
||||||
|
i=1;
|
||||||
|
for m=1:Nanta
|
||||||
|
for n=1:Nantb
|
||||||
|
subplot(Nanta,Nantb,i);
|
||||||
|
plot(20*log10(abs(fchanestsB2A(:,m,n,t))))
|
||||||
|
hold on
|
||||||
|
plot(20*log10(abs(fchanestsA2B(:,m,n,t))),'r')
|
||||||
|
ylim([0 80])
|
||||||
|
i=i+1;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
figure(5)
|
||||||
|
for t=1
|
||||||
|
for m=1:Nanta
|
||||||
|
subplot(2,4,m);
|
||||||
|
Rb2a_comp = repmat(chanestsB2A(:,m,m,t)',120,1).*Db2a_R(:,(m-1)*301+(1:301),t);
|
||||||
|
plot(Rb2a_comp(:),'x');
|
||||||
|
subplot(2,4,4+m);
|
||||||
|
Ra2b_comp = repmat(chanestsA2B(:,m,m,t)',120,1).*Da2b_R(:,(m-1)*301+(1:301),t);
|
||||||
|
plot(Ra2b_comp(:),'rx');
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if (0)
|
||||||
%% estimate F matrix assuming it is diagonal for sanity checking
|
%% estimate F matrix assuming it is diagonal for sanity checking
|
||||||
Fhatloc = zeros(Nmeas,301,Nanta,Nantb);
|
Fhatloc = zeros(Nmeas,301,Nanta,Nantb);
|
||||||
for t=1:Nmeas
|
for t=1:Nmeas
|
||||||
@@ -218,7 +247,8 @@ if(paramsinitialized)
|
|||||||
axis([-2 2 -2 2])
|
axis([-2 2 -2 2])
|
||||||
|
|
||||||
%disp(squeeze(mean(Fhatloc,2)));
|
%disp(squeeze(mean(Fhatloc,2)));
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
error('You have to run init.params.m first!')
|
error('You have to run init.params.m first!')
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user