GNU Radio 3.6.5 C++ API

digital_costas_loop_cc.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2006,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 
00024 #ifndef INCLUDED_DIGITAL_COSTAS_LOOP_CC_H
00025 #define INCLUDED_DIGITAL_COSTAS_LOOP_CC_H
00026 
00027 #include <gr_sync_block.h>
00028 #include <gri_control_loop.h>
00029 #include <stdexcept>
00030 #include <fstream>
00031 #include <digital_api.h>
00032 
00033 class digital_costas_loop_cc;
00034 typedef boost::shared_ptr<digital_costas_loop_cc> digital_costas_loop_cc_sptr;
00035 
00036 
00037 DIGITAL_API digital_costas_loop_cc_sptr 
00038 digital_make_costas_loop_cc (float loop_bw, int order
00039                              ) throw (std::invalid_argument);
00040 
00041 /*! 
00042  * \brief A Costas loop carrier recovery module.
00043  * \ingroup synchronizers_blk
00044  *  
00045  * \details
00046  *  The Costas loop locks to the center frequency of a signal and
00047  *  downconverts it to baseband. The second (order=2) order loop is
00048  *  used for BPSK where the real part of the output signal is the
00049  *  baseband BPSK signal and the imaginary part is the error
00050  *  signal. When order=4, it can be used for quadrature modulations
00051  *  where both I and Q (real and imaginary) are outputted.
00052  *
00053  *  More details can be found online:
00054  *
00055  *  J. Feigin, "Practical Costas loop design: Designing a simple and
00056  *  inexpensive BPSK Costas loop carrier recovery circuit," RF signal
00057  *  processing, pp. 20-36, 2002.
00058  *
00059  *  http://rfdesign.com/images/archive/0102Feigin20.pdf
00060  */
00061 class DIGITAL_API digital_costas_loop_cc : public gr_sync_block, public gri_control_loop
00062 {
00063   friend DIGITAL_API digital_costas_loop_cc_sptr
00064   digital_make_costas_loop_cc (float loop_bw, int order
00065                                ) throw (std::invalid_argument);
00066 
00067   int d_order;
00068 
00069   /*!
00070    * \brief Carrier tracking PLL for QPSK
00071    * input: complex; output: complex
00072    * <br>The Costas loop can have two output streams:
00073    *    stream 1 is the baseband I and Q;
00074    *    stream 2 is the normalized frequency of the loop
00075    *
00076    * \param loop_bw  internal 2nd order loop bandwidth (~ 2pi/100)
00077    * \param order the loop order, either 2, 4, or 8
00078    */
00079   digital_costas_loop_cc (float loop_bw, int order
00080                           ) throw (std::invalid_argument);
00081   
00082   /*! \brief the phase detector circuit for 8th-order PSK loops
00083    *  \param sample complex sample
00084    *  \return the phase error
00085    */
00086   float phase_detector_8(gr_complex sample) const;    // for 8PSK
00087 
00088   /*! \brief the phase detector circuit for fourth-order loops
00089    *  \param sample complex sample
00090    *  \return the phase error
00091    */
00092   float phase_detector_4(gr_complex sample) const;    // for QPSK
00093 
00094   /*! \brief the phase detector circuit for second-order loops
00095    *  \param sample a complex sample
00096    *  \return the phase error
00097    */
00098   float phase_detector_2(gr_complex sample) const;    // for BPSK
00099 
00100 
00101   float (digital_costas_loop_cc::*d_phase_detector)(gr_complex sample) const;
00102 
00103 public:
00104 
00105   int work (int noutput_items,
00106             gr_vector_const_void_star &input_items,
00107             gr_vector_void_star &output_items);
00108 };
00109 
00110 #endif