mirror of https://github.com/PentHertz/srsLTE.git
Minor AGC bugfix in dB conversion (#817)
* Fix issue in AGC confusing dB with linear * Minor esthetic changes
This commit is contained in:
commit
be60b78ceb
|
@ -835,15 +835,15 @@ int main(int argc, char **argv) {
|
|||
#endif
|
||||
|
||||
ZERO_OBJECT(pdsch_cfg);
|
||||
for (uint32_t i = 0; i < SRSLTE_MAX_CODEWORDS; i++) {
|
||||
pdsch_cfg.softbuffers.tx[i] = softbuffers[i];
|
||||
for (uint32_t j = 0; j < SRSLTE_MAX_CODEWORDS; j++) {
|
||||
pdsch_cfg.softbuffers.tx[j] = softbuffers[j];
|
||||
}
|
||||
pdsch_cfg.rnti = UE_CRNTI;
|
||||
|
||||
pmch_cfg.pdsch_cfg = pdsch_cfg;
|
||||
|
||||
while ((nf < nof_frames || nof_frames == -1) && !go_exit) {
|
||||
for (sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME && (nf < nof_frames || nof_frames == -1); sf_idx++) {
|
||||
for (sf_idx = 0; sf_idx < SRSLTE_NOF_SF_X_FRAME && (nf < nof_frames || nof_frames == -1) && !go_exit; sf_idx++) {
|
||||
/* Set Antenna port resource elements to zero */
|
||||
bzero(sf_symbols[0], sizeof(cf_t) * sf_n_re);
|
||||
|
||||
|
@ -960,8 +960,8 @@ int main(int argc, char **argv) {
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < pmch_cfg.pdsch_cfg.grant.tb[0].tbs / 8; i++) {
|
||||
data_mbms[i] = i % 255;
|
||||
for (int j = 0; j < pmch_cfg.pdsch_cfg.grant.tb[0].tbs / 8; j++) {
|
||||
data_mbms[j] = j % 255;
|
||||
}
|
||||
|
||||
pmch_cfg.area_id = mbsfn_area_id;
|
||||
|
|
|
@ -48,8 +48,8 @@ typedef enum SRSLTE_API {
|
|||
typedef struct SRSLTE_API{
|
||||
float bandwidth;
|
||||
float gain;
|
||||
float min_gain;
|
||||
float max_gain;
|
||||
float min_gain_db;
|
||||
float max_gain_db;
|
||||
float y_out;
|
||||
bool lock;
|
||||
bool isfirst;
|
||||
|
@ -76,7 +76,7 @@ SRSLTE_API void srslte_agc_free(srslte_agc_t *q);
|
|||
|
||||
SRSLTE_API void srslte_agc_reset(srslte_agc_t *q);
|
||||
|
||||
SRSLTE_API void srslte_agc_set_gain_range(srslte_agc_t* q, float min_gain, float max_gain);
|
||||
SRSLTE_API void srslte_agc_set_gain_range(srslte_agc_t *q, float min_gain_db, float max_gain_db);
|
||||
|
||||
SRSLTE_API void srslte_agc_set_bandwidth(srslte_agc_t *q,
|
||||
float bandwidth);
|
||||
|
@ -91,7 +91,7 @@ SRSLTE_API float srslte_agc_get_output_level(srslte_agc_t *q);
|
|||
SRSLTE_API float srslte_agc_get_gain(srslte_agc_t *q);
|
||||
|
||||
SRSLTE_API void srslte_agc_set_gain(srslte_agc_t *q,
|
||||
float init_gain_value);
|
||||
float init_gain_value_db);
|
||||
|
||||
SRSLTE_API void srslte_agc_lock(srslte_agc_t *q,
|
||||
bool enable);
|
||||
|
|
|
@ -39,8 +39,8 @@ int srslte_agc_init_acc(srslte_agc_t *q, srslte_agc_mode_t mode, uint32_t nof_fr
|
|||
bzero(q, sizeof(srslte_agc_t));
|
||||
q->mode = mode;
|
||||
q->nof_frames = nof_frames;
|
||||
q->max_gain = 90.0;
|
||||
q->min_gain = 0.0;
|
||||
q->max_gain_db = 90.0;
|
||||
q->min_gain_db = 0.0;
|
||||
if (nof_frames > 0) {
|
||||
q->y_tmp = srslte_vec_malloc(sizeof(float) * nof_frames);
|
||||
if (!q->y_tmp) {
|
||||
|
@ -87,11 +87,10 @@ void srslte_agc_reset(srslte_agc_t *q) {
|
|||
}
|
||||
}
|
||||
|
||||
void srslte_agc_set_gain_range(srslte_agc_t* q, float min_gain, float max_gain)
|
||||
{
|
||||
void srslte_agc_set_gain_range(srslte_agc_t *q, float min_gain_db, float max_gain_db) {
|
||||
if (q) {
|
||||
q->min_gain = min_gain;
|
||||
q->max_gain = max_gain;
|
||||
q->min_gain_db = min_gain_db;
|
||||
q->max_gain_db = max_gain_db;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,8 +114,8 @@ float srslte_agc_get_gain(srslte_agc_t *q) {
|
|||
return q->gain;
|
||||
}
|
||||
|
||||
void srslte_agc_set_gain(srslte_agc_t *q, float init_gain_value) {
|
||||
q->gain = init_gain_value;
|
||||
void srslte_agc_set_gain(srslte_agc_t *q, float init_gain_value_db) {
|
||||
q->gain = srslte_convert_dB_to_power(init_gain_value_db);
|
||||
}
|
||||
|
||||
void srslte_agc_lock(srslte_agc_t *q, bool enable) {
|
||||
|
@ -133,14 +132,14 @@ void srslte_agc_process(srslte_agc_t *q, cf_t *signal, uint32_t len) {
|
|||
if (!q->uhd_handler) {
|
||||
srslte_vec_sc_prod_cfc(signal, q->gain, signal, len);
|
||||
} else {
|
||||
if (gain_db < q->min_gain) {
|
||||
gain_db = q->min_gain + 5.0;
|
||||
if (gain_db < q->min_gain_db) {
|
||||
gain_db = q->min_gain_db + 5.0;
|
||||
INFO("Warning: Rx signal strength is too high. Forcing minimum Rx gain %.2fdB\n", gain_db);
|
||||
} else if (gain_db > q->max_gain) {
|
||||
gain_db = q->max_gain;
|
||||
} else if (gain_db > q->max_gain_db) {
|
||||
gain_db = q->max_gain_db;
|
||||
INFO("Warning: Rx signal strength is too weak. Forcing maximum Rx gain %.2fdB\n", gain_db);
|
||||
} else if (isinf(gain_db) || isnan(gain_db)) {
|
||||
gain_db = (q->min_gain + q->max_gain) / 2.0;
|
||||
gain_db = (q->min_gain_db + q->max_gain_db) / 2.0;
|
||||
INFO("Warning: AGC went to an unknown state. Setting Rx gain to %.2fdB\n", gain_db);
|
||||
}
|
||||
|
||||
|
|
|
@ -184,12 +184,13 @@ int rf_cell_search(srslte_rf_t *rf, uint32_t nof_rx_antennas,
|
|||
} else {
|
||||
ret = srslte_ue_cellsearch_scan(&cs, found_cells, &max_peak_cell);
|
||||
}
|
||||
if (ret < 0) {
|
||||
|
||||
srslte_rf_stop_rx_stream(rf);
|
||||
|
||||
if (ret < 0) {
|
||||
ERROR("Error searching cell\n");
|
||||
return SRSLTE_ERROR;
|
||||
} else if (ret == 0) {
|
||||
srslte_rf_stop_rx_stream(rf);
|
||||
ERROR("Could not find any cell in this frequency\n");
|
||||
return SRSLTE_SUCCESS;
|
||||
}
|
||||
|
@ -221,7 +222,6 @@ int rf_cell_search(srslte_rf_t *rf, uint32_t nof_rx_antennas,
|
|||
*cfo = found_cells[max_peak_cell].cfo;
|
||||
}
|
||||
|
||||
srslte_rf_stop_rx_stream(rf);
|
||||
srslte_ue_cellsearch_free(&cs);
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -321,7 +321,7 @@ static void generate_freq_sss(srslte_sync_t* q, uint32_t N_id_1)
|
|||
srslte_dft_run_c(&q->idftp_sss, symbol, q->sss_signal[n]);
|
||||
}
|
||||
q->sss_generated = true;
|
||||
INFO("Generated SSS for N_id_1=%d, cell_id=%d\n", N_id_1, cell_id);
|
||||
DEBUG("Generated SSS for N_id_1=%d, cell_id=%d\n", N_id_1, cell_id);
|
||||
}
|
||||
|
||||
int srslte_sync_set_N_id_1(srslte_sync_t* q, uint32_t N_id_1)
|
||||
|
@ -523,7 +523,7 @@ static bool sync_sss_symbol(srslte_sync_t* q, const cf_t* input, uint32_t* sf_id
|
|||
}
|
||||
*N_id_1 = q->N_id_1;
|
||||
*corr = ratio;
|
||||
INFO("SSS correlation with N_id_1=%d, sf0=%.2f, sf5=%.2f, sf_idx=%d, ratio=%.1f\n",
|
||||
DEBUG("SSS correlation with N_id_1=%d, sf0=%.2f, sf5=%.2f, sf_idx=%d, ratio=%.1f\n",
|
||||
q->N_id_1,
|
||||
res[0],
|
||||
res[1],
|
||||
|
@ -668,7 +668,7 @@ srslte_sync_find_ret_t srslte_sync_find(srslte_sync_t *q, const cf_t *input, uin
|
|||
q->cfo_cp_mean = SRSLTE_VEC_EMA(cfo_cp, q->cfo_cp_mean, q->cfo_ema_alpha);
|
||||
}
|
||||
|
||||
INFO("CP-CFO: estimated=%f, mean=%f\n", cfo_cp, q->cfo_cp_mean);
|
||||
DEBUG("CP-CFO: estimated=%f, mean=%f\n", cfo_cp, q->cfo_cp_mean);
|
||||
|
||||
/* Correct CFO with the averaged CFO estimation */
|
||||
srslte_cfo_correct(&q->cfo_corr_frame, input_ptr, q->temp, -q->cfo_cp_mean / q->fft_size);
|
||||
|
@ -686,7 +686,7 @@ srslte_sync_find_ret_t srslte_sync_find(srslte_sync_t *q, const cf_t *input, uin
|
|||
}
|
||||
}
|
||||
|
||||
INFO("PSS: id=%d, peak_pos=%d, peak_value=%f\n", q->N_id_2, peak_pos, q->peak_value);
|
||||
DEBUG("PSS: id=%d, peak_pos=%d, peak_value=%f\n", q->N_id_2, peak_pos, q->peak_value);
|
||||
|
||||
// Save peak position
|
||||
if (peak_position) {
|
||||
|
@ -719,7 +719,7 @@ srslte_sync_find_ret_t srslte_sync_find(srslte_sync_t *q, const cf_t *input, uin
|
|||
q->cfo_pss_mean = SRSLTE_VEC_EMA(q->cfo_pss, q->cfo_pss_mean, q->cfo_ema_alpha);
|
||||
}
|
||||
|
||||
INFO("PSS-CFO: filter=%s, estimated=%f, mean=%f\n",
|
||||
DEBUG("PSS-CFO: filter=%s, estimated=%f, mean=%f\n",
|
||||
q->pss_filtering_enabled ? "yes" : "no",
|
||||
q->cfo_pss,
|
||||
q->cfo_pss_mean);
|
||||
|
|
|
@ -121,6 +121,7 @@ int srslte_ue_cellsearch_init_multi(srslte_ue_cellsearch_t* q,
|
|||
|
||||
for (int i = 0; i < nof_rx_antennas; i++) {
|
||||
q->sf_buffer[i] = srslte_vec_malloc(3 * sizeof(cf_t) * SRSLTE_SF_LEN_PRB(100));
|
||||
bzero(q->sf_buffer[i], 3 * sizeof(cf_t) * SRSLTE_SF_LEN_PRB(100));
|
||||
}
|
||||
q->nof_rx_antennas = nof_rx_antennas;
|
||||
|
||||
|
@ -263,6 +264,7 @@ int srslte_ue_cellsearch_scan(srslte_ue_cellsearch_t * q,
|
|||
uint32_t nof_detected_cells = 0;
|
||||
|
||||
for (uint32_t N_id_2=0;N_id_2<3 && ret >= 0;N_id_2++) {
|
||||
INFO("CELL SEARCH: Starting scan for N_id_2=%d\n", N_id_2);
|
||||
ret = srslte_ue_cellsearch_scan_N_id_2(q, N_id_2, &found_cells[N_id_2]);
|
||||
if (ret < 0) {
|
||||
ERROR("Error searching cell\n");
|
||||
|
@ -319,7 +321,7 @@ int srslte_ue_cellsearch_scan_N_id_2(srslte_ue_cellsearch_t * q,
|
|||
q->candidates[nof_detected_frames].psr = srslte_sync_get_peak_value(&q->ue_sync.sfind);
|
||||
q->candidates[nof_detected_frames].cfo = 15000 * srslte_sync_get_cfo(&q->ue_sync.sfind);
|
||||
q->candidates[nof_detected_frames].frame_type = srslte_ue_sync_get_frame_type(&q->ue_sync);
|
||||
DEBUG("CELL SEARCH: [%d/%d/%d]: Found peak PSR=%.3f, Cell_id: %d CP: %s, CFO=%.1f KHz\n",
|
||||
INFO("CELL SEARCH: [%d/%d/%d]: Found peak PSR=%.3f, Cell_id: %d CP: %s, CFO=%.1f KHz\n",
|
||||
nof_detected_frames,
|
||||
nof_scanned_frames,
|
||||
q->nof_valid_frames,
|
||||
|
|
|
@ -160,12 +160,12 @@ int srslte_ue_mib_decode(srslte_ue_mib_t * q,
|
|||
if (ret < 0) {
|
||||
ERROR("Error decoding PBCH (%d)\n", ret);
|
||||
} else if (ret == 1) {
|
||||
INFO("MIB decoded: %u\n", q->frame_cnt);
|
||||
INFO("MIB decoded: %u, snr=%.1f dB\n", q->frame_cnt, q->chest_res.snr_db);
|
||||
srslte_ue_mib_reset(q);
|
||||
ret = SRSLTE_UE_MIB_FOUND;
|
||||
} else {
|
||||
ret = SRSLTE_UE_MIB_NOTFOUND;
|
||||
INFO("MIB not decoded: %u\n", q->frame_cnt);
|
||||
INFO("MIB not decoded: %u, snr=%.1f dB\n", q->frame_cnt, q->chest_res.snr_db);
|
||||
q->frame_cnt++;
|
||||
}
|
||||
|
||||
|
|
|
@ -138,15 +138,14 @@ void srslte_ue_sync_reset(srslte_ue_sync_t *q) {
|
|||
|
||||
int srslte_ue_sync_start_agc(srslte_ue_sync_t *q,
|
||||
float (set_gain_callback)(void *, float),
|
||||
float min_gain,
|
||||
float max_gain,
|
||||
float init_gain_value)
|
||||
{
|
||||
float min_gain_db,
|
||||
float max_gain_db,
|
||||
float init_gain_value_db) {
|
||||
int n = srslte_agc_init_uhd(&q->agc, SRSLTE_AGC_MODE_PEAK_AMPLITUDE, 0, set_gain_callback, q->stream);
|
||||
q->do_agc = n==0?true:false;
|
||||
if (q->do_agc) {
|
||||
srslte_agc_set_gain_range(&q->agc, min_gain, max_gain);
|
||||
srslte_agc_set_gain(&q->agc, init_gain_value);
|
||||
srslte_agc_set_gain_range(&q->agc, min_gain_db, max_gain_db);
|
||||
srslte_agc_set_gain(&q->agc, init_gain_value_db);
|
||||
srslte_ue_sync_set_agc_period(q, 4);
|
||||
}
|
||||
return n;
|
||||
|
@ -595,7 +594,7 @@ static int track_peak_ok(srslte_ue_sync_t* q, uint32_t track_idx)
|
|||
/* Adjust current CFO estimation with PSS
|
||||
* Since sync track has enabled only PSS-based correlation, get_cfo() returns that value only, already filtered.
|
||||
*/
|
||||
INFO("TRACK: cfo_current=%f, cfo_strack=%f\n", 15000*q->cfo_current_value, 15000*srslte_sync_get_cfo(&q->strack));
|
||||
DEBUG("TRACK: cfo_current=%f, cfo_strack=%f\n", 15000*q->cfo_current_value, 15000*srslte_sync_get_cfo(&q->strack));
|
||||
if (15000*fabsf(srslte_sync_get_cfo(&q->strack)) > q->cfo_pss_min) {
|
||||
q->cfo_current_value += srslte_sync_get_cfo(&q->strack)*q->cfo_loop_bw_pss;
|
||||
q->pss_stable_cnt = 0;
|
||||
|
@ -765,7 +764,8 @@ int srslte_ue_sync_zerocopy(srslte_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_P
|
|||
srslte_agc_process(&q->agc, input_buffer[0], q->sf_len);
|
||||
}
|
||||
|
||||
INFO("SYNC FIND: sf_idx=%d, ret=%d, next_state=%d\n", q->sf_idx, ret, q->state);
|
||||
INFO("SYNC FIND: sf_idx=%d, ret=%d, peak_pos=%d, peak_value=%.2f, mean_cp_cfo=%.2f, mean_pss_cfo=%.2f, total_cfo_khz=%.1f\n", q->sf_idx, ret, q->peak_idx,
|
||||
q->sfind.peak_value, q->sfind.cfo_cp_mean, q->sfind.cfo_pss_mean, 15 * srslte_sync_get_cfo(&q->sfind));
|
||||
|
||||
break;
|
||||
case SF_TRACK:
|
||||
|
@ -829,10 +829,12 @@ int srslte_ue_sync_zerocopy(srslte_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_P
|
|||
}
|
||||
|
||||
q->frame_total_cnt++;
|
||||
}
|
||||
|
||||
INFO("SYNC TRACK: sf_idx=%d, ret=%d, peak_pos=%d, peak_value=%.2f, mean_cp_cfo=%.2f, mean_pss_cfo=%.2f, total_cfo_khz=%.1f\n", q->sf_idx, ret, track_idx,
|
||||
q->strack.peak_value, q->strack.cfo_cp_mean, q->strack.cfo_pss_mean, 15 * srslte_sync_get_cfo(&q->strack));
|
||||
} else {
|
||||
INFO("SYNC TRACK: sf_idx=%d, ret=%d, next_state=%d\n", q->sf_idx, ret, q->state);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue