Commit 07d18bb4 authored by Florian Kaltenberger's avatar Florian Kaltenberger

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4181 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 047913d2
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
signalA2B=zeros(N,4); signalA2B=zeros(N,4);
signalB2A=zeros(N,4); signalB2A=zeros(N,4);
signalB2A_prec=zeros(N,4); signalB2A_prec=zeros(N,4);
signalB2A_diag=zeros(N,4);
%%----------Node A to B transmission---------%% %%----------Node A to B transmission---------%%
for i=1:4 for i=1:4
...@@ -37,7 +38,9 @@ chanestsA2B=reshape(diag(repmat(Da2b_T,1,Nantb)'*Da2b_R)/size(Da2b_T,1),301,Nant ...@@ -37,7 +38,9 @@ chanestsA2B=reshape(diag(repmat(Da2b_T,1,Nantb)'*Da2b_R)/size(Da2b_T,1),301,Nant
for i=1:301 for i=1:301
YA=chanestsA2B(i,:).'; YA=chanestsA2B(i,:).';
F=Fs(:,:,i); F=Fs(:,:,i);
Bd(:,i) = conj(F*YA)./norm(F*YA); Fd=Fds(:,:,i);
BFs(:,i) = conj(F*YA)./norm(F*YA);
BDs(:,i) = conj(Fd*YA)./norm(Fd*YA);
end end
%% generate normal and beamformed signals %% generate normal and beamformed signals
...@@ -45,24 +48,24 @@ end ...@@ -45,24 +48,24 @@ end
for i=1:size(seqf,1) for i=1:size(seqf,1)
% precoding % precoding
for j=1:size(seqf,2) for j=1:size(seqf,2)
symbol_prec(:,j)=Bd(:,j)*seqf(i,j); seqf_prec_full(:,i,j)=BFs(:,j)*seqf(i,j);
seqf_prec_diag(:,i,j)=BDs(:,j)*seqf(i,j);
end 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 end
tmps_prec_diag = ofdm_mod(seqf_prec_full,amp);
tmps_prec_full = ofdm_mod(seqf_prec_diag,amp);
%%
for i=1:4 for i=1:4
if(active_rfB(i)) if(active_rfB(i))
signalB2A(:,i)=floor(tmps/sqrt(3))*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-1,:)*2; %make sure LSB is 0 (switch=tx) signalB2A_prec_full(:,i)=tmps_prec_full(i-1,:)*2; %make sure LSB is 0 (switch=tx)
signalB2A_prec_diag(:,i)=tmps_prec_diag(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_full(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
signalB2A_prec_diag(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
end end
end end
...@@ -77,17 +80,27 @@ sleep(0.01); ...@@ -77,17 +80,27 @@ sleep(0.01);
P_rx = 10*log10(mean(abs(receivedB2A(:,1)).^2)) 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))) P_tx_prec_diag = 10*log10(sum(mean(abs(signalB2A_prec_diag(:,2:4)).^2)))
oarf_send_frame(card,signalB2A_prec,n_bit); oarf_send_frame(card,signalB2A_prec_diag,n_bit);
%keyboard
sleep(0.01);
receivedB2A_prec_diag=oarf_get_frame(card);
sleep(0.01);
% measure SNR
P_rx_prec_diag = 10*log10(mean(abs(receivedB2A_prec_diag(:,1)).^2))
%% send beamformed DL signal
P_tx_prec_full = 10*log10(sum(mean(abs(signalB2A_prec_full(:,2:4)).^2)))
oarf_send_frame(card,signalB2A_prec_full,n_bit);
%keyboard %keyboard
sleep(0.01); sleep(0.01);
receivedB2A_prec=oarf_get_frame(card); receivedB2A_prec_full=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)) P_rx_prec_full = 10*log10(mean(abs(receivedB2A_prec_full(:,1)).^2))
figure(10) figure(10)
bar([P_tx P_tx_prec; P_rx P_rx_prec]); bar([P_tx P_tx_prec_diag P_tx_prec_full; P_rx P_rx_prec_diag P_rx_prec_full]);
legend('normal','beamformed') legend('normal','beamformed F diag', 'beamformed F full')
ylim([0 60]) ylim([0 60])
drawnow drawnow
...@@ -19,10 +19,18 @@ end ...@@ -19,10 +19,18 @@ end
Fs = zeros(Nantb,Nantb,301); Fs = zeros(Nantb,Nantb,301);
for s=1:301 for s=1:301
[F, HA]=alterproj(CHB2A,CHA2B, s, Nantb, N_loc, Nmeas); [F, HA]=alterproj(CHB2A,CHA2B, s, Nantb, N_loc, Nmeas);
Fs(:,:,s)=F; Fs(:,:,s)=F;
%HAs{s}=HA; %HAs{s}=HA;
end end
%% calculate the diag F matrix based on last position
Fds = zeros(Nantb,Nantb,301);
for s=1:301
CHA = squeeze(chanestsA2B(s,:,:));
CHB = aqueeze(chanestsB2A(s,:,:));
Fds(:,:,s)=diag(diag(CHB*CHA')./diag(CHA*CHA'));
end
%% plot F %% plot F
figure(1) figure(1)
clf clf
......
# % Author: Mirsad Cirkic % Author: Mirsad Cirkic
# % Organisation: Eurecom (and Linkoping University) % Organisation: Eurecom (and Linkoping University)
# % E-mail: mirsad.cirkic@liu.se % E-mail: mirsad.cirkic@liu.se
function [carrierdata, s]=genrandpskseq(N,M,amp) function [carrierdata, s]=genrandpskseq(N,M,amp)
if(mod(N,640)~=0) if(mod(N,640)~=0)
error('The sequence length must be divisible with 640.'); error('The sequence length must be divisible with 640.');
endif end
s = zeros(N,1); s = zeros(N,1);
MPSK=exp(sqrt(-1)*([1:M]*2*pi/M+pi/M)); MPSK=exp(sqrt(-1)*([1:M]*2*pi/M+pi/M));
...@@ -18,12 +18,12 @@ for i=0:(N/640-1) ...@@ -18,12 +18,12 @@ for i=0:(N/640-1)
datablock=MPSK(ceil(rand(301,1)*M)); datablock=MPSK(ceil(rand(301,1)*M));
for j=1:301 for j=1:301
carrierdata(i+1,j)=datablock(j); carrierdata(i+1,j)=datablock(j);
endfor 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);
% 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);
endfor end
endfunction end
\ No newline at end of file \ No newline at end of file
function sigt = ofdm_mod(sigf,amp)
[Nant,Nsymb,Nsub] = size(sigf);
sigt = zeros(Nant,Nsymb*640);
for i=1:Nsymb
symbol=squeeze(sigf(:,i,:));
% insert zero subcarriers
symbol=cat(2,zeros(Nant,1),symbol(:,1:150),zeros(Nant,210),symbol(:,151:301));
% ofdm modulation
symbol_t=ifft(symbol,512,2);
% Adding cycl. prefix making the block of 640 elements
symbol_cp = cat(2,symbol_t(:,end-127:end), symbol_t);
sigt(:,(1:640)+(i-1)*640)=floor(amp*symbol_cp);
end
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