Contents

comm.AGC System object

Package: comm

Adaptively adjust gain for constant signal-level output

Description

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 signal-level output:

  1. Define and set up your automatic gain controller object. See Construction.

  2. 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.

Construction

H = comm.AGC creates an automatic gain controller (AGC) System object, H, that adaptively adjusts its gain to achieve a constant signal level at the output.

H = comm.AGC(Name,Value) creates an AGC object, H, with the specified property Name set to the specified Value. You can specify additional name-value pair arguments in any order as (Name1,Value1,...,NameN,ValueN).

Properties

DetectorMethod

Detector method

Specify the detector method as one of Rectifier | Square Law. The default is Rectifier.

When you set the DetectorMethod to 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 update period. The AGC adjusts the gain to obtain unit voltage at the output of the detector.

When you set the DetectorMethod to Square law, the AGC detector outputs an energy value that is proportional to the square of the output voltage. The detector squares and then averages the input signal over the update period. The AGC adjusts the gain to obtain unit energy at the output of the detector.

LoopMethod

Loop method

Specify the loop method of the AGC as one of Linear | Logarithmic. The default is Linear.

When you set the LoopMethod to 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 set the LoopMethod to 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.

UpdatePeriod

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 update period. Setting the period greater than 1 increases the speed of the AGC algorithm.

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

StepSize

Step size for gain updates

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 update period, you may also need to increase the step size. Similarly, if you decrease the update period, you may also need to decrease the step size.

MaximumGain

Maximum gain in decibels

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

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

GainOutputPort

Enable gain output

This port displays the gain that the AGC applies to the input signal. When you set this property to true, the step method outputs instantaneous gain values. The default is false.

Methods

cloneCreate AGC object with same property values
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
resetReset internal states of automatic gain controller
stepApply adaptive gain to input signal

Examples

expand all

Adaptively Adjust the Received Signal Amplitude Using an AGC

Modulate and amplify a QPSK signal, set the received signal amplitude to approximately 1 volt using an AGC, and then plot the output.

Create a QPSK modulated signal using the QPSK System object.

data = randi([0 3],10000,1);
hMod = comm.QPSKModulator;
modData = step(hMod, data);

Amplify the modulated signal.

txSig = 4*modData;

Create an AGC System object™ and pass the transmitted signal through it using the step function. The AGC adjusts the received signal amplitude to approximately 1.

hAGC = comm.AGC;
rxSig = step(hAGC,txSig);

Plot the signal constellations of the transmit and received signals after the AGC reaches steady-state.

h = scatterplot(txSig(1000:end),1,0,'*');
hold on
scatterplot(rxSig(1000:end),1,0,'or',h);
legend('Input of AGC', 'Output of AGC')

Measure and compare the power of the tranmitted and received signals after the AGC has reached steady-state. The power of the transmitted signal is 16 times larger than the power of the received signal.

txPower = var(txSig(5000:end));
rxPower = var(rxSig(5000:end));
[txPower rxPower]
ans =

   15.9985    0.9999

Compare the Performance of an AGC with a Rectifier Detector and a Square Law Detector

Modulate a QPSK signal, adjust the received signal level using two AGC objects, and then plot the AGC response as a function of the number of symbols.

Create a QPSK modulated signal with an amplitude of 4.

data = randi([0 3],200,1);
hMod = comm.QPSKModulator;
modData = 4*step(hMod,data);

Create two AGC System objects to adjust the received signal level. Use a rectifier detector and a square law detector, each with update period 10.

hAGC1 = comm.AGC('DetectorMethod','Rectifier','UpdatePeriod',10);
hAGC2 = comm.AGC('DetectorMethod','Square law','UpdatePeriod',10);
txSig1 = step(hAGC1,modData);
txSig2 = step(hAGC2,modData);

Plot AGC response as a function of the number of symbols.

plot([abs(txSig1) abs(txSig2)])
grid on
xlabel('Symbols')
ylabel('Amplitude')
legend('Rectifier detector','Square law detector')

Plot Effect of Step Size on AGC Performance

Create two AGC System objects™ to adjust the receive signal level using two different step sizes with identical update periods.

Generate a 16-PSK signal having power equal to 10 W.

data = randi([0 15],1000,1);
hMod = comm.PSKModulator('ModulationOrder',16, ...
    'PhaseOffset',pi/16);
modData = sqrt(10)*step(hMod,data);

Create a set of raised cosine matched filters with their Gain property set so that they have unity output power.

hTxFilt = comm.RaisedCosineTransmitFilter('Gain',sqrt(8));
hRxFilt = comm.RaisedCosineReceiveFilter('Gain',sqrt(1/8));

Filter the modulated signal through the raised cosine transmit filter object.

txSig = step(hTxFilt,modData);

Create two AGC objects to adjust the received signal level. Select a step size of 0.01 and 0.1, respectively. Set the update period to 10.

hAGC1 = comm.AGC('StepSize',0.01,'UpdatePeriod',10);
hAGC2 = comm.AGC('StepSize',0.1,'UpdatePeriod',10);

Pass the modulated signal through the two AGC objects using the step function.

rxAGC1 = step(hAGC1,txSig);
rxAGC2 = step(hAGC2,txSig);

Filter the AGC output signals using the step function associated with the raised cosine receive filter object.

rxSig1 = step(hRxFilt,rxAGC1);
rxSig2 = step(hRxFilt,rxAGC2);

Plot the power of the filtered AGC responses. The signal with the larger step size converges faster to the AGC target power level of 1 W.

plot([abs(rxSig1).^2 abs(rxSig2).^2])
grid on
xlabel('Symbols')
ylabel('Power (W)')
legend('Step Size 0.01','Step Size 0.1')

Plot the power of the steady-state filtered AGC signals by considering only the last 500 symbols. The larger AGC step size results in less accurate gain correction.

plot((501:1000),[abs(rxSig1(501:1000)).^2 abs(rxSig2(501:1000)).^2])
grid on
xlabel('Symbols')
ylabel('Power (W)')
legend('Step Size 0.01','Step Size 0.1')

This suggests a trade off with the StepSize property as larger values result in faster convergence at the expense of less accurate gain control.

Show Effect of Maximum AGC Gain on QAM Signal

Pass a noisy 16-QAM signal through two AGCs having different maximum gain settings.

Generate random data symbols and apply 16-QAM modulation. The modulator object is set so that the signal constellation has an average power of 1 W.

data = randi([0 15],100000,1);
hMod = comm.RectangularQAMModulator('NormalizationMethod','Average power');
txSig = step(hMod,data);

Attenuate the signal by 30 dB to emulate the effects of propagation loss.

rxSig = txSig/1000;

Add AWGN with a 20 dB signal-to-noise ratio.

rxSig = awgn(rxSig,20,'measured');

Create two AGC System objects™. Set the MaximumGain property of the first AGC to 30 dB and set the MaximumGain property of the second AGC to 25 dB. For both objects, set the StepSize property to 5.

hAGC1 = comm.AGC('MaximumGain',30,'StepSize',5);
hAGC2 = comm.AGC('MaximumGain',25,'StepSize',5);

Pass the received signal through the two AGCs.

rxSig1 = step(hAGC1,rxSig);
rxSig2 = step(hAGC2,rxSig);

Create a Constellation Diagram System object with the reference constellation determined by using the constellation function of the QAM modulator.

hC = comm.ConstellationDiagram;
hC.ReferenceConstellation = constellation(hMod);

Display the last 10,000 points of the received signal from the AGC with the 30 dB maximum gain by invoking the step function. The received constellation is well aligned with the reference points as the AGC compensated for the signal attenuation.

hC.Title = 'Maximum Gain 30 dB';
step(hC,rxSig1(end-10000:end))

Display the last 10,000 points of the received signal from the AGC with the 25 dB maximum gain. The AGC with the smaller maximum gain cannot fully compensate for the effects of the 30 dB attenuation.

hC.Title = 'Maximum Gain 25 dB';
step(hC,rxSig2(end-10000:end))

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.

y(n)=g(n)x(n);e(n)=Az(m);g(n+1)=g(n)+Ke(n);

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 the linear loop.

y(n)=eg(n)x(n);e(n)=ln(A)ln(z(m));g(n+1)=g(n)+Ke(n);

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 type detector

z = |y| when the detector represents a rectifier

z(m)=1Nn=mN(m+1)N1|y(n)|

where N represents the update period

Square law type detector

z = |y|2 represents the square law detector

z(m)=1Nn=mN(m+1)N1|y(n)|2

where N represents the update period

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.

See Also

Was this topic helpful?