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
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

View File

@ -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

View File

@ -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

View File

@ -2,7 +2,7 @@
/*
* 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
* 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);
};

View File

@ -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(

View File

@ -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();