diff options
Diffstat (limited to 'gr-analog')
-rw-r--r-- | gr-analog/grc/analog_block_tree.xml | 1 | ||||
-rw-r--r-- | gr-analog/grc/analog_plateau_detector_fb.xml | 26 | ||||
-rw-r--r-- | gr-analog/include/analog/CMakeLists.txt | 3 | ||||
-rw-r--r-- | gr-analog/include/analog/plateau_detector_fb.h | 71 | ||||
-rw-r--r-- | gr-analog/lib/CMakeLists.txt | 18 | ||||
-rw-r--r-- | gr-analog/lib/gnuradio-analog.rc.in | 55 | ||||
-rw-r--r-- | gr-analog/lib/plateau_detector_fb_impl.cc | 82 | ||||
-rw-r--r-- | gr-analog/lib/plateau_detector_fb_impl.h | 50 | ||||
-rw-r--r-- | gr-analog/python/CMakeLists.txt | 1 | ||||
-rwxr-xr-x | gr-analog/python/qa_plateau_detector_fb.py | 46 | ||||
-rw-r--r-- | gr-analog/swig/analog_swig.i | 3 |
11 files changed, 354 insertions, 2 deletions
diff --git a/gr-analog/grc/analog_block_tree.xml b/gr-analog/grc/analog_block_tree.xml index b5b2ecd568..fb2731ae07 100644 --- a/gr-analog/grc/analog_block_tree.xml +++ b/gr-analog/grc/analog_block_tree.xml @@ -56,6 +56,7 @@ <block>analog_pll_carriertracking_cc</block> <block>analog_pll_freqdet_cf</block> <block>analog_pll_refout_cc</block> + <block>analog_plateau_detector_fb</block> </cat> <cat> <name>Probes</name> diff --git a/gr-analog/grc/analog_plateau_detector_fb.xml b/gr-analog/grc/analog_plateau_detector_fb.xml new file mode 100644 index 0000000000..f14efc97f4 --- /dev/null +++ b/gr-analog/grc/analog_plateau_detector_fb.xml @@ -0,0 +1,26 @@ +<?xml version="1.0"?> +<block> + <name>Plateau Detector</name> + <key>analog_plateau_detector_fb</key> + <import>from gnuradio import analog</import> + <make>analog.plateau_detector_fb($max_len, $threshold)</make> + <param> + <name>Max. plateau length</name> + <key>max_len</key> + <type>int</type> + </param> + <param> + <name>Threshold</name> + <key>threshold</key> + <value>0.9</value> + <type>real</type> + </param> + <sink> + <name>in</name> + <type>real</type> + </sink> + <source> + <name>out</name> + <type>byte</type> + </source> +</block> diff --git a/gr-analog/include/analog/CMakeLists.txt b/gr-analog/include/analog/CMakeLists.txt index b113dacc44..f46960c984 100644 --- a/gr-analog/include/analog/CMakeLists.txt +++ b/gr-analog/include/analog/CMakeLists.txt @@ -93,6 +93,7 @@ install(FILES fmdet_cf.h frequency_modulator_fc.h phase_modulator_fc.h + plateau_detector_fb.h pll_carriertracking_cc.h pll_freqdet_cf.h pll_refout_cc.h @@ -105,7 +106,7 @@ install(FILES rail_ff.h rotator.h sig_source_waveform.h - simple_squelch_cc.h + simple_squelch_cc.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio/analog COMPONENT "analog_devel" ) diff --git a/gr-analog/include/analog/plateau_detector_fb.h b/gr-analog/include/analog/plateau_detector_fb.h new file mode 100644 index 0000000000..33629bd18b --- /dev/null +++ b/gr-analog/include/analog/plateau_detector_fb.h @@ -0,0 +1,71 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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_ANALOG_PLATEAU_DETECTOR_FB_H +#define INCLUDED_ANALOG_PLATEAU_DETECTOR_FB_H + +#include <analog/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief Detects a plateau and marks the middle. + * + * Detect a plateau of a-priori known height. Input is a stream of floats, + * the output is a stream of bytes. Whenever a plateau is detected, the + * middle of that plateau is marked with a '1' on the output stream (all + * other samples are left at zero). + * + * You can use this in a Schmidl & Cox synchronisation algorithm to interpret + * the output of the normalized correlator. Just pass the length of the cyclic + * prefix (in samples) as the max_len parameter). + * + * Unlike the peak detectors, you must the now the absolute height of the plateau. + * Whenever the amplitude exceeds the given threshold, it starts assuming the + * presence of a plateau. + * + * An implicit hysteresis is provided by the fact that after detecting one plateau, + * it waits at least max_len samples before the next plateau can be detected. + * + * \ingroup analog + * + */ + class ANALOG_API plateau_detector_fb : virtual public gr_sync_block + { + public: + typedef boost::shared_ptr<plateau_detector_fb> sptr; + + /*! + * \param max_len Maximum length of the plateau + * \param threshold Anything above this value is considered a plateau + */ + static sptr make(int max_len, float threshold=0.9); + }; + + } // namespace analog +} // namespace gr + +#endif /* INCLUDED_ANALOG_PLATEAU_DETECTOR_FB_H */ + diff --git a/gr-analog/lib/CMakeLists.txt b/gr-analog/lib/CMakeLists.txt index f7d6723b4e..396ff04654 100644 --- a/gr-analog/lib/CMakeLists.txt +++ b/gr-analog/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -121,6 +121,7 @@ list(APPEND analog_sources fmdet_cf_impl.cc frequency_modulator_fc_impl.cc phase_modulator_fc_impl.cc + plateau_detector_fb_impl.cc pll_carriertracking_cc_impl.cc pll_freqdet_cf_impl.cc pll_refout_cc_impl.cc @@ -135,6 +136,21 @@ list(APPEND analog_sources sincos.cc ) +#Add Windows DLL resource file if using MSVC +IF(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-analog.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-analog.rc + @ONLY) + + list(APPEND analog_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-analog.rc + ) + +ENDIF(MSVC) + list(APPEND analog_libs volk gnuradio-core diff --git a/gr-analog/lib/gnuradio-analog.rc.in b/gr-analog/lib/gnuradio-analog.rc.in new file mode 100644 index 0000000000..7c8c1919f0 --- /dev/null +++ b/gr-analog/lib/gnuradio-analog.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2013 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 <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-analog" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-analog.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-analog.dll" + VALUE "ProductName", "gnuradio-analog" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-analog/lib/plateau_detector_fb_impl.cc b/gr-analog/lib/plateau_detector_fb_impl.cc new file mode 100644 index 0000000000..0d2890bc55 --- /dev/null +++ b/gr-analog/lib/plateau_detector_fb_impl.cc @@ -0,0 +1,82 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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_io_signature.h> +#include "plateau_detector_fb_impl.h" + +namespace gr { + namespace analog { + +plateau_detector_fb::sptr +plateau_detector_fb::make(int max_len, float threshold) +{ + return gnuradio::get_initial_sptr (new plateau_detector_fb_impl(max_len, threshold)); +} + +plateau_detector_fb_impl::plateau_detector_fb_impl(int max_len, float threshold) + : gr_sync_block("plateau_detector_fb", + gr_make_io_signature(1, 1, sizeof (float)), + gr_make_io_signature(1, 1, sizeof (char))), + d_max_len(max_len), + d_threshold(threshold) +{} + +plateau_detector_fb_impl::~plateau_detector_fb_impl() +{ +} + +int +plateau_detector_fb_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const float *in = (const float *) input_items[0]; + unsigned char *out = (unsigned char *) output_items[0]; + int flank_start; + + memset((void *) out, 0x00, noutput_items); + int i; + for (i = 0; i < noutput_items; i++) { + if (in[i] >= d_threshold) { + if (noutput_items-i < 2*d_max_len) { // If we can't finish, come back later + break; + } + flank_start = i; + while (i < noutput_items && in[i] >= d_threshold) + i++; + if ((i - flank_start) > 1) { // 1 Sample is not a plateau + out[flank_start + (i-flank_start)/2] = 1; + i = std::min(i+d_max_len, noutput_items-1); + } + } + } + + return i; +} + + } /* namespace analog */ +} /* namespace gr */ + diff --git a/gr-analog/lib/plateau_detector_fb_impl.h b/gr-analog/lib/plateau_detector_fb_impl.h new file mode 100644 index 0000000000..daf1dd56d9 --- /dev/null +++ b/gr-analog/lib/plateau_detector_fb_impl.h @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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_ANALOG_PLATEAU_DETECTOR_FB_IMPL_H +#define INCLUDED_ANALOG_PLATEAU_DETECTOR_FB_IMPL_H + +#include <analog/plateau_detector_fb.h> + +namespace gr { + namespace analog { + +class plateau_detector_fb_impl : public plateau_detector_fb +{ + private: + int d_max_len; + float d_threshold; + + public: + plateau_detector_fb_impl(int max_len, float threshold); + ~plateau_detector_fb_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + + } // namespace analog +} // namespace gr + +#endif /* INCLUDED_ANALOG_PLATEAU_DETECTOR_FB_IMPL_H */ + diff --git a/gr-analog/python/CMakeLists.txt b/gr-analog/python/CMakeLists.txt index 1657e5bf32..af4ed578f3 100644 --- a/gr-analog/python/CMakeLists.txt +++ b/gr-analog/python/CMakeLists.txt @@ -49,3 +49,4 @@ foreach(py_qa_test_file ${py_qa_test_files}) GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file}) endforeach(py_qa_test_file) endif(ENABLE_TESTING) + diff --git a/gr-analog/python/qa_plateau_detector_fb.py b/gr-analog/python/qa_plateau_detector_fb.py new file mode 100755 index 0000000000..5f8abc74ec --- /dev/null +++ b/gr-analog/python/qa_plateau_detector_fb.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +# +# Copyright 2012 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. +# + +from gnuradio import gr, gr_unittest +import analog_swig as analog + +class qa_plateau_detector_fb (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001_t (self): + # | Spur spike 1 | Plateau | Spur spike 2 + test_signal = (0, 1, .2, .4, .6, .8, 1, 1, 1, 1, 1, .8, .6, .4, 1, 0) + expected_sig = (0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0) + # | Center of Plateau + sink = gr.vector_sink_b() + self.tb.connect(gr.vector_source_f(test_signal), analog.plateau_detector_fb(5), sink) + self.tb.run () + self.assertEqual(expected_sig, sink.data()) + + +if __name__ == '__main__': + gr_unittest.run(qa_plateau_detector_fb, "qa_plateau_detector_fb.xml") diff --git a/gr-analog/swig/analog_swig.i b/gr-analog/swig/analog_swig.i index 016537c949..96f4e23a8c 100644 --- a/gr-analog/swig/analog_swig.i +++ b/gr-analog/swig/analog_swig.i @@ -46,6 +46,7 @@ #include "analog/noise_source_f.h" #include "analog/noise_source_c.h" #include "analog/phase_modulator_fc.h" +#include "analog/plateau_detector_fb.h" #include "analog/pll_carriertracking_cc.h" #include "analog/pll_freqdet_cf.h" #include "analog/pll_refout_cc.h" @@ -85,6 +86,7 @@ %include "analog/noise_source_f.h" %include "analog/noise_source_c.h" %include "analog/phase_modulator_fc.h" +%include "analog/plateau_detector_fb.h" %include "analog/pll_carriertracking_cc.h" %include "analog/pll_freqdet_cf.h" %include "analog/pll_refout_cc.h" @@ -120,6 +122,7 @@ GR_SWIG_BLOCK_MAGIC2(analog, noise_source_i); GR_SWIG_BLOCK_MAGIC2(analog, noise_source_f); GR_SWIG_BLOCK_MAGIC2(analog, noise_source_c); GR_SWIG_BLOCK_MAGIC2(analog, phase_modulator_fc); +GR_SWIG_BLOCK_MAGIC2(analog, plateau_detector_fb); GR_SWIG_BLOCK_MAGIC2(analog, pll_carriertracking_cc); GR_SWIG_BLOCK_MAGIC2(analog, pll_freqdet_cf); GR_SWIG_BLOCK_MAGIC2(analog, pll_refout_cc); |