mirror of https://github.com/PentHertz/srsLTE.git
Fixes #6 AGC
This commit is contained in:
parent
21edf74b06
commit
2cf6f96f24
|
@ -42,8 +42,8 @@
|
||||||
|
|
||||||
#include "srslte/config.h"
|
#include "srslte/config.h"
|
||||||
|
|
||||||
#define SRSLTE_AGC_DEFAULT_TARGET 0.7
|
#define SRSLTE_AGC_DEFAULT_TARGET 0.3
|
||||||
#define SRSLTE_AGC_DEFAULT_BW (5e-1)
|
#define SRSLTE_AGC_DEFAULT_BW 0.7
|
||||||
|
|
||||||
typedef enum SRSLTE_API {
|
typedef enum SRSLTE_API {
|
||||||
SRSLTE_AGC_MODE_ENERGY = 0,
|
SRSLTE_AGC_MODE_ENERGY = 0,
|
||||||
|
|
|
@ -177,7 +177,7 @@ void srslte_agc_process(srslte_agc_t *q, cf_t *signal, uint32_t len) {
|
||||||
gg = expf(-0.5*q->bandwidth*logf(q->y_out/q->target));
|
gg = expf(-0.5*q->bandwidth*logf(q->y_out/q->target));
|
||||||
q->gain *= gg;
|
q->gain *= gg;
|
||||||
}
|
}
|
||||||
DEBUG("AGC gain: %.2f (%.2f) y_out=%.3f, y=%.3f target=%.1f gg=%.2f\n", gain_db, gain_uhd_db, q->y_out, y, q->target, gg);
|
INFO("AGC gain: %.2f (%.2f) y_out=%.3f, y=%.3f target=%.1f gg=%.2f\n", gain_db, gain_uhd_db, q->y_out, y, q->target, gg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,18 +144,11 @@ void srslte_ue_sync_reset(srslte_ue_sync_t *q) {
|
||||||
|
|
||||||
|
|
||||||
int srslte_ue_sync_start_agc(srslte_ue_sync_t *q, double (set_gain_callback)(void*, double), float init_gain_value) {
|
int srslte_ue_sync_start_agc(srslte_ue_sync_t *q, double (set_gain_callback)(void*, double), float init_gain_value) {
|
||||||
uint32_t nframes;
|
int n = srslte_agc_init_uhd(&q->agc, SRSLTE_AGC_MODE_PEAK_AMPLITUDE, 0, set_gain_callback, q->stream);
|
||||||
if (q->nof_recv_sf == 1) {
|
|
||||||
nframes = 10;
|
|
||||||
} else {
|
|
||||||
nframes = 0;
|
|
||||||
}
|
|
||||||
int n = srslte_agc_init_uhd(&q->agc, SRSLTE_AGC_MODE_PEAK_AMPLITUDE, nframes, set_gain_callback, q->stream);
|
|
||||||
q->do_agc = n==0?true:false;
|
q->do_agc = n==0?true:false;
|
||||||
if (q->do_agc) {
|
if (q->do_agc) {
|
||||||
srslte_agc_set_gain(&q->agc, init_gain_value);
|
srslte_agc_set_gain(&q->agc, init_gain_value);
|
||||||
srslte_agc_set_target(&q->agc, 0.3);
|
srslte_ue_sync_set_agc_period(q, 4);
|
||||||
srslte_agc_set_bandwidth(&q->agc, 0.8);
|
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
@ -329,7 +322,6 @@ int srslte_ue_sync_set_cell(srslte_ue_sync_t *q, srslte_cell_t cell)
|
||||||
memcpy(&q->cell, &cell, sizeof(srslte_cell_t));
|
memcpy(&q->cell, &cell, sizeof(srslte_cell_t));
|
||||||
q->fft_size = srslte_symbol_sz(q->cell.nof_prb);
|
q->fft_size = srslte_symbol_sz(q->cell.nof_prb);
|
||||||
q->sf_len = SRSLTE_SF_LEN(q->fft_size);
|
q->sf_len = SRSLTE_SF_LEN(q->fft_size);
|
||||||
q->agc_period = 0;
|
|
||||||
|
|
||||||
if (cell.id == 1000) {
|
if (cell.id == 1000) {
|
||||||
|
|
||||||
|
|
|
@ -125,6 +125,7 @@ private:
|
||||||
float get_last_gain();
|
float get_last_gain();
|
||||||
float get_last_cfo();
|
float get_last_cfo();
|
||||||
void set_N_id_2(int N_id_2);
|
void set_N_id_2(int N_id_2);
|
||||||
|
void set_agc_enable(bool enable);
|
||||||
ret_code run(srslte_cell_t *cell);
|
ret_code run(srslte_cell_t *cell);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -174,6 +174,16 @@ bool phch_recv::wait_radio_reset() {
|
||||||
void phch_recv::set_agc_enable(bool enable)
|
void phch_recv::set_agc_enable(bool enable)
|
||||||
{
|
{
|
||||||
do_agc = enable;
|
do_agc = enable;
|
||||||
|
if (do_agc) {
|
||||||
|
if (running && radio_h) {
|
||||||
|
srslte_ue_sync_start_agc(&ue_sync, callback_set_rx_gain, radio_h->get_rx_gain());
|
||||||
|
search_p.set_agc_enable(true);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Error setting AGC: PHY not initiatec\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Error stopping AGC: not implemented\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void phch_recv::set_time_adv_sec(float _time_adv_sec)
|
void phch_recv::set_time_adv_sec(float _time_adv_sec)
|
||||||
|
@ -832,6 +842,14 @@ float phch_recv::search::get_last_cfo()
|
||||||
return srslte_ue_sync_get_cfo(&ue_mib_sync.ue_sync);
|
return srslte_ue_sync_get_cfo(&ue_mib_sync.ue_sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void phch_recv::search::set_agc_enable(bool enable) {
|
||||||
|
if (enable) {
|
||||||
|
srslte_ue_sync_start_agc(&ue_mib_sync.ue_sync, callback_set_rx_gain, p->radio_h->get_rx_gain());
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Error stop AGC not implemented\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
phch_recv::search::ret_code phch_recv::search::run(srslte_cell_t *cell)
|
phch_recv::search::ret_code phch_recv::search::run(srslte_cell_t *cell)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -891,11 +909,6 @@ phch_recv::search::ret_code phch_recv::search::run(srslte_cell_t *cell)
|
||||||
// Set options defined in expert section
|
// Set options defined in expert section
|
||||||
p->set_ue_sync_opts(&ue_mib_sync.ue_sync, cfo);
|
p->set_ue_sync_opts(&ue_mib_sync.ue_sync, cfo);
|
||||||
|
|
||||||
// Start AGC after initial cell search
|
|
||||||
if (p->do_agc) {
|
|
||||||
srslte_ue_sync_start_agc(&ue_mib_sync.ue_sync, callback_set_rx_gain, p->radio_h->get_rx_gain());
|
|
||||||
}
|
|
||||||
|
|
||||||
srslte_ue_sync_reset(&ue_mib_sync.ue_sync);
|
srslte_ue_sync_reset(&ue_mib_sync.ue_sync);
|
||||||
|
|
||||||
/* Find and decode MIB */
|
/* Find and decode MIB */
|
||||||
|
@ -1011,7 +1024,6 @@ phch_recv::sfn_sync::ret_code phch_recv::sfn_sync::run_subframe(srslte_cell_t *c
|
||||||
Info("SYNC: DONE, TTI=%d, sfn_offset=%d\n", *tti_cnt, sfn_offset);
|
Info("SYNC: DONE, TTI=%d, sfn_offset=%d\n", *tti_cnt, sfn_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
srslte_ue_sync_set_agc_period(ue_sync, 20);
|
|
||||||
srslte_ue_sync_decode_sss_on_track(ue_sync, true);
|
srslte_ue_sync_decode_sss_on_track(ue_sync, true);
|
||||||
reset();
|
reset();
|
||||||
return SFN_FOUND;
|
return SFN_FOUND;
|
||||||
|
|
|
@ -1436,7 +1436,7 @@ void phch_worker::update_measurements()
|
||||||
dl_metrics.rsrp = phy->avg_rsrp_dbm;
|
dl_metrics.rsrp = phy->avg_rsrp_dbm;
|
||||||
dl_metrics.rsrq = phy->avg_rsrq_db;
|
dl_metrics.rsrq = phy->avg_rsrq_db;
|
||||||
dl_metrics.rssi = phy->avg_rssi_dbm;
|
dl_metrics.rssi = phy->avg_rssi_dbm;
|
||||||
dl_metrics.pathloss = phy->pathloss;
|
dl_metrics.pathloss = phy->get_radio()->get_rx_gain();
|
||||||
dl_metrics.sinr = phy->avg_snr_db;
|
dl_metrics.sinr = phy->avg_snr_db;
|
||||||
dl_metrics.turbo_iters = srslte_pdsch_last_noi(&ue_dl.pdsch);
|
dl_metrics.turbo_iters = srslte_pdsch_last_noi(&ue_dl.pdsch);
|
||||||
phy->set_dl_metrics(dl_metrics);
|
phy->set_dl_metrics(dl_metrics);
|
||||||
|
|
|
@ -130,11 +130,7 @@ bool ue::init(all_args_t *args_)
|
||||||
|
|
||||||
// Init layers
|
// Init layers
|
||||||
|
|
||||||
if (args->rf.rx_gain < 0) {
|
// PHY inits in background, start before radio
|
||||||
phy.set_agc_enable(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// PHY initis in background, start before radio
|
|
||||||
args->expert.phy.nof_rx_ant = args->rf.nof_rx_ant;
|
args->expert.phy.nof_rx_ant = args->rf.nof_rx_ant;
|
||||||
phy.init(&radio, &mac, &rrc, phy_log, &args->expert.phy);
|
phy.init(&radio, &mac, &rrc, phy_log, &args->expert.phy);
|
||||||
|
|
||||||
|
@ -222,6 +218,11 @@ bool ue::init(all_args_t *args_)
|
||||||
phy.wait_initialize();
|
phy.wait_initialize();
|
||||||
phy.configure_ul_params();
|
phy.configure_ul_params();
|
||||||
|
|
||||||
|
// Enable AGC once PHY is initialized
|
||||||
|
if (args->rf.rx_gain < 0) {
|
||||||
|
phy.set_agc_enable(true);
|
||||||
|
}
|
||||||
|
|
||||||
printf("...\n");
|
printf("...\n");
|
||||||
nas.attach_request();
|
nas.attach_request();
|
||||||
|
|
||||||
|
|
|
@ -1062,6 +1062,7 @@ bool rrc::ho_prepare() {
|
||||||
|
|
||||||
int target_cell_idx = find_neighbour_cell(serving_cell->earfcn, mob_reconf.mob_ctrl_info.target_pci);
|
int target_cell_idx = find_neighbour_cell(serving_cell->earfcn, mob_reconf.mob_ctrl_info.target_pci);
|
||||||
if (target_cell_idx < 0) {
|
if (target_cell_idx < 0) {
|
||||||
|
rrc_log->console("Received HO command to unknown PCI=%d\n", mob_reconf.mob_ctrl_info.target_pci);
|
||||||
rrc_log->error("Could not find target cell earfcn=%d, pci=%d\n", serving_cell->earfcn, mob_reconf.mob_ctrl_info.target_pci);
|
rrc_log->error("Could not find target cell earfcn=%d, pci=%d\n", serving_cell->earfcn, mob_reconf.mob_ctrl_info.target_pci);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue