Commit 551a2721 authored by Rohit Gupta's avatar Rohit Gupta

First X310 Calibration and harmonization of B210 and X310 configuration

parent a208ba8c
...@@ -98,6 +98,10 @@ typedef struct { ...@@ -98,6 +98,10 @@ typedef struct {
//! \brief Center frequency in Hz for TX. //! \brief Center frequency in Hz for TX.
//! index: [0..rx_num_channels[ !!! see lte-ue.c:427 FIXME iterates over rx_num_channels //! index: [0..rx_num_channels[ !!! see lte-ue.c:427 FIXME iterates over rx_num_channels
double tx_freq[4]; double tx_freq[4];
//! \brief Pointer to Calibration table for RX gains
rx_gain_calib_table_t *rx_gain_calib_table;
//! mode for rxgain (ExpressMIMO2) //! mode for rxgain (ExpressMIMO2)
rx_gain_t rxg_mode[4]; rx_gain_t rxg_mode[4];
//! \brief Gain for RX in dB. //! \brief Gain for RX in dB.
......
...@@ -171,17 +171,30 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp ...@@ -171,17 +171,30 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp
#endif #endif
/*
if (cc>1) { if (cc>1) {
// receive multiple channels (e.g. RF A and RF B) // receive multiple channels (e.g. RF A and RF B)
std::vector<void *> buff_ptrs; std::vector<void *> buff_ptrs;
for (int i=0;i<cc;i++) buff_ptrs.push_back(buff_tmp[i]); for (int i=0;i<cc;i++) buff_ptrs.push_back(buff_tmp[i]);
samples_received = s->rx_stream->recv(buff_ptrs, nsamps, s->rx_md); samples_received = s->rx_stream->recv(buff_ptrs, nsamps, s->rx_md);
} else { } else {
// receive a single channel (e.g. from connector RF A) // receive a single channel (e.g. from connector RF A)
samples_received = s->rx_stream->recv(buff_tmp[0], nsamps, s->rx_md); samples_received = s->rx_stream->recv(buff_tmp[0], nsamps, s->rx_md);
}*/
if (cc>1) {
// receive multiple channels (e.g. RF A and RF B)
std::vector<void *> buff_ptrs;
for (int i=0;i<cc;i++) buff_ptrs.push_back(buff[i]);
samples_received = s->rx_stream->recv(buff_ptrs, nsamps, s->rx_md);
} else {
// receive a single channel (e.g. from connector RF A)
samples_received = s->rx_stream->recv(buff[0], nsamps, s->rx_md);
} }
/*
// bring RX data into 12 LSBs for softmodem RX // bring RX data into 12 LSBs for softmodem RX
for (int i=0;i<cc;i++) { for (int i=0;i<cc;i++) {
for (int j=0; j<nsamps2; j++) { for (int j=0; j<nsamps2; j++) {
...@@ -196,6 +209,8 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp ...@@ -196,6 +209,8 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp
#endif #endif
} }
} }
*/
if (samples_received < nsamps) { if (samples_received < nsamps) {
printf("[recv] received %d samples out of %d\n",samples_received,nsamps); printf("[recv] received %d samples out of %d\n",samples_received,nsamps);
...@@ -279,7 +294,7 @@ int trx_usrp_set_gains(openair0_device* device, ...@@ -279,7 +294,7 @@ int trx_usrp_set_gains(openair0_device* device,
exit(-1); exit(-1);
} }
s->usrp->set_rx_gain(openair0_cfg[0].rx_gain[0]-openair0_cfg[0].rx_gain_offset[0]); s->usrp->set_rx_gain(openair0_cfg[0].rx_gain[0]-openair0_cfg[0].rx_gain_offset[0]);
printf("Setting USRP RX gain to %f\n", openair0_cfg[0].rx_gain[0]-openair0_cfg[0].rx_gain_offset[0]); printf("Setting USRP RX gain to %f (rx_gain %f,gain_range.stop() %f)\n", openair0_cfg[0].rx_gain[0]-openair0_cfg[0].rx_gain_offset[0],openair0_cfg[0].rx_gain[0],gain_range.stop());
return(0); return(0);
} }
...@@ -289,7 +304,7 @@ int trx_usrp_stop(int card) { ...@@ -289,7 +304,7 @@ int trx_usrp_stop(int card) {
} }
rx_gain_calib_table_t calib_table[] = { rx_gain_calib_table_t calib_table_b210[] = {
{3500000000.0,46.0}, {3500000000.0,46.0},
{2660000000.0,53.0}, {2660000000.0,53.0},
{2300000000.0,54.0}, {2300000000.0,54.0},
...@@ -297,19 +312,29 @@ rx_gain_calib_table_t calib_table[] = { ...@@ -297,19 +312,29 @@ rx_gain_calib_table_t calib_table[] = {
{816000000.0,62.0}, {816000000.0,62.0},
{-1,0}}; {-1,0}};
rx_gain_calib_table_t calib_table_x310[] = {
{3500000000.0,77.0},
{2660000000.0,80.0},
{2300000000.0,81.0},
{1880000000.0,82.0},
{816000000.0,89},
{-1,0}};
void set_rx_gain_offset(openair0_config_t *openair0_cfg, int chain_index) { void set_rx_gain_offset(openair0_config_t *openair0_cfg, int chain_index) {
int i=0; int i=0;
// loop through calibration table to find best adjustment factor for RX frequency // loop through calibration table to find best adjustment factor for RX frequency
double min_diff = 6e9,diff; double min_diff = 6e9,diff;
while (calib_table[i].freq>0) { while (openair0_cfg->rx_gain_calib_table[i].freq>0) {
diff = fabs(openair0_cfg->rx_freq[chain_index] - calib_table[i].freq); diff = fabs(openair0_cfg->rx_freq[chain_index] - openair0_cfg->rx_gain_calib_table[i].freq);
printf("cal %d: freq %f, offset %f, diff %f\n", printf("cal %d: freq %f, offset %f, diff %f\n",
i,calib_table[i].freq,calib_table[i].offset,diff); i,
openair0_cfg->rx_gain_calib_table[i].freq,
openair0_cfg->rx_gain_calib_table[i].offset,diff);
if (min_diff > diff) { if (min_diff > diff) {
min_diff = diff; min_diff = diff;
openair0_cfg->rx_gain_offset[chain_index] = calib_table[i].offset; openair0_cfg->rx_gain_offset[chain_index] = openair0_cfg->rx_gain_calib_table[i].offset;
} }
i++; i++;
} }
...@@ -375,6 +400,8 @@ int openair0_dev_init_usrp(openair0_device* device, openair0_config_t *openair0_ ...@@ -375,6 +400,8 @@ int openair0_dev_init_usrp(openair0_device* device, openair0_config_t *openair0_
// this is not working yet, master clock has to be set via constructor // this is not working yet, master clock has to be set via constructor
// set master clock rate and sample rate for tx & rx for streaming // set master clock rate and sample rate for tx & rx for streaming
//s->usrp->set_master_clock_rate(usrp_master_clock); //s->usrp->set_master_clock_rate(usrp_master_clock);
openair0_cfg[0].rx_gain_calib_table = calib_table_x310;
} else { } else {
printf("Found USRP B200"); printf("Found USRP B200");
s->usrp = uhd::usrp::multi_usrp::make(args); s->usrp = uhd::usrp::multi_usrp::make(args);
...@@ -387,6 +414,8 @@ int openair0_dev_init_usrp(openair0_device* device, openair0_config_t *openair0_ ...@@ -387,6 +414,8 @@ int openair0_dev_init_usrp(openair0_device* device, openair0_config_t *openair0_
// s->usrp->set_clock_source("internal"); // s->usrp->set_clock_source("internal");
// set master clock rate and sample rate for tx & rx for streaming // set master clock rate and sample rate for tx & rx for streaming
s->usrp->set_master_clock_rate(30.72e6); s->usrp->set_master_clock_rate(30.72e6);
openair0_cfg[0].rx_gain_calib_table = calib_table_b210;
} }
......
...@@ -2965,24 +2965,28 @@ openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL; ...@@ -2965,24 +2965,28 @@ openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL;
else { else {
openair0_cfg[card].rx_gain[i] = PHY_vars_UE_g[0][0]->rx_total_gain_dB;// - USRP_GAIN_OFFSET; // calibrated for USRP B210 @ 2.6 GHz, 30.72 MS/s openair0_cfg[card].rx_gain[i] = PHY_vars_UE_g[0][0]->rx_total_gain_dB;// - USRP_GAIN_OFFSET; // calibrated for USRP B210 @ 2.6 GHz, 30.72 MS/s
} }
switch(frame_parms[0]->N_RB_DL) { switch(frame_parms[0]->N_RB_DL) {
case 6: case 6:
openair0_cfg[card].rx_gain[i] -= 6; openair0_cfg[card].rx_gain[i] -= 12;
break; break;
case 25: case 25:
openair0_cfg[card].rx_gain[i] += 6; openair0_cfg[card].rx_gain[i] -= 6;
break; break;
case 50: case 50:
openair0_cfg[card].rx_gain[i] += 8; openair0_cfg[card].rx_gain[i] -= 3;
break;
case 100:
openair0_cfg[card].rx_gain[i] -= 0;
break; break;
default: default:
break; break;
} }
} }
......
...@@ -410,6 +410,7 @@ static void *UE_thread_synch(void *arg) ...@@ -410,6 +410,7 @@ static void *UE_thread_synch(void *arg)
UE->UE_scan_carrier = 0; UE->UE_scan_carrier = 0;
// rerun with new cell parameters and frequency-offset // rerun with new cell parameters and frequency-offset
for (i=0;i<openair0_cfg[0].rx_num_channels;i++) { for (i=0;i<openair0_cfg[0].rx_num_channels;i++) {
openair0_cfg[0].rx_gain[i] = UE->rx_total_gain_dB;//-USRP_GAIN_OFFSET;
openair0_cfg[0].rx_freq[i] -= UE->lte_ue_common_vars.freq_offset; openair0_cfg[0].rx_freq[i] -= UE->lte_ue_common_vars.freq_offset;
openair0_cfg[0].tx_freq[i] = openair0_cfg[0].rx_freq[i]+uplink_frequency_offset[0][i]; openair0_cfg[0].tx_freq[i] = openair0_cfg[0].rx_freq[i]+uplink_frequency_offset[0][i];
downlink_frequency[0][i] = openair0_cfg[0].rx_freq[i]; downlink_frequency[0][i] = openair0_cfg[0].rx_freq[i];
......
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