GNU Radio Manual and C++ API Reference  3.7.14.0
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
slicer_agc_impl.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2002 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 _ATSC_SLICER_AGC_H_
24 #define _ATSC_SLICER_AGC_H_
25 
26 #include <gnuradio/atsc/api.h>
28 #include <math.h>
29 
30 /*!
31  * \brief Automatic Gain Control class for atsc slicer
32  *
33  * Given perfect data, output values will be +/- {7, 5, 3, 1}
34  */
35 
37 {
38 
39 public:
40  atsci_slicer_agc() : _gain(1), dc(0.0025){};
41 
42 
43  float gain() { return _gain; }
44 
45 #if 1
46  float scale(float input)
47  {
48  float t = input * _gain;
49  float output = t - REFERENCE;
50  float error = REFERENCE - dc.filter(t);
51  _gain += error * RATE;
52  return output;
53  }
54 #else
55  float scale(float input)
56  {
57  float avg = dc.filter(input);
58  if (fabs(avg) < .1)
59  avg = .1;
60  _gain += _gain * .99 + .01 * REFERENCE / avg;
61  return input * _gain - REFERENCE;
62  }
63 #endif
64 
65 protected:
66  static const float REFERENCE = 1.25; // pilot reference value
67  static const float RATE = 1.0e-5; // adjustment rate
68  float _gain; // current gain
70 };
71 
72 #endif /* _ATSC_SLICER_AGC_H_ */
#define ATSC_API
Definition: gr-atsc/include/gnuradio/atsc/api.h:30
atsci_slicer_agc()
Definition: slicer_agc_impl.h:40
Automatic Gain Control class for atsc slicer.
Definition: slicer_agc_impl.h:36
gr::filter::single_pole_iir< float, float, float > dc
Definition: slicer_agc_impl.h:69
float gain()
Definition: slicer_agc_impl.h:43
float scale(float input)
Definition: slicer_agc_impl.h:46
float _gain
Definition: slicer_agc_impl.h:68