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:
committed by
Robert Schmidt
parent
4c698bce2b
commit
95a8767383
@@ -106,7 +106,7 @@
|
||||
#define CONFIG_HLP_SNR "Set average SNR in dB (for --siml1 option)\n"
|
||||
#define CONFIG_HLP_NOS1 "Disable s1 interface\n"
|
||||
#define CONFIG_HLP_NOKRNMOD "(noS1 only): Use tun instead of namesh module \n"
|
||||
|
||||
#define CONFIG_HLP_AGC "Rx Gain control used for UE"
|
||||
/*--------------------------------------------------------------------------------------------------------------------------------*/
|
||||
/* command line parameters for LOG utility */
|
||||
/* optname helpstr paramflags XXXptr defXXXval type numelt */
|
||||
|
||||
+38
-5
@@ -351,10 +351,31 @@ typedef struct {
|
||||
int rx_offset;
|
||||
} syncData_t;
|
||||
|
||||
static int nr_ue_adjust_rx_gain(PHY_VARS_NR_UE *UE, openair0_config_t *cfg0, int gain_change)
|
||||
{
|
||||
// Increase the RX gain by the value determined by adjust_rxgain
|
||||
cfg0->rx_gain[0] += gain_change;
|
||||
|
||||
// Set new RX gain.
|
||||
int ret_gain = UE->rfdevice.trx_set_gains_func(&UE->rfdevice, cfg0);
|
||||
// APPLY RX gain again if crossed the MAX RX gain threshold
|
||||
if (ret_gain < 0) {
|
||||
gain_change += ret_gain;
|
||||
cfg0->rx_gain[0] += ret_gain;
|
||||
ret_gain = UE->rfdevice.trx_set_gains_func(&UE->rfdevice, cfg0);
|
||||
}
|
||||
|
||||
int applied_rxgain = cfg0->rx_gain[0] - cfg0->rx_gain_offset[0];
|
||||
LOG_I(PHY, "Rxgain adjusted by %d dB, RX gain: %d dB \n", gain_change, applied_rxgain);
|
||||
|
||||
return gain_change;
|
||||
}
|
||||
|
||||
static void UE_synch(void *arg) {
|
||||
syncData_t *syncD = (syncData_t *)arg;
|
||||
PHY_VARS_NR_UE *UE = syncD->UE;
|
||||
UE->is_synchronized = 0;
|
||||
openair0_config_t *cfg0 = &openair0_cfg[UE->rf_map.card];
|
||||
|
||||
if (UE->target_Nid_cell != -1) {
|
||||
LOG_W(NR_PHY, "Starting re-sync detection for target Nid_cell %i\n", UE->target_Nid_cell);
|
||||
@@ -386,18 +407,30 @@ static void UE_synch(void *arg) {
|
||||
|
||||
// rerun with new cell parameters and frequency-offset
|
||||
// todo: the freq_offset computed on DL shall be scaled before being applied to UL
|
||||
nr_rf_card_config_freq(&openair0_cfg[UE->rf_map.card], ul_carrier, dl_carrier, freq_offset);
|
||||
nr_rf_card_config_freq(cfg0, ul_carrier, dl_carrier, freq_offset);
|
||||
|
||||
if (get_nrUE_params()->agc) {
|
||||
nr_ue_adjust_rx_gain(UE, cfg0, UE->adjust_rxgain);
|
||||
}
|
||||
|
||||
LOG_I(PHY,
|
||||
"Got synch: hw_slot_offset %d, carrier off %d Hz, rxgain %f (DL %f Hz, UL %f Hz)\n",
|
||||
hw_slot_offset,
|
||||
freq_offset,
|
||||
openair0_cfg[UE->rf_map.card].rx_gain[0],
|
||||
openair0_cfg[UE->rf_map.card].rx_freq[0],
|
||||
openair0_cfg[UE->rf_map.card].tx_freq[0]);
|
||||
cfg0->rx_gain[0] - cfg0->rx_gain_offset[0],
|
||||
cfg0->rx_freq[0],
|
||||
cfg0->tx_freq[0]);
|
||||
|
||||
UE->rfdevice.trx_set_freq_func(&UE->rfdevice, &openair0_cfg[0]);
|
||||
UE->rfdevice.trx_set_freq_func(&UE->rfdevice, cfg0);
|
||||
UE->is_synchronized = 1;
|
||||
} else {
|
||||
int gain_change = 0;
|
||||
if (get_nrUE_params()->agc)
|
||||
gain_change = nr_ue_adjust_rx_gain(UE, cfg0, INCREASE_IN_RXGAIN);
|
||||
if (gain_change)
|
||||
LOG_I(PHY, "synch retry: Rx gain increased \n");
|
||||
else
|
||||
LOG_E(PHY, "synch Failed: \n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
{"num-ues", NULL, 0, .iptr=&(NB_UE_INST), .defuintval=1, TYPE_INT, 0}, \
|
||||
{"ntn-koffset", CONFIG_HLP_NTN_KOFFSET, 0, .uptr=&(nrUE_params.ntn_koffset), .defuintval=0, TYPE_UINT, 0}, \
|
||||
{"ntn-ta-common", CONFIG_HLP_NTN_TA_COMMON, 0, .dblptr=&(nrUE_params.ntn_ta_common), .defdblval=0.0, TYPE_DOUBLE, 0}, \
|
||||
{"agc", CONFIG_HLP_AGC, PARAMFLAG_BOOL, .iptr=&(nrUE_params.agc), .defintval=0, TYPE_INT, 0}, \
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
@@ -90,6 +91,7 @@ typedef struct {
|
||||
int ldpc_offload_flag;
|
||||
unsigned int ntn_koffset;
|
||||
double ntn_ta_common;
|
||||
int agc;
|
||||
} nrUE_params_t;
|
||||
extern uint64_t get_nrUE_optmask(void);
|
||||
extern uint64_t set_nrUE_optmask(uint64_t bitmask);
|
||||
|
||||
Reference in New Issue
Block a user