Commit 84fb51d8 authored by guibene's avatar guibene

WHERE2 measurements

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4306 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent e52c28aa
CC = gcc
CFLAGS = -DUSER_MODE
XTRA_CFLAGS = -msse -msse2 -mssse3
#ifndef OPENAIR0_DIR
# $(error Environment variable OPENAIR0_DIR must be set!)
#else
# CFLAGS += -I$(OPENAIR0_DIR)/express-mimo/software/pcie
#endif
GCCVERSION = $(shell gcc --version | grep ^gcc | sed 's/^.* //g')
ifeq "$(GCCVERSION)" "4.4.3"
CFLAGS += -Wno-packed-bitfield-compat
endif
ifeq "$(GCCVERSION)" "4.5.2"
CFLAGS += -Wno-packed-bitfield-compat
endif
ifeq "$(GCCVERSION)" "4.6.1"
CFLAGS += -Wno-packed-bitfield-compat
endif
OPENAIRTARGETS_DIR ?=../../../..
OPENAIROBJS += $(OPENAIRTARGETS_DIR)/ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.o
CFLAGS += -I$(OPENAIRTARGETS_DIR)/ARCH/EXMIMO/USERSPACE/LIB -I$(OPENAIRTARGETS_DIR)/ARCH/EXMIMO/DEFS
#OPENAIROBJS = $(OPENAIR1_DIR)/PHY/CONFIG/openair_readconfigfile.o $(OPENAIR1_DIR)/PHY/CONFIG/openair_configure.o
OCTAVEOBJS = oarf_config_exmimo.oct oarf_get_frame.oct oarf_stop.oct oarf_send_frame.oct oarf_get_num_detected_cards.oct
all: $(OCTAVEOBJS) gpib_send.oct
oarf: $(OCTAVEOBJS)
$(OPENAIROBJS) : %.o : %.c
gcc -c $(CFLAGS) $(XTRA_CFLAGS) -o $@ $<
test:
echo $(OPENAIROBJS)
$(OCTAVEOBJS) : %.oct : %.cc $(OPENAIROBJS)
mkoctfile -o $@ $(CFLAGS) -lm $(OPENAIROBJS) $<
gpib_send.oct: gpib_send.cc
mkoctfile -I/usr/include/gpib -I/usr/local/include/gpib -lgpib gpib_send.cc
clean:
rm -f gpib_send.oct $(OCTAVEOBJS) $(OPENAIROBJS) *.o octave-core
function [sig,sig_length] = OFDM_TX(num_carriers,num_zeros,prefix_length,input)
% OFDM Transmitter - DC removed
% sig is the output signal
% length is the length of the output signal
% num_carriers - number of sub-carriers (power of 2)
% num_zeros - number of zeros minus 1 (DC) in output spectrum (odd)
% prefix_length - length of cyclic prefix
% input - input dimensions (length = number_carriers - num_zeros - 1)
if (length(input) + num_zeros + 1 ~= num_carriers)
fprintf('error in lengths\n');
return;
end
ext_input = [0 input(1:length(input)/2) zeros(1,num_zeros) input((1+length(input)/2) : length(input))];
output_1 = ifft(ext_input);
sig = [output_1((num_carriers - prefix_length + 1) : num_carriers) output_1];
sig_length = length(sig);
function sig = OFDM_TX_FRAME(num_carriers,num_zeros,prefix_length,num_symbols_frame,preamble_length)
% sig - output signal
% sig_length - output signal length
% num_carriers - number of sub-carriers
% num_zeros - number of zero carriers minus 1 (DC)
% prefix_length - length of cyclic prefix
% num_symbols_frame - number of symbols per OFDM frame
% preamble_length - length of 4-QAM preamble
num_useful_carriers = num_carriers - num_zeros -1;
sig = [];
for k=1:preamble_length
QAM4_preamble = QAM_MOD(4,floor(256*abs(rand(1,num_useful_carriers/4))));
sig = [sig OFDM_TX(num_carriers,num_zeros,prefix_length,QAM4_preamble)];
end
for k=1:(num_symbols_frame - preamble_length)
QAM_data = QAM_MOD(256,floor(256*abs(rand(1,num_useful_carriers))));
sig = [sig OFDM_TX(num_carriers,num_zeros,prefix_length,QAM_data)];
end
function [sig,sig_length] = QAM_MOD(size,input)
% sig - output symbols
% size - modulation size (4,16,256)
% input - vector of bytes to be modulated
AM2 = [-1 1];
AM4 = [-3 -1 1 3]; AM4 = 2*AM4/sqrt(AM4*AM4');
AM16 = [-15 -13 -11 -9 -7 -5 -3 -1 1 3 5 7 9 11 13 15]; AM16 = 4*AM16/sqrt(AM16*AM16');
sig = zeros(1,length(input)*8/log2(size));
sig_length = length(input)*8/log2(size);
for l=1:length(input)
if (size == 256)
sig(l) = (AM16(1+ floor((input(l)/16))) +sqrt(-1)*AM16(1+rem(input(l),16)))/sqrt(2);
elseif (size == 16)
sig(1 + 2*(l-1)) = (AM4(1+floor((input(l)/64))) + sqrt(-1)*AM4(1+rem(floor(input(l)/16) , 4)))/sqrt(2);
sig(2 + 2*(l-1)) = (AM4(1+rem(floor(input(l)/4) , 4)) + sqrt(-1)*AM4(1+rem(input(l) , 4)))/sqrt(2);
elseif (size == 4)
sig(1+ 4*(l-1)) = (AM2(1+(floor(input(l)/128))) + sqrt(-1)*AM2(1+rem(floor(input(l)/64) , 2)))/sqrt(2);
sig(2+ 4*(l-1)) = (AM2(1+rem(floor(input(l)/32) ,2)) + sqrt(-1)*AM2(1+rem(floor(input(l)/16) , 2)))/sqrt(2);
sig(3+ 4*(l-1)) = (AM2(1+rem(floor(input(l)/8) , 2)) + sqrt(-1)*AM2(1+rem(floor(input(l)/4) , 2)))/sqrt(2);
sig(4+ 4*(l-1)) = (AM2(1+rem(floor(input(l)/2) , 2)) + sqrt(-1)*AM2(1+rem(input(l) , 2)))/sqrt(2);
end
end
chan=1;
hold off ;
card=0;
s=oarf_get_frame(card);
s2=zeros(76800*2,1);
s2(1:2:end) = s(:,chan);
s2(2:2:end) = s(:,chan);
plot(real(s2),'b',"markersize",1);
hold on; plot(imag(s2),'r',"markersize",1);
bit11_I = rem(floor(real(2048+s(:,chan))/2048),2);
bit11_Q = rem(floor(imag((2048*j)+s(:,chan))/2048),2);
bit11_IQ = zeros(1,2*length(bit11_I));
bit11_IQ(1:2:end) = bit11_I;
bit11_IQ(2:2:end) = bit11_Q;
plot(500*bit11_IQ,'k')
axis([0 76800 -1000 1000])
vlen=76800
chan=2
gainimb_rx = -0.0020; phaseimb_rx = -2.38; % ExMIMO1 / lime1, VGAgain2 = 0, 1.9 GHz
gainimb_rx = 0.55; phaseimb_rx = 24.3; % ExMIMO1 / lime1, VGAgain2 = 0, 1.9 GHz
phaseimb_rx = phaseimb_rx/180*pi; % phaser imb in radians
beta_rx = (1/2)*(1 + (1+ gainimb_rx) * exp(1i*phaseimb_rx));
alpha_rx = (1/2)*(1 - (1+ gainimb_rx) * exp(-1i*phaseimb_rx));
den=abs(beta_rx)^2-abs(alpha_rx)^2;
beta_rx=beta_rx/den;
alpha_rx=alpha_rx/den;
s2 = beta_rx.*s + alpha_rx.*conj(s);
hold off ; plot(20*log10(abs(fftshift(fft(s2(:,chan)))))); grid on;
dual_tx=0;
eNBflag = 0;
card=0;
limeparms;
%% acquisition
%rf_mode = ( RXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM + RXOUTSW )*[1 1 0 0];
rf_mode = ( RXEN + TXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM )*[1 1 1 1];
% internal loopback test
%rf_mode = (RXEN+TXEN+TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAByp+RFBBLNA1)*[1 1 0 0];
%rf_mode = (RXEN+ TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAByp+RFBBLNA1)*[1 1 1 1];
%rf_mode = [0 0 0 0];
%% Select DMA directions
rf_mode = rf_mode + (DMAMODE_RX + DMAMODE_TX)*[1 0 0 0];
freq_rx = (1907600000 - 0*9000)*[1 1 1 1];
%rf_local= [rfl(56,56,31,31) rfl(16,12,31,31) rfl(36,48,31,31) rfl(32,20,31,31)]; % 1.9 GHz, Exmimo2-No1, lime_cal_exmimo
%rf_local= [rfl(34,40,31,31) rfl(20,25,38,21) rfl(12,38,21,14) rfl(31,19,36, 6)]; % 1.9 GHz, Exmimo2-No1, LIME GUI
rf_local= [rfl(32,36,26,25) rfl(20,25,37,21) rfl(12,38,21,14) rfl(31,19,36, 6)];
rf_vcocal=(( 0xE)*(2^6)) + ( 0xE)*[1 1 1 1]; % 1.907 GHz, (OLD)
freq_tx = freq_rx + 000000; % 1kHz offset: @30 MSPS: 2.5 sines, @15 MSPS: 5 sines, @7 MSPS: 10 sines
rf_rxdc = rf_rxdc*[1 1 1 1];
tx_gain = 13*[1 1 1 1]; rx_gain = 25*[1 1 1 1]; amp=32000;
%tx_gain = 25*[1 1 1 1]; rx_gain = 0*[1 1 1 1]; amp=32000;
oarf_config_exmimo(card,freq_rx,freq_tx,0,dual_tx,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal);
sleep(1);
% create_testvector
vlen=76800
chan=1
v=0000*exp(-i*(3*[0:vlen-1]/vlen)*2*pi); v=[v;v]'; oarf_send_frame(card,v,16); sleep(0.2);
s = oarf_get_frame(card); figure ; plot(real(s(:,chan)),'b-.',"markersize",2) ; hold on ; plot(imag(s(:,chan)),'r-.',"markersize",2);
s = s(:,chan) - mean(s(:,chan)); % remove DC
e_s0 = sum( s' * s )
v=amp*exp(-i*(10000*[0:vlen-1]/vlen)*2*pi); e_v=sum(v*v'); v=[v;v]'; oarf_send_frame(card,v,16); sleep(0.2);
s = oarf_get_frame(card); figure ; plot(real(s(:,chan)),'b-.',"markersize",2) ; hold on ; plot(imag(s(:,chan)),'r-.',"markersize",2);
s = s(:,chan) - mean(s(:,chan)); % remove DC
figure; plot(20*log10(fftshift(abs(fft(s))))); grid on;
e_v
e_s = sum( s' * s )
s_over_s0_db = 10*log10( e_s / e_s0 )
dual_tx=0;
eNBflag = 0;
card=0;
limeparms;
%% acquisition
%rf_mode = ( RXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM + RXOUTSW )*[1 1 0 0];
rf_mode = ( TXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM )*[1 1 0 0];
% internal loopback test
%rf_mode = (RXEN+TXEN+TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAByp+RFBBLNA1)*[1 1 0 0];
%rf_mode = (RXEN+ TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAByp+RFBBLNA1)*[1 1 1 1];
%rf_mode = [0 0 0 0];
%% Select DMA directions
rf_mode = rf_mode + (DMAMODE_TX)*[0 1 0 0];
freq_rx = (1907600000 - 0*9000)*[1 1 1 1];
%rf_local= [rfl(56,56,31,31) rfl(16,12,31,31) rfl(36,48,31,31) rfl(32,20,31,31)]; % 1.9 GHz, Exmimo2-No1, lime_cal_exmimo
%rf_local= [rfl(34,40,31,31) rfl(20,25,38,21) rfl(12,38,21,14) rfl(31,19,36, 6)]; % 1.9 GHz, Exmimo2-No1, LIME GUI
%rf_local= [rfl(32,36,26,25) rfl(20,25,37,21) rfl(12,38,21,14) rfl(31,19,36, 6)];
rf_local= [rfl(33,36,26,25) rfl(20,24,37,21) rfl(12,38,21,14) rfl(31,19,36, 6)];
rf_vcocal=(( 0xE)*(2^6)) + ( 0xE)*[1 1 1 1]; % 1.907 GHz, (OLD)
freq_tx = freq_rx + 000000; % 1kHz offset: @30 MSPS: 2.5 sines, @15 MSPS: 5 sines, @7 MSPS: 10 sines
rf_rxdc = rf_rxdc*[1 1 1 1];
tx_gain = 20*[1 1 1 1]; rx_gain = 25*[1 1 1 1]; amp=10000;
%tx_gain = 25*[1 1 1 1]; rx_gain = 0*[1 1 1 1]; amp=32000;
oarf_config_exmimo(card, freq_rx,freq_tx,0,dual_tx,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal);
sleep(1);
% create_testvector
vlen=76800
chan=1
%v=0000*exp(-i*(3*[0:vlen-1]/vlen)*2*pi); v=[v;v]'; oarf_send_frame(card,v,16); sleep(0.2);
%s = oarf_get_frame(card); figure ; plot(real(s(:,chan)),'b-.',"markersize",2) ; hold on ; plot(imag(s(:,chan)),'r-.',"markersize",2);
% create_testvector
vlen=76800
chan=1
amp=10000
%v=0000*exp(-i*(3*[0:vlen-1]/vlen)*2*pi); v=[v;v]'; oarf_send_frame(card,v,16); sleep(0.2);
%s = oarf_get_frame(card); figure ; plot(real(s(:,chan)),'b-.',"markersize",2) ; hold on ; plot(imag(s(:,chan)),'r-.',"markersize",2);
v=amp*exp(-i*(10000*[0:vlen-1]/vlen)*2*pi); v=[v;v]';
%for gainimb_tx = -0.05:0.01:0.05
%for phaseimb_tx= -5:1:5
gainimb_tx = -0.028; % gain imabalance of modulator in linear scale
phaseimb_tx = 3.0; % phase imbalance of modulator in degrees
gainimb_tx = -0.028; phaseimb_tx = 3.0; % for exmimo2-1 lime1
phaseimb_tx = phaseimb_tx/180*pi; % phaser imb in radians
beta_tx = (1/2)*(1 + (1+ gainimb_tx) * exp(1i*phaseimb_tx));
alpha_tx = (1/2)*(1 - (1+ gainimb_tx) * exp(-1i*phaseimb_tx));
den=abs(beta_tx)^2-abs(alpha_tx)^2;
beta_tx=beta_tx/den;
alpha_tx=alpha_tx/den;
v = beta_tx.*v + alpha_tx.*conj(v);
sleep(0.5); oarf_send_frame(card,v,16);
% Basic configuration script for ExpressMIMO-1 and ExpressMIMO-2
% Some functions are only available on ExpressMIMO-2!
limeparms;
eNBflag = 0;
card=0;
tdd_config = TXRXSWITCH_LSB;
%tdd_config = TXRXSWITCH_TESTTX;
syncmode = SYNCMODE_FREE;
%% acquisition
%rf_mode = ( RXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM + RXOUTSW )*[1 1 0 0];
rf_mode = ( RXEN + TXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM )*[ 1 0 0 0 ];
%rf_mode = rf_mode + (RXEN+TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM )*[ 0 1 0 0 ];
% internal loopback test
%rf_mode = (RXEN+TXEN+TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAByp+RFBBLNA1)*[1 1 0 0];
%rf_mode = (RXEN+TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA.1ON+LNAByp+RFBBLNA1)*[1 1 1 1];
%rf_mode = [0 0 0 0];
%% Select DMA directions
%rf_mode = rf_mode + (DMAMODE_RX)*[0 1 0 0];
%rf_mode = rf_mode + (DMAMODE_RX)*[0 0 1 1];
%rf_mode = rf_mode + (DMAMODE_TX)*[1 1 0 0];
rf_mode = rf_mode + (DMAMODE_RX + DMAMODE_TX)*[ 1 0 0 0 ];
%rf_mode = rf_mode + (DMAMODE_RX )*[0 1 0 0];
%rf_mode = rf_mode + (DMAMODE_TX)*[1 0 0 0]; rf_mode = rf_mode + (DMAMODE_RX)*[0 1 0 0];
%freq_rx = 749600000*[1 1 1 1];
%rf_local= [8255004 8253440 8257340 8257340]; % 700 MHz
%rf_vcocal=((0x24)*(2^6)) + (0x24)*[1 1 1 1]; % 700 MHz
freq_rx = (1907600000 - 0*9000)*[1 1 1 1];
%rf_local= [rfl( 0, 0,31,31) rfl(28,44,31,31) rfl(60,60,31,31) rfl(60,60,31,31)]; % 1.9 GHz, OLD
%rf_local= [rfl(56,56,31,31) rfl(16,12,31,31) rfl(36,48,31,31) rfl(32,20,31,31)]; % 1.9 GHz, Exmimo2-No1, lime_cal_exmimo
%rf_local= [rfl(34,40,31,31) rfl(20,25,38,21) rfl(12,38,21,14) rfl(31,19,36, 6)]; % 1.9 GHz, Exmimo2-No1, LIME GUI
rf_local= [rfl(20,25,26,04) rfl(20,25,26,04) 0 0]; % 1.9 GHz & 860 MHz, VGA2Gain=0
%rf_local= [0 rfl(20,25,38,21) 0 0 ]; % 1.9 GHz, VGA2Gain=30
rf_vcocal=(( 0xE)*(2^6)) + ( 0xE)*[1 1 1 1]; % 1.907 GHz, (OLD)
%rf_vcocal=((0x14)*(2^6)) + (0x13)*[1 1 1 1]; % 1.907 GHz, RX(msbs)+ TX(lsbs), RX:0xC..0x14, TX:0xB..0x13 (ExMIMO2-No1)
%rf_vcocal=((0x12)*(2^6)) + (0x10)*[1 1 1 1]; % 1.917 GHz, RX(msbs)+ TX(lsbs), RX:0xD..0x16, TX:0xC..0x14 (ExMIMO2-No1)
%freq_rx = ( 860000000 - 0*9000)*[1 1 1 1];
%rf_vcocal=((0x1d)*(2^6)) + (0x1d)*[1 1 1 1]; % 860 MHz
freq_tx = freq_rx + 0000000; % 1kHz offset: @30 MSPS: 2.5 sines, @15 MSPS: 5 sines, @7 MSPS: 10 sines
tx_gain = 13*[1 1 1 1];
rx_gain = 20*[1 1 1 1];
rf_rxdc = rf_rxdc*[1 1 1 1];
rffe_rxg_low = 63*[1 1 1 1];
rffe_rxg_final = 63*[1 1 1 1];
rffe_band = TVWS_TDD*[1 1 1 1];
oarf_config_exmimo(card,freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band)
%sleep(0.2)
% stuff for I/Q imbalance correction on RX
%gainimb_rx = -0.0020; phaseimb_rx = -2.38; % RX IQ imbal. ExMIMO1 / lime1, VGAgain2 = 0, 1.9 GHz
gainimb_rx = -0.0030; phaseimb_rx = -2.38; % RX IQ imbal. ExMIMO1 / lime1, VGAgain2 = 30, 1.9 GHz
phaseimb_rx = phaseimb_rx/180*pi; % phaser imb in radians
beta_rx = (1/2)*(1 + (1+ gainimb_rx) * exp(1i*phaseimb_rx));
alpha_rx = (1/2)*(1 - (1+ gainimb_rx) * exp(-1i*phaseimb_rx));
den=abs(beta_rx)^2-abs(alpha_rx)^2;
beta_rx=beta_rx/den;
alpha_rx=alpha_rx/den;
% create_testvector
vlen=76800
%v=10000*exp(-i*2*pi*1/7.68*[0:vlen-1]); v=[v;v]'; oarf_send_frame(card,v,16);
%v=([2:1+vlen; 10002:10001+vlen] - i*[3:2+vlen; 10003:10002+vlen])';
%v=32767*(1+i)*ones(vlen,2); oarf_send_frame(card,v,16);
%v = floor(( [640:639+vlen ; 640:639+vlen] / 5 ))'; oarf_send_frame(card,v,16);
%v = floor(( [75000:-1:75001-vlen ; 75000:-1:75001-vlen] / 5 ))'; oarf_send_frame(card,v,16);
%v=i*2^11*ones(vlen,2)+2^11*ones(vlen,2); oarf_send_frame(card,v,16);
%v=15000*exp(-i*2*pi*1/7.68*[0:vlen-1]); v=[v;v]'; oarf_send_frame(card,v,16);
%v=10000*exp(-i*(3000*[0:vlen-1]/vlen)*2*pi); v=[v;v]'; oarf_send_frame(card,v,16);
%v=20000*exp(-i*pi*(0:vlen-1)/2); v=[v;v]'; oarf_send_frame(card,v,16);
% Set LSB to RX (,1) or to TX(,0)
%v=10000*m'.*exp(-i*(50*[0:vlen-1]/vlen)*2*pi); v=bitset(real(v),1,0) + i*bitset(imag(v),1,0); v=[v;v]'; oarf_send_frame(card,v,16);
v2=15000*sin((1:vlen)/vlen*2*pi); v2=[v2;v2]';
v=15000*exp(i*2*pi*1/7.68*[1:vlen]); v=[v;v]';
%oarf_send_frame(card,v,16);
%len=1000;off=0; chan=2; s=oarf_get_frame(card); hold off ; plot(real(s(off+1:off+len,chan)),'-o',"markersize",2) ; hold on ; plot(imag(s(off+1:off+len,chan)),'r-o',"markersize",2)
%chan=1; s = oarf_get_frame(card); hold off ; plot(real(s(:,chan)),'b-o',"markersize",2) ; hold on ; plot(imag(s(:,chan)),'r-o',"markersize",2)
%while 1;len=5000;off=0; chan=1; s = oarf_get_frame(card); hold off ; plot(real(s(off+1:off+len,chan)),'-o',"markersize",2) ; hold on ; plot(imag(s(off+1:off+len,chan)),'r-o',"markersize",3); sleep(0.3);endwhile
%chan=2; s=oarf_get_frame(card); s=s-0.99999*mean(s(:,chan)); s = beta_rx.*s + alpha_rx.*conj(s); hold off ; plot(20*log10(abs(fftshift(fft(s(:,chan)))))); grid on; min_r=min(real(s(:,chan))); min_i=min(imag(s(:,chan))); max_r=max(real(s(:,chan))); max_i=max(imag(s(:,chan))); disp("Min-I/Q Max-I/Q"); disp([min_r min_i max_r max_i]);
%chan=2; s=oarf_get_frame(card); s=s-0.99999*mean(s(:,chan)); s = beta_rx.*s + alpha_rx.*conj(s); hold off ; plot(20*log10(abs(fftshift(fft(hamming(vlen).*s(:,chan)))))); grid on; min_r=min(real(s(:,chan))); min_i=min(imag(s(:,chan))); max_r=max(real(s(:,chan))); max_i=max(imag(s(:,chan))); disp("Min-I/Q Max-I/Q"); disp([min_r min_i max_r max_i]);
% Switch off limes
limeparms;
eNBflag = 0;
card=-1;
tdd_config = TXRXSWITCH_LSB;
%tdd_config = TXRXSWITCH_TESTTX;
syncmode = SYNCMODE_FREE;
rf_mode = [0 0 0 0];
%% Select DMA directions
rf_mode = rf_mode + (DMAMODE_RX + DMAMODE_TX)*[ 1 0 0 0 ];
rf_mode = rf_mode + (DMAMODE_RX )*[0 1 0 0];
freq_rx = (1907593260)*[1 1 1 1];
rf_local= [0 0 0 0 ];
rf_vcocal=(( 0xE)*(2^6)) + ( 0xE)*[1 1 1 1]; % 1.907 GHz, (OLD)
freq_tx = freq_rx + 0000000; % 1kHz offset: @30 MSPS: 2.5 sines, @15 MSPS: 5 sines, @7 MSPS: 10 sines
tx_gain = 13*[1 1 1 1];
rx_gain = 10*[1 1 1 1];
rf_rxdc = (1 + 1*(2^8))*[1 1 1 1]; % I:LSB, Q:MSB
oarf_config_exmimo(card,freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal)
oarf_stop(-1);
%sleep(0.2)
% Basic configuration script for ExpressMIMO-1 and ExpressMIMO-2
% Some functions are only available on ExpressMIMO-2!
limeparms;
eNBflag = 0;
card=0;
tdd_config = TXRXSWITCH_LSB;
%tdd_config = TXRXSWITCH_TESTTX;
tdd_config += TEST_ADACLOOP_EN;
syncmode = SYNCMODE_FREE;
%% acquisition
%rf_mode = ( RXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM + RXOUTSW )*[1 1 0 0];
rf_mode = ( RXEN + TXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM )*[ 1 1 0 0 ];
%% Select DMA directions
rf_mode = rf_mode + (DMAMODE_RX + DMAMODE_TX)*[ 1 0 0 0 ];
rf_mode = rf_mode + (DMAMODE_TX )*[0 1 0 0];
freq_rx = (1907600000)*[1 1 1 1];
rf_local= [rfl(20,25,26,04) rfl(20,25,26,04) 0 0]; % 1.9 GHz & 860 MHz, VGA2Gain=0
rf_vcocal=(( 0xE)*(2^6)) + ( 0xE)*[1 1 1 1]; % 1.907 GHz, (OLD)
freq_tx = freq_rx + 0000000; % 1kHz offset: @30 MSPS: 2.5 sines, @15 MSPS: 5 sines, @7 MSPS: 10 sines
tx_gain = 13*[1 1 1 1];
rx_gain = 20*[1 1 1 1];
rf_rxdc = (1 + 1*(2^8))*[1 1 1 1]; % I:LSB, Q:MSB
rffe_rxg_low = 61*[1 1 1 1];
rffe_rxg_final = 61*[1 1 1 1];
rffe_band = B19G_TDD*[1 1 1 1];
oarf_config_exmimo(card,freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band)
% create_testvector
vlen=76800
v = floor(( [ (201:200+60000) - i*(101:100+60000) ] ))' - (30000+i*30000);
v = [v; floor(( [ (201:200+vlen-60000) - i*(101:100+vlen-60000) ] ))' - (30000+i*30000) ];
%v=([11:10+vlen] - i*[101:100+vlen])'; % attention, doesn't wrap!
%v=15000*exp(-i*2*pi*1/7.68*[0:vlen-1])';
v2=30000*(1+i)*ones(vlen,2);
oarf_send_frame(card,[v v2],16);
sleep(2); % need this, otherwise, get_frame will return garbage sometimes
%len=1000;off=0; chan=2; hold off ; plot(real(s(off+1:off+len,chan)),'-o',"markersize",2) ; hold on ; plot(imag(s(off+1:off+len,chan)),'r-o',"markersize",2)
chan=1; s = oarf_get_frame(card); hold off ; grid on; plot(real(s(:,chan)),'b-o',"markersize",2) ; hold on ; plot(imag(s(:,chan)),'r-o',"markersize",2)
% Try out multicard setup
limeparms;
eNBflag = 0;
tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_LSB;
rf_mode = ( RXEN + TXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM )*[1 0 0 0];
rf_mode = rf_mode + (DMAMODE_RX + DMAMODE_TX)*[1 0 0 0];
freq_rx = (1908600000 - 0*9000)*[1 1 1 1];
freq_tx = freq_rx + 0000000; % 1kHz offset: @30 MSPS: 2.5 sines, @15 MSPS: 5 sines, @7 MSPS: 10 sines
rf_local= [ rfl(20,25,26,04) 0 0 0 ]; % 1.9 GHz & 860 MHz, VGA2Gain=0
rf_vcocal=(( 0xE)*(2^6)) + ( 0xE)*[1 1 1 1]; % 1.907 GHz, (OLD)
tx_gain = 13*[1 1 1 1];
rx_gain = 20*[1 1 1 1];
rf_rxdc = rf_rxdc*[1 1 1 1];
% set first card to slave mode
card=1; % -1 for all cards
syncmode = SYNCMODE_SLAVE;
oarf_config_exmimo(card,freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal)
sleep(1)
% set second card to master mode
card=0; % -1 for all cards
syncmode = SYNCMODE_MASTER;
oarf_config_exmimo(card,freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal)
sleep(1)
% create_testvector
vlen=76800
%v=5000*exp(-i*(300*[0:vlen-1]/vlen)*2*pi); v=[v;v;v;v]'; oarf_send_frame(0,v,16);
%v=5000*exp(-i*( 30*[0:vlen-1]/vlen)*2*pi); v=[v;v;v;v]'; oarf_send_frame(1,v,16);
%len=1000;off=0; chan=2; s=oarf_get_frame(card); hold off ; plot(real(s(off+1:off+len,chan)),'-o',"markersize",2) ; hold on ; plot(imag(s(off+1:off+len,chan)),'r-o',"markersize",2)
%while 1;len=5000;off=0; chan=1; s = oarf_get_frame(card); hold off ; plot(real(s(off+1:off+len,chan)),'-o',"markersize",2) ; hold on ; plot(imag(s(off+1:off+len,chan)),'r-o',"markersize",3); sleep(0.3);endwhile
%while 1;len=vlen;off=0; chan=[1 5]; s = oarf_get_frame(-1); hold off ; plot(real(s(off+1:off+len,chan)),'-o',"markersize",2) ; hold on ; plot(imag(s(off+1:off+len,chan)),'r-o',"markersize",3); sleep(0.5);endwhile
v = 5000* [ zeros(1,1000) ones(1,500) zeros(1,500) ones(1,1) zeros(1,vlen-1000-1000-1)]; v=[v;v;v;v]'; oarf_send_frame(1,v,16);
sleep(1)
len=2500;off=0; chan=[1 5]; s = oarf_get_frame(-1); hold off ; plot(real(s(off+1:off+len,chan)),'-o',"markersize",2) ; hold on ; plot(imag(s(off+1:off+len,chan)),'r-o',"markersize",2);
dual_tx=0;
eNBflag = 0;
card=0;
limeparms;
% internal loopback test
rf_mode = (RXEN+TXEN+TXLPFNORM+TXLPFEN+TXLPF5+RXLPFNORM+RXLPFEN+RXLPF5+LNA1ON+LNAByp+RFBBLNA1)*[1 1 0 0];
%rf_mode = [0 0 0 0];
%% Select DMA directions
%rf_mode = rf_mode + (DMAMODE_RX)*[1 0 0 0 ];
%rf_mode = rf_mode + (DMAMODE_RX)*[1 1 0 0];
%rf_mode = rf_mode + (DMAMODE_TX)*[1 1 0 0];
%rf_mode = rf_mode + (DMAMODE_RX + DMAMODE_TX)*[1 0 0 0];
rf_mode = rf_mode + (DMAMODE_RX + DMAMODE_TX)*[1 0 0 0];
freq_rx = 1907600000*[1 1 1 1];
rf_local= [8254744 8255063 8257340 8257340]; % 1.9 GHz
rf_vcocal=((0xE)*(2^6)) + (0xE)*[1 1 1 1]; % 1.9 GHz
freq_tx = freq_rx + 1;
tx_gain = 25*[1 1 1 1];
rx_gain = 20*[1 1 1 1];
rf_rxdc = rf_rxdc*[1 1 1 1];
oarf_config_exmimo(card, freq_rx,freq_tx,0,dual_tx,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal)
% create_testvector
vlen=76800
%v=([2:1+vlen; 10002:10001+vlen] - i*[3:2+vlen; 10003:10002+vlen])'; % achtung, wrapped nicht!
v = floor(( [640:639+vlen ; 640:639+vlen] / 5 ))';
break
sleep(5)
oarf_send_frame(card,v,16);
%len=1000;off=0; chan=2; hold off ; plot(real(s(off+1:off+len,chan)),'-o',"markersize",2) ; hold on ; plot(imag(s(off+1:off+len,chan)),'r-o',"markersize",2)
chan=1; s = oarf_get_frame(card); hold off ; plot(real(s(:,chan)),'b',"markersize",1) ; % hold on ; plot(imag(s(:,chan)),'r',"markersize",1)
This diff is collapsed.
close all
clear all
hold off
card = 0;
% Maxime Guillaud - created Wed May 10 18:08:04 CEST 2006
gpib_card=0; % first GPIB PCI card in the computer
gpib_device=28; % this is configured in the signal generator Utilities->System->GPIB->Address menu
cables_loss_dB = 6; % we need to account for the power loss between the signal generator and the card input (splitter, cables)
dual_tx = 0;
tdd = 1;
fc = 1907600e3; % this has to be the same as in the config file
fs = 7680e3;
%fs = 6500e3;
fref = fc+fs/4;
power_dBm=-70;
f_off_min = 1e6;
limeparms;
%rf_mode = (RXEN+TXEN+TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAMax+RFBBNORM)*[1 1 1 1];
rf_mode = (RXEN+0+TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAMax+RFBBNORM+DMAMODE_RX+0)*[1 0 0 0];
freq_rx = fc*[1 0 0 0];
freq_tx = freq_rx+1920000;
rx_gain = 30*[1 1 1 1];
tx_gain = 25*[1 1 1 1];
%rf_local=rf_local*[1 1 1 1];
rf_local = [8254813 8255016 8254813 8254813]; %exmimo2_2
%rf_rxdc =rf_rxdc*[1 1 1 1];
rf_rxdc = [37059 35459 36300 36999]; %exmimo2_2
rf_vcocal=rf_vcocal_19G*[1 1 1 1];
tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_LSB;
syncmode = SYNCMODE_FREE;
rffe_rxg_low = 63*[1 1 1 1];
rffe_rxg_final = 63*[1 1 1 1];
rffe_band = B19G_TDD*[1 1 1 1];
%gpib_send(gpib_card,gpib_device,'*RST;*CLS'); % reset and configure the signal generator
%gpib_send(gpib_card,gpib_device,['POW ' int2str(power_dBm+cables_loss_dB) 'dBm']);
%gpib_send(gpib_card,gpib_device,['FREQ 1.91860 Ghz']); % set the frequency
%gpib_send(gpib_card,gpib_device,['FREQ ' int2str(fref/1e3) 'khz']); % set the frequency
%gpib_send(gpib_card,gpib_device,'OUTP:STAT ON'); % activate output
%keyboard;
sleep(2)
step = 4096;
i=0;
do
format long
fc
freq_rx = fc*[1 0 0 0];
freq_tx = freq_rx+1920000;
oarf_config_exmimo(card, freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,0,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band);
i=i+1;
sleep(1);
s=oarf_get_frame(card); %oarf_get_frame
nb_rx = 1; %size(s,2);
% find the DC component
m = mean(s);
s_phase = unwrap(angle(s(10000:4:length(s),1).'));
s_phase = s_phase - s_phase(1,1);
f_off = mean(s_phase(2:length(s_phase))*fs/4./(1:(length(s_phase)-1))/2/pi)
plot(1:length(s_phase),s_phase,'r');
if (nb_rx>1)
s_phase2 = unwrap(angle(s(10000:4:length(s),2).'));
s_phase2 = s_phase2 - s_phase2(1,1);
f_off2 = mean(s_phase2(2:length(s_phase2))*fs/4./(1:(length(s_phase2)-1))/2/pi)
hold on
plot(1:length(s_phase2),s_phase2,'g');
drawnow;
hold off
end
if (abs(f_off) < f_off_min)
f_off_min = abs((f_off));
end
if ((f_off) > 0)
fc = fc + step;
else
fc = fc - step;
endif
step = step/2;
until (step < 50)