From b6101982e270948b4a3185ee745ed76bb8661552 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Sat, 15 Aug 2009 12:30:45 -0700 Subject: Created new gr-noaa top-level component. Initial work: - Carrier recovery/mixer PLL block - Start of POES grc pipeline, recovers Manchester symbols only - Start of GOES grc pipeline, recovers BPSK symbols only --- gr-noaa/lib/.gitignore | 4 ++ gr-noaa/lib/Makefile.am | 40 +++++++++++++++++++ gr-noaa/lib/noaa_carrier_pll_cc.cc | 82 ++++++++++++++++++++++++++++++++++++++ gr-noaa/lib/noaa_carrier_pll_cc.h | 55 +++++++++++++++++++++++++ 4 files changed, 181 insertions(+) create mode 100644 gr-noaa/lib/.gitignore create mode 100644 gr-noaa/lib/Makefile.am create mode 100644 gr-noaa/lib/noaa_carrier_pll_cc.cc create mode 100644 gr-noaa/lib/noaa_carrier_pll_cc.h (limited to 'gr-noaa/lib') 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 +#include +#include +#include + +#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 + +class noaa_carrier_pll_cc; +typedef boost::shared_ptr 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 */ -- cgit From 6b6a5522e0b1d12ef5d697b1067a87dfe584cec6 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Sat, 29 Aug 2009 11:12:37 -0700 Subject: Work in progress, incomplete * Renamed noaa.carrier_pll_cc to noaa.hrpt_pll_cc * Added nop noaa.hrpt_sync_cc * Renamed grc apps to use usrp_ prefix and protocol name * Installed grc generated scripts to path --- gr-noaa/lib/Makefile.am | 6 ++- gr-noaa/lib/noaa_carrier_pll_cc.cc | 82 -------------------------------------- gr-noaa/lib/noaa_carrier_pll_cc.h | 55 ------------------------- gr-noaa/lib/noaa_hrpt_pll_cc.cc | 82 ++++++++++++++++++++++++++++++++++++++ gr-noaa/lib/noaa_hrpt_pll_cc.h | 55 +++++++++++++++++++++++++ gr-noaa/lib/noaa_hrpt_sync_cc.cc | 62 ++++++++++++++++++++++++++++ gr-noaa/lib/noaa_hrpt_sync_cc.h | 57 ++++++++++++++++++++++++++ 7 files changed, 260 insertions(+), 139 deletions(-) delete mode 100644 gr-noaa/lib/noaa_carrier_pll_cc.cc delete mode 100644 gr-noaa/lib/noaa_carrier_pll_cc.h create mode 100644 gr-noaa/lib/noaa_hrpt_pll_cc.cc create mode 100644 gr-noaa/lib/noaa_hrpt_pll_cc.h create mode 100644 gr-noaa/lib/noaa_hrpt_sync_cc.cc create mode 100644 gr-noaa/lib/noaa_hrpt_sync_cc.h (limited to 'gr-noaa/lib') diff --git a/gr-noaa/lib/Makefile.am b/gr-noaa/lib/Makefile.am index 39a4f1155..2690ddb54 100644 --- a/gr-noaa/lib/Makefile.am +++ b/gr-noaa/lib/Makefile.am @@ -29,7 +29,8 @@ lib_LTLIBRARIES = \ libgnuradio-noaa.la libgnuradio_noaa_la_SOURCES = \ - noaa_carrier_pll_cc.cc + noaa_hrpt_pll_cc.cc \ + noaa_hrpt_sync_cc.cc libgnuradio_noaa_la_LIBADD = \ $(GNURADIO_CORE_LA) @@ -37,4 +38,5 @@ libgnuradio_noaa_la_LIBADD = \ libgnuradio_noaa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 grinclude_HEADERS = \ - noaa_carrier_pll_cc.h + noaa_hrpt_pll_cc.h \ + noaa_hrpt_sync_cc.h diff --git a/gr-noaa/lib/noaa_carrier_pll_cc.cc b/gr-noaa/lib/noaa_carrier_pll_cc.cc deleted file mode 100644 index d6a86faa1..000000000 --- a/gr-noaa/lib/noaa_carrier_pll_cc.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- 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 -#include -#include -#include - -#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 deleted file mode 100644 index 8e6de866e..000000000 --- a/gr-noaa/lib/noaa_carrier_pll_cc.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- 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 - -class noaa_carrier_pll_cc; -typedef boost::shared_ptr 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 */ diff --git a/gr-noaa/lib/noaa_hrpt_pll_cc.cc b/gr-noaa/lib/noaa_hrpt_pll_cc.cc new file mode 100644 index 000000000..46fe24da4 --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_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 +#include +#include +#include + +#define M_TWOPI (2*M_PI) + +noaa_hrpt_pll_cc_sptr +noaa_make_hrpt_pll_cc(float alpha, float beta, float max_offset) +{ + return gnuradio::get_initial_sptr(new noaa_hrpt_pll_cc(alpha, beta, max_offset)); +} + +noaa_hrpt_pll_cc::noaa_hrpt_pll_cc(float alpha, float beta, float max_offset) + : gr_sync_block("noaa_hrpt_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_hrpt_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_hrpt_pll_cc.h b/gr-noaa/lib/noaa_hrpt_pll_cc.h new file mode 100644 index 000000000..810454406 --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_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_HRPT_PLL_CC_H +#define INCLUDED_NOAA_HRPT_PLL_CC_H + +#include + +class noaa_hrpt_pll_cc; +typedef boost::shared_ptr noaa_hrpt_pll_cc_sptr; + +noaa_hrpt_pll_cc_sptr +noaa_make_hrpt_pll_cc(float alpha, float beta, float max_offset); + +class noaa_hrpt_pll_cc : public gr_sync_block +{ + friend noaa_hrpt_pll_cc_sptr noaa_make_hrpt_pll_cc(float alpha, float beta, float max_offset); + noaa_hrpt_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_HRPT_PLL_CC_H */ diff --git a/gr-noaa/lib/noaa_hrpt_sync_cc.cc b/gr-noaa/lib/noaa_hrpt_sync_cc.cc new file mode 100644 index 000000000..47858d758 --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_sync_cc.cc @@ -0,0 +1,62 @@ +/* -*- 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 +#include + +noaa_hrpt_sync_cc_sptr +noaa_make_hrpt_sync_cc(float alpha, float beta, float sps, float max_offset) +{ + return gnuradio::get_initial_sptr(new noaa_hrpt_sync_cc(alpha, beta, sps, max_offset)); +} + +noaa_hrpt_sync_cc::noaa_hrpt_sync_cc(float alpha, float beta, float sps, float max_offset) + : gr_block("noaa_hrpt_sync_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_sps(sps), d_max_offset(max_offset), + d_phase(0.0), d_freq(0.0) +{ +} + +int +noaa_hrpt_sync_cc::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + int ninputs = ninput_items[0]; + const gr_complex *in = (const gr_complex *) input_items[0]; + gr_complex *out = (gr_complex *) output_items[0]; + + int i = 0, j = 0; + while (i < ninputs && j < noutput_items) { + out[j++] = in[i++]; + } + + consume_each(i); + return j; +} diff --git a/gr-noaa/lib/noaa_hrpt_sync_cc.h b/gr-noaa/lib/noaa_hrpt_sync_cc.h new file mode 100644 index 000000000..f5b23ccaf --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_sync_cc.h @@ -0,0 +1,57 @@ +/* -*- 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_HRPT_SYNC_CC_H +#define INCLUDED_NOAA_HRPT_SYNC_CC_H + +#include + +class noaa_hrpt_sync_cc; +typedef boost::shared_ptr noaa_hrpt_sync_cc_sptr; + +noaa_hrpt_sync_cc_sptr +noaa_make_hrpt_sync_cc(float alpha, float beta, float sps, float max_offset); + +class noaa_hrpt_sync_cc : public gr_block +{ + friend noaa_hrpt_sync_cc_sptr noaa_make_hrpt_sync_cc(float alpha, float beta, float sps, float max_offset); + noaa_hrpt_sync_cc(float alpha, float beta, float sps, float max_offset); + + float d_alpha; // 1st order loop constant + float d_beta; // 2nd order loop constant + float d_sps; // samples per symbol + float d_max_offset; // Maximum frequency offset for d_sps, samples/symbol + float d_phase; // Instantaneous symbol phase + float d_freq; // Instantaneous symbol frequency, samples/symbol + + public: + int general_work(int noutput_items, + gr_vector_int &ninput_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_HRPT_SYNC_CC_H */ -- cgit From 225d3141a7f4754eae5a1a041e1d18dc38131772 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Sat, 29 Aug 2009 13:24:58 -0700 Subject: Implemented crude timing recovery using zero crossings but no resampling --- gr-noaa/lib/noaa_hrpt_sync_cc.cc | 31 ++++++++++++++++++++++++++++--- gr-noaa/lib/noaa_hrpt_sync_cc.h | 1 + 2 files changed, 29 insertions(+), 3 deletions(-) (limited to 'gr-noaa/lib') diff --git a/gr-noaa/lib/noaa_hrpt_sync_cc.cc b/gr-noaa/lib/noaa_hrpt_sync_cc.cc index 47858d758..46cc277bd 100644 --- a/gr-noaa/lib/noaa_hrpt_sync_cc.cc +++ b/gr-noaa/lib/noaa_hrpt_sync_cc.cc @@ -27,6 +27,11 @@ #include #include +inline int signum(float f) +{ + return f >= 0.0 ? 1 : -1; +} + noaa_hrpt_sync_cc_sptr noaa_make_hrpt_sync_cc(float alpha, float beta, float sps, float max_offset) { @@ -37,8 +42,10 @@ noaa_hrpt_sync_cc::noaa_hrpt_sync_cc(float alpha, float beta, float sps, float m : gr_block("noaa_hrpt_sync_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_sps(sps), d_max_offset(max_offset), - d_phase(0.0), d_freq(0.0) + d_alpha(alpha), d_beta(beta), + d_sps(sps), d_max_offset(max_offset), + d_phase(0.0), d_freq(1.0/sps), + d_last_sign(1) { } @@ -54,7 +61,25 @@ noaa_hrpt_sync_cc::general_work(int noutput_items, int i = 0, j = 0; while (i < ninputs && j < noutput_items) { - out[j++] = in[i++]; + float sample = in[i++].imag(); + int sign = signum(sample); + d_phase += d_freq; + + // Train on zero crossings in center region of symbol + if (sign != d_last_sign) { + if (d_phase > 0.25 && d_phase < 0.75) { + float phase_err = d_phase-0.5; + d_phase -= phase_err*d_alpha; // 1st order phase adjustment + d_freq -= phase_err*d_beta; // 2nd order frequency adjustment + } + + d_last_sign = sign; + } + + if (d_phase > 1.0) { + out[j++] = in[i]; + d_phase -= 1.0; + } } consume_each(i); diff --git a/gr-noaa/lib/noaa_hrpt_sync_cc.h b/gr-noaa/lib/noaa_hrpt_sync_cc.h index f5b23ccaf..6abbcad48 100644 --- a/gr-noaa/lib/noaa_hrpt_sync_cc.h +++ b/gr-noaa/lib/noaa_hrpt_sync_cc.h @@ -42,6 +42,7 @@ class noaa_hrpt_sync_cc : public gr_block float d_max_offset; // Maximum frequency offset for d_sps, samples/symbol float d_phase; // Instantaneous symbol phase float d_freq; // Instantaneous symbol frequency, samples/symbol + int d_last_sign; // Tracks zero crossings public: int general_work(int noutput_items, -- cgit From 65bcd58b65219408268e5db1b8fbafb2d3ccc215 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Mon, 7 Sep 2009 13:22:16 -0700 Subject: Updated HRPT blocks/scripts for testing. Seeing good minor frame sync's. * Change PLL and SYNC blocks to output floats * Correct bit sense * Update RX script to record ascii bits --- gr-noaa/lib/Makefile.am | 8 ++-- gr-noaa/lib/noaa_hrpt_pll_cc.cc | 82 ------------------------------------- gr-noaa/lib/noaa_hrpt_pll_cc.h | 55 ------------------------- gr-noaa/lib/noaa_hrpt_pll_cf.cc | 82 +++++++++++++++++++++++++++++++++++++ gr-noaa/lib/noaa_hrpt_pll_cf.h | 55 +++++++++++++++++++++++++ gr-noaa/lib/noaa_hrpt_sync_cc.cc | 87 ---------------------------------------- gr-noaa/lib/noaa_hrpt_sync_cc.h | 58 --------------------------- gr-noaa/lib/noaa_hrpt_sync_ff.cc | 87 ++++++++++++++++++++++++++++++++++++++++ gr-noaa/lib/noaa_hrpt_sync_ff.h | 58 +++++++++++++++++++++++++++ 9 files changed, 286 insertions(+), 286 deletions(-) delete mode 100644 gr-noaa/lib/noaa_hrpt_pll_cc.cc delete mode 100644 gr-noaa/lib/noaa_hrpt_pll_cc.h create mode 100644 gr-noaa/lib/noaa_hrpt_pll_cf.cc create mode 100644 gr-noaa/lib/noaa_hrpt_pll_cf.h delete mode 100644 gr-noaa/lib/noaa_hrpt_sync_cc.cc delete mode 100644 gr-noaa/lib/noaa_hrpt_sync_cc.h create mode 100644 gr-noaa/lib/noaa_hrpt_sync_ff.cc create mode 100644 gr-noaa/lib/noaa_hrpt_sync_ff.h (limited to 'gr-noaa/lib') diff --git a/gr-noaa/lib/Makefile.am b/gr-noaa/lib/Makefile.am index 2690ddb54..913638783 100644 --- a/gr-noaa/lib/Makefile.am +++ b/gr-noaa/lib/Makefile.am @@ -29,8 +29,8 @@ lib_LTLIBRARIES = \ libgnuradio-noaa.la libgnuradio_noaa_la_SOURCES = \ - noaa_hrpt_pll_cc.cc \ - noaa_hrpt_sync_cc.cc + noaa_hrpt_pll_cf.cc \ + noaa_hrpt_sync_ff.cc libgnuradio_noaa_la_LIBADD = \ $(GNURADIO_CORE_LA) @@ -38,5 +38,5 @@ libgnuradio_noaa_la_LIBADD = \ libgnuradio_noaa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 grinclude_HEADERS = \ - noaa_hrpt_pll_cc.h \ - noaa_hrpt_sync_cc.h + noaa_hrpt_pll_cf.h \ + noaa_hrpt_sync_ff.h diff --git a/gr-noaa/lib/noaa_hrpt_pll_cc.cc b/gr-noaa/lib/noaa_hrpt_pll_cc.cc deleted file mode 100644 index 46fe24da4..000000000 --- a/gr-noaa/lib/noaa_hrpt_pll_cc.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- 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 -#include -#include -#include - -#define M_TWOPI (2*M_PI) - -noaa_hrpt_pll_cc_sptr -noaa_make_hrpt_pll_cc(float alpha, float beta, float max_offset) -{ - return gnuradio::get_initial_sptr(new noaa_hrpt_pll_cc(alpha, beta, max_offset)); -} - -noaa_hrpt_pll_cc::noaa_hrpt_pll_cc(float alpha, float beta, float max_offset) - : gr_sync_block("noaa_hrpt_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_hrpt_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_hrpt_pll_cc.h b/gr-noaa/lib/noaa_hrpt_pll_cc.h deleted file mode 100644 index 810454406..000000000 --- a/gr-noaa/lib/noaa_hrpt_pll_cc.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- 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_HRPT_PLL_CC_H -#define INCLUDED_NOAA_HRPT_PLL_CC_H - -#include - -class noaa_hrpt_pll_cc; -typedef boost::shared_ptr noaa_hrpt_pll_cc_sptr; - -noaa_hrpt_pll_cc_sptr -noaa_make_hrpt_pll_cc(float alpha, float beta, float max_offset); - -class noaa_hrpt_pll_cc : public gr_sync_block -{ - friend noaa_hrpt_pll_cc_sptr noaa_make_hrpt_pll_cc(float alpha, float beta, float max_offset); - noaa_hrpt_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_HRPT_PLL_CC_H */ diff --git a/gr-noaa/lib/noaa_hrpt_pll_cf.cc b/gr-noaa/lib/noaa_hrpt_pll_cf.cc new file mode 100644 index 000000000..08ab1d15f --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_pll_cf.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 +#include +#include +#include + +#define M_TWOPI (2*M_PI) + +noaa_hrpt_pll_cf_sptr +noaa_make_hrpt_pll_cf(float alpha, float beta, float max_offset) +{ + return gnuradio::get_initial_sptr(new noaa_hrpt_pll_cf(alpha, beta, max_offset)); +} + +noaa_hrpt_pll_cf::noaa_hrpt_pll_cf(float alpha, float beta, float max_offset) + : gr_sync_block("noaa_hrpt_pll_cf", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(1, 1, sizeof(float))), + 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_hrpt_pll_cf::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]; + float *out = (float *) 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)).imag(); + } + + return noutput_items; +} diff --git a/gr-noaa/lib/noaa_hrpt_pll_cf.h b/gr-noaa/lib/noaa_hrpt_pll_cf.h new file mode 100644 index 000000000..507d47fe7 --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_pll_cf.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_HRPT_PLL_CF_H +#define INCLUDED_NOAA_HRPT_PLL_CF_H + +#include + +class noaa_hrpt_pll_cf; +typedef boost::shared_ptr noaa_hrpt_pll_cf_sptr; + +noaa_hrpt_pll_cf_sptr +noaa_make_hrpt_pll_cf(float alpha, float beta, float max_offset); + +class noaa_hrpt_pll_cf : public gr_sync_block +{ + friend noaa_hrpt_pll_cf_sptr noaa_make_hrpt_pll_cf(float alpha, float beta, float max_offset); + noaa_hrpt_pll_cf(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_HRPT_PLL_CF_H */ diff --git a/gr-noaa/lib/noaa_hrpt_sync_cc.cc b/gr-noaa/lib/noaa_hrpt_sync_cc.cc deleted file mode 100644 index 46cc277bd..000000000 --- a/gr-noaa/lib/noaa_hrpt_sync_cc.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- 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 -#include - -inline int signum(float f) -{ - return f >= 0.0 ? 1 : -1; -} - -noaa_hrpt_sync_cc_sptr -noaa_make_hrpt_sync_cc(float alpha, float beta, float sps, float max_offset) -{ - return gnuradio::get_initial_sptr(new noaa_hrpt_sync_cc(alpha, beta, sps, max_offset)); -} - -noaa_hrpt_sync_cc::noaa_hrpt_sync_cc(float alpha, float beta, float sps, float max_offset) - : gr_block("noaa_hrpt_sync_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_sps(sps), d_max_offset(max_offset), - d_phase(0.0), d_freq(1.0/sps), - d_last_sign(1) -{ -} - -int -noaa_hrpt_sync_cc::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - int ninputs = ninput_items[0]; - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - int i = 0, j = 0; - while (i < ninputs && j < noutput_items) { - float sample = in[i++].imag(); - int sign = signum(sample); - d_phase += d_freq; - - // Train on zero crossings in center region of symbol - if (sign != d_last_sign) { - if (d_phase > 0.25 && d_phase < 0.75) { - float phase_err = d_phase-0.5; - d_phase -= phase_err*d_alpha; // 1st order phase adjustment - d_freq -= phase_err*d_beta; // 2nd order frequency adjustment - } - - d_last_sign = sign; - } - - if (d_phase > 1.0) { - out[j++] = in[i]; - d_phase -= 1.0; - } - } - - consume_each(i); - return j; -} diff --git a/gr-noaa/lib/noaa_hrpt_sync_cc.h b/gr-noaa/lib/noaa_hrpt_sync_cc.h deleted file mode 100644 index 6abbcad48..000000000 --- a/gr-noaa/lib/noaa_hrpt_sync_cc.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- 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_HRPT_SYNC_CC_H -#define INCLUDED_NOAA_HRPT_SYNC_CC_H - -#include - -class noaa_hrpt_sync_cc; -typedef boost::shared_ptr noaa_hrpt_sync_cc_sptr; - -noaa_hrpt_sync_cc_sptr -noaa_make_hrpt_sync_cc(float alpha, float beta, float sps, float max_offset); - -class noaa_hrpt_sync_cc : public gr_block -{ - friend noaa_hrpt_sync_cc_sptr noaa_make_hrpt_sync_cc(float alpha, float beta, float sps, float max_offset); - noaa_hrpt_sync_cc(float alpha, float beta, float sps, float max_offset); - - float d_alpha; // 1st order loop constant - float d_beta; // 2nd order loop constant - float d_sps; // samples per symbol - float d_max_offset; // Maximum frequency offset for d_sps, samples/symbol - float d_phase; // Instantaneous symbol phase - float d_freq; // Instantaneous symbol frequency, samples/symbol - int d_last_sign; // Tracks zero crossings - - public: - int general_work(int noutput_items, - gr_vector_int &ninput_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_HRPT_SYNC_CC_H */ diff --git a/gr-noaa/lib/noaa_hrpt_sync_ff.cc b/gr-noaa/lib/noaa_hrpt_sync_ff.cc new file mode 100644 index 000000000..f17ad54dc --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_sync_ff.cc @@ -0,0 +1,87 @@ +/* -*- 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 +#include + +inline int signum(float f) +{ + return f >= 0.0 ? 1 : -1; +} + +noaa_hrpt_sync_ff_sptr +noaa_make_hrpt_sync_ff(float alpha, float beta, float sps, float max_offset) +{ + return gnuradio::get_initial_sptr(new noaa_hrpt_sync_ff(alpha, beta, sps, max_offset)); +} + +noaa_hrpt_sync_ff::noaa_hrpt_sync_ff(float alpha, float beta, float sps, float max_offset) + : gr_block("noaa_hrpt_sync_ff", + gr_make_io_signature(1, 1, sizeof(float)), + gr_make_io_signature(1, 1, sizeof(float))), + d_alpha(alpha), d_beta(beta), + d_sps(sps), d_max_offset(max_offset), + d_phase(0.0), d_freq(1.0/sps), + d_last_sign(1) +{ +} + +int +noaa_hrpt_sync_ff::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + int ninputs = ninput_items[0]; + const float *in = (const float *) input_items[0]; + float *out = (float *) output_items[0]; + + int i = 0, j = 0; + while (i < ninputs && j < noutput_items) { + float sample = in[i++]; + int sign = signum(sample); + d_phase += d_freq; + + // Train on zero crossings in center region of symbol + if (sign != d_last_sign) { + if (d_phase > 0.25 && d_phase < 0.75) { + float phase_err = d_phase-0.5; + d_phase -= phase_err*d_alpha; // 1st order phase adjustment + d_freq -= phase_err*d_beta; // 2nd order frequency adjustment + } + + d_last_sign = sign; + } + + if (d_phase > 1.0) { + out[j++] = -sample; // Invert sense, -68 degrees=1 + d_phase -= 1.0; + } + } + + consume_each(i); + return j; +} diff --git a/gr-noaa/lib/noaa_hrpt_sync_ff.h b/gr-noaa/lib/noaa_hrpt_sync_ff.h new file mode 100644 index 000000000..51502698b --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_sync_ff.h @@ -0,0 +1,58 @@ +/* -*- 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_HRPT_SYNC_FF_H +#define INCLUDED_NOAA_HRPT_SYNC_FF_H + +#include + +class noaa_hrpt_sync_ff; +typedef boost::shared_ptr noaa_hrpt_sync_ff_sptr; + +noaa_hrpt_sync_ff_sptr +noaa_make_hrpt_sync_ff(float alpha, float beta, float sps, float max_offset); + +class noaa_hrpt_sync_ff : public gr_block +{ + friend noaa_hrpt_sync_ff_sptr noaa_make_hrpt_sync_ff(float alpha, float beta, float sps, float max_offset); + noaa_hrpt_sync_ff(float alpha, float beta, float sps, float max_offset); + + float d_alpha; // 1st order loop constant + float d_beta; // 2nd order loop constant + float d_sps; // samples per symbol + float d_max_offset; // Maximum frequency offset for d_sps, samples/symbol + float d_phase; // Instantaneous symbol phase + float d_freq; // Instantaneous symbol frequency, samples/symbol + int d_last_sign; // Tracks zero crossings + + public: + int general_work(int noutput_items, + gr_vector_int &ninput_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_HRPT_SYNC_FF_H */ -- cgit From b7d1c551fb374a0e5219fbb4d118f3f19f448393 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Tue, 8 Sep 2009 16:52:37 -0700 Subject: Changed synchronizer to output sliced bits. --- gr-noaa/lib/Makefile.am | 4 +- gr-noaa/lib/noaa_hrpt_sync_fb.cc | 90 ++++++++++++++++++++++++++++++++++++++++ gr-noaa/lib/noaa_hrpt_sync_fb.h | 58 ++++++++++++++++++++++++++ gr-noaa/lib/noaa_hrpt_sync_ff.cc | 87 -------------------------------------- gr-noaa/lib/noaa_hrpt_sync_ff.h | 58 -------------------------- 5 files changed, 150 insertions(+), 147 deletions(-) create mode 100644 gr-noaa/lib/noaa_hrpt_sync_fb.cc create mode 100644 gr-noaa/lib/noaa_hrpt_sync_fb.h delete mode 100644 gr-noaa/lib/noaa_hrpt_sync_ff.cc delete mode 100644 gr-noaa/lib/noaa_hrpt_sync_ff.h (limited to 'gr-noaa/lib') diff --git a/gr-noaa/lib/Makefile.am b/gr-noaa/lib/Makefile.am index 913638783..1b758871a 100644 --- a/gr-noaa/lib/Makefile.am +++ b/gr-noaa/lib/Makefile.am @@ -30,7 +30,7 @@ lib_LTLIBRARIES = \ libgnuradio_noaa_la_SOURCES = \ noaa_hrpt_pll_cf.cc \ - noaa_hrpt_sync_ff.cc + noaa_hrpt_sync_fb.cc libgnuradio_noaa_la_LIBADD = \ $(GNURADIO_CORE_LA) @@ -39,4 +39,4 @@ libgnuradio_noaa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 grinclude_HEADERS = \ noaa_hrpt_pll_cf.h \ - noaa_hrpt_sync_ff.h + noaa_hrpt_sync_fb.h diff --git a/gr-noaa/lib/noaa_hrpt_sync_fb.cc b/gr-noaa/lib/noaa_hrpt_sync_fb.cc new file mode 100644 index 000000000..f99947f82 --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_sync_fb.cc @@ -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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +inline int signum(float f) +{ + return f >= 0.0 ? 1 : -1; +} + +noaa_hrpt_sync_fb_sptr +noaa_make_hrpt_sync_fb(float alpha, float beta, float sps, float max_offset) +{ + return gnuradio::get_initial_sptr(new noaa_hrpt_sync_fb(alpha, beta, sps, max_offset)); +} + +noaa_hrpt_sync_fb::noaa_hrpt_sync_fb(float alpha, float beta, float sps, float max_offset) + : gr_block("noaa_hrpt_sync_fb", + gr_make_io_signature(1, 1, sizeof(float)), + gr_make_io_signature(1, 1, sizeof(char))), + d_alpha(alpha), d_beta(beta), + d_sps(sps), d_max_offset(max_offset), + d_phase(0.0), d_freq(1.0/sps), + d_last_sign(1) +{ +} + +int +noaa_hrpt_sync_fb::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + int ninputs = ninput_items[0]; + const float *in = (const float *)input_items[0]; + char *out = (char *)output_items[0]; + + int i = 0, j = 0; + while (i < ninputs && j < noutput_items) { + float sample = in[i++]; + int sign = signum(sample); + d_phase += d_freq; + + // Train on zero crossings in center region of symbol + if (sign != d_last_sign) { + if (d_phase > 0.25 && d_phase < 0.75) { + float phase_err = d_phase-0.5; + d_phase -= phase_err*d_alpha; // 1st order phase adjustment + d_freq -= phase_err*d_beta; // 2nd order frequency adjustment + } + + d_last_sign = sign; + } + + if (d_phase > 1.0) { + if (sample < 0.0) + out[j++] = 1; + else + out[j++] = 0; + d_phase -= 1.0; + } + } + + consume_each(i); + return j; +} diff --git a/gr-noaa/lib/noaa_hrpt_sync_fb.h b/gr-noaa/lib/noaa_hrpt_sync_fb.h new file mode 100644 index 000000000..a9416b9ea --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_sync_fb.h @@ -0,0 +1,58 @@ +/* -*- 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_HRPT_SYNC_FB_H +#define INCLUDED_NOAA_HRPT_SYNC_FB_H + +#include + +class noaa_hrpt_sync_fb; +typedef boost::shared_ptr noaa_hrpt_sync_fb_sptr; + +noaa_hrpt_sync_fb_sptr +noaa_make_hrpt_sync_fb(float alpha, float beta, float sps, float max_offset); + +class noaa_hrpt_sync_fb : public gr_block +{ + friend noaa_hrpt_sync_fb_sptr noaa_make_hrpt_sync_fb(float alpha, float beta, float sps, float max_offset); + noaa_hrpt_sync_fb(float alpha, float beta, float sps, float max_offset); + + float d_alpha; // 1st order loop constant + float d_beta; // 2nd order loop constant + float d_sps; // samples per symbol + float d_max_offset; // Maximum frequency offset for d_sps, samples/symbol + float d_phase; // Instantaneous symbol phase + float d_freq; // Instantaneous symbol frequency, samples/symbol + int d_last_sign; // Tracks zero crossings + + public: + int general_work(int noutput_items, + gr_vector_int &ninput_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_HRPT_SYNC_FB_H */ diff --git a/gr-noaa/lib/noaa_hrpt_sync_ff.cc b/gr-noaa/lib/noaa_hrpt_sync_ff.cc deleted file mode 100644 index f17ad54dc..000000000 --- a/gr-noaa/lib/noaa_hrpt_sync_ff.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- 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 -#include - -inline int signum(float f) -{ - return f >= 0.0 ? 1 : -1; -} - -noaa_hrpt_sync_ff_sptr -noaa_make_hrpt_sync_ff(float alpha, float beta, float sps, float max_offset) -{ - return gnuradio::get_initial_sptr(new noaa_hrpt_sync_ff(alpha, beta, sps, max_offset)); -} - -noaa_hrpt_sync_ff::noaa_hrpt_sync_ff(float alpha, float beta, float sps, float max_offset) - : gr_block("noaa_hrpt_sync_ff", - gr_make_io_signature(1, 1, sizeof(float)), - gr_make_io_signature(1, 1, sizeof(float))), - d_alpha(alpha), d_beta(beta), - d_sps(sps), d_max_offset(max_offset), - d_phase(0.0), d_freq(1.0/sps), - d_last_sign(1) -{ -} - -int -noaa_hrpt_sync_ff::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - int ninputs = ninput_items[0]; - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - int i = 0, j = 0; - while (i < ninputs && j < noutput_items) { - float sample = in[i++]; - int sign = signum(sample); - d_phase += d_freq; - - // Train on zero crossings in center region of symbol - if (sign != d_last_sign) { - if (d_phase > 0.25 && d_phase < 0.75) { - float phase_err = d_phase-0.5; - d_phase -= phase_err*d_alpha; // 1st order phase adjustment - d_freq -= phase_err*d_beta; // 2nd order frequency adjustment - } - - d_last_sign = sign; - } - - if (d_phase > 1.0) { - out[j++] = -sample; // Invert sense, -68 degrees=1 - d_phase -= 1.0; - } - } - - consume_each(i); - return j; -} diff --git a/gr-noaa/lib/noaa_hrpt_sync_ff.h b/gr-noaa/lib/noaa_hrpt_sync_ff.h deleted file mode 100644 index 51502698b..000000000 --- a/gr-noaa/lib/noaa_hrpt_sync_ff.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- 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_HRPT_SYNC_FF_H -#define INCLUDED_NOAA_HRPT_SYNC_FF_H - -#include - -class noaa_hrpt_sync_ff; -typedef boost::shared_ptr noaa_hrpt_sync_ff_sptr; - -noaa_hrpt_sync_ff_sptr -noaa_make_hrpt_sync_ff(float alpha, float beta, float sps, float max_offset); - -class noaa_hrpt_sync_ff : public gr_block -{ - friend noaa_hrpt_sync_ff_sptr noaa_make_hrpt_sync_ff(float alpha, float beta, float sps, float max_offset); - noaa_hrpt_sync_ff(float alpha, float beta, float sps, float max_offset); - - float d_alpha; // 1st order loop constant - float d_beta; // 2nd order loop constant - float d_sps; // samples per symbol - float d_max_offset; // Maximum frequency offset for d_sps, samples/symbol - float d_phase; // Instantaneous symbol phase - float d_freq; // Instantaneous symbol frequency, samples/symbol - int d_last_sign; // Tracks zero crossings - - public: - int general_work(int noutput_items, - gr_vector_int &ninput_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_HRPT_SYNC_FF_H */ -- cgit From ce9a41e69f5e3b9e0280d22fa778d167c3982db7 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Tue, 8 Sep 2009 21:08:29 -0700 Subject: Added HRPT deframer block --- gr-noaa/lib/Makefile.am | 2 + gr-noaa/lib/noaa_hrpt_deframer.cc | 102 ++++++++++++++++++++++++++++++++++++++ gr-noaa/lib/noaa_hrpt_deframer.h | 52 +++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 gr-noaa/lib/noaa_hrpt_deframer.cc create mode 100644 gr-noaa/lib/noaa_hrpt_deframer.h (limited to 'gr-noaa/lib') diff --git a/gr-noaa/lib/Makefile.am b/gr-noaa/lib/Makefile.am index 1b758871a..578c98ada 100644 --- a/gr-noaa/lib/Makefile.am +++ b/gr-noaa/lib/Makefile.am @@ -29,6 +29,7 @@ lib_LTLIBRARIES = \ libgnuradio-noaa.la libgnuradio_noaa_la_SOURCES = \ + noaa_hrpt_deframer.cc \ noaa_hrpt_pll_cf.cc \ noaa_hrpt_sync_fb.cc @@ -38,5 +39,6 @@ libgnuradio_noaa_la_LIBADD = \ libgnuradio_noaa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 grinclude_HEADERS = \ + noaa_hrpt_deframer.h \ noaa_hrpt_pll_cf.h \ noaa_hrpt_sync_fb.h diff --git a/gr-noaa/lib/noaa_hrpt_deframer.cc b/gr-noaa/lib/noaa_hrpt_deframer.cc new file mode 100644 index 000000000..71712277b --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_deframer.cc @@ -0,0 +1,102 @@ +/* -*- 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 +#include + +#define ST_IDLE 0 +#define ST_SYNCED 1 + +#define HRPT_MINOR_FRAME_SYNC 0x0A116FD719D83C95LL +#define HRPT_BITS_PER_MINOR_FRAME 11090*10 +#define HRPT_SYNC_LENGTH 6*10 + +static int frames_seen = 0; + +noaa_hrpt_deframer_sptr +noaa_make_hrpt_deframer() +{ + return gnuradio::get_initial_sptr(new noaa_hrpt_deframer()); +} + +noaa_hrpt_deframer::noaa_hrpt_deframer() + : gr_sync_block("noaa_hrpt_deframer", + gr_make_io_signature(1, 1, sizeof(char)), + gr_make_io_signature(0, 0, 0)) +{ + enter_idle(); +} + +void +noaa_hrpt_deframer::enter_idle() +{ + d_state = ST_IDLE; +} + +void +noaa_hrpt_deframer::enter_synced() +{ + d_state = ST_SYNCED; + d_count = HRPT_BITS_PER_MINOR_FRAME-HRPT_SYNC_LENGTH; +} + +int +noaa_hrpt_deframer::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const char *in = (const char *)input_items[0]; + + int i = 0; + while (i < noutput_items) { + char bit = in[i++]; + if (d_state != ST_SYNCED) + fprintf(stderr, "."); + + switch (d_state) { + case ST_IDLE: + d_shifter = (d_shifter << 1) | bit; // MSB transmitted first + + if ((d_shifter & 0x0FFFFFFFFFFFFFFF) == HRPT_MINOR_FRAME_SYNC) { + fprintf(stderr, "\nSYNC #%i...", frames_seen++); + enter_synced(); + } + break; + + case ST_SYNCED: + if (--d_count == 0) { + fprintf(stderr, "done."); + enter_idle(); + } + break; + + default: + throw std::runtime_error("noaa_hrpt_deframer: bad state\n"); + } + } + + return i; +} diff --git a/gr-noaa/lib/noaa_hrpt_deframer.h b/gr-noaa/lib/noaa_hrpt_deframer.h new file mode 100644 index 000000000..bc91bc89c --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_deframer.h @@ -0,0 +1,52 @@ +/* -*- 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_HRPT_DEFRAMER_H +#define INCLUDED_NOAA_HRPT_DEFRAMER_H + +#include + +class noaa_hrpt_deframer; +typedef boost::shared_ptr noaa_hrpt_deframer_sptr; + +noaa_hrpt_deframer_sptr +noaa_make_hrpt_deframer(); + +class noaa_hrpt_deframer : public gr_sync_block +{ + friend noaa_hrpt_deframer_sptr noaa_make_hrpt_deframer(); + noaa_hrpt_deframer(); + + unsigned int d_state; + unsigned int d_count; + unsigned long long d_shifter; // 60 bit sync word + + void enter_idle(); + void enter_synced(); + +public: + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_NOAA_HRPT_DEFRAMER_H */ -- cgit From 2628e9cddc43d57a3346e240c8f7e58722bc61f1 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Sun, 20 Sep 2009 12:47:34 -0700 Subject: Add HRPT word output to deframer Put in half bit width matched filter Change default sync_alpha to 0.05 --- gr-noaa/lib/noaa_hrpt_deframer.cc | 61 +++++++++++++++++++++++++++------------ gr-noaa/lib/noaa_hrpt_deframer.h | 21 +++++++++----- 2 files changed, 56 insertions(+), 26 deletions(-) (limited to 'gr-noaa/lib') diff --git a/gr-noaa/lib/noaa_hrpt_deframer.cc b/gr-noaa/lib/noaa_hrpt_deframer.cc index 71712277b..b0de09c91 100644 --- a/gr-noaa/lib/noaa_hrpt_deframer.cc +++ b/gr-noaa/lib/noaa_hrpt_deframer.cc @@ -26,13 +26,19 @@ #include #include +#include #define ST_IDLE 0 #define ST_SYNCED 1 -#define HRPT_MINOR_FRAME_SYNC 0x0A116FD719D83C95LL -#define HRPT_BITS_PER_MINOR_FRAME 11090*10 -#define HRPT_SYNC_LENGTH 6*10 +#define SYNC1 0x0284 +#define SYNC2 0x016F +#define SYNC3 0x035C +#define SYNC4 0x019D +#define SYNC5 0x020F +#define SYNC6 0x0095 + +#define HRPT_MINOR_FRAME_SYNC 0x0A116FD719D83C95LL static int frames_seen = 0; @@ -43,10 +49,11 @@ noaa_make_hrpt_deframer() } noaa_hrpt_deframer::noaa_hrpt_deframer() - : gr_sync_block("noaa_hrpt_deframer", - gr_make_io_signature(1, 1, sizeof(char)), - gr_make_io_signature(0, 0, 0)) + : gr_block("noaa_hrpt_deframer", + gr_make_io_signature(1, 1, sizeof(char)), + gr_make_io_signature(1, 1, sizeof(short))) { + set_output_multiple(6); // room for writing full sync when received enter_idle(); } @@ -60,36 +67,51 @@ void noaa_hrpt_deframer::enter_synced() { d_state = ST_SYNCED; - d_count = HRPT_BITS_PER_MINOR_FRAME-HRPT_SYNC_LENGTH; + d_bit_count = HRPT_BITS_PER_WORD; + d_word_count = HRPT_MINOR_FRAME_WORDS-HRPT_SYNC_WORDS; + d_word = 0; } int -noaa_hrpt_deframer::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) +noaa_hrpt_deframer::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { + int ninputs = ninput_items[0]; const char *in = (const char *)input_items[0]; + unsigned short *out = (unsigned short *)output_items[0]; - int i = 0; - while (i < noutput_items) { + int i = 0, j = 0; + while (i < ninputs && j < noutput_items) { char bit = in[i++]; - if (d_state != ST_SYNCED) - fprintf(stderr, "."); switch (d_state) { case ST_IDLE: d_shifter = (d_shifter << 1) | bit; // MSB transmitted first if ((d_shifter & 0x0FFFFFFFFFFFFFFF) == HRPT_MINOR_FRAME_SYNC) { - fprintf(stderr, "\nSYNC #%i...", frames_seen++); + fprintf(stderr, "SYNC #%i", frames_seen++); + out[j++] = SYNC1; + out[j++] = SYNC2; + out[j++] = SYNC3; + out[j++] = SYNC4; + out[j++] = SYNC5; + out[j++] = SYNC6; enter_synced(); } break; case ST_SYNCED: - if (--d_count == 0) { - fprintf(stderr, "done."); - enter_idle(); + d_word = (d_word << 1) | bit; // MSB transmitted first + if (--d_bit_count == 0) { + out[j++] = d_word; + d_word = 0; + d_bit_count = HRPT_BITS_PER_WORD; + if (--d_word_count == 0) { + fprintf(stderr, "...done\n"); + enter_idle(); + } } break; @@ -98,5 +120,6 @@ noaa_hrpt_deframer::work(int noutput_items, } } - return i; + consume_each(i); + return j; } diff --git a/gr-noaa/lib/noaa_hrpt_deframer.h b/gr-noaa/lib/noaa_hrpt_deframer.h index bc91bc89c..0aeb16a2d 100644 --- a/gr-noaa/lib/noaa_hrpt_deframer.h +++ b/gr-noaa/lib/noaa_hrpt_deframer.h @@ -23,7 +23,11 @@ #ifndef INCLUDED_NOAA_HRPT_DEFRAMER_H #define INCLUDED_NOAA_HRPT_DEFRAMER_H -#include +#define HRPT_SYNC_WORDS 6 +#define HRPT_MINOR_FRAME_WORDS 11090 +#define HRPT_BITS_PER_WORD 10 + +#include class noaa_hrpt_deframer; typedef boost::shared_ptr noaa_hrpt_deframer_sptr; @@ -31,22 +35,25 @@ typedef boost::shared_ptr noaa_hrpt_deframer_sptr; noaa_hrpt_deframer_sptr noaa_make_hrpt_deframer(); -class noaa_hrpt_deframer : public gr_sync_block +class noaa_hrpt_deframer : public gr_block { friend noaa_hrpt_deframer_sptr noaa_make_hrpt_deframer(); noaa_hrpt_deframer(); unsigned int d_state; - unsigned int d_count; - unsigned long long d_shifter; // 60 bit sync word + unsigned int d_bit_count; + unsigned int d_word_count; + unsigned long long d_shifter; // 60 bit sync word + unsigned short d_word; // 10 bit HRPT word void enter_idle(); void enter_synced(); public: - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); }; #endif /* INCLUDED_NOAA_HRPT_DEFRAMER_H */ -- cgit From f8fcb642dabca11870886c53dfdff66c86774db0 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Sun, 20 Sep 2009 19:32:30 -0700 Subject: Added skeleton HRPT decoder block --- gr-noaa/lib/Makefile.am | 2 ++ gr-noaa/lib/noaa_hrpt_decoder.cc | 64 ++++++++++++++++++++++++++++++++++++++++ gr-noaa/lib/noaa_hrpt_decoder.h | 47 +++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 gr-noaa/lib/noaa_hrpt_decoder.cc create mode 100644 gr-noaa/lib/noaa_hrpt_decoder.h (limited to 'gr-noaa/lib') diff --git a/gr-noaa/lib/Makefile.am b/gr-noaa/lib/Makefile.am index 578c98ada..6435d192e 100644 --- a/gr-noaa/lib/Makefile.am +++ b/gr-noaa/lib/Makefile.am @@ -29,6 +29,7 @@ lib_LTLIBRARIES = \ libgnuradio-noaa.la libgnuradio_noaa_la_SOURCES = \ + noaa_hrpt_decoder.cc \ noaa_hrpt_deframer.cc \ noaa_hrpt_pll_cf.cc \ noaa_hrpt_sync_fb.cc @@ -39,6 +40,7 @@ libgnuradio_noaa_la_LIBADD = \ libgnuradio_noaa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 grinclude_HEADERS = \ + noaa_hrpt_decoder.h \ noaa_hrpt_deframer.h \ noaa_hrpt_pll_cf.h \ noaa_hrpt_sync_fb.h diff --git a/gr-noaa/lib/noaa_hrpt_decoder.cc b/gr-noaa/lib/noaa_hrpt_decoder.cc new file mode 100644 index 000000000..7aa815c5c --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_decoder.cc @@ -0,0 +1,64 @@ +/* -*- 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 +#include + +#define SYNC1 0x0284 +#define SYNC2 0x016F +#define SYNC3 0x035C +#define SYNC4 0x019D +#define SYNC5 0x020F +#define SYNC6 0x0095 + +noaa_hrpt_decoder_sptr +noaa_make_hrpt_decoder() +{ + return gnuradio::get_initial_sptr(new noaa_hrpt_decoder()); +} + +noaa_hrpt_decoder::noaa_hrpt_decoder() + : gr_sync_block("noaa_hrpt_decoder", + gr_make_io_signature(1, 1, sizeof(short)), + gr_make_io_signature(0, 0, 0)) +{ + d_word_count = 0; +} + +int +noaa_hrpt_decoder::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const unsigned short *in = (const unsigned short*)input_items[0]; + + int i = 0; + while (i < noutput_items) { + unsigned short word = in[i++]; + } + + return i; +} diff --git a/gr-noaa/lib/noaa_hrpt_decoder.h b/gr-noaa/lib/noaa_hrpt_decoder.h new file mode 100644 index 000000000..305243b09 --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_decoder.h @@ -0,0 +1,47 @@ +/* -*- 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_HRPT_DECODER_H +#define INCLUDED_NOAA_HRPT_DECODER_H + +#include + +class noaa_hrpt_decoder; +typedef boost::shared_ptr noaa_hrpt_decoder_sptr; + +noaa_hrpt_decoder_sptr +noaa_make_hrpt_decoder(); + +class noaa_hrpt_decoder : public gr_sync_block +{ + friend noaa_hrpt_decoder_sptr noaa_make_hrpt_decoder(); + noaa_hrpt_decoder(); + + unsigned int d_word_count; + +public: + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_NOAA_HRPT_DECODER_H */ -- cgit From 751e1a0608cb51525f78fe5476be46ef6e461774 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Sun, 20 Sep 2009 19:57:30 -0700 Subject: Dumps HRPT frames to text file similar to specification document --- gr-noaa/lib/noaa_hrpt_decoder.cc | 13 +++++++++++++ gr-noaa/lib/noaa_hrpt_deframer.cc | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'gr-noaa/lib') diff --git a/gr-noaa/lib/noaa_hrpt_decoder.cc b/gr-noaa/lib/noaa_hrpt_decoder.cc index 7aa815c5c..4fae0173d 100644 --- a/gr-noaa/lib/noaa_hrpt_decoder.cc +++ b/gr-noaa/lib/noaa_hrpt_decoder.cc @@ -58,6 +58,19 @@ noaa_hrpt_decoder::work(int noutput_items, int i = 0; while (i < noutput_items) { unsigned short word = in[i++]; + d_word_count++; + fprintf(stderr, "%5u: ", d_word_count); + for (int pos = 0; pos < 10; pos++) { + char ch = (word & (1 << 9)) ? '1' : '0'; + word = word << 1; + fprintf(stderr, "%c ", ch); + } + fprintf(stderr, "\n"); + + if (d_word_count == 11090) { + d_word_count = 0; + fprintf(stderr, "\n"); + } } return i; diff --git a/gr-noaa/lib/noaa_hrpt_deframer.cc b/gr-noaa/lib/noaa_hrpt_deframer.cc index b0de09c91..77a8e3263 100644 --- a/gr-noaa/lib/noaa_hrpt_deframer.cc +++ b/gr-noaa/lib/noaa_hrpt_deframer.cc @@ -91,7 +91,7 @@ noaa_hrpt_deframer::general_work(int noutput_items, d_shifter = (d_shifter << 1) | bit; // MSB transmitted first if ((d_shifter & 0x0FFFFFFFFFFFFFFF) == HRPT_MINOR_FRAME_SYNC) { - fprintf(stderr, "SYNC #%i", frames_seen++); + //fprintf(stderr, "SYNC #%i", frames_seen++); out[j++] = SYNC1; out[j++] = SYNC2; out[j++] = SYNC3; @@ -109,7 +109,7 @@ noaa_hrpt_deframer::general_work(int noutput_items, d_word = 0; d_bit_count = HRPT_BITS_PER_WORD; if (--d_word_count == 0) { - fprintf(stderr, "...done\n"); + //fprintf(stderr, "...done\n"); enter_idle(); } } -- cgit From 7c4b43a1a4b3ff6c99fe96805f8d4518a22eb0a5 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Wed, 23 Sep 2009 11:40:19 -0700 Subject: Split HRPT script into live receive and post-processing Cleanup debug info Created 'demod_hrpt_file.py' Updated 'usrp_rx_hrpt.py' with GUI, USRP, and config file --- gr-noaa/lib/noaa_hrpt_decoder.cc | 8 ++++---- gr-noaa/lib/noaa_hrpt_deframer.cc | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'gr-noaa/lib') diff --git a/gr-noaa/lib/noaa_hrpt_decoder.cc b/gr-noaa/lib/noaa_hrpt_decoder.cc index 4fae0173d..8cfaa913c 100644 --- a/gr-noaa/lib/noaa_hrpt_decoder.cc +++ b/gr-noaa/lib/noaa_hrpt_decoder.cc @@ -59,17 +59,17 @@ noaa_hrpt_decoder::work(int noutput_items, while (i < noutput_items) { unsigned short word = in[i++]; d_word_count++; - fprintf(stderr, "%5u: ", d_word_count); + //fprintf(stderr, "%5u: ", d_word_count); for (int pos = 0; pos < 10; pos++) { char ch = (word & (1 << 9)) ? '1' : '0'; word = word << 1; - fprintf(stderr, "%c ", ch); + //fprintf(stderr, "%c ", ch); } - fprintf(stderr, "\n"); + //fprintf(stderr, "\n"); if (d_word_count == 11090) { d_word_count = 0; - fprintf(stderr, "\n"); + //fprintf(stderr, "\n"); } } diff --git a/gr-noaa/lib/noaa_hrpt_deframer.cc b/gr-noaa/lib/noaa_hrpt_deframer.cc index 77a8e3263..b0de09c91 100644 --- a/gr-noaa/lib/noaa_hrpt_deframer.cc +++ b/gr-noaa/lib/noaa_hrpt_deframer.cc @@ -91,7 +91,7 @@ noaa_hrpt_deframer::general_work(int noutput_items, d_shifter = (d_shifter << 1) | bit; // MSB transmitted first if ((d_shifter & 0x0FFFFFFFFFFFFFFF) == HRPT_MINOR_FRAME_SYNC) { - //fprintf(stderr, "SYNC #%i", frames_seen++); + fprintf(stderr, "SYNC #%i", frames_seen++); out[j++] = SYNC1; out[j++] = SYNC2; out[j++] = SYNC3; @@ -109,7 +109,7 @@ noaa_hrpt_deframer::general_work(int noutput_items, d_word = 0; d_bit_count = HRPT_BITS_PER_WORD; if (--d_word_count == 0) { - //fprintf(stderr, "...done\n"); + fprintf(stderr, "...done\n"); enter_idle(); } } -- cgit