GNU Radio 3.5.1 C++ API
digital_constellation_receiver_cb.h
Go to the documentation of this file.
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 takes care of receiving generic modulated signals
00045  * through phase, frequency, and symbol synchronization.
00046  * \ingroup sync_blk
00047  * \ingroup demod_blk
00048  * \ingroup digital
00049  *
00050  * This block takes care of receiving generic modulated signals
00051  * through phase, frequency, and symbol synchronization. It performs
00052  * carrier frequency and phase locking as well as symbol timing
00053  * recovery.
00054  *
00055  * The phase and frequency synchronization are based on a Costas loop
00056  * that finds the error of the incoming signal point compared to its
00057  * nearest constellation point. The frequency and phase of the NCO are
00058  * updated according to this error.
00059  *
00060  * The symbol synchronization is done using a modified Mueller and
00061  * Muller circuit from the paper:
00062  * 
00063  *    G. R. Danesfahani, T.G. Jeans, "Optimisation of modified Mueller
00064  *    and Muller algorithm," Electronics Letters, Vol. 31, no. 13, 22
00065  *    June 1995, pp. 1032 - 1033.
00066  *
00067  * This circuit interpolates the downconverted sample (using the NCO
00068  * developed by the Costas loop) every mu samples, then it finds the
00069  * sampling error based on this and the past symbols and the decision
00070  * made on the samples. Like the phase error detector, there are
00071  * optimized decision algorithms for BPSK and QPKS, but 8PSK uses
00072  * another brute force computation against all possible symbols. The
00073  * modifications to the M&M used here reduce self-noise.
00074  *
00075  */
00076 
00077 class DIGITAL_API digital_constellation_receiver_cb : public gr_block, public gri_control_loop
00078 {
00079 public:
00080   int general_work (int noutput_items,
00081                     gr_vector_int &ninput_items,
00082                     gr_vector_const_void_star &input_items,
00083                     gr_vector_void_star &output_items);
00084 
00085 protected:
00086 
00087  /*!
00088    * \brief Constructor to synchronize incoming M-PSK symbols
00089    *
00090    * \param constellation       constellation of points for generic modulation
00091    * \param loop_bw     Loop bandwidth of the Costas Loop (~ 2pi/100)
00092    * \param fmin        minimum normalized frequency value the loop can achieve
00093    * \param fmax        maximum normalized frequency value the loop can achieve
00094    *
00095    * The constructor also chooses which phase detector and decision maker to use in the
00096    * work loop based on the value of M.
00097    */
00098   digital_constellation_receiver_cb (digital_constellation_sptr constellation, 
00099                                      float loop_bw, float fmin, float fmax);
00100 
00101   void phase_error_tracking(float phase_error);
00102 
00103 private:
00104   unsigned int d_M;
00105 
00106   digital_constellation_sptr d_constellation;
00107   unsigned int d_current_const_point;
00108 
00109   //! delay line length.
00110   static const unsigned int DLLEN = 8;
00111   
00112   //! delay line plus some length for overflow protection
00113   __GR_ATTR_ALIGNED(8) gr_complex d_dl[2*DLLEN];
00114   
00115   //! index to delay line
00116   unsigned int d_dl_idx;
00117 
00118   friend DIGITAL_API digital_constellation_receiver_cb_sptr
00119   digital_make_constellation_receiver_cb (digital_constellation_sptr constell,
00120                                           float loop_bw, float fmin, float fmax);
00121 };
00122 
00123 #endif