Main Content

Generate I/Q Data from Vector Signal Transceiver Using NI-RFSG Scripting

This example shows how to connect to an NI PXIe-5841 Vector Signal Transceiver (VST) and use it to generate I/Q data using NI-RFSG scripts. For more information about scripts, see Scripting Instructions in the NI RF Signal Generators Help.

Connect to Instrument

Connect to a VST instrument using the ividev function. For this example, specify the driver name as niRFSG and the resource name as PXI1Slot2. Alternatively, for simulated hardware, you can leave the resource name unspecified ("") and set the IVI driver setup name-value argument as Model:5841. The driver setup is also optional. If you do not specify a name-value argument for the driver setup, ividev uses default setup values. For more information about default argument values, see ividev.

isSimulated = true;
if isSimulated
    dev = ividev("niRFSG", "PXI1Slot2", Simulate=true, DriverSetup="Model:5841")
    dev = ividev("niRFSG", "PXI1Slot2")
dev = 
  niRFSG with properties:

                         Model: "NI PXIe-5841" 
                  Manufacturer: "National Instruments" 
                  SerialNumber: "" 
                  ResourceName: "PXI1Slot2" 
                  VendorDriver: "niRFSG" 
                      Simulate: 1 

                    ChannelIDs: "0" 
               FIFOEndpointIDs: "FIFOEndpoint0" 
                MarkerEventIDs: ["marker0", "marker1", "marker2", "marker3"] 
              ScriptTriggerIDs: ["scripttrigger0", "scripttrigger1", "scripttrigger2", ... ] 

                           Arb: [1x1 Arb] 
                         Clock: [1x1 Clock] 
             ConfigurationList: [1x1 ConfigurationList] 
                   Deembedding: [1x1 Deembedding] 
         DeviceCharacteristics: [1x1 DeviceCharacteristics] 
                DeviceSpecific: [1x1 DeviceSpecific] 
                        Events: [1x1 Events] 
           ExternalCalibration: [1x1 ExternalCalibration] 
         InherentIVIAttributes: [1x1 InherentIVIAttributes] 
                  IQImpairment: [1x1 IQImpairment] 
    LoadConfigurationsFromFile: [1x1 LoadConfigurationsFromFile] 
                    Modulation: [1x1 Modulation] 
                      Obsolete: [1x1 Obsolete] 
                    PeerToPeer: [1x1 PeerToPeer] 
                            RF: [1x1 RF] 
               SelfCalibration: [1x1 SelfCalibration] 
                      Triggers: [1x1 Triggers] 

Show all functions

Configure Generation Properties

Configure the VST to generate I/Q data on channel "0". For single channel devices, the channel can also be specified as "". Set the following parameters to the specified values:

  • Frequency — 1 GHz

  • Reference power level — –20 dBm

  • Generation mode — Scripting

  • Power level mode — Peak power

  • Arbitrary waveform generator clock frequency — 5 MHz

  • Arbitrary waveform prefilter gain — –2.0 dB

  • Signal bandwidth — 100 KHz

Explore different options by using tab-completion in the Live Editor.

ch = "0";
configureRF(dev, 1e9, -20);
configureGenerationMode(dev, "SCRIPT");
configurePowerLevelType(dev, "PEAK_POWER");

dev.Arb.IQRate = 5e6; 
dev.Arb.PrefilterGain = -2.0;
dev.Arb.SignalBandwidth = 100e3;

Configure Waveform Data

Write complex-valued I/Q data, as separate real and imaginary components, to the VST's buffer using writeArbWaveform.

numPoints = 1e6;
x = linspace(-pi, pi, numPoints);
data1 = cos(x) + 1i*sin(x);
data2 = sin(x) + 1i*cos(x);

morePendingData = false;
writeArbWaveform(dev, "signal1", numPoints, real(data1), imag(data1), morePendingData);
writeArbWaveform(dev, "signal2", numPoints, real(data2), imag(data2), morePendingData);

Configure Script

Configure the VST to repeatedly generate "signal1" and "signal2" using writeScript.

scriptName = "twoSignals";
repeatScript = compose("script %s\n repeat forever\n generate signal1\n generate signal2\n end repeat\n end script", scriptName);
writeScript(dev, repeatScript);

Generate I/Q Data

Initiate I/Q data generation on the VST and check its status to see whether it has finished. Then, generate data for approximately 10 seconds or until the VST completes generation, whichever happens first.

isDone = checkGenerationStatus(dev);

count = 1;
while ~isDone && count <= 100
    isDone = checkGenerationStatus(dev);
    count = count+1;

configureOutputEnabled(dev, false);

Clean Up

Disconnect from the instrument and clear the ividev object from the workspace.

clear dev

See Also

| |

Related Topics