/* -*- 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 #include #include #include #include "vector_pll_cc_impl.h" namespace gr { namespace digitalhf { vector_pll_cc::sptr vector_pll_cc::make(float samp_rate, size_t order, std::vector freq_multipliers) { return gnuradio::get_initial_sptr (new vector_pll_cc_impl(samp_rate, order, freq_multipliers)); } /* * The private constructor */ vector_pll_cc_impl::vector_pll_cc_impl(float samp_rate, size_t order, std::vector freq_multipliers) : gr::sync_block("vector_pll_cc", gr::io_signature::make(1, 1, freq_multipliers.size() * sizeof(gr_complex)), gr::io_signature::make(1, 1, freq_multipliers.size() * sizeof(gr_complex))) , _ts(1.0/samp_rate) , _order(order) , _freq_multipliers(freq_multipliers) , _control_loop(6.28/600.0, -6.28/600.0*10, 6.28/600.0*10) , _theta (freq_multipliers.size(), 0.0f) , _dtheta(freq_multipliers.size(), 0.0f) , _absz(freq_multipliers.size(), 1.0f) , _b({+0.6284830097698858, -0.6281540229565162}) , _uf(0) , _ud(0) { GR_LOG_DECLARE_LOGPTR(d_logger); GR_LOG_ASSIGN_LOGPTR(d_logger, "vector_pll_cc"); for (int i=0; i<_freq_multipliers.size(); ++i) { std::cout << "FM: " << i <<" " << _freq_multipliers[i] << std::endl; } } vector_pll_cc_impl::~vector_pll_cc_impl() { } int vector_pll_cc_impl::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { gr::thread::scoped_lock lock(d_setlock); size_t const vlen = _freq_multipliers.size(); const gr_complex *in = (const gr_complex*)input_items[0]; gr_complex *out = (gr_complex*)output_items[0]; _control_loop.frequency_limit(); std::vector error(vlen); float const mu = 5e-2; for (int i=0; i