Adaptively adjust gain for constant signallevel output
The comm.AGC
System
object™ creates an
automatic gain controller (AGC) that adaptively adjusts its gain to
achieve a constant signal level at the output.
To adaptively adjust gain for constant signallevel output:
Define and set up your automatic gain controller object. See Construction.
Call step
to adaptively adjust gain and achieve
a constant signal level at the output according to the properties
of comm.AGC
. The behavior of step
is
specific to each object in the toolbox.
Starting in R2016b, instead of using the step
method
to perform the operation defined by the System
object, you can
call the object with arguments, as if it were a function. For example, y
= step(obj,x)
and y = obj(x)
perform
equivalent operations.
H = comm.AGC
creates an AGC System
object, H
,
that adaptively adjusts its gain to achieve a constant signal level
at the output.
H = comm.AGC(
creates
an AGC object, Name
,Value
)H
, with the specified property Name
set
to the specified Value
. You can specify additional
namevalue pair arguments in any order as (Name1
,Value1
,...,NameN
,ValueN
).

Step size for gain updates Specify the step size as a real positive scalar. The default
is 

Target output power level Specify the desired output power level as a real positive scalar.
The power is measured in Watts referenced to 1 ohm . The default is 

Length of the averaging window Specify the length of the averaging window in samples as a positive
integer scalar. The default is NoteIf you use the AGC with higher order QAM signals, you might
need to reduce the variation in the gain during steadystate operation.
Inspect the scatter plot at the output of the AGC and increase the
averaging length as needed. An increase in 

Maximum power gain in decibels Specify the maximum gain of the AGC in decibels as a positive
scalar. The default is If the AGC input signal power is very small, the AGC gain will
be very large. This can cause problems when the input signal power
suddenly increases. Use 
reset  Reset internal states of automatic gain controller 
step  Apply adaptive gain to input signal 
Common to All System Objects  

clone  Create System object with same property values 
getNumInputs  Expected number of inputs to a System object 
getNumOutputs  Expected number of outputs of a System object 
isLocked  Check locked states of a System object (logical) 
release  Allow System object property value changes 
For the logarithmic loop AGC, 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 provides good performance for a variety of signal types, including amplitude modulation. Unlike the previous AGC (R2015a and earlier), the detector is applied to the input signal, which results in faster convergence times and increased signal power variation at the detector input. The larger variation is not a problem for floating point systems. A block diagram of the algorithm is shown.
Mathematically, the algorithm is summarized as
$$\begin{array}{l}y(n)=x(n)\cdot \mathrm{exp}(g(n1))\\ z(n)=D(x(n))\cdot \mathrm{exp}(2g(n1))\\ e(n)=A\mathrm{ln}(z(n))\\ g(n)=g(n1)+K\cdot e(n),\end{array}$$
where
x represents the input signal.
y represents the output signal.
g represents the loop gain.
D(•) represents the detector function.
z represents the detector output.
A represents the reference value.
e represents the error signal.
K represents the step size.
The AGC uses a square law detector, in which the output of the detector, z, is given by
$$z(m)=\frac{1}{N}{\displaystyle {\sum}_{n=mN}^{(m+1)N1}{\lefty(n)\right}^{2}}\text{\hspace{0.17em}},$$
where N represents the update period.
Attack time — The duration it takes the AGC to respond to an increase in the input amp litude.
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 steadystate operation.
Increasing the step size decreases the attack time and decay times, but it also increases gain pumping.