From 82c9ff2850235a69206a1fb2db3a9f039608a6f6 Mon Sep 17 00:00:00 2001 From: Manolis Surligas Date: Thu, 31 Mar 2016 21:58:29 +0300 Subject: [PATCH] Fix the doppler correction mechanism The doppler correction mechanism has successfully passed the first tests using the GPredict software for the radio control. The corrections seems to be quite smooth. The next step is to apply it at an audible signal. --- grc/satnogs_doppler_correction_cc.xml | 77 +++++++++++++++------------ lib/doppler_correction_cc_impl.cc | 36 +++++++------ 2 files changed, 65 insertions(+), 48 deletions(-) diff --git a/grc/satnogs_doppler_correction_cc.xml b/grc/satnogs_doppler_correction_cc.xml index 084bb41..63840f8 100644 --- a/grc/satnogs_doppler_correction_cc.xml +++ b/grc/satnogs_doppler_correction_cc.xml @@ -1,38 +1,49 @@ - doppler_correction_cc - satnogs_doppler_correction_cc - satnogs - import satnogs - satnogs.doppler_correction_cc($target_freq) - - - ... - ... - ... - + Doppler Correction + satnogs_doppler_correction_cc + satnogs + import satnogs + satnogs.doppler_correction_cc($target_freq, $sampling_rate, $corrections_per_sec) - - - in - - + + Target Frequency + target_freq + real + + + + Sample Rate + sampling_rate + samp_rate + real + + + + Corrections per Second + corrections_per_sec + 1000 + int + - - - out - - + + freq + message + + + + reset + message + 1 + + + + in + complex + + + + out + complex + diff --git a/lib/doppler_correction_cc_impl.cc b/lib/doppler_correction_cc_impl.cc index d877dd5..2d1525b 100644 --- a/lib/doppler_correction_cc_impl.cc +++ b/lib/doppler_correction_cc_impl.cc @@ -24,6 +24,7 @@ #include #include "doppler_correction_cc_impl.h" +#include #include namespace gr @@ -75,7 +76,7 @@ namespace gr * and the input message handler are NOT reentrant. */ set_max_noutput_items (d_samp_rate / 2.0); - set_alignment(8); + set_alignment (8); set_msg_handler ( pmt::mp ("freq"), @@ -104,11 +105,15 @@ namespace gr d_freq_diff = d_target_freq - new_freq; if (!d_have_est) { d_freq_est_num++; - if (d_freq_est_num > d_est_thrhld - 1) { - d_have_est = true; - } d_doppler_freqs.push_back ( freq_drift (nitems_written (0), d_freq_diff)); + if (d_freq_est_num > d_est_thrhld - 1) { + d_doppler_fit_engine.fit (d_doppler_freqs); + d_doppler_fit_engine.predict_freqs (d_predicted_freqs, + d_corrections_per_sec, + d_update_period); + d_have_est = true; + } } else { d_doppler_freqs.pop_front (); @@ -121,6 +126,7 @@ namespace gr d_doppler_fit_engine.predict_freqs (d_predicted_freqs, d_corrections_per_sec, d_update_period); + d_corrections = 0; } } @@ -180,20 +186,20 @@ namespace gr d_update_period); d_corrections = 0; } + } - cnt = std::min(d_update_period - d_corrected_samples, - (size_t) (noutput_items - produced)); - /* Perform the doppler shift correction */ - volk_32fc_x2_multiply_32fc (out + produced, in + produced, - d_nco_buff + d_corrected_samples, cnt); + cnt = std::min (d_update_period - d_corrected_samples, + (size_t) (noutput_items - produced)); + /* Perform the doppler shift correction */ + volk_32fc_x2_multiply_32fc (out + produced, in + produced, + d_nco_buff + d_corrected_samples, cnt); - /* Make the proper advances */ - produced += (int) cnt; - d_corrected_samples += cnt; + /* Make the proper advances */ + produced += (int) cnt; + d_corrected_samples += cnt; - if(d_corrected_samples == d_update_period) { - d_corrected_samples = 0; - } + if (d_corrected_samples == d_update_period) { + d_corrected_samples = 0; } } }