GNU Radio Manual and C++ API Reference  3.7.13.4
The Free & Open Software Radio Ecosystem
quadrature_demod_cf.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2004,2012 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef INCLUDED_ANALOG_QUADRATURE_DEMOD_CF_H
24 #define INCLUDED_ANALOG_QUADRATURE_DEMOD_CF_H
25 
26 #include <gnuradio/analog/api.h>
27 #include <gnuradio/sync_block.h>
28 
29 namespace gr {
30  namespace analog {
31 
32  /*!
33  * \brief quadrature demodulator: complex in, float out
34  * \ingroup modulators_blk
35  *
36  * \details
37  * This can be used to demod FM, FSK, GMSK, etc. The input is complex
38  * baseband, output is the signal frequency in relation to the sample
39  * rated, multiplied with the gain.
40  *
41  * Mathematically, this block calculates the product of the one-sample
42  * delayed input and the conjugate undelayed signal, and then calculates
43  * the argument of the resulting complex number:
44  *
45  * \f$y[n] = \mathrm{arg}\left(x[n] \, \bar x [n-1]\right)\f$.
46  *
47  * Let \f$x\f$ be a complex sinusoid with amplitude \f$A>0\f$, (absolute)
48  * frequency \f$f\in\mathbb R\f$ and phase \f$\phi_0\in[0;2\pi]\f$ sampled at
49  * \f$f_s>0\f$ so, without loss of generality,
50  *
51  * \f$x[n]= A e^{j2\pi( \frac f{f_s} n + \phi_0)}\f$
52  *
53  * then
54  *
55  * \f{align*}{ y[n] &= \mathrm{arg}\left(A e^{j2\pi\left( \frac f{f_s} n + \phi_0\right)} \overline{A e^{j2\pi( \frac f{f_s} (n-1) + \phi_0)}}\right)\\
56  * & = \mathrm{arg}\left(A^2 e^{j2\pi\left( \frac f{f_s} n + \phi_0\right)} e^{-j2\pi( \frac f{f_s} (n-1) + \phi_0)}\right)\\
57  * & = \mathrm{arg}\left( A^2 e^{j2\pi\left( \frac f{f_s} n + \phi_0 - \frac f{f_s} (n-1) - \phi_0\right)}\right)\\
58  * & = \mathrm{arg}\left( A^2 e^{j2\pi\left( \frac f{f_s} n - \frac f{f_s} (n-1)\right)}\right)\\
59  * & = \mathrm{arg}\left( A^2 e^{j2\pi\left( \frac f{f_s} \left(n-(n-1)\right)\right)}\right)\\
60  * & = \mathrm{arg}\left( A^2 e^{j2\pi \frac f{f_s}}\right) \intertext{$A$ is real, so is $A^2$ and hence only \textit{scales}, therefore $\mathrm{arg}(\cdot)$ is invariant:} &= \mathrm{arg}\left(e^{j2\pi \frac f{f_s}}\right)\\
61  * &= \frac f{f_s}\\
62  * &&\blacksquare
63  * \f}
64  */
65  class ANALOG_API quadrature_demod_cf : virtual public sync_block
66  {
67  public:
68  // gr::analog::quadrature_demod_cf::sptr
69  typedef boost::shared_ptr<quadrature_demod_cf> sptr;
70 
71  /* \brief Make a quadrature demodulator block.
72  *
73  * \param gain Gain setting to adjust the output amplitude. Set
74  * based on converting the phase difference between
75  * samples to a nominal output value.
76  */
77  static sptr make(float gain);
78 
79  virtual void set_gain(float gain) = 0;
80  virtual float gain() const = 0;
81  };
82 
83  } /* namespace analog */
84 } /* namespace gr */
85 
86 #endif /* INCLUDED_ANALOG_QUADRATURE_DEMOD_CF_H */
boost::shared_ptr< quadrature_demod_cf > sptr
Definition: quadrature_demod_cf.h:69
Include this header to use the message passing features.
Definition: logger.h:695
synchronous 1:1 input to output with historyOverride work to provide the signal processing implementa...
Definition: sync_block.h:37
#define ANALOG_API
Definition: gr-analog/include/gnuradio/analog/api.h:30
quadrature demodulator: complex in, float out
Definition: quadrature_demod_cf.h:65