Automatic Gain Control

Because received signals may have wildly varying magnitudes, a dynamic gain system is required to normalize the magnitude of the signal going into the receiver. This is needed to guarantee that clipping does not occur in the analog-digital converters, and also to ensure that the signal is large enough to be meaningful to the receiver.

The gain value is chosen using an automatic gain control (AGC) peripheral, which detects the magnitude of the received signal and determines radio-amplifier gains which place the baseband output signal in the correct range for the receiver.

AGC Algorithm

This AGC peripheral is designed specifically for the Maxim 2829 radios, and implements an algorithm tailored only to them. The general theory of operation is as follows:

The radios apply gain at two points during downconversion: course gain is applied at RF (0, 15, or 31 dB), and a fine-grained gain is applied at baseband (0-62 dB, in steps of 2 dB). Using an analog received signal strength indicator (RSSI), the algorithm selects the appropriate RF gain. It then uses the digital signal to set the baseband gain. The choice of RF and baseband gains is determined by the target received signal setting, which is passed into the algorithm upon initialization.

Before the AGC runs, the gain values in the radio are calibrated such that background noise appears to the receiver at -19 dBm. When a packet is detected, the AGC is triggered, chooses gains, and sets the signal strength to the target value. These gains are locked until the AGC is reset. Ideally, this reset should occur when a packet has been completely processed, so that the AGC is ready for the next packet.

DC Offset Correction

As a result of changing gains in the radios, a DC offset (DCO) may be introduced in the downconverted signal, and it may not be the same in the I and Q paths. The AGC peripheral contains a core to remove the DCO in both I and Q paths. This core may or may not be enabled, depending on user requirements.


A driver abstracts register-level operations from the programming-interface; below the functions for controlling the AGC are described. The driver source code is available in PlatformSupport/CustomPeripherals/drivers/ofdm_AGC_mimo_opbw_v1_01_a/src/. It must be included in the project code in order to call the functions below.

void ofdm_AGC_MasterReset()

Resets all state in the AGC, though does not reinitialize any parameters. All averagers and other state-machines are reset, and the AGC is enabled when the routine completes. This routine MUST be called before the AGC can be used reliably.

void ofdm_AGC_Reset()

Resets the gains in the radio to their calibration values, but no other state in the core.

void ofdm_AGC_Initialize(int noise_estimate)

Resets and initializes the AGC peripheral with all required parameters. The initial baseband gain is computed from the noise estimate, so an accurate guess of the noise floor is required. This value is generally near -85 dBm.

Upon completing this routine, the AGC is enabled and ready to be triggered by the packet detector.

void ofdm_AGC_FiltSel(unsigned int state)

Choose the downsampling filter depending on the value of state.

state = 0 : downsampling only
state = 1 : use 32-tap decimating filter

void ofdm_AGC_SetDCO(unsigned int state)

Enable or disable DC Offset correction

state = 0 : DCO disable
state = 1 : DCO enable

ofdm_AGC_SetTarget(signed int c)

Sets the target signal strength value to c dBm. After the AGC completes its execution, the receiver will see a signal of this magnitude.

void ofdm_AGC_setNoiseEstimate(int noise_estimate)

Updates the noise-estimate and re-computes calibration gain values, but WITHOUT reseting state in the AGC.

unsigned int ofdm_AGC_GetGains(void)

(MIMO core only)

Polls the AGC core and returns the current gain values as set in the radio. These are received in a 16 bit value, divided as shown below:

hi[0 gBB_B g_RF_B | 0 g_BB_A g_RF_A]lo

g_BB_A and g_BB_B are each 5 bits wide, and represent the value of the baseband gains set in radios A and B. g_RF_A and g_RF_B are 2 bits wide, and return the RF gain value in radios A and B. The values are interpreted as follows:

g_BB * 2 = baseband gain in dB
g_RF = 0 : 0 dB RF gain
g_RF = 1 : 15 dB RF gain
g_RF = 2 : 31 dB RF gain

Example Instantiation

Below is a sample instantiation sequence for the AGC core.

    // Announce initialization
    xil_printf("AGC initialization...\r\n");
    // Call the overall init routine -- Master Reset is included in this, use -85 dBm as noise floor estimate
    // Choose the raised-cosine decimation filter
    // Enable DC offset correction

    // Set the target signal strength to -15 dBm
    // Reset the gains to their calibration values, computed in the Init routine
    // Announce success
    xil_printf("AGC setup complete!  Ready to detect a packet!\r\n");

After this code executes, the AGC will be armed and ready to trigger on the next packet detection. After the packet has been processed, ofdm_AGC_Reset() should be called to return the gains to their calibration values. No other reset is required to prepare the AGC for the next packet.

Last modified 16 years ago Last modified on Sep 3, 2008, 12:48:02 AM