GNU Radio Manual and C++ API Reference  3.7.9.2
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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>
27 #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  public:
39  atsci_slicer_agc () : _gain(1), dc(0.0025) {};
40 
41 
42  float gain () { return _gain; }
43 
44 #if 1
45  float scale (float input){
46  float t = input * _gain;
47  float output = t - REFERENCE;
48  float error = REFERENCE - dc.filter (t);
49  _gain += error * RATE;
50  return output;
51  }
52 #else
53  float scale(float input){
54  float avg = dc.filter(input);
55  if(fabs(avg)<.1)avg=.1;
56  _gain += _gain*.99 + .01* REFERENCE/avg;
57  return input*_gain - REFERENCE;
58  }
59 #endif
60 
61  protected:
62 
63  static const float REFERENCE = 1.25; // pilot reference value
64  static const float RATE = 1.0e-5; // adjustment rate
65  float _gain; // current gain
66  gr_single_pole_iir<float,float,float> dc;
67 };
68 
69 #endif /* _ATSC_SLICER_AGC_H_ */
gr_single_pole_iir< float, float, float > dc
Definition: slicer_agc_impl.h:66
#define ATSC_API
Definition: gr-atsc/include/gnuradio/atsc/api.h:30
atsci_slicer_agc()
Definition: slicer_agc_impl.h:39
Automatic Gain Control class for atsc slicer.
Definition: slicer_agc_impl.h:36
float gain()
Definition: slicer_agc_impl.h:42
float scale(float input)
Definition: slicer_agc_impl.h:45
float _gain
Definition: slicer_agc_impl.h:65