How to Acquire Data with the NI-RFSA .NET Class Library

NI RF Vector Signal Analyzers (NI-RFSA 18.1) Help

Edition Date: June 2018

Part Number: 372058U-01

View Product Info

Download Help (Windows Only)


NI-RFSA 18.1 Help
NI-RFSA 18.2.1 Help
NI-RFSA 19.1 Help

You can acquire data with the NI-RFSA .NET class library with a fetch method or a read method.

Acquiring Data Using Fetch Methods

Follow these steps to acquire data with a fetch method:

  1. Initialize NIRfsa.
  2. Configure NIRfsa.
  3. Use Initiate to initiate acquisition.
  4. Use Fetch to transfer the acquired samples from the NI-RFSA device memory to the system memory.

You can configure NI-RFSA to acquire data in one of the following modes:

  • IQ
  • Spectrum

Acquiring Data in IQ Mode

The following code snippet shows how to configure NIRfsa to acquire data in IQ mode: (The snippet assumes that a NIRfsa session has already been created.)

VB.NET
session.Configuration.AcquisitionType = RfsaAcquisitionType.IQ
C#
session.Configuration.AcquisitionType = RfsaAcquisitionType.IQ;

Fetch: You can fetch the acquired data either as a single record or as a set of multiple records, and both single and multi record fetch methods support a regular fetch acquisition or a memory-optimized acquisition. You can fetch data as one of the following data types:

Some examples of NI-Rfsa fetch methods include:

Refer to the NIRfsa class library function reference for a complete list of fetch methods.

The following code snippet shows a single-record memory-optimized fetch method:

VB.NET
Using session As New NIRfsa("Rfsa", True, True)
    session.Configuration.AcquisitionType = RfsaAcquisitionType.IQ
    session.Configuration.Vertical.ReferenceLevel = -10.0
    session.Configuration.IQ.CarrierFrequency = 10000000.0
    session.Configuration.IQ.NumberOfSamples = 1000
    Dim data As New ComplexWaveform(Of ComplexDouble)(1000)
    session.Acquisition.IQ.Initiate()
    session.Acquisition.IQ.MemoryOptimizedFetchIQSingleRecordComplexWaveform(Of ComplexDouble)(0, 1000, New PrecisionTimeSpan(5), data)
End Using
C#
using (NIRfsa session = new NIRfsa("Rfsa", true, true))
{
session.Configuration.AcquisitionType = RfsaAcquisitionType.IQ;
session.Configuration.Vertical.ReferenceLevel = -10.0;
session.Configuration.IQ.CarrierFrequency = 10E+6;
session.Configuration.IQ.NumberOfSamples = 1000;
ComplexWaveform<ComplexDouble> data = new ComplexWaveform<ComplexDouble>(1000);
session.Acquisition.IQ.Initiate();
session.Acquisition.IQ.MemoryOptimizedFetchIQSingleRecordComplexWaveform<ComplexDouble>(0, 1000, new PrecisionTimeSpan(5),ref data);
}

Acquiring Data Using Read Methods

Follow these steps to acquire data with a read method:

  1. Initialize Rfsa.
  2. Configure Rfsa.
  3. Use Read to initiate acquisition, wait for the acquisition to finish and retrieve the data

Unlike fetch methods read methods support only common use cases, and multi-record read methods do not exist.

You can read data as one of the following data types:

Some examples of NI-Rfsa read methods include:

Refer to the NIRfsa class library function reference for a complete list of read methods.

Acquiring Data in Spectrum Mode

The following code snippet shows how to configure NI-Rfsa to acquire data in Spectrum mode: (The snippet assumes that a NIRfsa session has already been created.)

VB.NET
session.Configuration.AcquisitionType = RfsaAcquisitionType.Spectrum
C#
session.Configuration.AcquisitionType = RfsaAcquisitionType.Spectrum;

You can only use spectrum mode with read methods, not fetch methods. Spectrum mode supports both regular and memory-optimized read methods. The following data types are supported:

Here are the various Read methods that exist, divided into buckets:

A Brief Discussion on Memory-optimized Overloads

When we acquire data using regular ‘fetch’ or ‘read’ methods, we internally create an array and pass it to the underlying NIRfsa to be filled. Every time a call is made, we end up instantiating new memory. This normally does not create any problems, if the user is careful with references and makes sure that things he doesn’t require are not referenced anywhere, thus making sure that garbage collector frees up the memory. But even regular calls to garbage collector can be a performance hit.

The reasons mentioned above necessitated the creation of memory-optimized versions of the regular fetch and read methods. Most of times, users want to call fetch or read in a loop giving the same number of records and number of samples, or number of spectral lines as the case maybe. If a user can make sure that he/she can perform all their tasks on the retrieved record before the next loop iteration, then he/she can reuse the memory created for the previous iteration. Thus all the memory optimized versions take in an ‘out’ parameter, which returns the data to the user. For every function call if the size of the ‘data’ retrieved matches the size of the ‘out data’ parameter, then new memory is not instantiated. In case there is a mismatch we instantiate a new memory, which gets assigned to the ‘out data’ parameter, and from the next integration onwards, this memory will be reused if possible. The code snippet for using a memory-optimized fetch is shown above.

WAS THIS ARTICLE HELPFUL?

Not Helpful