diff options
author | Piotr Krysik <ptrkrysik@gmail.com> | 2017-01-23 21:53:48 +0100 |
---|---|---|
committer | Piotr Krysik <ptrkrysik@gmail.com> | 2017-01-23 21:53:48 +0100 |
commit | 654d652a730e579a770f9a9381c4da13659f6ff6 (patch) | |
tree | dc4021d70005eeccd29066329bac4ae3859aa714 /lib | |
parent | 93ba6bc2c24eef808fafa41233102e59e56ff1d8 (diff) |
Ressurected old frequency correction function
Diffstat (limited to 'lib')
-rw-r--r-- | lib/receiver/receiver_impl.cc | 38 | ||||
-rw-r--r-- | lib/receiver/receiver_impl.h | 2 |
2 files changed, 7 insertions, 33 deletions
diff --git a/lib/receiver/receiver_impl.cc b/lib/receiver/receiver_impl.cc index f43f6e0..e69183f 100644 --- a/lib/receiver/receiver_impl.cc +++ b/lib/receiver/receiver_impl.cc @@ -26,7 +26,6 @@ #include <gnuradio/io_signature.h> #include <gnuradio/math.h> -#include <volk/volk.h> #include <math.h> #include <boost/circular_buffer.hpp> #include <algorithm> @@ -35,7 +34,6 @@ #include <viterbi_detector.h> #include <string.h> #include <iostream> -#include <time.h> //!!! //#include <iomanip> #include <boost/scoped_ptr.hpp> @@ -534,44 +532,22 @@ bool receiver_impl::find_fcch_burst(const gr_complex *input, const int nitems, d return result; } -double receiver_impl::estim_freq_norm(const gr_complex * input, unsigned first_sample, unsigned last_sample) //another frequency estimator +double receiver_impl::compute_freq_offset(const gr_complex * input, unsigned first_sample, unsigned last_sample) { - + double phase_sum = 0; unsigned ii; - double sum = 0; - - for (ii = first_sample; ii < last_sample-1; ii++) + for (ii = first_sample; ii < last_sample; ii++) { - sum += fast_atan2f(input[ii+1] * conj(input[ii])); + double phase_diff = compute_phase_diff(input[ii], input[ii-1]) - (M_PI / 2) / d_OSR; + phase_sum += phase_diff; } - int N = last_sample-1-first_sample; - return sum/(2*M_PI)/N * d_OSR; -} -double receiver_impl::compute_freq_offset(const gr_complex * input, unsigned first_sample, unsigned last_sample) -{ - float freq_norm = estim_freq_norm(input, first_sample, last_sample); - float freq_offset = (freq_norm - 0.25) * 1625000.0/6.0; + double phase_offset = phase_sum / (last_sample - first_sample); + double freq_offset = phase_offset * 1625000.0 / (12.0 * M_PI); return freq_offset; } -//double receiver_impl::compute_freq_offset(const gr_complex * input, unsigned first_sample, unsigned last_sample) -//{ -// double phase_sum = 0; -// unsigned ii; - -// for (ii = first_sample; ii < last_sample; ii++) -// { -// double phase_diff = compute_phase_diff(input[ii], input[ii-1]) - (M_PI / 2) / d_OSR; -// phase_sum += phase_diff; -// } - -// double phase_offset = phase_sum / (last_sample - first_sample); -// double freq_offset = phase_offset * 1625000.0 / (12.0 * M_PI); -// return freq_offset; -//} - inline float receiver_impl::compute_phase_diff(gr_complex val1, gr_complex val2) { gr_complex conjprod = val1 * conj(val2); diff --git a/lib/receiver/receiver_impl.h b/lib/receiver/receiver_impl.h index 251cf55..6074dd5 100644 --- a/lib/receiver/receiver_impl.h +++ b/lib/receiver/receiver_impl.h @@ -108,8 +108,6 @@ namespace gr { * @return true if frequency offset was faound */ double compute_freq_offset(const gr_complex * input, unsigned first_sample, unsigned last_sample); - - double estim_freq_norm(const gr_complex * input, unsigned first_sample, unsigned last_sample); //normalized frequency estimator /** Computes angle between two complex numbers * * @param val1 first complex number |