Make doppler correction block compatible with the coarse one

This commit is contained in:
Manolis Surligas 2019-12-17 21:39:27 +02:00
parent 96aaf11a30
commit d656020bc2
6 changed files with 39 additions and 20 deletions

View File

@ -5,6 +5,7 @@ parameters:
- id: target_freq - id: target_freq
label: Target frequency label: Target frequency
dtype: real dtype: real
default: 0.0
- id: offset - id: offset
label: Offset label: Offset
@ -33,7 +34,5 @@ outputs:
templates: templates:
imports: import satnogs imports: import satnogs
make: satnogs.coarse_doppler_correction_cc(${target_freq}, ${offset}, ${sampling_rate}) make: satnogs.coarse_doppler_correction_cc(${target_freq}, ${offset}, ${sampling_rate})
callbacks:
- set_new_freq_locked(${target_freq})
file_format: 1 file_format: 1

View File

@ -5,6 +5,12 @@ parameters:
- id: target_freq - id: target_freq
label: Target frequency label: Target frequency
dtype: real dtype: real
default: 0.0
- id: offset
label: LO Offset
dtype: real
default: 0.0
- id: sampling_rate - id: sampling_rate
label: Sample Rate label: Sample Rate
@ -14,21 +20,21 @@ parameters:
- id: corrections_per_sec - id: corrections_per_sec
label: Corrections per Second label: Corrections per Second
dtype: int dtype: int
default: 1000 default: 100
inputs: inputs:
- label: in
domain: stream
dtype: complex
- id: freq - id: freq
domain: message domain: message
optional: true
- id: reset - id: reset
domain: message domain: message
optional: true optional: true
- label: in
domain: stream
dtype: complex
outputs: outputs:
- label: out - label: out
domain: stream domain: stream
@ -36,6 +42,6 @@ outputs:
templates: templates:
imports: import satnogs 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 file_format: 1

View File

@ -47,7 +47,7 @@ public:
* The message input \p freq receives periodically messages containing * The message input \p freq receives periodically messages containing
* the predicted absolute frequency of the satellite at that specific time. * the predicted absolute frequency of the satellite at that specific time.
* @param target_freq the absolute frequency of the satellite * @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 * This is very common on SDR receivers to avoid DC spikes at the center
* frequency. This block can automatically compensate this offset * frequency. This block can automatically compensate this offset
* @param sampling_rate the sampling rate of the signal * @param sampling_rate the sampling rate of the signal

View File

@ -2,7 +2,7 @@
/* /*
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
* *
* Copyright (C) 2016, Libre Space Foundation <http://librespacefoundation.org/> * Copyright (C) 2016,2019 Libre Space Foundation <http://libre.space>
* *
* This program is free software: you can redistribute it and/or modify * 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 * 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 * \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 * and applies proper corrections to keep the carrier at the desired
* frequency. To achieve that it uses messages containing the absolute * frequency. To achieve that it uses messages containing the absolute
* predicted frequency of the satellite from software like Gpredict. * predicted frequency of the satellite from software like Gpredict.
@ -47,12 +47,15 @@ public:
* received periodically messages containing the predicted absolute * received periodically messages containing the predicted absolute
* frequency of the satellite at that specific time. * frequency of the satellite at that specific time.
* @param target_freq the absolute frequency of the satellite * @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 sampling_rate the sampling rate of the signal
* @param corrections_per_sec the number of the corrections every second * @param corrections_per_sec the number of the corrections every second
* that the block should perform * that the block should perform
*/ */
static sptr static sptr
make(double target_freq, double sampling_rate, make(double target_freq, double offset, double sampling_rate,
size_t corrections_per_sec = 1000); size_t corrections_per_sec = 1000);
}; };

View File

@ -31,11 +31,14 @@ namespace gr {
namespace satnogs { namespace satnogs {
doppler_correction_cc::sptr 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) size_t corrections_per_sec)
{ {
return gnuradio::get_initial_sptr( 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)); corrections_per_sec));
} }
@ -43,19 +46,23 @@ doppler_correction_cc::make(double target_freq, double sampling_rate,
* The private constructor * The private constructor
*/ */
doppler_correction_cc_impl::doppler_correction_cc_impl( 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::sync_block("doppler_correction_cc",
gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(1, 1, sizeof(gr_complex))), gr::io_signature::make(1, 1, sizeof(gr_complex))),
d_target_freq(target_freq), d_target_freq(target_freq),
d_offset(offset),
d_samp_rate(sampling_rate), 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_est_thrhld(7),
d_corrections_per_sec(corrections_per_sec), d_corrections_per_sec(corrections_per_sec),
d_nco(), d_nco(),
/* A 3-rd order polynomial curve fitting is more than enough */ /* A 3-rd order polynomial curve fitting is more than enough */
d_doppler_fit_engine(3), d_doppler_fit_engine(3),
d_freq_diff(0.0), d_freq_diff(offset),
d_have_est(false), d_have_est(false),
d_freq_est_num(0), d_freq_est_num(0),
d_corrections(0), d_corrections(0),
@ -83,6 +90,7 @@ doppler_correction_cc_impl::doppler_correction_cc_impl(
pmt::mp("reset"), pmt::mp("reset"),
boost::bind(&doppler_correction_cc_impl::reset, this, _1)); 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 */ /* Allocate the buffer that will hold the predicted frequency differences */
d_predicted_freqs = new double[d_corrections_per_sec]; 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); boost::mutex::scoped_lock lock(d_mutex);
double new_freq; double new_freq;
new_freq = pmt::to_double(msg); 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) { if (!d_have_est) {
d_freq_est_num++; d_freq_est_num++;
d_doppler_freqs.push_back( d_doppler_freqs.push_back(

View File

@ -33,6 +33,7 @@ namespace satnogs {
class doppler_correction_cc_impl : public doppler_correction_cc { class doppler_correction_cc_impl : public doppler_correction_cc {
private: private:
const double d_target_freq; const double d_target_freq;
const double d_offset;
const double d_samp_rate; const double d_samp_rate;
const size_t d_update_period; const size_t d_update_period;
const size_t d_est_thrhld; const size_t d_est_thrhld;
@ -57,7 +58,9 @@ private:
reset(pmt::pmt_t msg); reset(pmt::pmt_t msg);
public: 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); size_t corrections_per_sec);
~doppler_correction_cc_impl(); ~doppler_correction_cc_impl();