Commit e956a3e9 authored by Xiwen JIANG's avatar Xiwen JIANG

Octave script for WSA demo

parent 2e5a7fb7
%
% PURPOSE : channel estimation using least square method
%
% ARGUMENTS :
%
% m_sym_T : transmitted symbol, d_N_f x d_N_ofdm x d_N_ant_act x d_N_meas
% m_sym_R : received symbol, d_N_f x d_N_ofdm x d_N_ant_act x d_N_meas
% d_N_meas : number of measurements
%
% OUTPUTS :
%
% m_H_est : estimation of sub-channels, d_N_antR x d_N_antT x d_N_f x d_N_meas
%
%**********************************************************************************************
% EURECOM - All rights reserved
%
% AUTHOR : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Apr-29-2014 X. JIANG 0.1 creation of code
%
% REFERENCES/NOTES/COMMENTS :
%
% - Based on the function "runmeas_full_duplex" created by Mirsad Cirkic, Florian Kaltenberger.
%
%**********************************************************************************************
function m_H_est = f_ch_est(m_sym_T, m_sym_R)
%% ** initialisation **
[d_N_f,d_N_OFDM,d_N_antT,d_N_meas] = size(m_sym_T);
d_N_antR = size(m_sym_R,3);
m_H_est = zeros(d_N_antR,d_N_antT,d_N_f,d_N_meas);
%% ** estimate the subband channel for each measurement and antenna **
for d_n_meas = 1:d_N_meas
for d_n_f = 1:d_N_f
m_y = reshape(m_sym_R(d_n_f,:,:,d_n_meas),d_N_OFDM,d_N_antR).'; % squeeze: problem for antenna number = 1 case
m_s = reshape(m_sym_T(d_n_f,:,:,d_n_meas),d_N_OFDM,d_N_antT).';
m_H_est(:,:,d_n_f,d_n_meas) = m_y*m_s'/(m_s*m_s'); % LS channel estimation
end
end
end
function m_sig_T = f_ofdm_mod(m_sym_T, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rf, d_amp)
d_N_ant_act = sum(v_active_rf);
%** mapping useful data to favorable carriers **
m_sym_T_ext = zeros(d_N_FFT,d_N_OFDM,d_N_ant_act);
m_sym_T_ext(362:512,:,:) = m_sym_T(1:151,:,:);
m_sym_T_ext(2:151,:,:) = m_sym_T(152:301,:,:);
%** ifft **
m_sig_T_ = sqrt(d_N_FFT)*ifft(m_sym_T_ext,d_N_FFT,1);
%** add cyclic prefix **
m_sig_T_ = [m_sig_T_(end-d_N_CP+1:end,:,:); m_sig_T_];
d_L = (d_N_FFT+d_N_CP)*d_N_OFDM;
m_sig_T = floor(reshape(m_sig_T_,d_L,d_N_ant_act)*d_amp);
end
%
% PURPOSE : OFDM Receiver
%
% ARGUMENTS :
%
% m_sig_R : received signal with dimension ((d_N_FFT+d_N_CP)*d_N_ofdm) x d_N
% d_N_FFT : total carrier number
% d_N_CP : extented cyclic prefix
% d_N_OFDM : OFDM symbol number per frame
% v_active_rf : active RF antenna indicator
%
% OUTPUTS :
%
% m_sym_R : transmitted signal before IFFT with dimension d_N_f x d_N_ofdm x d_N_ant_act
%
%**********************************************************************************************
% EURECOM - All rights reserved
%
% AUTHOR : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Apr-29-2014 X. JIANG 0.1 creation of code
%
% REFERENCES/NOTES/COMMENTS :
%
% - Based on the function "genrandpskseq" created by Mirsad Cirkic, Florian Kaltenberger.
%
%**********************************************************************************************
function m_sym_R = f_ofdm_rx(m_sig_R, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rf)
d_N_ant_act = sum(v_active_rf);
m_sig_R_eff = m_sig_R(:,find(v_active_rf));
m_sig_R_f = reshape(m_sig_R_eff,(d_N_FFT+d_N_CP),d_N_OFDM,d_N_ant_act);
%** delete the CP **
m_sig_R_noCP = m_sig_R_f(d_N_CP+1:end,:,:);
%** fft **
%m_sym_R_fft = fft(m_sig_R_noCP,d_N_FFT,1);
m_sym_R_fft = 1/sqrt(d_N_FFT)*fft(m_sig_R_noCP,d_N_FFT,1);
m_sym_R = m_sym_R_fft([362:512 2:151],:,:);
end
%
% PURPOSE : OFDM Transmitter
%
% ARGUMENTS :
%
% d_M : modulation order
% d_N_f : carrier number carrying data
% d_N_FFT : total carrier number
% d_N_CP : extented cyclic prefix
% d_N_OFDM : OFDM symbol number per frame
% d_N_ant : antenna number
% v_active_rf : active RF antenna indicator
% d_amp : amplitude
%
% OUTPUTS :
%
% m_sym_T : transmitted signal before IFFT with dimension d_N_f x d_N_OFDM x d_N_ant_act
% m_sig_T : OFDM signal with dimension ((d_N_FFT+d_N_CP)*d_N_OFDM) x d_N_ant
%
%**********************************************************************************************
% EURECOM - All rights reserved
%
% AUTHOR : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Apr-29-2014 X. JIANG 0.1 creation of code
%
% REFERENCES/NOTES/COMMENTS :
%
% - Based on the function "genrandpskseq" created by Mirsad Cirkic, Florian Kaltenberger.
%
%**********************************************************************************************
function [m_sym_T, m_sig_T] = f_ofdm_tx(d_M, d_N_f, d_N_FFT, d_N_CP, d_N_OFDM, d_N_ant, v_active_rf, d_amp)
d_N_ant_act = sum(v_active_rf);
%** constellation table **
v_MPSK = exp(sqrt(-1)*([1:d_M]*2*pi/d_M+pi/d_M));
%** transmitted symbol **
m_sym_T = v_MPSK(ceil(rand(d_N_f, d_N_OFDM, d_N_ant_act)*d_M));
%** mapping useful data to favorable carriers **
m_sym_T_ext = zeros(d_N_FFT,d_N_OFDM,d_N_ant_act);
m_sym_T_ext(362:512,:,:) = m_sym_T(1:151,:,:);
m_sym_T_ext(2:151,:,:) = m_sym_T(152:301,:,:);
%** ifft **
m_sig_T_ = sqrt(d_N_FFT)*ifft(m_sym_T_ext,d_N_FFT,1);
%m_sig_T_ = ifft(m_sym_T_ext,d_N_FFT,1);
%** add cyclic prefix **
m_sig_T_ = [m_sig_T_(end-d_N_CP+1:end,:,:); m_sig_T_];
d_L = (d_N_FFT+d_N_CP)*d_N_OFDM;
m_sig_T_temp = reshape(m_sig_T_,d_L,d_N_ant_act);
%** mapping to active antennas **
m_sig_T = zeros(d_L,d_N_ant);
m_sig_T(:,find(v_active_rf)) = floor(m_sig_T_temp*d_amp);
end
%
% PURPOSE : TLS solution for AX = B based on alternative projection
%
% ARGUMENTS :
%
% A : observation of A
% B : observation of B
%
% OUTPUTS :
%
% X : TLS solution for X
%
%**********************************************************************************************
% EURECOM - All rights reserved
%
% AUTHOR : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Mai-05-2014 X. JIANG 0.1 creation of code
%
% REFERENCES/NOTES/COMMENTS :
%
% - none.
%
%**********************************************************************************************
function [X_est A_est B_est] = f_tls_ap(A,B)
%** initlisation **
e_new = 0;
e_old = 1e14;
e_thr = 1e-5; %error threshold: what if the error cannot fall down under the error threshold
X_est = eye(size(A,2));
A_est = A;
%** alternative projection **
while(abs(e_new-e_old)>e_thr)
e_old = e_new;
% optimise X_est
X_est = (A_est'*A_est)\A_est'*B;
%optimise A_est
A_est = B*X_est'/(X_est*X_est');
e_new = norm(A_est*X_est-B)^2+norm(A_est-A)^2;
end
B_est = A_est*X_est;
end
\ No newline at end of file
%
% PURPOSE : TLS solution for AX = B based on SVD
%
% ARGUMENTS :
%
% A : observation of A
% B : observation of B
%
% OUTPUTS :
%
% X : TLS solution for X
%
%**********************************************************************************************
% EURECOM - All rights reserved
%
% AUTHOR : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Apr-30-2014 X. JIANG 0.1 creation of code
%
% REFERENCES/NOTES/COMMENTS :
%
% - I. Markovsky and S. V. Huffel, Overview of total least-squares methods, Signal Processing, vol. 87, pp.
% 22832302, 2007
%
%**********************************************************************************************
function [X_est A_est B_est]= f_tls_svd(A,B)
C = [A B];
n = size(A,2);
d = size(B,2);
[U S V] = svd(C,0);
V12 = V(1:n,n+1:end);
V22 = V(n+1:end,n+1:end);
S1 = S(1:n,1:n);
Z12 = zeros(n,d);
Z22 = zeros(d);
Z21 = zeros(d,n);
X_est = - V12/V22;
C_est = U*[S1 Z12;Z21 Z22]*V';
A_est = C_est(:,n);
B_est = C_est(:,n+1:end);
% delta_C = -U*diag([0,0,S(3,3),S(4,4)])*V';
end
\ No newline at end of file
7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933 7098 1933
10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55 10 -55
32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0 32440 0
32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0
32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0
32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0 32767 0
d_N_antM = 3;
d_N_f = 300;
m_F_norm = ones(d_N_antM, d_N_f)*(1+0*1i);
m_F_Q15 = zeros(d_N_antM, d_N_f*2);
m_F_Q15(:,1:2:end-1) = floor(real(m_F_norm)*(2^15))-1;
m_F_Q15(:,2:2:end) = floor(imag(m_F_norm)*(2^15));
%%save('-ascii','calibF.mtx','m_F2_diag_Q14');
dlmwrite('result/calibF_iden.mtx', m_F_Q15,' ');
%
% SCRIPT ID : s_beamforming
%
% PROJECT NAME : TDD Recoprocity
%
% PURPOSE : perform beamforming based on TDD calibration
%
%**********************************************************************************************
% Eurecom - All rights reserved
%
% AUTHOR(s) : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Apr-30-2014 X. JIANG 0.1 script creation v0.1
%
% REFERENCES/NOTES/COMMENTS :
%
% - Based on the script "beamforming" created by Mirsad Cirkic, Florian Kaltenberger.
%
%**********************************************************************************************
clear all
%% -------- initilisation --------
d_M = 4; % modulation order, e.g. 4 means QPSK
%** frequency **
d_fc = 2580000000; %1907600000;
d_delta_f = 15000;
d_N_f = 301; % carrier number carrying data
d_N_FFT = 512; % total carrier number
d_N_CP = 128; % extented cyclic prefix
%%** time **
d_N_OFDM = 120; % number of ofdm symbol per frame
d_N_meas = 1; % measuement number
%%** space **
d_N_antA = 4; % antenna number at site a
d_N_antB = 4; % antenna number at site b
v_active_rfA = [1 1 0 0];
v_active_rfB = [0 0 0 1];
active_rf = v_active_rfA | v_active_rfB;
v_indA = find(v_active_rfA); % active antenna index at site a
v_indB = find(v_active_rfB); % active antenna index at site b
d_N_antA_act = length(v_indA);
d_N_antB_act = length(v_indB);
%
%%** amplitude **
d_amp = pow2(13);
d_n_bit = 16;
card = 0;
%% -------- load F --------
o_result = load('result/m_F.mat');
m_F = o_result.m_F;
%% -------- channel measurement --------
s_run_meas;
%% -------- signal precoding --------
v_MPSK = exp(sqrt(-1)*([1:d_M]*2*pi/d_M+pi/d_M));
m_sym_TA = v_MPSK(ceil(rand(d_N_f, d_N_OFDM)*d_M));
m_sym_TA_ideal = zeros(d_N_f,d_N_OFDM,d_N_antA_act);
m_sym_TA_iden = zeros(d_N_f,d_N_OFDM,d_N_antA_act);
m_sym_TA_diag = zeros(d_N_f,d_N_OFDM,d_N_antA_act);
d_N_sig = (d_N_FFT + d_N_CP)*d_N_OFDM;
m_sig_TA_ideal = ones(d_N_sig,4)*(1+1i);
m_sig_TA_iden = ones(d_N_sig,4)*(1+1i);
m_sig_TA_diag = ones(d_N_sig,4)*(1+1i);
m_sig_TB = ones(d_N_sig,4)*(1+1i);
m_H_calib_A2B = zeros(1,2, d_N_f);
for d_f = 1:d_N_f
%** ideal case **
v_H_A2B_ideal = squeeze(m_H_est_A2B(:,:,d_f));
v_P_ideal = v_H_A2B_ideal'/norm(v_H_A2B_ideal);
m_sym_TA_ideal(d_f,:,:) = (v_P_ideal*m_sym_TA(d_f,:)).';
%** identity matrix **
v_H_A2B_iden = squeeze(m_H_est_B2A(:,:,d_f)).';
v_P_iden = v_H_A2B_iden'/norm(v_H_A2B_iden);
m_sym_TA_iden(d_f,:,:) = (v_P_iden*m_sym_TA(d_f,:)).';
%** diagonal calibration **
v_H_A2B_diag = squeeze(m_H_est_B2A(:,:,d_f).')*diag(m_F(:,d_f));
v_P_diag = v_H_A2B_diag'/norm(v_H_A2B_diag);
m_sym_TA_diag(d_f,:,:) = (v_P_diag*m_sym_TA(d_f,:)).';
m_H_calib_A2B(:,:,d_f) = v_H_A2B_diag;
end
%% -------- signal transmission --------
m_sig_TA_ideal(:,v_indA) = f_ofdm_mod(m_sym_TA_ideal,d_N_FFT,d_N_CP,d_N_OFDM,v_active_rfA,d_amp)*2;
m_sig_TA_iden(:,v_indA) = f_ofdm_mod(m_sym_TA_iden,d_N_FFT,d_N_CP,d_N_OFDM,v_active_rfA,d_amp)*2;
m_sig_TA_diag(:,v_indA) = f_ofdm_mod(m_sym_TA_diag,d_N_FFT,d_N_CP,d_N_OFDM,v_active_rfA,d_amp)*2;
d_N_sig_R = d_N_OFDM*(d_N_FFT+d_N_CP);
v_P = exp(1i*2*pi*(0:(d_N_sig_R-1))/4).';
m_P = repmat(v_P,1,4);
oarf_send_frame(card,m_sig_TB,d_n_bit);
m_noise_RB_ = oarf_get_frame(-2);
m_noise_RB = m_noise_RB_(1:d_N_sig,:).*m_P;
m_n_sym_RB = f_ofdm_rx(m_noise_RB, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rfB);
oarf_send_frame(card,m_sig_TA_ideal,d_n_bit);
m_sig_RB_ideal_ = oarf_get_frame(-2);
m_sig_RB_ideal = m_sig_RB_ideal_(1:d_N_sig,:).*m_P;
m_sym_RB_ideal = f_ofdm_rx(m_sig_RB_ideal, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rfB);
oarf_send_frame(card,m_sig_TA_iden,d_n_bit);
m_sig_RB_iden_ = oarf_get_frame(-2);
m_sig_RB_iden = m_sig_RB_iden_(1:d_N_sig,:).*m_P;
m_sym_RB_iden = f_ofdm_rx(m_sig_RB_iden, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rfB);
oarf_send_frame(card,m_sig_TA_diag,d_n_bit);
m_sig_RB_diag_ = oarf_get_frame(-2);
m_sig_RB_diag = m_sig_RB_diag_(1:d_N_sig,:).*m_P;
m_sym_RB_diag = f_ofdm_rx(m_sig_RB_diag, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rfB);
%% -------- SNR measurement --------
%** noise measurment **
v_P_n = mean(var(squeeze(m_n_sym_RB),0,2));
%** SNR caculation
%v_P_s_ideal = zeros(301,1);
%for d_f=1:d_N_f
% v_H_A2B_ideal = squeeze(m_H_est_A2B(:,:,d_f));
% v_P_s_ideal(d_f) = norm(v_H_A2B_ideal)^2;
%end
%keyboard;
v_P_s_ideal = var(squeeze(m_sym_RB_ideal),0,2);
v_P_s_iden = var(squeeze(m_sym_RB_iden),0,2);
v_P_s_diag = var(squeeze(m_sym_RB_diag),0,2);
v_SNR_ideal_ = 10*log10((v_P_s_ideal-v_P_n)./v_P_n);
v_SNR_iden_ = 10*log10((v_P_s_iden-v_P_n)./v_P_n);
v_SNR_diag_ = 10*log10((v_P_s_diag-v_P_n)./v_P_n);
v_SNR_ideal = nan(d_N_f+1,1);
v_SNR_iden = nan(d_N_f+1,1);
v_SNR_diag = nan(d_N_f+1,1) ;
v_SNR_ideal([1:151 153:302]) = v_SNR_ideal_([1:151 152:301]);
v_SNR_iden([1:151 153:302]) = v_SNR_iden_([1:151 152:301]) ;
v_SNR_diag([1:151 153:302]) = v_SNR_diag_([1:151 152:301]) ;
%save('-v7','result/bf_gain_4x1_t3.mat','v_SNR_ideal','v_SNR_iden','v_SNR_diag','v_SNR_full');
%% -------- plot --------
v_f = d_fc-floor(d_N_f/2)*d_delta_f:d_delta_f:d_fc+ceil(d_N_f/2)*d_delta_f;
figure(6)
hold on
plot(v_f,v_SNR_ideal,'k-o')
plot(v_f,v_SNR_iden,'g-')
plot(v_f,v_SNR_diag,'r-*')
hold off
%ylim([30 40])
%%------------- Calibration ---------------
m_F_test = zeros(2, d_N_f);
for d_f = 1:d_N_f
m_F_test(:,d_f) = (squeeze(m_H_est_A2B(:,:,d_f)).')./squeeze(m_H_est_B2A(:,:,d_f));
end
%figure(12)
%subplot(2,1,1)
%hold on;
%for d_f=1:d_N_f
% plot(m_F_test(1,d_f),'bo')
% plot(m_F_test(2,d_f),'ro')
%end
%hold off;
%title('Diagonal F');
%axis([-2 2 -2 2])
%grid on
%
%subplot(2,1,2)
%hold on;
%for d_f=1:d_N_f
% plot(m_F(1,d_f),'bo')
% plot(m_F(2,d_f),'ro')
%end
%hold off;
%title('Diagonal F');
%axis([-2 2 -2 2])
%grid on
figure(13)
subplot(2,2,1)
plot(20*log10(abs(squeeze(m_H_est_A2B).')),'-');
ylim([0 100])
subplot(2,2,2)
plot(20*log10(abs(squeeze(m_H_calib_A2B).')),'-');
ylim([0 100])
subplot(2,2,3)
plot(angle(squeeze(m_H_est_A2B).'),'-');
subplot(2,2,4)
plot(angle(squeeze(m_H_calib_A2B).'),'-');
%
% SCRIPT ID : s_run_calib
%
% PROJECT NAME : TDD Recoprocity
%
% PURPOSE : channel calibration for MISO case
%
%**********************************************************************************************
% Eurecom - All rights reserved
%
% AUTHOR(s) : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Apr-30-2014 X. JIANG 0.1 script creation v0.1
% Feb-21-2017 X. JIANG 0.2 script adaption for WSA demo at Berlin
%
% REFERENCES/NOTES/COMMENTS :
%
% - Based on the script "calibration" created by Mirsad Cirkic, Florian Kaltenberger.
%
%**********************************************************************************************
%% ** initilisation **
%---------- to change in experiement ---------
%clc
%clear all
%close all
%d_N_f = 301; % carrier number carrying data
%d_N_meas = 10; % measuement number
%d_N_loc = 5; % Rx locations
%d_N_antM = 2; % max active antenna number for site a and site b
%----------------------------------------------
%% -------- System parameters --------
d_M = 4; % modulation order, e.g. 4 means QPSK
%** frequency **
d_N_f = 301; % carrier number carrying data
d_N_FFT = 512; % total carrier number
d_N_CP = 128; % extented cyclic prefix
%** time **
d_N_OFDM = 120; % number of ofdm symbol per frame
d_N_meas = 1; % measuement number
%** space **
d_N_antA = 4; % antenna number at site a
d_N_antB = 4; % antenna number at site b
v_indA = find(v_active_rfA); % active antenna index at site a
v_indB = find(v_active_rfB); % active antenna index at site b
%** amplitude **
d_amp = pow2(13)-1; % to see how to be used??
%% -------- calibration parameters -------
d_N_loc = 1; % Rx locations
d_N_antM = max(sum(v_active_rfA),sum(v_active_rfB)); % max active antenna number for site a and site b
m_H_A2B = zeros(d_N_antM,d_N_meas*d_N_loc, d_N_f); % d_N_antA x (d_N_meas*d_N_loc) x d_N_f
m_H_B2A = zeros(d_N_antM,d_N_meas*d_N_loc, d_N_f); % d_N_antA x (d_N_meas*d_N_loc) x d_N_f
m_F = zeros(d_N_antM,d_N_f);
m_F_ = zeros(d_N_antM,d_N_meas,d_N_f);
%% ** collect the measurement data from different locations **
d_loc = 1;
while(d_loc <= d_N_loc)
% run measurement, note: uncomment "clear all"
s_run_meas;
% -----------------------------------------------------
d_yes = yes_or_no('valid measurement?');
if d_yes == 1
m_H_A2Bi = permute(squeeze(m_H_est_A2B),[1 3 2]);
m_H_B2Ai = permute(squeeze(m_H_est_B2A),[1 3 2]);
m_H_A2B(:,(d_loc-1)*d_N_meas+1:d_loc*d_N_meas,:) = m_H_A2Bi;
m_H_B2A(:,(d_loc-1)*d_N_meas+1:d_loc*d_N_meas,:) = m_H_B2Ai;
d_loc = d_loc +1
end
%keyboard;
pause
end
%s_run_meas;
%% --- the following part is dedicated to B2A MISO -----
%m_H_A2B = squeeze(m_H_est_A2B);
%m_H_B2A = squeeze(m_H_est_B2A);
%% -----------------------------------------------------
%% ** calibration **
for d_f = 1:d_N_f
m_F(:,d_f) = mean(m_H_A2B(:,:,d_f)./m_H_B2A(:,:,d_f),2);
end
m_F_norm = zeros(d_N_antM+1, d_N_f);
m_F_norm(1, :) = mean(m_F(1, :),2);
m_F_norm(2, :) = mean(m_F(2, :),2);
m_F_norm(3, :) = 1;
m_F_norm = m_F_norm./max(max(abs(m_F_norm)))*0.99;
%keyboard
save('-v7','result/m_F.mat','m_F');
%% ** transform the data to Q2.14 format and store it in a .mtx file
m_F_Q15 = zeros(d_N_antM+1,d_N_f*2);
m_F_Q15(:,1:2:end-1) = floor(real(m_F_norm)*(2^15));
m_F_Q15(:,2:2:end) = floor(imag(m_F_norm)*(2^15));
%%save('-ascii','calibF.mtx','m_F2_diag_Q14');
dlmwrite('result/calibF.mtx', m_F_Q15,' ');
%% ** plot **
figure(11)
hold on;
for d_f=1:d_N_f
plot(m_F_norm(1,d_f),'bo')
plot(m_F_norm(2,d_f),'ro')
plot(m_F_norm(3,d_f)+0.000001*1i,'ko')
end
hold off;
title('Diagonal F');
axis([-2 2 -2 2])
grid on
%figure(12)
%hold on;
%for d_f=1:d_N_f
% plot(m_F_(1,1,d_f),'bo')
% plot(m_F_(2,1,d_f),'ro')
%% plot(m_F_(1,3,d_f),'gx')
%% plot(m_F_(2,3,d_f),'yx')
%% plot(m_F_(1,5,d_f),'c+')
%% plot(m_F_(2,5,d_f),'m+')
%end
%hold off;
%title('Diagonal F');
%axis([-2 2 -2 2])
%grid on
close all
m_H_B2A = load('m_H_B2A_1card_test1.mat');
m_H_B2A = m_H_B2A.m_H_B2A;
m_H_A2B = load('m_H_A2B_1card_test1.mat');
m_H_A2B = m_H_A2B.m_H_A2B;
%% ** normalisation **
%for d_f = 1:d_N_f
% for d_n_meas = 1:d_N_meas
% m_H_B2A(:,d_n_meas,d_f) = m_H_B2A(:,d_n_meas,d_f)/max(abs(m_H_B2A(:,d_n_meas,d_f)));
% m_H_A2B(:,d_n_meas,d_f) = m_H_A2B(:,d_n_meas,d_f)/max(abs(m_H_A2B(:,d_n_meas,d_f)));
% end
%end
%keyboard;
%% ** average **
%m_H_B2A_ = zeros(size(m_H_B2A,1),15,size(m_H_B2A,3));
%m_H_A2B_ = zeros(size(m_H_A2B,1),15,size(m_H_A2B,3));
%for d_f = 1:d_N_f
% for d_l = 1:d_N_loc
% m_H_B2A_(:,d_l,d_f) = mean(m_H_B2A(:,(d_l-1)*10+1:d_l*10,d_f),2);
% m_H_A2B_(:,d_l,d_f) = mean(m_H_A2B(:,(d_l-1)*10+1:d_l*10,d_f),2);
% end
%end
%keyboard;
%% ** calibration **
for d_f = 1:d_N_f
[m_F0(:,:,d_f),m_A0_est,m_B0_est] = f_tls_svd(m_H_B2A(:,:,d_f).',m_H_A2B(:,:,d_f).');
% [m_F1(:,:,d_f),m_A0_est,m_B0_est] = f_tls_svd(m_H_B2A(:,:,d_f).',m_H_A2B(:,51:100,d_f).');
% [m_F2(:,:,d_f),m_A0_est,m_B0_est] = f_tls_svd(m_H_B2A(:,:,d_f).',m_H_A2B(:,101:150,d_f).');
[m_F3(:,:,d_f),m_A1_est,m_B1_est] = f_tls_ap(m_H_B2A(:,:,d_f).',m_H_A2B(:,:,d_f).');
%[m_F0(:,:,d_f),m_A0_est,m_B0_est] = f_tls_svd(m_H_B2A_(:,1:50,d_f).',m_H_A2B_(:,1:50,d_f).');
%[m_F1(:,:,d_f),m_A0_est,m_B0_est] = f_tls_svd(m_H_B2A_(:,51:100,d_f).',m_H_A2B_(:,51:100,d_f).');
%[m_F2(:,:,d_f),m_A0_est,m_B0_est] = f_tls_svd(m_H_B2A_(:,101:150,d_f).',m_H_A2B_(:,101:150,d_f).');
%[m_F3(:,:,d_f),m_A1_est,m_B1_est] = f_tls_ap(m_H_B2A_(:,:,d_f).',m_H_A2B_(:,:,d_f).');
end
%oarf_stop(cardA);
%oarf_stop(cardB);
%% ** plot **
figure(10)
hold on;
for d_f=1:size(m_F0,3);
m_F= m_F0(:,:,d_f);
plot(m_F(1,1),'bo')
plot(m_F(2,2),'ko')
plot(diag(m_F,1),'r+')
plot(diag(m_F,-1),'gx')
end
hold off;
title('F0');
axis([-10 10 -10 10])
grid on
figure(11)
hold on;
for d_f=1:size(m_F1,3);
m_F= m_F1(:,:,d_f);
plot(m_F(1,1),'bo')
plot(m_F(2,2),'ko')
plot(diag(m_F,1),'r+')
plot(diag(m_F,-1),'gx')
end
hold off;
title('F1');
axis([-10 10 -10 10])
grid on
figure(12)
hold on;
for d_f=1:size(m_F2,3);
m_F= m_F2(:,:,d_f);
plot(m_F(1,1),'bo')
plot(m_F(2,2),'ko')
plot(diag(m_F,1),'r+')
plot(diag(m_F,-1),'gx')
end
hold off;
title('F2');
axis([-10 10 -10 10])
grid on;
figure(13)
hold on;
for d_f=1:size(m_F3,3);
m_F= m_F3(:,:,d_f);
plot(m_F(1,1),'bo')
plot(m_F(2,2),'ko')
plot(diag(m_F,1),'r+')
plot(diag(m_F,-1),'gx')
end
hold off;
title('F3');
axis([-10 10 -10 10])
grid on
clear all
close all
addpath([getenv('OPENAIR_TARGETS') '/ARCH/EXMIMO/USERSPACE/OCTAVE']);
addpath([getenv('OPENAIR_DIR') '/cmake_targets/lte_build_oai/build']);
%% -------- ExpressMIMO2 configuration --------
limeparms;
card = 0;
v_active_rfA = [1 1 0 0];
v_active_rfB = [0 0 1 0];
active_rf = v_active_rfA | v_active_rfB;
if(v_active_rfA*v_active_rfB'~=0)
error('The A and B transceive chains must be orthogonal./n')
end
fc = 2580000000; %1907600000; %1912600000; %fc = 859.5e6;
fs = 7.68e6;
freq_tx = fc*active_rf;
freq_rx = (fc+fs/4)*active_rf;
tdd_config = DUPLEXMODE_FDD+TXRXSWITCH_LSB; %we need the LSB switching for the woduplex script, otherwise we don't receive anything
rx_gain = [10 10 10 0];%10*active_rf;
tx_gain = [10 10 10 0];%10*active_rf;
%rx_gain = 20*active_rf;
%tx_gain = 20*active_rf;
syncmode = SYNCMODE_FREE;
eNB_flag = 0;
%rf_mode=(RXEN+TXEN+TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAByp+RFBBLNA1) * active_rf;
%rf_mode=(TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAMax+RFBBNORM) * active_rf;
% we have to enable both DMA transfers so that the switching signal in the LSB of the TX buffer gets set
rf_mode = (TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF5+LNA1ON+LNAMax+RFBBNORM+DMAMODE_TX+TXEN+DMAMODE_RX+RXEN) * active_rf;
rf_rxdc = rf_rxdc*active_rf; %???
rf_vcocal = rf_vcocal_19G*active_rf;
rf_local = [8254744 8255063 8257340 8257340]; %eNB2tx 1.9GHz
rffe_rxg_low = 31*active_rf;
rffe_rxg_final = 63*active_rf;
rffe_band = B19G_TDD*active_rf;
autocal_mode = active_rf;
resampling_factor = [2 2 2 2];
oarf_stop(card);
sleep(0.1);
oarf_config_exmimo(0,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,resampling_factor);
d_n_bit = 16;
%
% SCRIPT ID : s_run_meas
%
% PROJECT NAME : TDD Recoprocity
%
% PURPOSE : full transmission and receive train for TDD reciprocity calibration
%
%**********************************************************************************************
% Eurecom - All rights reserved
%
% AUTHOR(s) : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Apr-29-2014 X. JIANG 0.1 script creation v0.1
%
% REFERENCES/NOTES/COMMENTS :
%
% - Based on the script "run_full_duplex" created by Mirsad Cirkic, Florian Kaltenberger.
%
%**********************************************************************************************
%% ** initialisation **
%% ------------- to change in experiment ------------
%clc
close all
%clear all
%
%d_M = 4; % modulation order, e.g. 4 means QPSK
%
%%%** frequency **
%d_N_f = 301; % carrier number carrying data
%d_N_FFT = 512; % total carrier number
%d_N_CP = 128; % extented cyclic prefix
%%** time **
%d_N_OFDM = 120; % number of ofdm symbol per frame
%d_N_meas = 10; % measuement number
%%** antenna **
%d_N_antA = 4; % antenna number at site a
%d_N_antB = 4; % antenna number at site b
%v_active_rfA=[0 0 1 0]; %temp
%v_active_rfB=[1 1 0 0];
%v_indA = find(v_active_rfA); % active antenna index at site a
%v_indB = find(v_active_rfB); % active antenna index at site b
%d_amp = 10;
%% ----------------------------------------------------
m_sym_T = zeros(d_N_f,d_N_OFDM,3,d_N_meas);
m_sym_TA = zeros(d_N_f,d_N_OFDM/2,length(v_indA),d_N_meas);
m_sym_TB = zeros(d_N_f,d_N_OFDM/2,length(v_indB),d_N_meas);
m_sym_RA = zeros(d_N_f,d_N_OFDM/2,length(v_indA),d_N_meas);
m_sym_RB = zeros(d_N_f,d_N_OFDM/2,length(v_indB),d_N_meas);
%** simulation**
%m_sig_R = zeros((d_N_FFT+d_N_CP)*d_N_OFDM,4);
for d_n_meas = 1:d_N_meas
%% -------- tx --------
%** tx of site A **
[m_sym_T(:,:,:,d_n_meas), m_sig_T] = f_ofdm_tx(d_M, d_N_f, d_N_FFT, d_N_CP, d_N_OFDM, d_N_antA, active_rf, d_amp);
m_sym_TA(:,:,:,d_n_meas) = m_sym_T(:,1:end/2,1:end-1,d_n_meas);
m_sym_TB(:,:,:,d_n_meas) = m_sym_T(:,end/2+1:end,end,d_n_meas);
%** simulation
%m_sym_TA(:,d_N_OFDM/4+1:d_N_OFDM/2,1,d_n_meas) = 0;
%m_sig_T(end/4+1:end/2,v_indA(1)) = 0;
%m_sym_TA(:,1:d_N_OFDM/4,2,d_n_meas) = 0;
%m_sig_T(1:end/4,v_indA(2)) = 0;
%m_sig_T(1:end/2, v_indA) = m_sig_T(1:end/2,v_indA);
%m_sig_T(end/2+1:end, v_indA) = 0;
%m_sig_T(end/2+1:end, v_indB) = m_sig_T(end/2+1:end,v_indB);
%m_sig_T(1:end/2, v_indB) = 0;
%m_sig_R(end/2+1:end,1) = m_sig_T(end/2+1:end,4);
%m_sig_R(end/2+1:end,2) = m_sig_T(end/2+1:end,4);
%m_sig_R(1:end/2,4) = m_sig_T(1:end/2,1)+m_sig_T(1:end/2,2);
%** prepare the signal **
m_sym_TA(:,d_N_OFDM/4+1:d_N_OFDM/2,v_indA(1),d_n_meas) = 0;
m_sym_TA(:,1:d_N_OFDM/4,v_indA(2),d_n_meas) = 0;
m_sig_T(1:end/2, v_indA) = m_sig_T(1:end/2,v_indA)*2;
m_sig_T(end/2+1:end, v_indB) = m_sig_T(end/2+1:end,v_indB)*2;
m_sig_T(end/2+1:end, v_indA) = 1+1i;
m_sig_T(1:end/2, v_indB) = 1+1i;
m_sig_T(end/4+1:end/2,v_indA(1)) = 1+1i;
m_sig_T(1:end/4,v_indA(2)) = 1+1i;
%% -------- channel --------
%** Transmission from A to B **
oarf_send_frame(card,m_sig_T,d_n_bit);
m_sig_R_ = oarf_get_frame(-2);
d_N_sig_R = d_N_OFDM*(d_N_FFT+d_N_CP);
v_P = exp(1i*2*pi*(0:(d_N_sig_R-1))/4).';
m_sig_R = m_sig_R_(1:d_N_sig_R,:) .* repmat(v_P,1,size(m_sig_R_,2));
m_sig_RA = m_sig_R(end/2+1:end,:);
m_sig_RB = m_sig_R(1:end/2,:);
%% -------- rx --------
m_sym_RB(:,:,:,d_n_meas) = f_ofdm_rx(m_sig_RB, d_N_FFT, d_N_CP, d_N_OFDM/2, v_active_rfB);
m_sym_RA(:,:,:,d_n_meas) = f_ofdm_rx(m_sig_RA, d_N_FFT, d_N_CP, d_N_OFDM/2, v_active_rfA);
end
% keyboard;
%** channel estimation **
m_H_est_A2B = f_ch_est(m_sym_TA, m_sym_RB); %dimension: d_N_antR x d_N_antT x d_N_f x d_N_meas
m_H_est_B2A = f_ch_est(m_sym_TB, m_sym_RA);
%% -------- plot --------
%** channel estimation in frequency domain **
m_H_A2B_draw = squeeze(m_H_est_A2B(1,:,:,1)).';
m_H_B2A_draw = squeeze(m_H_est_B2A(:,1,:,1)).';
%keyboard
figure(1)
subplot(2,1,1)
plot(real(m_sig_RA(:,v_indA)),'-');
title('m_sig_RA')
subplot(2,1,2)
plot(real(m_sig_RB(:,v_indB)),'b-');
hold on
plot(real(m_sig_RB(end-100:end,v_indB)),'r-')
title('m_sig_RB')
figure(2)
subplot(2,2,1)
plot(20*log10(abs(m_H_A2B_draw)),'-');
title('|h| vs. freq (A2B)')
xlabel('freq')
ylabel('|h|')
ylim([0 100])
subplot(2,2,2)
plot(20*log10(abs(m_H_B2A_draw)),'-');
title('|h| vs. freq (B2A)')
xlabel('freq')
ylabel('|h|')
ylim([0 100])
subplot(2,2,3)
plot(angle(m_H_A2B_draw),'-');
title('angle(h) vs. freq (A2B)')
xlabel('freq')
ylabel('angle(h)')
subplot(2,2,4)
plot(angle(m_H_B2A_draw),'-');
title('angle(h) vs. freq (B2A)')
xlabel('freq')
ylabel('angle(h)')
figure(3)
plot(m_sym_RA(1,:,1,1),'b*')
% hold on
% plot(m_sym_RA(1,:,1,3),'r*')
% hold on
% plot(m_sym_RA(1,:,1,5),'g*')
title('m sym RA 1')
figure(4)
plot(m_sym_RA(1,:,2,1),'b*')
% hold on
% plot(m_sym_RA(1,:,2,3),'r*')
% hold on
% plot(m_sym_RA(1,:,2,5),'g*')
title('m sym RA 2')
figure(5)
subplot(2,1,1)
plot(m_sym_RB(1,1:end/2,1,1),'b*')
% hold on
% plot(m_sym_RB(1,1:end/2,1,3),'r*')
% hold on
% plot(m_sym_RB(1,1:end/2,1,5),'g*')
title('m sym RB ant 2')
subplot(2,1,2)
plot(m_sym_RB(1,end/2+1:end,1,1),'b*')
% hold on
% plot(m_sym_RB(1,end/2+1:end,1,3),'r*')
% hold on
% plot(m_sym_RB(1,end/2+1:end,1,5),'g*')
title('m sym RB ant 2')
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