DSPRelated.com
Forums

Simple AGC (automatic gain control) algorithm

Started by AntonZ July 29, 2003
I need a simple AGC system. I have no time to develop it thourouly and
have no much experience in creating such systems. Can anyone suggest a
simple AGC algorithm?
AntonZ wrote:

> I need a simple AGC system. I have no time to develop it thourouly and > have no much experience in creating such systems. Can anyone suggest a > simple AGC algorithm?
I include a simple AGC function in my free open source code library HawkVoiceDI. You can download it from my website below. -- Phil Frisbie, Jr. Hawk Software http://www.hawksoft.com
On 29 Jul 2003 04:46:26 -0700, anton@global-ops.com (AntonZ) wrote:

>I need a simple AGC system. I have no time to develop it thourouly and >have no much experience in creating such systems. Can anyone suggest a >simple AGC algorithm?
The simplest I know is: if(signal too big)decrease gain, else increase gain Can't offer much more without more info. Cheers, Eric Jacobsen Minister of Algorithms, Intel Corp. My opinions may not be Intel's opinions. http://www.ericjacobsen.org
"Eric Jacobsen" <eric.jacobsen@ieee.org> wrote in message
news:3f26975a.300291931@news.earthlink.net...
> On 29 Jul 2003 04:46:26 -0700, anton@global-ops.com (AntonZ) wrote: > > >I need a simple AGC system. I have no time to develop it thourouly and > >have no much experience in creating such systems. Can anyone suggest a > >simple AGC algorithm? > > The simplest I know is: > > if(signal too big)decrease gain, > else increase gain > > Can't offer much more without more info. > > Cheers, > > Eric Jacobsen > Minister of Algorithms, Intel Corp. > My opinions may not be Intel's opinions. > http://www.ericjacobsen.org
if(signal too big)decrease gain by percentage "k1", else increase gain by percentage "k2". k1 and k2 determine how fast/slow the agc acts. often k1>k2 so the agc acts quickly / the gain decreases quickly / with large signals and only gradually increases as signal level goes down. Fred
Fred Marshall wrote:
> > "Eric Jacobsen" <eric.jacobsen@ieee.org> wrote in message > news:3f26975a.300291931@news.earthlink.net... > > On 29 Jul 2003 04:46:26 -0700, anton@global-ops.com (AntonZ) wrote: > > > > >I need a simple AGC system. I have no time to develop it thourouly and > > >have no much experience in creating such systems. Can anyone suggest a > > >simple AGC algorithm? > > > > The simplest I know is: > > > > if(signal too big)decrease gain, > > else increase gain > > > > Can't offer much more without more info. > > > > Cheers, > > > > Eric Jacobsen > > Minister of Algorithms, Intel Corp. > > My opinions may not be Intel's opinions. > > http://www.ericjacobsen.org > > if(signal too big)decrease gain by percentage "k1", > else increase gain by percentage "k2". > k1 and k2 determine how fast/slow the agc acts. often k1>k2 so the agc acts > quickly / the gain decreases quickly / with large signals and only gradually > increases as signal level goes down. > > Fred
It's sometimes good to have a dead zone where the gain doesn't change. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
> The simplest I know is: > > if(signal too big)decrease gain, > else increase gain
That's that I already know. Your algorithm is about to change gain too often, there should be some highmark and lowmark levels. The problem is to determine is the signal is big or small.
> Can't offer much more without more info.
FSK 50-450kHz, processing is on fixed point 55xx. I can control VREF level on ADC, depending on the signal. I want signal to have amplitude not higher than 80-90% of the full scale and lower than 40-50% of full scale. The problems are how to measure is the signal "big" or "small", how to adjust gain, how to do it on fixed point Anton
> > if(signal too big)decrease gain by percentage "k1",
I want to develop an estimate. What is signal "too big", what is signal "too small". I need a reliable estimate of what is "big" and what is "small". It seems to be the most difficult task to develop such an estimate in AGC system design
anton@global-ops.com (AntonZ) wrote in message news:<7c8cdd95.0307290346.18de8e20@posting.google.com>...
> I need a simple AGC system. I have no time to develop it thourouly and > have no much experience in creating such systems. Can anyone suggest a > simple AGC algorithm?
A good agc should have a true scale invariant property. That is, if x-->y then g*x-->y . This requires some kind of log or exponential relationship in the control path. There is a simple and good agc in one of the ti dsp app notes, not as agc by itself but as part of another application. Can't remember the app or the volume but it's there somewhere. Matt

AntonZ wrote:

> I need a simple AGC system. I have no time to develop it thourouly and > have no much experience in creating such systems. Can anyone suggest a > simple AGC algorithm?
You cannot really do the 'if this bigger than that then reduce that routine' as it is pretty ad-hoc by all accounts and not a true servo.In fact I am willing to bet that that approach may lead to an alegbraic loop (though not sure). See this earlier thread http://groups.google.co.nz/groups?q=agc+code+aberdonian_2000&hl=en&lr=&ie=UTF-8&safe=off&selm=3E5F11BE.BCE4F612%40NAESPAMm.com&rnum=1 Assume yin is the input to the AGC (say a speech signal) and yout is the AGC output. loop forever { /* Voltage controlled amplifier is just a multiplier here */ yout=yin*iout /* error */ err=spoint-abs(yout) /* Integrate */ iout1=iout iout=iout1+gain*err } The gain needs to found by trial and error. If gain is too big you will get instability and if too small it will be too slow to respond. try gain=0.001 for starters and increase it. In fact the gain limit is a function of the size of yin. spoint = 1 will do for a set-point. All an AGC is is a voltage controlled amplifier (a multiplier here), a rectifier, a setpoint and a low-pass filter. The filter here is an integrator so as to get zero steady-state errror to a step change in amplitude. If you wnat to get fancy you can have two integrators and phase-lead compensator though it is difficult to keep stable for large dynamic ranges. regards Tom
Tom,

Your AGC is a hell of simple! I even have doubts it will work. It
seems it can be easily adapted to fixed point. I will try to model it
in Matlab/Simulink.

> > I need a simple AGC system. I have no time to develop it thourouly and > > have no much experience in creating such systems. Can anyone suggest a > > simple AGC algorithm? > > You cannot really do the 'if this bigger than that then reduce that > routine' as it is pretty ad-hoc by all accounts and not a true servo.In > fact I am willing to bet that that approach may lead to an alegbraic loop > (though not sure). > > See this earlier thread > > http://groups.google.co.nz/groups?q=agc+code+aberdonian_2000&hl=en&lr=&ie=UTF-8&safe=off&selm=3E5F11BE.BCE4F612%40NAESPAMm.com&rnum=1 > > > > Assume yin is the input to the AGC (say a speech signal) and yout is the > AGC > output. > > loop forever > { > /* Voltage controlled amplifier is just a multiplier here */ > yout=yin*iout > > /* error */ > err=spoint-abs(yout) > > /* Integrate */ > iout1=iout > iout=iout1+gain*err } > > > > The gain needs to found by trial and error. If gain is too big you will > get instability > and if too small it will be too slow to respond. try gain=0.001 for > starters and increase it. In fact the gain limit is a function of the size > of yin. > spoint = 1 will do for a set-point. > > All an AGC is is a voltage controlled amplifier (a multiplier here), a > rectifier, a setpoint and a low-pass filter. The filter here is an > integrator so as to get zero steady-state errror to a step change in > amplitude. If you wnat to get fancy you can have two integrators and > phase-lead compensator though it is difficult to keep stable for large > dynamic ranges. > > > regards > > Tom