Automatic gain control

Thread Starter


Joined May 9, 2009
I'm trying to build an automatic gain control circuit but I don't really know where to start.

Basically I want to measure the peak voltage of an input waveform and adjust the gain of an op-amp or other amplifier to compensate.

I was thinking of using a PIC microcontroller and an adjustable gain amplifier, but I think that an analog circuit would probably be better. Anyone got any suggestions?

I can vary gain using a JFET control, the important part is calculating the gain adjustment.


Joined Apr 24, 2007
As in most feedback systems based on classical control theory, the basic operation is just to subtract the feedback from a setpoint voltage that corresponds to the desired output. But you will have to worry about scaling the result for your gain adjuster's control input, and might need to worry about having enough dynamic range everywhere. A lot might also depend on exactly what you want the AGC to be able to do.

I am not sure that an analog circuit would necessarily be better. A mostly-digital implementation might be both better and easier to implement, for all I know. But I have only designed purely-analog AGC-type circuits.

To do the subtraction with an analog circuit, you could just use a simple opamp difference amplifier. You can find probably all of the opamp circuits you will need in application notes AN-20 and AN-31, at (Actually, you might want to use a differential integrator opamp circuit, instead of a plain difference amplifier.)

What frequencies are you going to be dealing with? RF? Audio? I will assume audio.

Your detector will probably just be an envelope detector or an averaging detector. If you need a very fast and accurate correction response (say 200 ms or less for a full-scale error), it can be tricky to get a simple one of those to work well all the way across the extended audio range, or for more than about 2.5 decades of frequency.

You will probably want to use a high-input-impedance opamp buffer or amplifier to pick off the signal to measure and create the feedback. Then, for the detector, you "could" use a series diode followed by a capacitor to ground. That would be a really-basic peak detector. But you will also need a resistance in parallel with the capacitor, to be able to follow downward-going signal envelopes. Adjusting the resistor and capacitor values will define how the detector handles a particular range of signal and envelope frequencies. And instead of a plain diode, you might want to use an "ideal diode" type of opamp circuit, so it can go all the way to zero. And you might want a full-wave rectifier version, so you will also "see" the envelope of the negative half of the signal. After the detector, you'll probably need another opamp buffer or amplifier. And somewhere in the feedback path you might need a low-pass filter, so you don't end up modulating the envelope amplitude with detector artifacts. There might be a lot of time-constants to adjust, to get it right, depending on your application.

If you are at all familiar with spice, I strongly recommend using LTspice (or your favorite spice, but LTspice is free to download from and is really great) to model and simulate your design. With LTspice you can even have WAV files as inputs and outputs. If you are not familiar with it, maybe now is a good time to learn.


Last edited:


Joined Jul 3, 2008
I'm trying to build an automatic gain control circuit but I don't really know where to start.
I thought I would add attachments of my old electronics notes that briefly discuss some basic AGC circuits. These are not necessarily the final circuits you would want to use, but they form a starting point to understand the basics.