GNU Radio 3.6.5 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2011 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef INCLUDED_DIGITAL_CONSTELLATION_RECEIVER_CB_H 00024 #define INCLUDED_DIGITAL_CONSTELLATION_RECEIVER_CB_H 00025 00026 #include <digital_api.h> 00027 #include <gr_block.h> 00028 #include <digital_constellation.h> 00029 #include <gruel/attributes.h> 00030 #include <gri_control_loop.h> 00031 #include <gr_complex.h> 00032 #include <math.h> 00033 #include <fstream> 00034 00035 class digital_constellation_receiver_cb; 00036 typedef boost::shared_ptr<digital_constellation_receiver_cb> digital_constellation_receiver_cb_sptr; 00037 00038 // public constructor 00039 DIGITAL_API digital_constellation_receiver_cb_sptr 00040 digital_make_constellation_receiver_cb (digital_constellation_sptr constellation, 00041 float loop_bw, float fmin, float fmax); 00042 00043 /*! 00044 * \brief This block does fine-phase and frequency locking and decision making. 00045 * \ingroup symbol_coding_blk 00046 * \ingroup modulators_blk 00047 * 00048 * \details 00049 * The phase and frequency synchronization are based on a Costas loop 00050 * that finds the error of the incoming signal point compared to its 00051 * nearest constellation point. The frequency and phase of the NCO are 00052 * updated according to this error. 00053 * 00054 * The decicision making itself is performed by the appropriate method of the 00055 * passed constellation object. 00056 * 00057 */ 00058 00059 class DIGITAL_API digital_constellation_receiver_cb : public gr_block, public gri_control_loop 00060 { 00061 public: 00062 int general_work (int noutput_items, 00063 gr_vector_int &ninput_items, 00064 gr_vector_const_void_star &input_items, 00065 gr_vector_void_star &output_items); 00066 00067 protected: 00068 00069 /*! 00070 * \brief Constructor to synchronize incoming M-PSK symbols 00071 * 00072 * \param constellation constellation object for generic demodulation 00073 * \param loop_bw Loop bandwidth of the Costas Loop (~ 2pi/100) 00074 * \param fmin minimum normalized frequency value the loop can achieve 00075 * \param fmax maximum normalized frequency value the loop can achieve 00076 * 00077 */ 00078 digital_constellation_receiver_cb (digital_constellation_sptr constellation, 00079 float loop_bw, float fmin, float fmax); 00080 00081 void phase_error_tracking(float phase_error); 00082 00083 private: 00084 unsigned int d_M; 00085 00086 digital_constellation_sptr d_constellation; 00087 unsigned int d_current_const_point; 00088 00089 //! delay line length. 00090 static const unsigned int DLLEN = 8; 00091 00092 //! delay line plus some length for overflow protection 00093 __GR_ATTR_ALIGNED(8) gr_complex d_dl[2*DLLEN]; 00094 00095 //! index to delay line 00096 unsigned int d_dl_idx; 00097 00098 friend DIGITAL_API digital_constellation_receiver_cb_sptr 00099 digital_make_constellation_receiver_cb (digital_constellation_sptr constell, 00100 float loop_bw, float fmin, float fmax); 00101 }; 00102 00103 #endif