Accelerating the pace of engineering and science

# AGC

## Library

RF Impairments Correction

## Description

This automatic gain controller (AGC) block adaptively adjusts its gain to achieve a constant signal level at the output.

## Dialog Box

Detector method

Specify the method that the block uses to perform envelope detection. The default is Rectifier.

When you select Rectifier, the AGC detector outputs a voltage value proportional to the envelope amplitude of the output signal. The detector rectifies and then averages the input signal over the period of gain updates in samples. The AGC adjusts the gain to obtain unity voltage at the output of the detector.

When you select Square law, the AGC detector outputs a power value that is proportional to the square of the output voltage. The detector squares and then averages the input signal over the period of gain updates in samples. The AGC adjusts the gain to obtain unity power at the output of the detector.

Loop method

Specify the AGC loop implementation that the block uses. The default is Linear.

When you select Linear, the AGC uses the direct value of the detector output to determine the gain value. Typically, a linear loop responds quickly to increases in the input signal level. However, the loop's response to decreases in the input signal level tends to be slow.

When you select Logarithmic, the AGC uses the logarithm of the detector output to determine the gain value. Logarithmic loops respond to decreases in the input signal level much more quickly than linear loops.

Period of gain updates in samples

Specify the period of the gain updates as a double- or single-precision, real, integer-valued scalar. The default is 100.

The number of input samples must be an integer multiple of this parameter value. Setting the period greater than 1 increases the speed of the AGC algorithm.

If you increase the period of the gain updates, you may also need to increase the step size. Similarly, if you decrease the period of the gain updates, you may also need to decrease the step size.

Step size

Specify the step size for gain updates as a double- or single-precision, real, positive scalar. The default is 0.1.

If you increase the loop gain, the AGC responds to changes at the input signal level faster. However, gain pumping also increase.

If you increase the period of the gain updates, you may also need to increase the step size. Similarly, if you decrease the period of the gain updates, you may also need to decrease the step size.

Maximum gain in dB

Specify the maximum gain of the AGC in decibels as a positive scalar. The default is 30.

If the input signal to the AGC has a very low signal level, the AGC gain may increase rapidly. Use this parameter to limit the gain that the AGC applies to the input signal.

Enable gain output

Select this check box to enable a secondary block output port. This port displays the gain that the AGC applies to the input signal.

## Algorithms

### Linear Loop AGC

In a linear loop AGC, the detector uses its output directly to generate an error signal. After applying a step size, the AGC passes the error signal to an integrator. The output of the integrator is used as the variable gain. Linear loop AGCs are limited by their decay, or slew, characteristics. In other words, they respond to input signal increases much more quickly than they respond to input signal decreases.

$\begin{array}{l}y\left(n\right)=g\left(n\right)\cdot x\left(n\right);\\ e\left(n\right)=A-z\left(m\right);\\ g\left(n+1\right)=g\left(n\right)+K\cdot e\left(n\right);\end{array}$

where

A represents the reference value, which is 1

K represents the step size

e represents the error signal

g represents the gain

x represents the input signal

y represents the output signal

z represents the detector output

### Logarithmic Loop AGC

In a logarithmic loop AGC, the logarithm of the ratio of the detector output and the reference signal represents the error signal. A logarithmic loop uses the exponential of the integrator output as the gain signal. Logarithmic loop AGCs have the same response time to both increases or decreases to the input signal amplitude.

The logarithmic loop has longer attack and decay times. However, the gain pumping of the logarithmic loop is better than that of the linear loop.

$\begin{array}{l}y\left(n\right)={e}^{g\left(n\right)}\cdot x\left(n\right);\\ e\left(n\right)=ln\left(A\right)-\mathrm{ln}\left(z\left(m\right)\right);\\ g\left(n+1\right)=g\left(n\right)+K\cdot e\left(n\right);\end{array}$

where

A represents the reference value, which is 1

K represents the step size

e represents the error signal

g represents the gain

x represents the input signal

y represents the output signal

z represents the detector output

### AGC Detector

Two AGC detectors are available:

#### Rectifier

z = |y| when the detector represents a rectifier

$z\left(m\right)=\frac{1}{N}{\sum }_{n=mN}^{\left(m+1\right)N-1}|y\left(n\right)|$

where N represents the period of the gain updates

#### Square Law

z = |y|2 represents the square law detector

$z\left(m\right)=\frac{1}{N}{\sum }_{n=mN}^{\left(m+1\right)N-1}{|y\left(n\right)|}^{2}$

where N represents the period of the gain updates

### Performance Considerations

There are three performance criteria for AGCs:

• Attack time: The duration it takes the AGC to respond to an increase in the input amplitude.

• Decay time: The duration it takes the AGC to respond to a decrease in the input amplitude.

• Gain pumping: The variation in the gain value during steady-state operation.

Increasing the step size decreases the attack time and decay times, but it also increases gain pumping.

## Examples

• To openopen an example that adaptively adjusts the received signal amplitude to approximately 1 volt, type doc_agc_received_signal_amplitude at the MATLAB® command line.

• To openopen an example that compare the performance of an AGC with a rectifier detector and a square law detector, type doc_agc_compare_rectifier_and_square_law at the MATLAB command line.

• Top openopen an example that plots the effect of step size on AGC performance, type doc_agc_plot_step_size at the MATLAB command line.

• To openopen an example that plots the effect of maximum gain on burst signals, type doc_agc_plot_max_gain at the MATLAB command line.