1
0
Fork 0
mirror of https://github.com/hb9fxq/gr-digitalhf synced 2024-11-05 05:55:53 +00:00

eary-late synchronization for a vector of signals (intermediate)

This commit is contained in:
Christoph Mayer 2019-09-09 16:02:35 +02:00
parent 7b5dadc712
commit 659fc1099a
6 changed files with 296 additions and 1 deletions

View file

@ -0,0 +1,47 @@
<?xml version="1.0"?>
<block>
<name>vector_early_late_cc</name>
<key>digitalhf_vector_early_late_cc</key>
<category>[digitalhf]</category>
<import>import digitalhf</import>
<make>digitalhf.vector_early_late_cc($sps,$alpha)</make>
<callback>set_mu($mu)</callback>
<!-- Make one 'param' node for every Parameter you want settable from the GUI.
Sub-nodes:
* name
* key (makes the value accessible as $keyname, e.g. in the make node)
* type -->
<param>
<name>SPS</name>
<key>sps</key>
<type>int</type>
</param>
<param>
<name>alpha</name>
<key>alpha</key>
<type>float</type>
</param>
<!-- Make one 'sink' node per input. Sub-nodes:
* name (an identifier for the GUI)
* type
* vlen
* optional (set to 1 for optional inputs) -->
<sink>
<name>in</name>
<type>complex</type>
</sink>
<!-- Make one 'source' node per output. Sub-nodes:
* name (an identifier for the GUI)
* type
* vlen
* optional (set to 1 for optional inputs) -->
<source>
<name>out</name>
<type>complex</type>
<!-- byte, short, xxx_vector -->
</source>
</block>

View file

@ -0,0 +1,58 @@
/* -*- c++ -*- */
/*
* Copyright 2018 hcab14@gmail.com.
*
* This 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, or (at your option)
* any later version.
*
* This software 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 software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDED_DIGITALHF_VECTOR_EARLY_LATE_CC_H
#define INCLUDED_DIGITALHF_VECTOR_EARLY_LATE_CC_H
#include <digitalhf/api.h>
#include <gnuradio/block.h>
namespace gr {
namespace digitalhf {
/*!
* \brief <+description of block+>
* \ingroup digitalhf
*
*/
class DIGITALHF_API vector_early_late_cc : virtual public gr::block
{
public:
typedef boost::shared_ptr<vector_early_late_cc> sptr;
/*!
* \brief Return a shared_ptr to a new instance of digitalhf::vector_early_late_cc.
*
* To avoid accidental use of raw pointers, digitalhf::vector_early_late_cc's
* constructor is in a private implementation
* class. digitalhf::vector_early_late_cc::make is the public interface for
* creating new instances.
*/
static sptr make(unsigned sps, // samples per symbols
float alpha); // filter parameter
};
} // namespace digitalhf
} // namespace gr
#endif /* INCLUDED_DIGITALHF_VECTOR_EARLY_LATE_CC_H */

View file

@ -32,7 +32,11 @@ list(APPEND digitalhf_sources
viterbi29_impl.cc
viterbi39_impl.cc
viterbi48_impl.cc
vector_pll_cc_impl.cc)
vector_pll_cc_impl.cc
vector_early_late_cc_impl.cc
lms.cc
rls.cc
)
set(digitalhf_sources "${digitalhf_sources}" PARENT_SCOPE)
if(NOT digitalhf_sources)

View file

@ -0,0 +1,122 @@
/* -*- c++ -*- */
/*
* Copyright 2018 hcab14@gmail.com.
*
* This 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, or (at your option)
* any later version.
*
* This software 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 software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <cmath>
#include <gnuradio/io_signature.h>
#include <gnuradio/expj.h>
#include <gnuradio/logger.h>
#include "vector_early_late_cc_impl.h"
namespace gr {
namespace digitalhf {
vector_early_late_cc::sptr
vector_early_late_cc::make(unsigned sps,
float alpha)
{
return gnuradio::get_initial_sptr
(new vector_early_late_cc_impl(sps, alpha));
}
/*
* The private constructor
*/
vector_early_late_cc_impl::vector_early_late_cc_impl(unsigned sps,
float alpha)
: gr::block("vector_early_late_cc",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(1, 1, sizeof(gr_complex)))
, _sps(sps)
, _alpha(alpha)
, _counter(0)
, _err(0.0f)
, _t(0.0f)
{
GR_LOG_DECLARE_LOGPTR(d_logger);
GR_LOG_ASSIGN_LOGPTR(d_logger, "vector_early_late_cc");
// -sps/2 ... -1 0 1 ... sps/2
// [ early ] [ late ]
set_history(1 + sps);
}
vector_early_late_cc_impl::~vector_early_late_cc_impl()
{
}
int
vector_early_late_cc_impl::general_work(int noutput_items,
gr_vector_int& ninput_items,
gr_vector_const_void_star& input_items,
gr_vector_void_star& output_items)
{
gr::thread::scoped_lock lock(d_setlock);
gr_complex const *in = (gr_complex const *)input_items[0];
gr_complex *out = (gr_complex *)output_items[0];
int const nin = ninput_items[0] - _sps;
// std::cout << "vector_early_late_cc_impl::general_work nin,sps= " << " " << nin << " " << _sps << " " << history() << std::endl;
assert(nin > 1);
if (nin < 1)
return 0;
int nout = 0;
int nin_processed = 0;
int i = history();
for (; i<ninput_items[0]-_sps/2 && nout<noutput_items; ++i) {
if (_counter == std::floor(_t)) {
// evaluate early and late
gr_complex early(0), late(0);
// float early(0), late(0);
for (int j=0; j<_sps; ++j) {
early += std::real(in[i-j]);
late += std::real(in[i+1+j]);
}
// output symbol
gr_complex _out(0);
for (int j=0; j<_sps; ++j) {
_out += in[i-j];
}
// out[nout++] = _out*(1.0f/(_sps-2));
out[nout++] = _out*(1.0f/_sps);
float const error = (std::real(early - late)*std::real(in[i]) +
std::imag(early - late)*std::imag(in[i]));
// float const error = (std::real(early) - std::real(late))*std::real(in[i]);
_err = (1.0f - _alpha)*_err + _alpha * error;
_t += float(_sps) - float(_counter) + 0.5*_err;
std::cout << "EL: err= "<< _err << " early/late= " << std::abs(early) << " " << std::abs(late) << " t= " << _t << std::endl;
_counter = 0;
}
consume(0, 1);
_counter +=1;
}
return nout;
}
} /* namespace digitalhf */
} /* namespace gr */

View file

@ -0,0 +1,60 @@
/* -*- c++ -*- */
/*
* Copyright 2018 hcab14@gmail.com.
*
* This 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, or (at your option)
* any later version.
*
* This software 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 software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDED_DIGITALHF_VECTOR_EARLY_LATE_CC_IMPL_H
#define INCLUDED_DIGITALHF_VECTOR_EARLY_LATE_CC_IMPL_H
#include <gnuradio/blocks/control_loop.h>
#include <digitalhf/vector_early_late_cc.h>
#include <array>
namespace gr {
namespace digitalhf {
class vector_early_late_cc_impl : public vector_early_late_cc
{
private:
// filter configuration
unsigned _sps;
float _alpha;
// filter state
int _counter;
float _err;
float _t;
public:
vector_early_late_cc_impl(unsigned sps,
float alpha);
virtual ~vector_early_late_cc_impl();
virtual int general_work(int noutput_items,
gr_vector_int& ninput_items,
gr_vector_const_void_star& input_items,
gr_vector_void_star& output_items);
protected:
};
} // namespace digitalhf
} // namespace gr
#endif /* INCLUDED_DIGITALHF_VECTOR_EARLY_LATE_CC_IMPL_H */

View file

@ -15,6 +15,7 @@
#include "digitalhf/viterbi39.h"
#include "digitalhf/viterbi48.h"
#include "digitalhf/vector_pll_cc.h"
#include "digitalhf/vector_early_late_cc.h"
%}
%include "digitalhf/adaptive_dfe.h"
@ -26,6 +27,9 @@ GR_SWIG_BLOCK_MAGIC2(digitalhf, doppler_correction_cc);
%include "digitalhf/vector_pll_cc.h"
GR_SWIG_BLOCK_MAGIC2(digitalhf, vector_pll_cc);
%include "digitalhf/vector_early_late_cc.h"
GR_SWIG_BLOCK_MAGIC2(digitalhf, vector_early_late_cc);
/* FIXME */
%include "digitalhf/viterbi27.h"
GR_SWIG_BLOCK_MAGIC2(digitalhf, viterbi27);