[comp.dsp] AGC with DSP...

sutin@helios (Brian Sutin) (05/08/91)

I am using a 12-bit DSP system to do real time processing on full frequency
range audio signals.  Because of the dynamic range in volume, however, 12 bits
is very inadequate at low signal levels.  The solution for my application,
since I do not need to know the actual volume, is to use an analog circuit
similar to an AGC:

     INPUT--->AMP 1--->DSP--->AMP 2--->OUTPUT
       |        ^               ^
       v        |               |
     POWER-----------------------

Here POWER calculates the power of the input signal, which is filtered at
something like 10Hz.  AMP 1 takes the input signal and amplifies/de-amplifies
the output to be about 1v.  AMP 2 takes the output from the DSP, also about
1v, and amplifies/de-amplifies back to the original volume level.  If both
amplifiers are linear to 12 bits over the entire power and frequency range,
then the entire configuration should have no audible distortion.

Since my circuit design knowledge is not up to this level, I have no idea
how to actually implement this application.  I cannot believe that someone
out there hasn't already done this, or doesn't have something better.

Any input by e-mail appreciated.

Brian Sutin
Lick Observatory, UCSC
sutin@helios.ucsc.edu

mcmahan@netcom.COM (Dave Mc Mahan) (05/09/91)

 In a previous article, sutin@helios (Brian Sutin) writes:
>I am using a 12-bit DSP system to do real time processing on full frequency
>range audio signals.  Because of the dynamic range in volume, however, 12 bits
>is very inadequate at low signal levels.  The solution for my application,
>since I do not need to know the actual volume, is to use an analog circuit
>similar to an AGC.

One thing you might want to try is to use a digitally programmable resistor
to attenuate the signal.  That way, you can know the gain in your CPU since
it is set by the CPU.  The CPU would just take an average of the last X number
of samples, multiply and/or offset this value to derive the proper attenuation
for the circuit configuration you select, and then send the value to the 
resistor.  One benefit from using a programmable resistor is that they 
generally have better frequency response (it's flatter over a wider bandwidth)
than other methods I have seen.  This tends to make it cheaper.  Such resistor
networks can be purchased from Dallas Semiconductor or MicroLinear Corp.  These
usually come with a synchronous serial input that you drive from two digital
output lines from your CPU.  If the range is semi-limited, this method will
work fine.  If not, you may have to incorporate the resistor into the gain
loop of an op-amp and use it to select the gain of the op-amp.  My circuit
theory is a bit rusty, but I think the circuit you want is:


                     _
                    | \ 
                    |  \ 
 Input              |   \ 
  >------ /\/\/\----| +  \
            R1      |     \_______________ Ouput to ADC
                ----| -   /
                |   |    /
                |   |   /
                |   |_ /   Op-Amp
                |
                \
            R2  /
                \
                /
               |
              _|_
              \_/
              Gnd 

This is a non-inverting Amplifier, and R2 is the programmable resistor.  R1
is some fixed resistor that is used to help define the gain of the circuit.
I think the formula for the gain is something like:

    Gain = (R2 + R1) / R1

You should verify this formula before using it, however.  The nice thing about
this is that you can make the gain of R2 dependent upon very complicated signal
conditions, since it is set by the CPU.  It can be set to track the peak of
a signal, the power of a signal, allow it to find the proper gain during one
part of the program and then lock it (by not changing it) for use at some other
point of the program, or just about anything else you have the CPU power to
compute.  The advantage to using the op-amp is that you can set it so that a
large input won't clip the input of your ADC and still give you the range you
need to amplify a small signal.  It's a bit more complicated, but has 
benefits you may want.


>Brian Sutin
>Lick Observatory, UCSC
>sutin@helios.ucsc.edu

  -dave
--
-- 
Dave McMahan                            mcmahan@netcom.com
					{apple,amdahl,claris}!netcom!mcmahan

grayt@Software.Mitel.COM (Tom Gray) (05/09/91)

:I am using a 12-bit DSP system to do real time processing on full frequency
:range audio signals.  Because of the dynamic range in volume, however, 12 bits
:is very inadequate at low signal levels.  The solution for my application,
:since I do not need to know the actual volume, is to use an analog circuit
:similar to an AGC:
:
:     INPUT--->AMP 1--->DSP--->AMP 2--->OUTPUT
:       |        ^               ^
:       v        |               |
:     POWER-----------------------
:
:Here POWER calculates the power of the input signal, which is filtered at
:something like 10Hz.  AMP 1 takes the input signal and amplifies/de-amplifies
:the output to be about 1v.  AMP 2 takes the output from the DSP, also about
:1v, and amplifies/de-amplifies back to the original volume level.  If both
:amplifiers are linear to 12 bits over the entire power and frequency range,
:then the entire configuration should have no audible distortion.
:
:Since my circuit design knowledge is not up to this level, I have no idea
:how to actually implement this application.  I cannot believe that someone
:out there hasn't already done this, or doesn't have something better.

What you are describing is a companding DAC. These are widely used in 
the communication industry to achieve a constant SNR over a wide
range of inputs. In this way the quantizing noise for a
loud talker (-18dBm) is thae same as that of a quiet talker (-35dBm).

Any complete text on communications will have a description of
the transfer functions used in the compressor and expander.
Approximations to logarithmic curves are often used.
Common ones are the A Law and mu255 Law curves. These are
described in CCITT documents.

Common telephoney codecs will supply 13 bit resolution with 8 bit
accuracy. Since these are $3 chips, they may be suitable for you.
 

raoul@eplunix.UUCP (Nico Garcia) (05/10/91)

In article <1991May9.043958.23925@netcom.COM>, mcmahan@netcom.COM (Dave Mc Mahan) writes:
>  In a previous article, sutin@helios (Brian Sutin) writes:
> >I am using a 12-bit DSP system to do real time processing on full frequency
> >range audio signals.  Because of the dynamic range in volume, however, 12 bits
> >is very inadequate at low signal levels.  The solution for my application,
> >since I do not need to know the actual volume, is to use an analog circuit
> >similar to an AGC.

Hmmm. After analyzing some AGC's in circuits, I've picked up a personal
distaste for them. They tend to do some very strange things to your harmonic
distortion as well. However, one way to do it is to peak sample your signal,
(both +/- peaks, actual circuit left as an exercise to the reader),
digitally read that (since who knows, you may want the information for
something) and use it to set an AD7111 programmable logarithmic attenuator.
Analog Devices makes them, and they're kind of nice.

To avoid AGC's all together, use several A/D's with overlap in their signal
ranges, generate a lookup table for input vs. output readings, and send
*that* to your computer. Do your AGC in software this way, where it won't
inject weirdness into your signal analysis.

Is this for speech or some other audio function?

-- 
			Nico Garcia
			Designs by Geniuses for use by Idiots
			eplunix!cirl!raoul@eddie.mit.edu