Add coarse doppler shift correction block
This commit is contained in:
parent
8a81ebc4ff
commit
c28c82c873
|
@ -35,5 +35,6 @@ install(FILES
|
|||
satnogs_upsat_fsk_frame_acquisition.xml
|
||||
satnogs_upsat_fsk_frame_encoder.xml
|
||||
satnogs_whitening.xml
|
||||
satnogs_udp_msg_sink.xml DESTINATION share/gnuradio/grc/blocks
|
||||
satnogs_udp_msg_sink.xml
|
||||
satnogs_coarse_doppler_correction_cc.xml DESTINATION share/gnuradio/grc/blocks
|
||||
)
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0"?>
|
||||
<block>
|
||||
<name>Coarse Doppler Correction</name>
|
||||
<key>satnogs_coarse_doppler_correction_cc</key>
|
||||
<category>satnogs</category>
|
||||
<import>import satnogs</import>
|
||||
<make>satnogs.coarse_doppler_correction_cc($target_freq, $sampling_rate)</make>
|
||||
<callback>set_new_freq_locked($target_freq)</callback>
|
||||
|
||||
<param>
|
||||
<name>Target Frequency</name>
|
||||
<key>target_freq</key>
|
||||
<type>real</type>
|
||||
</param>
|
||||
|
||||
<param>
|
||||
<name>Sample Rate</name>
|
||||
<key>sampling_rate</key>
|
||||
<value>samp_rate</value>
|
||||
<type>real</type>
|
||||
</param>
|
||||
|
||||
<sink>
|
||||
<name>freq</name>
|
||||
<type>message</type>
|
||||
</sink>
|
||||
|
||||
<sink>
|
||||
<name>in</name>
|
||||
<type>complex</type>
|
||||
</sink>
|
||||
|
||||
<source>
|
||||
<name>out</name>
|
||||
<type>complex</type>
|
||||
</source>
|
||||
</block>
|
|
@ -48,5 +48,6 @@ install(FILES
|
|||
upsat_fsk_frame_acquisition.h
|
||||
upsat_fsk_frame_encoder.h
|
||||
whitening.h
|
||||
udp_msg_sink.h DESTINATION include/satnogs
|
||||
udp_msg_sink.h
|
||||
coarse_doppler_correction_cc.h DESTINATION include/satnogs
|
||||
)
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
|
||||
*
|
||||
* Copyright (C) 2016, Libre Space Foundation <http://librespacefoundation.org/>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_SATNOGS_COARSE_DOPPLER_CORRECTION_CC_H
|
||||
#define INCLUDED_SATNOGS_COARSE_DOPPLER_CORRECTION_CC_H
|
||||
|
||||
#include <satnogs/api.h>
|
||||
#include <gnuradio/sync_block.h>
|
||||
|
||||
namespace gr
|
||||
{
|
||||
namespace satnogs
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief This block corrects the doppler effect between the ground
|
||||
* station and the satellite in a coarse and very simplified way.
|
||||
* Instead of changing the hardware center frequency, we use an NCO
|
||||
* to digitally compensate the doppler effect.
|
||||
*
|
||||
* \ingroup satnogs
|
||||
*
|
||||
*/
|
||||
class SATNOGS_API coarse_doppler_correction_cc : virtual public gr::sync_block
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr<coarse_doppler_correction_cc> sptr;
|
||||
|
||||
/**
|
||||
* The doppler correction block. The input is the complex signal at
|
||||
* baseband as it comes from the SDR device.
|
||||
*
|
||||
* 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 sampling_rate the sampling rate of the signal
|
||||
*/
|
||||
static sptr
|
||||
make (double target_freq, double sampling_rate);
|
||||
};
|
||||
|
||||
} // namespace satnogs
|
||||
} // namespace gr
|
||||
|
||||
#endif /* INCLUDED_SATNOGS_COARSE_DOPPLER_CORRECTION_CC_H */
|
||||
|
|
@ -48,7 +48,7 @@ namespace gr
|
|||
* The doppler correction block. The input is the complex signal at
|
||||
* baseband as it comes from the SDR device. The message input \p freq
|
||||
* received periodically messages containing the predicted absolute
|
||||
* frequency of the satellite at the moment of the
|
||||
* frequency of the satellite at that specific time.
|
||||
* @param target_freq the absolute frequency of the satellite
|
||||
* @param sampling_rate the sampling rate of the signal
|
||||
* @param corrections_per_sec the number of the corrections every second
|
||||
|
|
|
@ -46,7 +46,8 @@ list(APPEND satnogs_sources
|
|||
upsat_fsk_frame_acquisition_impl.cc
|
||||
upsat_fsk_frame_encoder_impl.cc
|
||||
whitening.cc
|
||||
udp_msg_sink_impl.cc )
|
||||
udp_msg_sink_impl.cc
|
||||
coarse_doppler_correction_cc_impl.cc )
|
||||
|
||||
set(satnogs_sources "${satnogs_sources}" PARENT_SCOPE)
|
||||
if(NOT satnogs_sources)
|
||||
|
|
|
@ -0,0 +1,128 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
|
||||
*
|
||||
* Copyright (C) 2016, Libre Space Foundation <http://librespacefoundation.org/>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include "coarse_doppler_correction_cc_impl.h"
|
||||
#include <volk/volk.h>
|
||||
|
||||
namespace gr
|
||||
{
|
||||
namespace satnogs
|
||||
{
|
||||
|
||||
coarse_doppler_correction_cc::sptr
|
||||
coarse_doppler_correction_cc::make (double target_freq,
|
||||
double sampling_rate)
|
||||
{
|
||||
return gnuradio::get_initial_sptr (
|
||||
new coarse_doppler_correction_cc_impl (target_freq, sampling_rate));
|
||||
}
|
||||
|
||||
/*
|
||||
* The private constructor
|
||||
*/
|
||||
coarse_doppler_correction_cc_impl::coarse_doppler_correction_cc_impl (
|
||||
double target_freq, double sampling_rate) :
|
||||
gr::sync_block ("coarse_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_samp_rate (sampling_rate),
|
||||
d_buf_items (std::min (8192UL, (size_t) (d_samp_rate / 4))),
|
||||
d_freq_diff (0),
|
||||
d_nco ()
|
||||
{
|
||||
message_port_register_in (pmt::mp ("freq"));
|
||||
|
||||
/*
|
||||
* NOTE:
|
||||
* Set the maximum number of samples to be equivalent of half a second.
|
||||
* With this way we are sure that at least one frequency message
|
||||
* per second will be processed.
|
||||
*
|
||||
* This is taken into consideration due to the fact that the work()
|
||||
* and the input message handler are NOT reentrant.
|
||||
*/
|
||||
set_max_noutput_items (d_samp_rate / 4.0);
|
||||
set_alignment (8);
|
||||
|
||||
set_msg_handler (
|
||||
pmt::mp ("freq"),
|
||||
boost::bind (&coarse_doppler_correction_cc_impl::new_freq, this, _1));
|
||||
|
||||
d_nco.set_freq (0);
|
||||
/* Allocate aligned memory for the NCO */
|
||||
d_nco_buff = (gr_complex *) volk_malloc (
|
||||
(d_samp_rate / 4) * sizeof(gr_complex), 32);
|
||||
if (!d_nco_buff) {
|
||||
throw std::runtime_error ("Could not allocate NCO memory");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
coarse_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 = d_target_freq - new_freq;
|
||||
d_nco.set_freq ((2 * M_PI * (-d_freq_diff)) / d_samp_rate);
|
||||
}
|
||||
|
||||
/*
|
||||
* Our virtual destructor.
|
||||
*/
|
||||
coarse_doppler_correction_cc_impl::~coarse_doppler_correction_cc_impl ()
|
||||
{
|
||||
volk_free (d_nco_buff);
|
||||
}
|
||||
|
||||
int
|
||||
coarse_doppler_correction_cc_impl::work (
|
||||
int noutput_items, gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
{
|
||||
const gr_complex *in = (const gr_complex *) input_items[0];
|
||||
gr_complex *out = (gr_complex *) output_items[0];
|
||||
|
||||
/* Perform the correction */
|
||||
d_nco.sincos (d_nco_buff, noutput_items, 1.0);
|
||||
volk_32fc_x2_multiply_32fc (out, in, d_nco_buff, noutput_items);
|
||||
|
||||
// Tell runtime system how many output items we produced.
|
||||
return noutput_items;
|
||||
}
|
||||
|
||||
void
|
||||
coarse_doppler_correction_cc_impl::set_target_freq (double freq)
|
||||
{
|
||||
boost::mutex::scoped_lock lock (d_mutex);
|
||||
d_target_freq = freq;
|
||||
d_freq_diff = 0.0;
|
||||
d_nco.set_freq (0);
|
||||
}
|
||||
|
||||
} /* namespace satnogs */
|
||||
} /* namespace gr */
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
|
||||
*
|
||||
* Copyright (C) 2016, Libre Space Foundation <http://librespacefoundation.org/>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_SATNOGS_COARSE_DOPPLER_CORRECTION_CC_IMPL_H
|
||||
#define INCLUDED_SATNOGS_COARSE_DOPPLER_CORRECTION_CC_IMPL_H
|
||||
|
||||
#include <satnogs/coarse_doppler_correction_cc.h>
|
||||
#include <gnuradio/fxpt_nco.h>
|
||||
|
||||
namespace gr
|
||||
{
|
||||
namespace satnogs
|
||||
{
|
||||
|
||||
class coarse_doppler_correction_cc_impl : public coarse_doppler_correction_cc
|
||||
{
|
||||
private:
|
||||
double d_target_freq;
|
||||
const double d_samp_rate;
|
||||
const size_t d_buf_items;
|
||||
double d_freq_diff;
|
||||
|
||||
gr::fxpt_nco d_nco;
|
||||
gr_complex *d_nco_buff;
|
||||
boost::mutex d_mutex;
|
||||
|
||||
void
|
||||
new_freq (pmt::pmt_t msg);
|
||||
|
||||
public:
|
||||
coarse_doppler_correction_cc_impl (double target_freq,
|
||||
double sampling_rate);
|
||||
~coarse_doppler_correction_cc_impl ();
|
||||
|
||||
// Where all the action really happens
|
||||
int
|
||||
work (int noutput_items, gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
|
||||
void
|
||||
set_target_freq (double freq);
|
||||
};
|
||||
|
||||
} // namespace satnogs
|
||||
} // namespace gr
|
||||
|
||||
#endif /* INCLUDED_SATNOGS_COARSE_DOPPLER_CORRECTION_CC_IMPL_H */
|
||||
|
|
@ -29,6 +29,7 @@
|
|||
#include "satnogs/upsat_fsk_frame_encoder.h"
|
||||
#include "satnogs/whitening.h"
|
||||
#include "satnogs/udp_msg_sink.h"
|
||||
#include "satnogs/coarse_doppler_correction_cc.h"
|
||||
%}
|
||||
|
||||
|
||||
|
@ -70,3 +71,5 @@ GR_SWIG_BLOCK_MAGIC2(satnogs, upsat_fsk_frame_encoder);
|
|||
%include "satnogs/whitening.h"
|
||||
%include "satnogs/udp_msg_sink.h"
|
||||
GR_SWIG_BLOCK_MAGIC2(satnogs, udp_msg_sink);
|
||||
%include "satnogs/coarse_doppler_correction_cc.h"
|
||||
GR_SWIG_BLOCK_MAGIC2(satnogs, coarse_doppler_correction_cc);
|
||||
|
|
Loading…
Reference in New Issue