From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

RF Automatic Level Control Algorithm

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • USB-5680

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Description

Signal sources provide precise, highly stable test signals for a variety of component and system test applications. Signal generators add precision modulation capabilities and are used to simulate signals for RF receiver performance testing.

 

In a test setup, passive devices such as cables, filters or switches are often used between the source and device under test (DUT). The accuracy of the signal level at the DUT is affected by the combination of the natural range of the signal generator plus any losses due to the external transmission line components. In most applications, the accuracy of the input signal level is critical.

 

This tutorial shows how to use the USB-5680 power meter in a feedback loop that provides the signal generator with a more precise level control. An algorithm for correcting an RF generator’s accuracy is used to control the generator and the power meter ensuring that the desired power level of the PXI-5652 is indeed reaching the DUT. The goal of this algorithm is to tighten the natural accuracy of the signal generator while also accounting for and calibrating out the path loss.

How to Use

1. Theory

Signal generators are used for testing many electronic circuits and systems by simulating the signals seen by the device under test (DUT) during actual use. One of the most fundamental requirements of a signal generator is that it must be capable of delivering an accurate signal level to the DUT under all operating conditions.

In practice, the signal level is measured directly on the output connector of the generator. But the DUT is almost certainly tested by routing the signal through amplifiers, cables, switches, signal splitters or other interface devices. As a result the signal can be significantly altered before it reaches the DUT. We must have a way to insure that the signal reaching the DUT is accurate. The Automatic Level Control (ALC) algorithm used in this example shows how to implement the NI 5680 power meter in a feedback loop to provide a more accurate level control to the signal generator. This algorithm is described by the state chart shown below.

Figure 1- ALC Algorithm State Chart

 

2. NI 5680 Power Meter

The NI 5680 is a highly accurate, stand-alone RF power meter that communicates with a PC using a USB connection. The NI 5680 is ideal for measuring the average power of continuous wave (CW) signals. The NI 5680 measures the true root-mean-square (RMS) power regardless of the type of input signal, meaning there is no frequency differentiation, it will measure all prominent power within the full bandwidth of the device (50 MHz to 6 GHz). This is important if the generator has high harmonic levels which could skew the power measurement.

You must zero the NI 5680 before any power measurements are taken, particularly when the meter operates within the lower 20 dB dynamic range of the device. The NI 5680 must be zeroed every time it is connected to a USB port.

 

3. Example Program

The following example illustrates how to use the NI 5680 power meter in conjunction with the NI RF Signal Generator to implement the ALC Algorithm. This application requires the use of both the NI 5680 and NI RFSG APIs.



Figure 2 - ALC Program Front Panel

 

  1. Open ALC Feedback Loop_FreqSweep.vi, located at the bottom of this page. The Front Panel, shown in Figure 2 above, has the following available settings.

    • Generator Resource Name – The Resource Name of the NI Signal Generator in your system.
    • Generator Reference Clock Source – The source of the reference clock on your RF Signal Generator.
    • Meter Resource Name - The Resource Name of the NI 5680 power meter in your system.
    • Offset – The value of the amount of offset introduced by external line attenuation.
    • Start Power (dBm) – The starting power level you want to sweep from.
    • End Power (dBm) – The ending power level you want to sweep to.
    • Number of Steps - The number of power levels you will generate at between the start and stop power levels.
    • Start Frequency (Hz) – The starting frequency level you want to sweep from.
    • End Frequency (dBm) – The ending frequency you want to sweep to.
    • Number of Steps - The number of frequencies you will generate at between the start and stop frequencies.
  2. Measure the attenuation, or offset, present in your system. This includes any splitters and cables used in the system. The splitter used in this example measures -1.94 dBm and the cable measures -0.31 dBm. Therefore, the total offset introduced by external line attenuation is -2.25 dBm.
  3. Set the above properties according to your specifications.
  4. Click the run arrow. Verify the final power reading by monitoring the Final Power Reading indicator located at the bottom of the screen.

The Automatic Level Control Algorithm has two main parts, the Power Meter Control Loop and the Generator control Loop. We will cover these two loops separately as they operate independently of each other. It is important to note that there are two versions of this algorithm attached at the bottom of the page. The first has a frequency sweep function built in along with a power sweep function while the second has only the power sweep function included. We will continue to discuss the power sweep version throughout this document. The complete program’s block diagram is shown below in Figure 3.



Figure 3 - ALC Complete BLock Diagram

 

4. Generator Control Loop

The first section of the program begins with the NI RFSG Initialize VI, which opens a resource to the signal generator that we want to use. An Obtain Notifier VI is also called to set up a Notifier so that the readings from the power meter will be read immediately. The program then enters the while loop. This loop executes until the reading from the power meter is within range or until the stop button is pressed.

The Configure state will be the first to execute. This state contains the RF Configuration VIs that are responsible for settings the power level, frequency, generation mode, and reference clock. This state also contains the RF Initiate VI, which starts signal generation. If the Stop button is pressed then the state machine progresses to the Stop state, otherwise it enters the Output Signal state. The Configure State is shown below in Figure 4.

Figure 4 - Configure State

 

Now that the signal generator is configured, the signal needs to be output. This is handled by the next two states, Output Signal and Apply Feedback. The Output Signal state inputs the power meter reading from the Wait On Notifier VI and then compares it to the desired power level set by the user. If the measured power level is within 0.18893 dBm of the desired power level, then the power level measured by the meter is output by the Power Level Property Node, the zero flag is set, and the program enters the Stop state. However, if the meter power level is different from the desired power level by a more than 0.18893 dBm, then the user input power level is used as the generator power output level in the Apply Feedback state, which is executed next. The Output Signal state is shown below in Figure 5.

Figure 5 - Output Signal State

 

The Apply Feedback state takes the desired power level and the measured power level and compares them again. If the measured power level is within 0.18893 dBm of the desired power level, then the zero flag is set and the program enters the Stop state. If it is not within this range, then the program enters the Apply Feedback state again until the measured power level is accurate. After the power level is accurate, the program enters the Stop state and the RF signal generator reference is released and the program ends. The Apply Feedback state is shown below in Figure 6.

Figure 6 - Apply Feedback State

 

5. Power Meter Control Loop

The second section of the program, the power meter control loop, begins with the ni568x Initialize VI, which opens a resource to the NI 5680 Power Meter. The ni568x Configure Units VI, which sets the measurement units to be used, executes next. It is followed by the ni568x Configure Correction Frequency VI, which sets the power meter frequency correction factor. The Power Meter Control Loop then enters its own while loop so that it can take measurements independent of the Generator Control Loop. While in the loop, an offset value is applied to the 5680 power meter. The ni568x Configure Offset VI uses the offset to compensate for system gains or losses between the DUT and the power meter. After the offset is applied, the meter is ready to take a measurement and the ni568x Read VI is called. This VI takes a measurement and sends it to the Notifier to be sent to the Generator Control Loop. The Power Meter Control Loop is shown below in Figure 7.

Figure 7 - Power Meter Control Loop

 

6. Results

Before starting the ALC program, we must decide on what frequency the signal needs to be. As an example, we want to output a 4.0 GHz signal and we also want to sweep the power output from -19 dBm to 0 dBm. The generator will start outputting a signal at -19 dBm, which is then measured by the power meter. This difference between the measured value and the target value is then calculated and that difference is applied to the next generator output level. This process continues for each power level step from -19 dBm to 0dBm. The first iteration of this sweep, with the power level set to -19 dBm, can be seen Figure 8 below. As seen in the figure, the generator's power level is -19.2909 dBm, a -0.2909 dBm difference from the target power level while the power meter's level is -19.1607, only a -0.1607 dBm difference from the target power level.

 



Figure 8 - Generator and Meter Power Levels vs. Target Power Level

 

 

7. Error Model

The NI signal generator has the inherent power level accuracy shown below.

 

For a frequency less than 3.3 GHz

•         Power level greater than -40 dBm…….+/- 1.8 dB

 

For a frequency greater than 3.3 GHz

•         Power level greater than -40 dBm…….+/-  2.0 dB

 

The NI 5680 Power Meter has the inherent power level accuracy shown below. These values were obtained by using the NI 5680 Power Meter Uncertainty Calculator. (link)

 

For a frequency less than 1.0 GHz

•         Power level greater than -20 dBm ………..+/-0.16911 dB

 

For a frequency greater than 1.0 GHz

•         Power level greater than -20 dBm ………..+/-0.18893 dB

 

By comparing the power level accuracy for both the RF Signal Generator and the NI 5680 Power Meter, we can see that the accuracy for the NI 5680 power meter is an order of magnitude better than the RF Signal Generator at all frequencies.

 

8. Third-Party Power Meter Implementation

The NI 5680 Power Meter can be easily replaced by a non-NI power meter if one is not available. Many instruments have LabVIEW instrument drivers that make them easily integrated into the ALC program. Gigatronics and Agilent RF power meters both have Plug and Play instrument drivers that are available on ni.com/idnet. Plug and Play instrument drivers simplify controlling and communicating with your instruments through a standard and straightforward programming model.  Using Plug and Play instrument drivers makes interacting with hardware easier than other instrument driver technologies.

An example on how to integrate the new instrument driver into the ALC code is shown below in Figure 10.



Figure 10 - Agilent E4416A Power Meter Control Loop Example

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors