3 * Copyright 2002 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
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 2, or (at your option)
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.
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.
23 #ifndef _ATSC_SLICER_AGC_H_
24 #define _ATSC_SLICER_AGC_H_
27 #include <gr_single_pole_iir.h>
30 * \brief Automatic Gain Control class for atsc slicer
32 * Given perfect data, output values will be +/- {7, 5, 3, 1}
35 class atsci_slicer_agc {
38 atsci_slicer_agc () : _gain(1), dc(0.0025) {};
41 float gain () { return _gain; }
44 float scale (float input){
45 float t = input * _gain;
46 float output = t - REFERENCE;
47 float error = REFERENCE - dc.filter (t);
48 _gain += error * RATE;
52 float scale(float input){
53 float avg = dc.filter(input);
54 if(fabs(avg)<.1)avg=.1;
55 _gain += _gain*.99 + .01* REFERENCE/avg;
56 return input*_gain - REFERENCE;
62 static const float REFERENCE = 1.25; // pilot reference value
63 static const float RATE = 1.0e-5; // adjustment rate
64 float _gain; // current gain
65 gr_single_pole_iir<float,float,float> dc;
68 #endif /* _ATSC_SLICER_AGC_H_ */