summaryrefslogtreecommitdiff
path: root/gr-noaa/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gr-noaa/lib')
-rw-r--r--gr-noaa/lib/.gitignore4
-rw-r--r--gr-noaa/lib/Makefile.am40
-rw-r--r--gr-noaa/lib/noaa_carrier_pll_cc.cc82
-rw-r--r--gr-noaa/lib/noaa_carrier_pll_cc.h55
4 files changed, 181 insertions, 0 deletions
diff --git a/gr-noaa/lib/.gitignore b/gr-noaa/lib/.gitignore
new file mode 100644
index 000000000..02b052397
--- /dev/null
+++ b/gr-noaa/lib/.gitignore
@@ -0,0 +1,4 @@
+Makefile
+Makefile.in
+.deps
+.libs
diff --git a/gr-noaa/lib/Makefile.am b/gr-noaa/lib/Makefile.am
new file mode 100644
index 000000000..39a4f1155
--- /dev/null
+++ b/gr-noaa/lib/Makefile.am
@@ -0,0 +1,40 @@
+#
+# 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.
+#
+
+include $(top_srcdir)/Makefile.common
+
+AM_CPPFLAGS = \
+ $(STD_DEFINES_AND_INCLUDES) \
+ $(WITH_INCLUDES)
+
+lib_LTLIBRARIES = \
+ libgnuradio-noaa.la
+
+libgnuradio_noaa_la_SOURCES = \
+ noaa_carrier_pll_cc.cc
+
+libgnuradio_noaa_la_LIBADD = \
+ $(GNURADIO_CORE_LA)
+
+libgnuradio_noaa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0
+
+grinclude_HEADERS = \
+ noaa_carrier_pll_cc.h
diff --git a/gr-noaa/lib/noaa_carrier_pll_cc.cc b/gr-noaa/lib/noaa_carrier_pll_cc.cc
new file mode 100644
index 000000000..d6a86faa1
--- /dev/null
+++ b/gr-noaa/lib/noaa_carrier_pll_cc.cc
@@ -0,0 +1,82 @@
+/* -*- 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 <noaa_carrier_pll_cc.h>
+#include <gr_io_signature.h>
+#include <gr_math.h>
+#include <gr_sincos.h>
+
+#define M_TWOPI (2*M_PI)
+
+noaa_carrier_pll_cc_sptr
+noaa_make_carrier_pll_cc(float alpha, float beta, float max_offset)
+{
+ return gnuradio::get_initial_sptr(new noaa_carrier_pll_cc(alpha, beta, max_offset));
+}
+
+noaa_carrier_pll_cc::noaa_carrier_pll_cc(float alpha, float beta, float max_offset)
+ : gr_sync_block("noaa_carrier_pll_cc",
+ gr_make_io_signature(1, 1, sizeof(gr_complex)),
+ gr_make_io_signature(1, 1, sizeof(gr_complex))),
+ d_alpha(alpha), d_beta(beta), d_max_offset(max_offset),
+ d_phase(0.0), d_freq(0.0)
+{
+}
+
+float
+phase_wrap(float phase)
+{
+ while (phase < -M_PI)
+ phase += M_TWOPI;
+ while (phase > M_PI)
+ phase -= M_TWOPI;
+
+ return phase;
+}
+
+int
+noaa_carrier_pll_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];
+
+ for (int i = 0; i < noutput_items; i++) {
+
+ // Adjust PLL phase/frequency
+ float error = phase_wrap(gr_fast_atan2f(in[i].imag(), in[i].real()) - d_phase);
+ d_freq = gr_branchless_clip(d_freq + error*d_beta, d_max_offset);
+ d_phase = phase_wrap(d_phase + error*d_alpha + d_freq);
+
+ // Generate and mix out carrier
+ float re, im;
+ gr_sincosf(d_phase, &im, &re);
+ out[i] = in[i]*gr_complex(re, -im);
+ }
+
+ return noutput_items;
+}
diff --git a/gr-noaa/lib/noaa_carrier_pll_cc.h b/gr-noaa/lib/noaa_carrier_pll_cc.h
new file mode 100644
index 000000000..8e6de866e
--- /dev/null
+++ b/gr-noaa/lib/noaa_carrier_pll_cc.h
@@ -0,0 +1,55 @@
+/* -*- 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_NOAA_CARRIER_PLL_CC_H
+#define INCLUDED_NOAA_CARRIER_PLL_CC_H
+
+#include <gr_sync_block.h>
+
+class noaa_carrier_pll_cc;
+typedef boost::shared_ptr<noaa_carrier_pll_cc> noaa_carrier_pll_cc_sptr;
+
+noaa_carrier_pll_cc_sptr
+noaa_make_carrier_pll_cc(float alpha, float beta, float max_offset);
+
+class noaa_carrier_pll_cc : public gr_sync_block
+{
+ friend noaa_carrier_pll_cc_sptr noaa_make_carrier_pll_cc(float alpha, float beta, float max_offset);
+ noaa_carrier_pll_cc(float alpha, float beta, float max_offset);
+
+ float d_alpha; // 1st order loop constant
+ float d_beta; // 2nd order loop constant
+ float d_max_offset; // Maximum frequency offset, radians/sample
+ float d_phase; // Instantaneous carrier phase
+ float d_freq; // Instantaneous carrier frequency, radians/sample
+
+ public:
+ virtual int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ void set_alpha(float alpha) { d_alpha = alpha; }
+ void set_beta(float beta) { d_beta = beta; }
+ void set_max_offset(float max_offset) { d_max_offset = max_offset; }
+};
+
+#endif /* INCLUDED_NOAA_CARRIER_PLL_CC_H */