discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Stereo FM receiver


From: Eric Blossom
Subject: Re: [Discuss-gnuradio] Stereo FM receiver
Date: Mon, 24 Jan 2005 22:55:53 -0800
User-agent: Mutt/1.5.6i

On Mon, Jan 24, 2005 at 09:20:28PM -0500, Anastasopoulos Achilleas wrote:
> 
> 
> Also, there is one thing that would be cool to implement:
> some sort of software AGC that measures the pilot power and updates
> the gain (to maintain a unit power subcarrier) every, say, 5 secs.
> One idea is to get the squared signal, measure the DC component
> and call filter.set_taps((...)) once every 5 seconds...
> I am not sure how to implement this (maybe using time.sleep(5))

You don't want to use time.sleep (...)

Here's an AGC primitive from the gnuradio-0.9 tarball.
It does it constantly.  It approximates power as absolute value, uses
a loop filter to control that adaptation rate and provides scaling of
the data passing through the block.

rate controls the adaptation rate.
reference is the value you want to drive the avg power to.

gain is the knob that's controlled by the loop.

/* -*- c++ -*- */
/*
 * Copyright 2002 Free Software Foundation, Inc.
 * 
 * This file is part of GNU Radio
 * 
 * GNU Radio is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 * 
 * GNU Radio is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with GNU Radio; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifndef INCLUDED_GRI_AGC_H
#define INCLUDED_GRI_AGC_H

#include <math.h>

/*!
 * \brief high performance Automatic Gain Control class
 *
 * Power is approximated by absolute value
 */

class gri_agc {

 public:
  gri_agc (float rate = 1e-4, float reference = 1.0, float gain = 1.0)
    : d_rate(rate), d_reference(reference), d_gain(gain) {};

  float rate () const      { return d_rate; }
  float reference () const { return d_reference; }
  float gain () const      { return d_gain;  }

  void setd_rate (float rate) { d_rate = rate; }
  void setd_reference (float reference) { d_reference = reference; }
  void setd_gain (float gain) { d_gain = gain; }

  float scale (float input){
    float output = input * d_gain;
    d_gain += (d_reference - fabsf (output)) * d_rate;
    return output;
  }

  void scale_n (float output[], const float input[], unsigned n){
    for (unsigned i = 0; i < n; i++)
      output[i] = scale (input[i]);
  }
  
 protected:
  float d_rate;                 // adjustment rate
  float d_reference;            // reference value
  float d_gain;                 // current gain
};

#endif /* INCLUDED_GRI_AGC_H */


A (very) minor amount of effort would be required to integrate it into
2.x Just derive a new block called gr_agc_ff (or gr_agc_cc) from
gr_sync_block.  Use gri_agc.h to do the work (call scale_n in the work
method).

If you need a complex version, it's a minor variation on this theme.

See http://www.gnu.org/software/gnuradio/doc/howto-write-a-block.html

If you've got time, please write gr_agc_{ff,cc}.{h,cc} and submit a patch.

Thanks!
Eric




reply via email to

[Prev in Thread] Current Thread [Next in Thread]