Adaptively adjust gain for constant signal-level output
Communications Toolbox / RF Impairments Correction
The automatic gain controller (AGC) block adaptively adjusts its gain to achieve a constant signal level at the output.
This icon shows the AGC block with the optional Px port.
In — Input signal
Input signal, specified as a column vector.
Complex Number Support: Yes
y — Output signal
Output signal, returned as an NS-element column vector. NS is the length of the input signal. The output signal is the same data type as the input signal.
Px — Power level estimate
Power level estimate, returned as an
NS-element column vector.
NS is the length of the
input signal. You can use
powerlevel as an energy
To enable this port, select the Enable output of estimated input power parameter.
Step size — Step size for gain updates
0.01 | positive scalar
Step size for gain updates, specified as a positive scalar. Increasing the step size enables the AGC to respond more quickly to changes in the input signal level but increases variation in the output signal level after reaching steady-state operation. For more information, see AGC Performance Criteria.
Desired output power (W) — Target output power level
1 | positive scalar
Target output power level, specified as a positive scalar. The power level is measured in watts referenced to 1 ohm.
Averaging length — Length of averaging window
100 | positive integer
Length of the averaging window in samples, specified as a positive integer. For more information on how the averaging length influences the variance of the AGC output signal in steady-state operation and the execution speed, see Tips.
Maximum power gain (dB) — Maximum power gain
60 (default) | positive scalar
Maximum power gain in decibels, specified as a positive scalar. Large gain adjustments can cause clipping when a small input signal power suddenly increases. Use this property to avoid large gain adjustments by limiting the gain that the AGC applies to the input signal. For an example, see Compare AGC Performance for Different Maximum Gains.
Enable output of estimated input power — Option to output estimated input power
off (default) | on
Select this check box to provide an output port,
Px, that returns an
estimate of the input signal power.
Simulate using — Type of simulation to run
Interpreted execution (default) |
Type of simulation to run, specified as
Interpreted execution— Simulate the model by using the MATLAB® interpreter. This option requires less startup time, but the speed of subsequent simulations is slower than with the
Code generationoption. In this mode, you can debug the source code of the block.
Code generation— Simulate the model by using generated C code. The first time you run a simulation, Simulink® generates C code for the block. The model reuses the C code for subsequent simulations unless the model changes. This option requires additional startup time, but the speed of the subsequent simulations is faster than with the
For more information, see Simulation Modes (Simulink).
The AGC implementation uses a logarithmic feedback loop. As this figure of the logarithmic-loop AGC algorithm shows, the output signal is the product of the input signal and the exponential of the loop gain. The error signal is the difference between the reference level and the product of the logarithm of the detector output and the exponential of the loop gain. After multiplying by the step size, the AGC passes the error signal to an integrator.
The logarithmic-loop AGC performs well for a variety of signal types, including amplitude modulation. The AGC Detector is applied to the input signal, which improves convergence times, but increases signal power variation at the detector input. Large signal variation at the detector input is acceptable for floating-point systems.
Mathematically, the algorithm is summarized as
x is the input signal.
y is the output signal.
g is the loop gain.
Detector(•) is the detector function.
z is the detector output.
A is the reference value.
err is the error signal.
K is the step size.
The AGC detector output, z, computes a square law detector given by
where N is the update period. The square law detector produces an output proportional to the square of the input signal y.
AGC Performance Criteria
Increasing the step size decreases the attack time and decay times, but it also increases gain pumping.
Attack time — The duration taken for the AGC to respond to an increase in the input amplitude
Decay time — The duration taken for the AGC to respond to a decrease in the input amplitude
Gain pumping — The variation in the gain value during steady-state operation
This block is designed for streaming applications.
If the signal amplitude does not change within the frame, you can simulate an ideal AGC by calculating the average gain desired for a frame of samples. Then, apply the gain to each sample in the frame.
If you use the AGC with higher order QAM signals, you might need to reduce the variation in the gain during steady-state operation. Inspect the constellation diagram at the output of the AGC during steady-state operation. You can increase the averaging length to avoid frequent gain adjustments. An increase in averaging length reduces execution speed.
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Introduced in R2013a