summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnuradio-core/src/lib/general/Makefile.am3
-rw-r--r--gnuradio-core/src/lib/general/general.i2
-rw-r--r--gnuradio-core/src/lib/general/gr_fll_band_edge_cc.cc146
-rw-r--r--gnuradio-core/src/lib/general/gr_fll_band_edge_cc.h90
-rw-r--r--gnuradio-core/src/lib/general/gr_fll_band_edge_cc.i36
-rw-r--r--grc/blocks/Makefile.am1
-rw-r--r--grc/blocks/block_tree.xml2
-rw-r--r--grc/blocks/gr_fll_band_edge_cc.xml40
8 files changed, 320 insertions, 0 deletions
diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am
index cf6ff1e65..ecef7d6e3 100644
--- a/gnuradio-core/src/lib/general/Makefile.am
+++ b/gnuradio-core/src/lib/general/Makefile.am
@@ -76,6 +76,7 @@ libgeneral_la_SOURCES = \
gr_fft_vcc_fftw.cc \
gr_fft_vfc.cc \
gr_firdes.cc \
+ gr_fll_band_edge_cc.cc \
gr_float_to_char.cc \
gr_float_to_complex.cc \
gr_float_to_short.cc \
@@ -229,6 +230,7 @@ grinclude_HEADERS = \
gr_fft_vcc_fftw.h \
gr_fft_vfc.h \
gr_firdes.h \
+ gr_fll_band_edge_cc.h \
gr_float_to_char.h \
gr_float_to_complex.h \
gr_float_to_short.h \
@@ -396,6 +398,7 @@ swiginclude_HEADERS = \
gr_fft_vcc.i \
gr_fft_vfc.i \
gr_firdes.i \
+ gr_fll_band_edge_cc.i \
gr_float_to_char.i \
gr_float_to_complex.i \
gr_float_to_short.i \
diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i
index e1161c8eb..2c26b59cd 100644
--- a/gnuradio-core/src/lib/general/general.i
+++ b/gnuradio-core/src/lib/general/general.i
@@ -140,6 +140,7 @@
#include <gr_wavelet_ff.h>
#include <gr_wvps_ff.h>
#include <gr_copy.h>
+#include <gr_fll_band_edge_cc.h>
%}
%include "gr_nop.i"
@@ -260,3 +261,4 @@
%include "gr_wavelet_ff.i"
%include "gr_wvps_ff.i"
%include "gr_copy.i"
+%include "gr_fll_band_edge_cc.i"
diff --git a/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.cc b/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.cc
new file mode 100644
index 000000000..946fc1e85
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.cc
@@ -0,0 +1,146 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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.
+ *
+ * GNU Radio 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 GNU Radio; 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 <gr_fll_band_edge_cc.h>
+#include <gr_fir_ccc.h>
+#include <gr_fir_util.h>
+#include <gri_fft.h>
+#include <gr_io_signature.h>
+#include <gr_expj.h>
+#include <gr_math.h>
+#include <cstdio>
+
+#define M_TWOPI (2*M_PI)
+
+gr_fll_band_edge_cc_sptr gr_make_fll_band_edge_cc (const std::vector<gr_complex> &taps)
+{
+ return gr_fll_band_edge_cc_sptr (new gr_fll_band_edge_cc (taps));
+}
+
+
+gr_fll_band_edge_cc::gr_fll_band_edge_cc (const std::vector<gr_complex> &taps)
+ : gr_sync_block ("fll_band_edge_cc",
+ gr_make_io_signature (1, 1, sizeof(gr_complex)),
+ gr_make_io_signature (1, 1, sizeof(gr_complex))),
+ d_updated (false)
+{
+ d_alpha = 0.01;
+ d_beta = 0.25*d_alpha*d_alpha;
+ d_max_freq = M_TWOPI * 0.25;
+ d_min_freq = M_TWOPI * -0.5;
+
+ d_freq = 0;
+ d_phase = 0;
+
+ std::vector<gr_complex> vtaps(0, taps.size());
+ d_filter_upper = gr_fir_util::create_gr_fir_ccc(vtaps);
+ d_filter_lower = gr_fir_util::create_gr_fir_ccc(vtaps);
+
+ set_taps(taps);
+}
+
+gr_fll_band_edge_cc::~gr_fll_band_edge_cc ()
+{
+}
+
+void
+gr_fll_band_edge_cc::set_taps (const std::vector<gr_complex> &taps)
+{
+ unsigned int i;
+
+ for(i = 0; i < taps.size(); i++) {
+ d_taps_upper.push_back(taps[i]);
+ d_taps_lower.push_back(conj(taps[i]));
+ }
+
+ d_filter_upper->set_taps(d_taps_upper);
+ d_filter_lower->set_taps(d_taps_lower);
+
+ // Set the history to ensure enough input items for each filter
+ set_history(d_taps_upper.size()+1);
+
+ d_updated = true;
+}
+
+void
+gr_fll_band_edge_cc::print_taps()
+{
+ unsigned int i;
+ printf("Upper Band-edge: [");
+ for(i = 0; i < d_taps_upper.size(); i++) {
+ printf(" %.4e + j%.4e,", d_taps_upper[i].real(), d_taps_upper[i].imag());
+ }
+ printf("]\n\n");
+
+ printf("Lower Band-edge: [");
+ for(i = 0; i < d_taps_lower.size(); i++) {
+ printf(" %.4e + j%.4e,", d_taps_lower[i].real(), d_taps_lower[i].imag());
+ }
+ printf("]\n\n");
+}
+
+int
+gr_fll_band_edge_cc::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];
+
+ if (d_updated) {
+ d_updated = false;
+ return 0; // history requirements may have changed.
+ }
+
+ int i;
+ gr_complex nco_out;
+ float out_upper, out_lower;
+ float error;
+ for(i = 0; i < noutput_items; i++) {
+ nco_out = gr_expj(d_phase);
+ out[i] = in[i] * nco_out;
+
+ out_upper = norm(d_filter_upper->filter(&out[i]));
+ out_lower = norm(d_filter_lower->filter(&out[i]));
+ error = 0.1*(out_lower - out_upper);
+ printf("error: %f\n", out_upper);
+
+ d_freq = d_freq + d_beta * error;
+ d_phase = d_phase + d_freq + d_alpha * error;
+
+ if(d_phase > M_PI)
+ d_phase -= M_TWOPI;
+ else if(d_phase < -M_PI)
+ d_phase += M_TWOPI;
+
+ if (d_freq > d_max_freq)
+ d_freq = d_max_freq;
+ else if (d_freq < d_min_freq)
+ d_freq = d_min_freq;
+ }
+
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.h b/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.h
new file mode 100644
index 000000000..1c47167f8
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.h
@@ -0,0 +1,90 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+
+#ifndef INCLUDED_GR_FLL_BAND_EDGE_CC_H
+#define INCLUDED_GR_FLL_BAND_EDGE_CC_H
+
+#include <gr_sync_block.h>
+
+class gr_fll_band_edge_cc;
+typedef boost::shared_ptr<gr_fll_band_edge_cc> gr_fll_band_edge_cc_sptr;
+gr_fll_band_edge_cc_sptr gr_make_fll_band_edge_cc (const std::vector<gr_complex> &taps);
+
+class gr_fir_ccc;
+class gri_fft_complex;
+
+/*!
+ * \class gr_fll_band_edge_cc
+ * \brief Frequency Lock Loop using band-edge filters
+ *
+ * \ingroup general
+ */
+
+class gr_fll_band_edge_cc : public gr_sync_block
+{
+ private:
+ /*!
+ * Build the FLL
+ * \param taps (vector/list of gr_complex) The taps of the band-edge filter
+ */
+ friend gr_fll_band_edge_cc_sptr gr_make_fll_band_edge_cc (const std::vector<gr_complex> &taps);
+
+ float d_alpha;
+ float d_beta;
+ float d_max_freq;
+ float d_min_freq;
+
+ gr_fir_ccc* d_filter_upper;
+ gr_fir_ccc* d_filter_lower;
+ std::vector<gr_complex> d_taps_upper;
+ std::vector<gr_complex> d_taps_lower;
+ bool d_updated;
+ float d_freq;
+ float d_phase;
+
+ /*!
+ * Build the FLL
+ * \param taps (vector/list of gr_complex) The taps of the band-edge filter
+ */
+ gr_fll_band_edge_cc(const std::vector<gr_complex> &taps);
+
+public:
+ ~gr_fll_band_edge_cc ();
+
+ /*!
+ * Resets the filter taps with the new prototype filter
+ * \param taps (vector/list of gr_complex) The band-edge filter
+ */
+ void set_taps (const std::vector<gr_complex> &taps);
+
+ /*!
+ * Print the taps to screen.
+ */
+ void print_taps();
+
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif
diff --git a/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.i b/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.i
new file mode 100644
index 000000000..a550bec4e
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.i
@@ -0,0 +1,36 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,fll_band_edge_cc);
+
+gr_fll_band_edge_cc_sptr gr_make_fll_band_edge_cc (const std::vector<gr_complex> &taps);
+
+class gr_fll_band_edge_cc : public gr_sync_block
+{
+ private:
+ gr_fll_band_edge_cc (const std::vector<gr_complex> &taps);
+
+ public:
+ ~gr_fll_band_edge_cc ();
+
+ void set_taps (const std::vector<gr_complex> &taps);
+};
diff --git a/grc/blocks/Makefile.am b/grc/blocks/Makefile.am
index 9c91af543..a284d6d85 100644
--- a/grc/blocks/Makefile.am
+++ b/grc/blocks/Makefile.am
@@ -108,6 +108,7 @@ dist_ourdata_DATA = \
gr_file_source.xml \
gr_filter_delay_fc.xml \
gr_fir_filter_xxx.xml \
+ gr_fll_band_edge_cc.xml \
gr_float_to_char.xml \
gr_float_to_complex.xml \
gr_float_to_short.xml \
diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml
index 57703f6d6..ba597756f 100644
--- a/grc/blocks/block_tree.xml
+++ b/grc/blocks/block_tree.xml
@@ -138,6 +138,8 @@
<block>gr_pll_freqdet_cf</block>
<block>gr_pll_refout_cc</block>
+ <block>gr_fll_band_edge_cc</block>
+
<block>gr_correlate_access_code_bb</block>
<block>gr_pn_correlator_cc</block>
<block>gr_simple_correlator</block>
diff --git a/grc/blocks/gr_fll_band_edge_cc.xml b/grc/blocks/gr_fll_band_edge_cc.xml
new file mode 100644
index 000000000..4fe2c03f1
--- /dev/null
+++ b/grc/blocks/gr_fll_band_edge_cc.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## FLL using Band-Edge Filters
+###################################################
+ -->
+<block>
+ <name>FLL Band-Edge</name>
+ <key>gr_fll_band_edge_cc</key>
+ <import>from gnuradio import gr</import>
+ <make>gr.fll_band_edge_cc($taps)</make>
+ <callback>set_taps($taps)</callback>
+
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex->Complex</name>
+ <key>cc</key>
+ <opt>input:complex</opt>
+ <opt>output:complex</opt>
+ <opt>taps:complex_vector</opt>
+ </option>
+ </param>
+
+ <param>
+ <name>Taps</name>
+ <key>taps</key>
+ <type>complex_vector</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type.input</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type.output</type>
+ </source>
+</block>