Commit 107b352c authored by Florian Kaltenberger's avatar Florian Kaltenberger
Browse files

replaced gpib_send with socket interface


git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5932 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 1f5551df
......@@ -2,26 +2,28 @@ close all
clear all
hold off
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
%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
smbv_ip_addr = "192.168.12.201";
command = [getenv("OPENAIR_TARGETS") "/TEST/ROHDE_SCHWARZ/EthernetRawCommand.out"];
fc = 1907600e3;
%fc = 1907600e3;
fc = 2.6e9;
%fc=800e6;
fs = 7680e3;
fref = fc+fs/4;
power_dBm = -100;
cables_loss_dB = 6; % we need to account for the power loss between the signal generator and the card input (splitter, cables)
power_dBm = [-70 -80 -90]+20;
cables_loss_dB = 12; % we need to account for the power loss between the signal generator and the card input (splitter, cables)
dual_tx = 0;
tdd = 1;
card = 0;
limeparms;
%rf_mode = (RXEN+TXEN+TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAMax+RFBBNORM+DMAMODE_RX+DMAMODE_TX)*[1 1 1 1];
rf_mode1 = (RXEN+0+TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAMax+RFBBNORM+DMAMODE_RX+0);
rf_mode2 = (RXEN+0+TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA2ON+LNAMax+RFBBNORM+DMAMODE_RX+0);
rf_mode = [rf_mode1 rf_mode2 0 0];
freq_rx = 1907600000*[1 1 1 1];
rf_mode = (RXEN+0+TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAMax+RFBBNORM+DMAMODE_RX+0)*[1 1 1 1];
freq_rx = fc*[1 1 1 1];
freq_tx = freq_rx;
tx_gain = 25*[1 1 1 1];
rx_gain = 15*[1 1 1 1];
......@@ -32,85 +34,96 @@ rf_local = [8254813 8255016 8254813 8254813]; %exmimo2_2
rf_rxdc = [37059 35459 36300 36999]; %exmimo2_2
rf_vcocal=rf_vcocal_19G*[1 1 1 1];
eNBflag = 0;
tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_LSB;
syncmode = SYNCMODE_FREE;
tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_TESTRX;
%syncmode = SYNCMODE_FREE;
syncmode = [SYNCMODE_MASTER SYNCMODE_SLAVE];
rffe_rxg_low = 63*[1 1 1 1];
rffe_rxg_final = 63*[1 1 1 1];
rffe_band = B19G_TDD*[1 1 1 1];
autocal = [1 1 1 1];
resampling_factor = [2 2 2 2];
gpib_send(gpib_card,gpib_device,'*RST;*CLS'); % reset and configure the signal generator
system(sprintf('%s %s ''*RST;*CLS''',command, smbv_ip_addr)); % reset and configure the signal generator
%gpib_send(gpib_card,gpib_device,sprintf("POW %ddBm",power_dBm+cables_loss_dB));
gpib_send(gpib_card,gpib_device,'POW -14dBm');
%gpib_send(gpib_card,gpib_device,'POW -14dBm');
%gpib_send(gpib_card,gpib_device,'FREQ 1.91860GHz');
%gpib_send(gpib_card,gpib_device,'FREQ 1.919225GHz');
%gpib_send(gpib_card,gpib_device,'FREQ 1.909225GHz');
gpib_send(gpib_card,gpib_device,sprintf("FREQ %dHz",fref));
system(sprintf('%s %s ''FREQ %ldHz''',command,smbv_ip_addr,fref));
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);
for card=1:oarf_get_num_detected_cards
oarf_config_exmimo(card-1,freq_rx,freq_tx,tdd_config,syncmode(card),rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal,resampling_factor);
end
autocal = [0 0 0 0];
ALL_rxrfmode = [LNAByp LNAMed LNAMax];
ALL_gain = 0:10:30;
SpN0 = zeros(length(ALL_rxrfmode),length(ALL_gain));
SpN1 = zeros(length(ALL_rxrfmode),length(ALL_gain));
N0 = zeros(length(ALL_rxrfmode),length(ALL_gain));
N1 = zeros(length(ALL_rxrfmode),length(ALL_gain));
S0 = zeros(length(ALL_rxrfmode),length(ALL_gain));
S1 = zeros(length(ALL_rxrfmode),length(ALL_gain));
G0 = zeros(length(ALL_rxrfmode),length(ALL_gain));
G1 = zeros(length(ALL_rxrfmode),length(ALL_gain));
NF0 = zeros(length(ALL_rxrfmode),length(ALL_gain));
NF1 = zeros(length(ALL_rxrfmode),length(ALL_gain));
SNR0 = zeros(length(ALL_rxrfmode),length(ALL_gain));
SNR1 = zeros(length(ALL_rxrfmode),length(ALL_gain));
ALL_gain = 0:5:30;
num_chains = 4*oarf_get_num_detected_cards;
SpN0 = zeros(length(ALL_rxrfmode),length(ALL_gain),num_chains);
%SpN1 = zeros(length(ALL_rxrfmode),length(ALL_gain));
N0 = zeros(length(ALL_rxrfmode),length(ALL_gain),num_chains);
%N1 = zeros(length(ALL_rxrfmode),length(ALL_gain));
S0 = zeros(length(ALL_rxrfmode),length(ALL_gain),num_chains);
S0_lin = zeros(length(ALL_rxrfmode),length(ALL_gain),num_chains);
%S1 = zeros(length(ALL_rxrfmode),length(ALL_gain),num_chains);
G0 = zeros(length(ALL_rxrfmode),length(ALL_gain),num_chains);
%G1 = zeros(length(ALL_rxrfmode),length(ALL_gain));
NF0 = zeros(length(ALL_rxrfmode),length(ALL_gain),num_chains);
%NF1 = zeros(length(ALL_rxrfmode),length(ALL_gain));
SNR0 = zeros(length(ALL_rxrfmode),length(ALL_gain),num_chains);
%SNR1 = zeros(length(ALL_rxrfmode),length(ALL_gain));
%keyboard
idx_power = 1;
for LNA=ALL_rxrfmode
for mode_idx = 1:3
LNA=ALL_rxrfmode(mode_idx);
%gpib_send(gpib_card,gpib_device,['POW ' int2str(power_dBm+cables_loss_dB) 'dBm']);
system(sprintf('%s %s ''POW %d dBm''',command,smbv_ip_addr,power_dBm(mode_idx)+cables_loss_dB));
idx_gain = 1;
for rx_gain=ALL_gain
rf_mode = (RXEN+TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNA+RFBBNORM+DMAMODE_RX)*[1 1 0 0];
rf_mode = (RXEN+TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNA+RFBBNORM+DMAMODE_RX)*[1 1 1 1];
rx_gain = rx_gain * [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);
for card=1:oarf_get_num_detected_cards
oarf_config_exmimo(card-1,freq_rx,freq_tx,tdd_config,syncmode(card),rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal,resampling_factor);
end
sleep(1);
% signal measurement
gpib_send(gpib_card,gpib_device,'OUTP:STAT ON'); % activate output
system(sprintf('%s %s ''OUTP:STAT ON''',command,smbv_ip_addr)); % activate output
sleep(.5);
s=oarf_get_frame(card);
s=oarf_get_frame(0);
sleep(.5);
SpN0(idx_power,idx_gain) = mean(abs(s(:,1)).^2) - abs(mean(s(:,1))).^2;
SpN1(idx_power,idx_gain) = mean(abs(s(:,2)).^2) - abs(mean(s(:,2))).^2;
SpN0(idx_power,idx_gain,:) = mean(abs(s).^2,1) - abs(mean(s,1)).^2;
%SpN1(idx_power,idx_gain) = mean(abs(s(:,2)).^2) - abs(mean(s(:,2))).^2;
figure(1);
hold off
plot(20*log10(abs(fft(s(:,1)))),'r',20*log10(abs(fft(s(:,2)))),'b')
plot(20*log10(abs(fft(s(:,end)))),'r'); %,20*log10(abs(fft(s(:,2)))),'b')
title("Signal");
ylim([0 200]);
% noise measurement
gpib_send(gpib_card,gpib_device,'OUTP:STAT OFF'); % deactivate output
system(sprintf('%s %s ''OUTP:STAT OFF''',command,smbv_ip_addr)); % deactivate output
sleep(.5);
s=oarf_get_frame(card); %oarf_get_frame
s=oarf_get_frame(0); %oarf_get_frame
sleep(.5);
N0(idx_power,idx_gain) = mean(abs(s(:,1)).^2) - abs(mean(s(:,1))).^2;
N1(idx_power,idx_gain) = mean(abs(s(:,2)).^2) - abs(mean(s(:,2))).^2;
N0(idx_power,idx_gain,:) = mean(abs(s).^2,1) - abs(mean(s,1)).^2;
%N1(idx_power,idx_gain) = mean(abs(s(:,2)).^2) - abs(mean(s(:,2))).^2;
figure(2);
hold off
plot(20*log10(abs(fft(s(:,1)))),'r',20*log10(abs(fft(s(:,2)))),'b')
plot(20*log10(abs(fft(s(:,end)))),'r'); %,20*log10(abs(fft(s(:,2)))),'b')
title("Noise");
ylim([0 200]);
......@@ -120,45 +133,54 @@ for LNA=ALL_rxrfmode
% error("something is wrong");
% end
S0(idx_power,idx_gain) = 10*log10(SpN0(idx_power,idx_gain)-N0(idx_power,idx_gain));
S1(idx_power,idx_gain) = 10*log10(SpN1(idx_power,idx_gain)-N1(idx_power,idx_gain));
G0(idx_power,idx_gain) = S0(idx_power,idx_gain) - power_dBm;
G1(idx_power,idx_gain) = S1(idx_power,idx_gain) - power_dBm;
NF0(idx_power,idx_gain) = 10*log10(N0(idx_power,idx_gain)) - G0(idx_power,idx_gain) + 105; % 108 is the thermal noise
NF1(idx_power,idx_gain) = 10*log10(N1(idx_power,idx_gain)) - G1(idx_power,idx_gain) + 105;
SNR0(idx_power,idx_gain) = S0(idx_power,idx_gain)-10*log10(N0(idx_power,idx_gain));
SNR1(idx_power,idx_gain) = S1(idx_power,idx_gain)-10*log10(N1(idx_power,idx_gain));
printf(' %d: Signal strength (%f,%f), Gain (%f %f), N (%f %f) SNR (%f %f) NF (%f %f)\n',
rx_gain(1), S0(idx_power,idx_gain),S1(idx_power,idx_gain),
G0(idx_power,idx_gain),G1(idx_power,idx_gain),
10*log10(N0(idx_power,idx_gain)),10*log10(N1(idx_power,idx_gain)),
SNR0(idx_power,idx_gain),SNR1(idx_power,idx_gain),
NF0(idx_power,idx_gain),NF1(idx_power,idx_gain));
fflush(stdout);
S0_lin(idx_power,idx_gain,:) = SpN0(idx_power,idx_gain,:)-N0(idx_power,idx_gain,:);
S0_lin(idx_power,idx_gain,S0_lin(idx_power,idx_gain,:)<0) = 0;
S0(idx_power,idx_gain,:) = 10*log10(S0_lin(idx_power,idx_gain,:));
%S1(idx_power,idx_gain) = 10*log10(SpN1(idx_power,idx_gain)-N1(idx_power,idx_gain));
G0(idx_power,idx_gain,:) = S0(idx_power,idx_gain,:) - power_dBm(mode_idx);
%G1(idx_power,idx_gain) = S1(idx_power,idx_gain) - power_dBm;
NF0(idx_power,idx_gain,:) = 10*log10(N0(idx_power,idx_gain,:)) - G0(idx_power,idx_gain,:) + 105; % 108 is the thermal noise
%NF1(idx_power,idx_gain) = 10*log10(N1(idx_power,idx_gain)) - G1(idx_power,idx_gain) + 105;
SNR0(idx_power,idx_gain,:) = S0(idx_power,idx_gain,:)-10*log10(N0(idx_power,idx_gain,:));
%SNR1(idx_power,idx_gain) = S1(idx_power,idx_gain)-10*log10(N1(idx_power,idx_gain));
%printf(' %d: Signal strength (%f,%f), Gain (%f %f), N (%f %f) SNR (%f %f) NF (%f %f)\n',
% rx_gain(1), S0(idx_power,idx_gain),S1(idx_power,idx_gain),
% G0(idx_power,idx_gain),G1(idx_power,idx_gain),
% 10*log10(N0(idx_power,idx_gain)),10*log10(N1(idx_power,idx_gain)),
% SNR0(idx_power,idx_gain),SNR1(idx_power,idx_gain),
% NF0(idx_power,idx_gain),NF1(idx_power,idx_gain));
%fflush(stdout);
%fprintf(fid,'%d, %d, %d, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f\n',
%power_dBm,gain2391,gain9862, S0,S1,G0,G1,10*log10(N0),10*log10(N1),SNR0,SNR1,NF0,NF1);
idx_gain = idx_gain + 1;
figure(3)
hold off
plot(ALL_gain,G0,'o-','markersize',10)
plot(ALL_gain,G0(:,:,1),'o-','markersize',10)
hold on
plot(ALL_gain,G1,'x-','markersize',10)
plot(ALL_gain,G0(:,:,2),'x-','markersize',10)
plot(ALL_gain,G0(:,:,3),'s-','markersize',10)
plot(ALL_gain,G0(:,:,4),'d-','markersize',10)
legend('Byp RX0','Med RX0','Max RX0','Byp RX1','Med RX1','Max RX1');
title('Gains')
figure(4)
hold off
plot(ALL_gain,NF0,'o-','markersize',10)
plot(ALL_gain,NF0(:,:,1),'o-','markersize',10)
hold on
plot(ALL_gain,NF1,'x-','markersize',10)
plot(ALL_gain,NF0(:,:,2),'x-','markersize',10)
plot(ALL_gain,NF0(:,:,3),'s-','markersize',10)
plot(ALL_gain,NF0(:,:,4),'d-','markersize',10)
legend('Byp RX0','Med RX0','Max RX0','Byp RX1','Med RX1','Max RX1');
title('Noise Figure')
idx_gain = idx_gain + 1;
end
idx_power = idx_power + 1;
end
%gpib_send(gpib_card,gpib_device,'OUTP:STAT OFF'); % deactivate output
......
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