// // Test AC gain control // void autotest_agc_crcf_ac_gain_control() { // set paramaters float gamma = 0.1f; // nominal signal level float bt = 0.1f; // bandwidth-time product float tol = 0.001f; // error tolerance float dphi = 0.1f; // NCO frequency // create AGC object and initialize agc_crcf q = agc_crcf_create(); agc_crcf_set_bandwidth(q, bt); unsigned int i; float complex x; float complex y; for (i=0; i<256; i++) { x = gamma * cexpf(_Complex_I*i*dphi); agc_crcf_execute(q, x, &y); } if (liquid_autotest_verbose) printf("gamma : %12.8f, rssi : %12.8f\n", gamma, agc_crcf_get_signal_level(q)); // Check results CONTEND_DELTA( agc_crcf_get_gain(q), 1.0f/gamma, tol); // destroy AGC object agc_crcf_destroy(q); }
void ofdmoqamframe64sync_execute_plcpshort(ofdmoqamframe64sync _q, float complex _x) { // run AGC, clip output float complex y; agc_crcf_execute(_q->sigdet, _x, &y); //if (agc_crcf_get_signal_level(_q->sigdet) < -15.0f) // return; if (cabsf(y) > 2.0f) y = 2.0f*liquid_cexpjf(cargf(y)); // auto-correlators //autocorr_cccf_push(_q->autocorr, _x); autocorr_cccf_push(_q->autocorr, y); autocorr_cccf_execute(_q->autocorr, &_q->rxx); #if DEBUG_OFDMOQAMFRAME64SYNC windowcf_push(_q->debug_rxx, _q->rxx); windowf_push(_q->debug_rssi, agc_crcf_get_signal_level(_q->sigdet)); #endif float rxx_mag = cabsf(_q->rxx); float threshold = (_q->rxx_thresh)*(_q->autocorr_length); if (rxx_mag > threshold) { // wait for auto-correlation to peak before changing state if (rxx_mag > _q->rxx_mag_max) { _q->rxx_mag_max = rxx_mag; return; } // estimate CFO _q->nu_hat = cargf(_q->rxx); if (_q->nu_hat > M_PI/2.0f) _q->nu_hat -= M_PI; if (_q->nu_hat < -M_PI/2.0f) _q->nu_hat += M_PI; _q->nu_hat *= 4.0f / (float)(_q->num_subcarriers); #if DEBUG_OFDMOQAMFRAME64SYNC_PRINT printf("rxx = |%12.8f| arg{%12.8f}\n", cabsf(_q->rxx),cargf(_q->rxx)); printf("nu_hat = %12.8f\n", _q->nu_hat); #endif nco_crcf_set_frequency(_q->nco_rx, _q->nu_hat); _q->state = OFDMOQAMFRAME64SYNC_STATE_PLCPLONG0; _q->g = agc_crcf_get_gain(_q->sigdet); #if DEBUG_OFDMOQAMFRAME64SYNC_PRINT printf("gain : %f\n", _q->g); #endif _q->timer=0; } }
// // Test RSSI on sinusoidal input // void autotest_agc_crcf_rssi_sinusoid() { // set paramaters float gamma = 0.3f; // nominal signal level float bt = 0.05f; // agc bandwidth float tol = 0.001f; // error tolerance // signal properties float dphi = 0.1f; // signal frequency // create AGC object and initialize agc_crcf q = agc_crcf_create(); agc_crcf_set_bandwidth(q, bt); unsigned int i; float complex x, y; for (i=0; i<512; i++) { // generate sample (complex sinusoid) x = gamma * cexpf(_Complex_I*dphi*i); // execute agc agc_crcf_execute(q, x, &y); } // get received signal strength indication float rssi = agc_crcf_get_signal_level(q); if (liquid_autotest_verbose) printf("gamma : %12.8f, rssi : %12.8f\n", gamma, rssi); // Check results CONTEND_DELTA( rssi, gamma, tol ); // destroy agc object agc_crcf_destroy(q); }