From d656020bc2ee5326100b9d08a94ec406d3a2b86e Mon Sep 17 00:00:00 2001 From: Manolis Surligas Date: Tue, 17 Dec 2019 21:39:27 +0200 Subject: [PATCH] Make doppler correction block compatible with the coarse one --- ...ogs_coarse_doppler_correction_cc.block.yml | 3 +-- grc/satnogs_doppler_correction_cc.block.yml | 20 ++++++++++++------- .../satnogs/coarse_doppler_correction_cc.h | 2 +- include/satnogs/doppler_correction_cc.h | 9 ++++++--- lib/doppler_correction_cc_impl.cc | 20 +++++++++++++------ lib/doppler_correction_cc_impl.h | 5 ++++- 6 files changed, 39 insertions(+), 20 deletions(-) diff --git a/grc/satnogs_coarse_doppler_correction_cc.block.yml b/grc/satnogs_coarse_doppler_correction_cc.block.yml index dac25f2..9eb16d5 100644 --- a/grc/satnogs_coarse_doppler_correction_cc.block.yml +++ b/grc/satnogs_coarse_doppler_correction_cc.block.yml @@ -5,6 +5,7 @@ parameters: - id: target_freq label: Target frequency dtype: real + default: 0.0 - id: offset label: Offset @@ -33,7 +34,5 @@ outputs: templates: imports: import satnogs make: satnogs.coarse_doppler_correction_cc(${target_freq}, ${offset}, ${sampling_rate}) - callbacks: - - set_new_freq_locked(${target_freq}) file_format: 1 diff --git a/grc/satnogs_doppler_correction_cc.block.yml b/grc/satnogs_doppler_correction_cc.block.yml index 427a8f9..de95399 100644 --- a/grc/satnogs_doppler_correction_cc.block.yml +++ b/grc/satnogs_doppler_correction_cc.block.yml @@ -5,6 +5,12 @@ parameters: - id: target_freq label: Target frequency dtype: real + default: 0.0 + +- id: offset + label: LO Offset + dtype: real + default: 0.0 - id: sampling_rate label: Sample Rate @@ -14,21 +20,21 @@ parameters: - id: corrections_per_sec label: Corrections per Second dtype: int - default: 1000 - + default: 100 inputs: +- label: in + domain: stream + dtype: complex + - id: freq domain: message + optional: true - id: reset domain: message optional: true -- label: in - domain: stream - dtype: complex - outputs: - label: out domain: stream @@ -36,6 +42,6 @@ outputs: templates: imports: import satnogs - make: satnogs.doppler_correction_cc(${target_freq}, ${sampling_rate}, ${corrections_per_sec}) + make: satnogs.doppler_correction_cc(${target_freq}, ${offset}, ${sampling_rate}, ${corrections_per_sec}) file_format: 1 diff --git a/include/satnogs/coarse_doppler_correction_cc.h b/include/satnogs/coarse_doppler_correction_cc.h index b18b8a8..2424b3b 100644 --- a/include/satnogs/coarse_doppler_correction_cc.h +++ b/include/satnogs/coarse_doppler_correction_cc.h @@ -47,7 +47,7 @@ public: * The message input \p freq receives periodically messages containing * the predicted absolute frequency of the satellite at that specific time. * @param target_freq the absolute frequency of the satellite - * @param offset the frequency offset from the actuall target frequency. + * @param offset the frequency offset from the actual target frequency. * This is very common on SDR receivers to avoid DC spikes at the center * frequency. This block can automatically compensate this offset * @param sampling_rate the sampling rate of the signal diff --git a/include/satnogs/doppler_correction_cc.h b/include/satnogs/doppler_correction_cc.h index e7e90b2..c88a983 100644 --- a/include/satnogs/doppler_correction_cc.h +++ b/include/satnogs/doppler_correction_cc.h @@ -2,7 +2,7 @@ /* * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module * - * Copyright (C) 2016, Libre Space Foundation + * Copyright (C) 2016,2019 Libre Space Foundation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,7 +29,7 @@ namespace satnogs { /*! * \brief This block corrects the doppler effect between the ground - * station and the satellite. It takes the imput stream in baseband + * station and the satellite. It takes the input stream in baseband * and applies proper corrections to keep the carrier at the desired * frequency. To achieve that it uses messages containing the absolute * predicted frequency of the satellite from software like Gpredict. @@ -47,12 +47,15 @@ public: * received periodically messages containing the predicted absolute * frequency of the satellite at that specific time. * @param target_freq the absolute frequency of the satellite + * @param offset the frequency offset from the actual target frequency. + * This is very common on SDR receivers to avoid DC spikes at the center + * frequency. This block can automatically compensate this offset * @param sampling_rate the sampling rate of the signal * @param corrections_per_sec the number of the corrections every second * that the block should perform */ static sptr - make(double target_freq, double sampling_rate, + make(double target_freq, double offset, double sampling_rate, size_t corrections_per_sec = 1000); }; diff --git a/lib/doppler_correction_cc_impl.cc b/lib/doppler_correction_cc_impl.cc index 309041d..e7a1e02 100644 --- a/lib/doppler_correction_cc_impl.cc +++ b/lib/doppler_correction_cc_impl.cc @@ -31,11 +31,14 @@ namespace gr { namespace satnogs { doppler_correction_cc::sptr -doppler_correction_cc::make(double target_freq, double sampling_rate, +doppler_correction_cc::make(double target_freq, + double offset, + double sampling_rate, size_t corrections_per_sec) { return gnuradio::get_initial_sptr( - new doppler_correction_cc_impl(target_freq, sampling_rate, + new doppler_correction_cc_impl(target_freq, offset, + sampling_rate, corrections_per_sec)); } @@ -43,19 +46,23 @@ doppler_correction_cc::make(double target_freq, double sampling_rate, * The private constructor */ doppler_correction_cc_impl::doppler_correction_cc_impl( - double target_freq, double sampling_rate, size_t corrections_per_sec) : + double target_freq, + double offset, + double sampling_rate, + size_t corrections_per_sec) : gr::sync_block("doppler_correction_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(gr_complex))), d_target_freq(target_freq), + d_offset(offset), d_samp_rate(sampling_rate), - d_update_period(sampling_rate / (double) corrections_per_sec), + d_update_period(sampling_rate / corrections_per_sec), d_est_thrhld(7), d_corrections_per_sec(corrections_per_sec), d_nco(), /* A 3-rd order polynomial curve fitting is more than enough */ d_doppler_fit_engine(3), - d_freq_diff(0.0), + d_freq_diff(offset), d_have_est(false), d_freq_est_num(0), d_corrections(0), @@ -83,6 +90,7 @@ doppler_correction_cc_impl::doppler_correction_cc_impl( pmt::mp("reset"), boost::bind(&doppler_correction_cc_impl::reset, this, _1)); + d_nco.set_freq((2 * M_PI * (-d_freq_diff)) / d_samp_rate); /* Allocate the buffer that will hold the predicted frequency differences */ d_predicted_freqs = new double[d_corrections_per_sec]; @@ -100,7 +108,7 @@ doppler_correction_cc_impl::new_freq(pmt::pmt_t msg) boost::mutex::scoped_lock lock(d_mutex); double new_freq; new_freq = pmt::to_double(msg); - d_freq_diff = new_freq - d_target_freq; + d_freq_diff = new_freq - (d_target_freq - d_offset); if (!d_have_est) { d_freq_est_num++; d_doppler_freqs.push_back( diff --git a/lib/doppler_correction_cc_impl.h b/lib/doppler_correction_cc_impl.h index 1f708d4..cf4f4e8 100644 --- a/lib/doppler_correction_cc_impl.h +++ b/lib/doppler_correction_cc_impl.h @@ -33,6 +33,7 @@ namespace satnogs { class doppler_correction_cc_impl : public doppler_correction_cc { private: const double d_target_freq; + const double d_offset; const double d_samp_rate; const size_t d_update_period; const size_t d_est_thrhld; @@ -57,7 +58,9 @@ private: reset(pmt::pmt_t msg); public: - doppler_correction_cc_impl(double target_freq, double sampling_rate, + doppler_correction_cc_impl(double target_freq, + double offset, + double sampling_rate, size_t corrections_per_sec); ~doppler_correction_cc_impl();