# automatic gain control

Started by February 14, 2008
```Hi,

i'm new in this area. I'm now using ADSP 21061 SHARC digital signal
processing. I want to ask about automatic gain control, how to compute the
signal power from the received signal? I want to use this signal power to
scalling my signal.

Cheers..

```
```On Thu, 14 Feb 2008 09:44:33 -0600, nwa wrote:

> Hi,
>
> i'm new in this area. I'm now using ADSP 21061 SHARC digital signal
> processing. I want to ask about automatic gain control, how to compute
> the signal power from the received signal? I want to use this signal
> power to scalling my signal.
>
> Cheers..

Square and average.  AGC loops are multiplicative, so it's usually a good
idea to take the logarithm of the average power to linearize the loop.

--
Tim Wescott
Control systems and communications consulting
http://www.wescottdesign.com

Need to learn how to apply control theory in your embedded system?
"Applied Control Theory for Embedded Systems" by Tim Wescott
Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
```
```
Tim Wescott wrote:

> On Thu, 14 Feb 2008 09:44:33 -0600, nwa wrote:
>
>
>>Hi,
>>
>>i'm new in this area. I'm now using ADSP 21061 SHARC digital signal
>>processing. I want to ask about automatic gain control, how to compute
>>the signal power from the received signal? I want to use this signal
>>power to scalling my signal.
>>
>>Cheers..
>
>
> Square and average.  AGC loops are multiplicative, so it's usually a good
> idea to take the logarithm of the average power to linearize the loop.

BTW they always recommend using a squaring detector which implies the
double numeric precision and requires the square root or log operation
which is quite expensive. In many cases you don't really need the exact
power but some sort of approximate measure of the signal. The averaged
absolute value works just as well as RMS for many practical cases. If
the peak detection is required, then the averager can have the different
fall and raise time constants.

DSP and Mixed Signal Design Consultant
http://www.abvolt.com
```
```Tim Wescott wrote:
> On Thu, 14 Feb 2008 09:44:33 -0600, nwa wrote:
>
>> Hi,
>>
>> i'm new in this area. I'm now using ADSP 21061 SHARC digital signal
>> processing. I want to ask about automatic gain control, how to compute
>> the signal power from the received signal? I want to use this signal
>> power to scalling my signal.
>>
>> Cheers..
>
> Square and average.  AGC loops are multiplicative, so it's usually a good
> idea to take the logarithm of the average power to linearize the loop.
>

That, and filtering. Else the AGC regulates your signal away. Often AGC
also requires nifty filters such as fast-attack/slow-release.

--
Regards, Joerg

http://www.analogconsultants.com/
```
```On Feb 15, 4:44 am, "nwa" <n.w.ars...@ncl.ac.uk> wrote:
> Hi,
>
> i'm new in this area. I'm now using ADSP 21061 SHARC digital signal
> processing. I want to ask about automatic gain control, how to compute the
> signal power from the received signal? I want to use this signal power to
> scalling my signal.
>
> Cheers..

Square then remove the dc component (ie a set point). Then integrate
and feedback to a multiplier. The multiplier has the other input as
the signal and it's output gets squared.
```
```On Thu, 14 Feb 2008 16:10:13 +0000, Vladimir Vassilevsky wrote:

> Tim Wescott wrote:
>
>> On Thu, 14 Feb 2008 09:44:33 -0600, nwa wrote:
>>
>>
>>>Hi,
>>>
>>>i'm new in this area. I'm now using ADSP 21061 SHARC digital signal
>>>processing. I want to ask about automatic gain control, how to compute
>>>the signal power from the received signal? I want to use this signal
>>>power to scalling my signal.
>>>
>>>Cheers..
>>
>>
>> Square and average.  AGC loops are multiplicative, so it's usually a
>> good idea to take the logarithm of the average power to linearize the
>> loop.
>
> BTW they always recommend using a squaring detector which implies the
> double numeric precision and requires the square root or log operation
> which is quite expensive. In many cases you don't really need the exact
> power but some sort of approximate measure of the signal. The averaged
> absolute value works just as well as RMS for many practical cases. If
> the peak detection is required, then the averager can have the different
> fall and raise time constants.
>
>
> DSP and Mixed Signal Design Consultant http://www.abvolt.com

A logarithm good enough for an AGC is cheap, particularly if you have a
chip with a normalizer.  You take the log to the base 2: shift up until
the MSB is set -- that's the mantissa of your log.  Then you take the
remainder and linearly interpolate it between where you are and the next
log up.

Averaging the magnitude works well and is less expensive unless you have
a DSP chip that can square quicker than it can take an absolute value.
For a wide-range AGC you can still do better with a log.

--
Tim Wescott
Control systems and communications consulting
http://www.wescottdesign.com

Need to learn how to apply control theory in your embedded system?
"Applied Control Theory for Embedded Systems" by Tim Wescott
Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
```
```
Tim Wescott wrote:

>>>Square and average.  AGC loops are multiplicative, so it's usually a
>>>good idea to take the logarithm of the average power to linearize the
>>>loop.
>>
>>BTW they always recommend using a squaring detector which implies the
>>double numeric precision and requires the square root or log operation
>>which is quite expensive. In many cases you don't really need the exact
>>power but some sort of approximate measure of the signal. The averaged
>>absolute value works just as well as RMS for many practical cases. If
>>the peak detection is required, then the averager can have the different
>>fall and raise time constants.

> A logarithm good enough for an AGC is cheap, particularly if you have a
> chip with a normalizer.  You take the log to the base 2: shift up until
> the MSB is set -- that's the mantissa of your log.  Then you take the
> remainder and linearly interpolate it between where you are and the next
> log up.

I have done that. IIRC the accuracy of this simplest log approximation
to come to the identical conclusions on so many different questions :)

> Averaging the magnitude works well and is less expensive unless you have
> a DSP chip that can square quicker than it can take an absolute value.
> For a wide-range AGC you can still do better with a log.

Usually, if the AGC has wide range, then it has to deal with the signal
to noise problem and with the dynamic variations also. So, the gain
adaptation requires some sort of magic inside the loop in the addition
to the common arithmetic.