Automatic update of USRP RX gain during initial search using --agc option

- if search fails, keeps increasing the rx gain (set by --ue-rxgain) by
  3 db until USRP max rx gain
- if initial sync is success, sets the rxgain to the value of
  (TARGET_RX_POWER (50) - pbch digital power in dB/RE)
This commit is contained in:
Raghavendra Dinavahi
2024-07-25 15:33:44 +02:00
committed by Robert Schmidt
parent 4c698bce2b
commit 95a8767383
10 changed files with 83 additions and 26 deletions
+17 -14
View File
@@ -869,7 +869,8 @@ int trx_usrp_set_gains(openair0_device *device,
if (openair0_cfg[0].rx_gain[0]-openair0_cfg[0].rx_gain_offset[0] > gain_range.stop()) {
LOG_E(HW,"RX Gain 0 too high, reduce by %f dB\n",
openair0_cfg[0].rx_gain[0]-openair0_cfg[0].rx_gain_offset[0] - gain_range.stop());
exit(-1);
int gain_diff = gain_range.stop() - (openair0_cfg[0].rx_gain[0] - openair0_cfg[0].rx_gain_offset[0]);
return gain_diff;
}
s->usrp->set_rx_gain(openair0_cfg[0].rx_gain[0]-openair0_cfg[0].rx_gain_offset[0]);
@@ -1424,25 +1425,27 @@ extern "C" {
}
for(int i=0; i<((int) s->usrp->get_rx_num_channels()); i++) {
if (i<openair0_cfg[0].rx_num_channels) {
s->usrp->set_rx_rate(openair0_cfg[0].sample_rate,i+choffset);
uhd::tune_request_t rx_tune_req(openair0_cfg[0].rx_freq[i],
openair0_cfg[0].tune_offset);
openair0_config_t *cfg = &openair0_cfg[0];
if (i < cfg->rx_num_channels) {
s->usrp->set_rx_rate(cfg->sample_rate, i + choffset);
uhd::tune_request_t rx_tune_req(cfg->rx_freq[i], cfg->tune_offset);
s->usrp->set_rx_freq(rx_tune_req, i+choffset);
set_rx_gain_offset(&openair0_cfg[0],i,bw_gain_adjust);
set_rx_gain_offset(cfg, i, bw_gain_adjust);
::uhd::gain_range_t gain_range = s->usrp->get_rx_gain_range(i+choffset);
// limit to maximum gain
double gain=openair0_cfg[0].rx_gain[i]-openair0_cfg[0].rx_gain_offset[i];
double gain = cfg->rx_gain[i] - cfg->rx_gain_offset[i];
if ( gain > gain_range.stop()) {
LOG_E(HW,"RX Gain too high, lower by %f dB\n",
gain - gain_range.stop());
gain=gain_range.stop();
LOG_E(HW, "RX Gain too high, lower by %f dB\n", gain - gain_range.stop());
gain = gain_range.stop();
}
s->usrp->set_rx_gain(gain,i+choffset);
LOG_I(HW,"RX Gain %d %f (%f) => %f (max %f)\n",i,
openair0_cfg[0].rx_gain[i],openair0_cfg[0].rx_gain_offset[i],
openair0_cfg[0].rx_gain[i]-openair0_cfg[0].rx_gain_offset[i],gain_range.stop());
LOG_I(HW,
"RX Gain %d %f (%f) => %f (max %f)\n",
i,
cfg->rx_gain[i],
cfg->rx_gain_offset[i],
cfg->rx_gain[i] - cfg->rx_gain_offset[i],
gain_range.stop());
}
}