|
|
|
@ -117,7 +117,7 @@ void srslte_agc_lock(srslte_agc_t *q, bool enable) {
|
|
|
|
|
void srslte_agc_process(srslte_agc_t *q, cf_t *signal, uint32_t len) {
|
|
|
|
|
if (!q->lock) {
|
|
|
|
|
float gain_db = 10*log10(q->gain);
|
|
|
|
|
float gain_uhd_db = 1.0;
|
|
|
|
|
float gain_uhd_db = 50.0;
|
|
|
|
|
//float gain_uhd = 1.0;
|
|
|
|
|
float y = 0;
|
|
|
|
|
// Apply current gain to input signal
|
|
|
|
@ -125,12 +125,12 @@ void srslte_agc_process(srslte_agc_t *q, cf_t *signal, uint32_t len) {
|
|
|
|
|
srslte_vec_sc_prod_cfc(signal, q->gain, signal, len);
|
|
|
|
|
} else {
|
|
|
|
|
if (gain_db < 0) {
|
|
|
|
|
gain_db = 0.0;
|
|
|
|
|
gain_db = 5.0;
|
|
|
|
|
}
|
|
|
|
|
if (isinf(gain_db) || isnan(gain_db)) {
|
|
|
|
|
gain_db = 10.0;
|
|
|
|
|
gain_db = 40.0;
|
|
|
|
|
} else {
|
|
|
|
|
gain_uhd_db = q->set_gain_callback(q->uhd_handler, gain_db);
|
|
|
|
|
gain_uhd_db = q->set_gain_callback(q->uhd_handler, gain_db);
|
|
|
|
|
q->gain = pow(10, gain_uhd_db/10);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -166,7 +166,7 @@ void srslte_agc_process(srslte_agc_t *q, cf_t *signal, uint32_t len) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double gg = 1.0;
|
|
|
|
|
double gg = 1.0;
|
|
|
|
|
if (q->isfirst) {
|
|
|
|
|
q->y_out = y;
|
|
|
|
|
q->isfirst = false;
|
|
|
|
@ -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));
|
|
|
|
|
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);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|