vst programming guide - cobham wirelesscobhamwireless.com/.../vst-programming-guide-.pdf · the ni...

38
November 2015 VST Basics Programming Guide Application Note Cobham Wireless - Validation Application Note 46900/845 www.cobham.com/wireless

Upload: duongkhanh

Post on 22-Sep-2018

232 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

November 2015

VST Basics Programming Guide

Application Note

Cobham Wireless - Validation

Application Note – 46900/845 www.cobham.com/wireless

Page 2: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

VST Introduction

© 2015 Cobham - 2 -

VST Basics Programming Guide

1  VST Introduction ....................................................................................................................................... 3 

1.1  The Purpose of this document ................................................................................................................................ 3 

1.2  Intended Audience .................................................................................................................................................. 3 

1.3  Scope ...................................................................................................................................................................... 3 

1.4  Where Can I Get More Information? ...................................................................................................................... 3 

1.5  What Programming Languages Can I Use? ........................................................................................................... 3 

1.6  Where Can I Get the VST Driver(s) From? ............................................................................................................ 4 

2  Setting Up the Programming Environment ............................................................................................ 5 

2.1  Visual Studio (2010) C++ ....................................................................................................................................... 5 

2.2  Setting up the Programming Environment for C# .NET .......................................................................................... 9 

3  Booting, Closing Down and Configuring the Reference Clock .......................................................... 10 

3.1  Booting the VST Module ....................................................................................................................................... 10 

3.2  Configuring the Reference Clock .......................................................................................................................... 11 

3.3  Example of Booting and Configuring Reference Clock ........................................................................................ 11 

3.4  Checking For Errors.............................................................................................................................................. 12 

3.5  Closing down the Instrument ................................................................................................................................ 14 

4  RFSA Basics ........................................................................................................................................... 15 

4.1  Configuring the RFSA for IQ Capture ................................................................................................................... 15 

4.2  RFSA Capture Parameters ................................................................................................................................... 15 

4.3  Configure the RFSA Number of Records ............................................................................................................. 17 

4.4  RFSA Capture Triggering ..................................................................................................................................... 17 

4.5  Starting the Capture and Retrieving IQ Samples ................................................................................................. 19 

5  RFSG Basics ........................................................................................................................................... 23 

5.1  Configuring RFSG ................................................................................................................................................ 23 

5.2  Configuring the RFSG RF Parameters ................................................................................................................. 24 

5.3  Configuring the RFSG for CW Tone Generation .................................................................................................. 25 

5.4  Configuring the RFSG for Waveform Generation ................................................................................................. 27 

5.5  Waveform Playback Triggers................................................................................................................................ 31 

5.6  Stopping Waveform Playback............................................................................................................................... 32 

6  RFSA/RFSG Self Calibration .................................................................................................................. 34 

7  Example Code ......................................................................................................................................... 36 

8  Appendix A .............................................................................................................................................. 37 

Page 3: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

VST Introduction

© 2015 Cobham - 3 -

VST Basics Programming Guide

1 VST Introduction

NI PXIe modular vector signal transceivers (VSTs) combine a vector signal analyzer and vector

signal generator with a user-programmable FPGA for real-time signal processing and control.

Built on the NI LabVIEW reconfigurable I/O (RIO) architecture, it delivers programming flexibility

and cutting-edge RF hardware to meet the most challenging RF applications.

1.1 The Purpose of this document

This document is intended to bring together in one document a primer on programming the NI

VST module. It covers the basics of where to get the software, how to configure the development

environment for both C#.NET and C/C++ and how to perform the VSA and VSG basics.

1.2 Intended Audience

This Application note is aimed at customers or Cobham Application engineers who are starting to

write software against the NI VST module.

1.3 Scope

This document is relevant for any NI VST module 5644r/5645r/5646r although 5644r is used as

an example throughout.

This document excludes discussion of advanced topics such as list mode operation or how to

interface with the COBHAM analysis library.

1.4 Where Can I Get More Information?

Once installed the RFSG and RFSA driver contains entries in the Start menu for Help Files which

describe in more detail all of the method calls.

http://sine.ni.com/nips/cds/view/p/lang/en/nid/210629 Provides details on features, specification,

data sheets and other resources.

1.5 What Programming Languages Can I Use?

C

C++

Page 4: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

VST Introduction

© 2015 Cobham - 4 -

.NET (C# and VB). (2 types of .NET interface exist and this document uses the C/C++

wrapper variant for examples rather than the dedicated .NET interface.)

LabVIEW

1.6 Where Can I Get the VST Driver(s) From?

http://search.ni.com/nisearch/app/main/p/bot/no/ap/tech/lang/en/pg/1/sn/ssnav:ndr/q/5644r/

NI-RFSA or NI-RFSG is the download to select. Despite the name, both download contain the

module driver component for the RFSG and RFSA.( C/C++ interface only )

Warning the file size is extremely large (~ 3.8 GB) and so a local copy should be sought.

The .NET class driver and the .NET wrapper can be found: http://www.ni.com/product-documentation/14434/en/#toc4

Page 5: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

Setting Up the Programming Environment

© 2015 Cobham - 5 -

2 Setting Up the Programming Environment

This document only describes how to setup the programming environment for C/C++ and C#.NET

in the Visual Studio IDE.

2.1 Visual Studio (2010) C++

The VST driver uses library (.lib) files to control the HW. A separate library is used for the VSA

and the VSG. (niRFSA.lib and niRFSG.lib )

Using Visual Studio 2010 as a guide the steps to reference the required libraries are as follows.

1. Add a path to the header files by right clicking on your C++ project within the solution explorer and selecting properties.

Figure 1 - Select Project Properties.

2. Select C/C++ from the panel on the left hand side and select “Additional Include Directories”

Page 6: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

Setting Up the Programming Environment

© 2015 Cobham - 6 -

Figure 2 - Add Additional Include Directories.

3. Enter the paths as seen in Figure 3.

Figure 3 - Add these file paths to the include files to your project.

4. Select the linker item from the left hand panel in the project property page and then select General and then select and edit the “Additional Library Directories”

Page 7: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

Setting Up the Programming Environment

© 2015 Cobham - 7 -

 

Figure 4 - Select the Additional Library Directories

5. Enter the paths as seen in Figure 5.

Figure 5 - Add these file paths to the include files to your project.

Page 8: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

Setting Up the Programming Environment

© 2015 Cobham - 8 -

6. Add the actual library files to be used. This is achieved by selecting the Input menu item from the left most panel in the project properties and selecting and editing the Additional Dependency setting.

 

Figure 6 - Select the Additional Dependencies Setting

7. Enter the files as seen in Figure 7.

Figure 7 - Add these library files as Additional Dependencies to your project.

Page 9: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

Setting Up the Programming Environment

© 2015 Cobham - 9 -

8. Now Add the Include files:

#include "niRFSG.h" #include "niRFSA.h" 

 9. And now VST method calls can be made e.g.

// Initiate VSA session     status = niRFSA_init("RIO0", VI_TRUE, VI_TRUE, &vsa);       ErrorCheckRFSA(vsa,status);

2.2 Setting up the Programming Environment for C# .NET

The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series of

method which call the underlying methods in the RFSA.dll and RFSG.dll using pInvoke. Add the

niRFSA.cs, niRFSG.cs and niInteropCommon.cs files to your project as seen in Figure 8.

Figure 8 - Adding the RFSA C# Wrapper File.

Then add the “NationalInstruments.ModularInstruments.Interop” namespace to your project files.

using NationalInstruments.ModularInstruments.Interop; 

Page 10: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

Booting, Closing Down and Configuring the Reference Clock

© 2015 Cobham - 10 -

3 Booting, Closing Down and Configuring the Reference Clock

3.1 Booting the VST Module

The VST has two components, the RFSG (signal generation) and the RFSA (vector digitizer).

Both are booted separately.

Booting the RFSA can be accomplished using two different method; “niRFSA_init” or

“niRFSA_InitWithOptions”.

Booting the RFSG can be accomplished using two different method; “niRFSG_init()” or

“niRFSG_InitWithOptions()”.

Both the RFSA and the RFSG boot methods require the resource name of the VST.This can be

found by loading National Instrument’s “Measurement and Automation Explorer” application (also

known as NI MAX), expanding the chassis object in the left most panel will reveal the PXIe cards.

We’re interested in the 5644R device. Clicking on it as seen in Figure 9 reveals more details

about that device and the Device Name can then be seen. (RIO0 in this case.)

Figure 9 - Finding the VST Device Name

Page 11: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

Booting, Closing Down and Configuring the Reference Clock

© 2015 Cobham - 11 -

WARNING: When booting Cobham PXI 3000 modules the VISA resource name is supplied to the

boot method rather than the Device Name.

The parameters for the niRFSA_init(C/C++) method or the niRFSA constructor (C#) are as

follows:

ResourceName ‐ Specifies the resource name of the device to initialize. 

IDQuery ‐ Specifies whether NI‐RFSA performs an ID query. When you perform an ID 

query, NI‐RFSA verifies the device you initialize is supported. 

Reset ‐ Specifies whether the NI‐RFSA device is reset during the initialization procedure. 

The output is:

VI – Identifier to the instrument session. 

Using the “niRFSA_InitWithOptions” method has an additional parameter:

OptionString ‐ Sets the initial value of certain attributes for the session. More details 

can be found in the NI RFSA documentation. 

 

3.2 Configuring the Reference Clock

To configure the Reference clock two methods are required; One to configure the settings

(niRFSA_ConfigureRefClock) and one to commit the setting (niRFSA_Commit). The parameters

for the niRFSA_ConfigureRefClock method are as follows:

Vi - Identifies the instrument session. Vi is obtained from the niRFSA_init or niRFSA_InitWithOptions method.

ClockSource - Specifies the Reference Clock source:

Setting Comment NIRFSA_VAL_ONBOARD_CLOCK_STR ("OnboardClock") 

Lock the NI-RFSA device to its onboard clock. 

NIRFSA_VAL_REF_IN_STR ("RefIn")  Lock the NI-RFSA device to the signal at the external REF IN connector. 

NIRFSA_VAL_PXI_CLK_STR ("PXI_Clk")  NI-RFSA locks the to the PXI backplane clock.  

RefClockRate ‐ Specifies the Reference Clock rate in hertz (Hz). For the VST, 10 MHz is 

the only supported value.  

3.3 Example of Booting and Configuring Reference Clock

Below are examples of booting the RFSA and configuring the VST to use it’s on board 10MHz

reference clock. A similar technique is used for the RFSG but the method call is “niRFSG_init()”.

3.3.1 C/C++ Example

ViStatus status; ViSession vsa = VI_NULL; ViReal64 referenceClockRate = 10e6; // 10 MHz ( VST only supports 10 MHz ) 

Page 12: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

Booting, Closing Down and Configuring the Reference Clock

© 2015 Cobham - 12 -

 // Initiate VSA session     status = niRFSA_init("RIO0", VI_TRUE, VI_TRUE, &vsa);           ErrorCheckRFSA(vsa,status);  // Configure 10MHz reference status = niRFSA_ConfigureRefClock(vsa, NIRFSA_VAL_ONBOARD_CLOCK_STR, referenceClockRate); ErrorCheckRFSA(vsa,status);  // Commit the settings to make clock settings active status = niRFSA_Commit(vsa); ErrorCheckRFSA(vsa,status); 

Figure 10 - Boot and Configure 10MHz Reference C/C++

3.3.2 C# .NET Example

int status; niRFSA Rfsa; double referenceClockRate = 10e6; // 10 MHz ( VST only supports 10 MHz )  // Initiate VSA session     Rfsa = new niRFSA("RIO0",true,false);             // Configure 10MHz reference status = Rfsa.ConfigureRefClock("OnboardClock", referenceClockRate);  ErrorCheckRFSA(Rfsa,status);  // Commit the settings to make clock settings active status = Rfsa.Commit(); ErrorCheckRFSA(Rfsa,status); 

Figure 11 - Boot and Configure 10MHz Reference C#

3.4 Checking For Errors

All C# and C++ methods return a status code which uses the following convention:

Value Meaning 0 Success

Positive Values Warnings Negative Values Errors

3.4.1 C/C++ Example

A method “niRFSA_error_message” can be used to convert the error code to an error message.

The example code in Figure 12 can be used to display a warning or error message

void ErrorCheckRFSA(ViSession Vsa, ViStatus Status) {   ViChar errMsg[256];    if ( Status > 0 ) // Warning 

Page 13: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

Booting, Closing Down and Configuring the Reference Clock

© 2015 Cobham - 13 -

  {     // Retrieve the error message based on the status code.     niRFSA_error_message(Vsa, Status, errMsg);      std::cout << "Warning : ";      // Loop through the array of chars printing them out to the STDOUT.     for( int i = 0 ; i < strlen(errMsg) ; i ++ )     {       std::cout << errMsg[i];      }     std::cout << std::endl;   }   else if ( Status < 0 ) // Error   {     // Retrieve the error message based on the status code.     niRFSA_error_message(Vsa, Status, errMsg);      std::cout << "Error : ";            // Loop through the array of chars printing them out to the STDOUT.     for( int i = 0 ; i < strlen(errMsg) ; i ++ )     {       std::cout << errMsg[i];      }     std::cout << std::endl;   }     } 

Figure 12 - RFSA Method to Check For Errors and Warnings.( C/C++)

3.4.2 C# Example

A method “ErrorMessage” can be used to convert the error code to an error message. The

example code in Figure 13 can be used to display a warning message.

Warning : The NI C# wrapper provided throws an exception before returning the error code if the

error code is negative (an error) but not if the error code is positive or zero indicating success or a

warning.

private void ErrorCheckRFSA(niRFSA Rfsa, int Status) {      StringBuilder sb = new StringBuilder(256);       if (Status > 0) // Warning      {           // Retrieve the error message based on the status code.           Rfsa.ErrorMessage(Status, sb);            Console.WriteLine("Warning : " + sb.ToString());      }           } 

Figure 13 - RFSA Method to Check For Errors and Warnings. (C#)

Note : The RFSG contains similar methods.

Page 14: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

Booting, Closing Down and Configuring the Reference Clock

© 2015 Cobham - 14 -

3.5 Closing down the Instrument

Once finished with the RFVSA close down the instrument to free up allocated resources.

3.5.1 C/C++ Example

ViStatus status;  // Close session status = niRFSA_close(vsa); ErrorCheckRFSA(vsa,status); 

3.5.2 C# Example

// Close session vsa.Close(); 

Note the C# method does not return any error codes but will throw an exception if an error occurs

during the “Close()” method call.

Page 15: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSA Basics

© 2015 Cobham - 15 -

4 RFSA Basics

The RFSA can be used in a number of complex ways such as in list mode or with a custom

FPGA. This section describes simple IQ capture. A full state diagram can be seen in Appendix A.

4.1 Configuring the RFSA for IQ Capture

The RFSA can operate in one of two modes. It can be setup to capture IQ or to capture a

spectrum. Calling niRFSA_ConfigureAcquisitionType selects one of the two modes with spectrum

being selected with the parameter set to NIRFSA_VAL_SPECTRUM and the IQ capture mode

can be set by using NIRFSA_VAL_IQ as the parameter.

4.1.1 C/C++ Example

// // Configure VST for capture // status = niRFSA_ConfigureAcquisitionType(vsa, NIRFSA_VAL_IQ); // IQ capture mode ErrorCheckRFSA(vsa,status); 

4.1.2 C# Example

// // Configure VST for capture // status = Rfsa.ConfigureAcquisitionType(niRFSAConstants.Iq); // IQ capture mode ErrorCheckRFSA(Rfsa,status); 

4.2 RFSA Capture Parameters

A digitizer IQ capture requires some basic settings such as frequency the capture is to be made

at, the capture length , the input range of the capture, the sample rate that the capture will be

made at and any trigger settings. The second parameter identifies the channel at which to apply

the setting value which as List-Mode is not being used can be set to “VI_NULL”

The dwell time or capture length like PXI 3000 is expressed in samples and so a basic conversion

of Sample Rate in Hz * Dwell Time in seconds will yield the number of samples required.

The RFSA operates in one of two modes when capturing IQ samples. It can either capture a finite

number of samples or acquire samples continuously until the “niRFSA_Abort” method is called.

When operating in the continuously acquire mode the device stores data in onboard memory in a

circular fashion. After the device fills the memory, it starts overwriting previously acquired data

from the beginning of the memory buffer. Retrieve the samples as they are being acquired, using

one of the niRFSA fetch I/Q functions, to avoid overwriting data before you retrieve it. Selecting

between the two modes is done by setting the third parameter to the

Page 16: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSA Basics

© 2015 Cobham - 16 -

“niRFSA_ConfigureNumberOfSamples” method to VI_TRUE or VI_FALSE. VI_True for finite

mode and VI_FALSE for acquire continuously.

4.2.1 C/C++ Example

ViStatus status;  ViReal64 CarrierFrequency = 1e9;   // 1 GHz ViReal64 ReferenceLevel = ‐20;   // ‐20 dBm ViReal64 DwellTime = 1e‐3;     // 1 ms capture time. ViReal64 SampleRate = 40e6;    // 40 MHz sample rate      // Set Frequency in Hz. status = niRFSA_ConfigureIQCarrierFrequency(vsa, VI_NULL, CarrierFrequency);  ErrorCheckRFSA(vsa,status);  // Set Expected Input level in dBm. status = niRFSA_ConfigureReferenceLevel(vsa, VI_NULL, ReferenceLevel);  ErrorCheckRFSA(vsa,status);      // Set Sample Rate in Hz. status = niRFSA_ConfigureIQRate(vsa, VI_NULL, SampleRate);  ErrorCheckRFSA(vsa,status);  // Convert the dwell time and the capture sample rate to number of samples. ViInt64 numSamples = (ViInt64)(DwellTime * SampleRate);  // Set Number of samples. status = niRFSA_ConfigureNumberOfSamples(vsa, VI_NULL, VI_TRUE, numSamples); ErrorCheckRFSA(vsa,status); 

4.2.2 C# Example

double carrierFrequency = 2.0e9; // 2 GHz. double referenceLevel   = 20;    // 20 dBm double dwellTime        = 1e‐3;  // 1 ms. double sampleRate       = 40e6;  // 40 MHz   long numSamples = (long)(dwellTime * sampleRate);  // Set Frequency in Hz status = Rfsa.ConfigureIQCarrierFrequency("", carrierFrequency); ErrorCheckRFSA(Rfsa, status);  // Set Level in dBm status = Rfsa.ConfigureReferenceLevel("", referenceLevel); ErrorCheckRFSA(Rfsa, status);  // Set sample rate in Hz. status = Rfsa.ConfigureIQRate("", sampleRate); ErrorCheckRFSA(Rfsa, status);  // Number of samples status = Rfsa.ConfigureNumberOfSamples("", true, numSamples); ErrorCheckRFSA(Rfsa, status); 

Page 17: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSA Basics

© 2015 Cobham - 17 -

4.3 Configure the RFSA Number of Records

The RFSA performs captures and stores the IQ in records. Each record can have a series of RF

capture settings as described in 4.2. As part of a capture the number of records to acquire needs

to be set and also if the record captures are going to be continuous. This is achieved in C/C++

using the “niRFSA_ConfigureNumberOfRecords” method or in C# with the

“ConfigureNumberOfRecords” method.

4.3.1 C/C++ Example

// Set Number of records. status = niRFSA_ConfigureNumberOfRecords(vsa, VI_NULL, VI_TRUE, 1);  ErrorCheckRFSA(vsa,status); 

4.3.2 C# Example

// Number of records status = Rfsa.ConfigureNumberOfRecords("", true, 1);  ErrorCheckRFSA(Rfsa, status); 

4.4 RFSA Capture Triggering

Triggers cause the RFSA to start its capture. The RFSA supports a number of complex trigger

types. This section covers some of the more basic varieties.

4.4.1 Free Run or Immediate Trigger

If no trigger is selected then the capture starts when the C/C++ “niRFSA_Initiate()” or C#

“Initiate()” method is called and the behavior is similar to a ‘free run trigger” or a PXI 3000

digitizer when the trigger source is set to “afDigitizerDll_tsSW_TRIG”. This can be achieved in the

RFSA by a C/C++ call to “niRFSA_DisableStartTrigger()” or a C# call to “DisableStartTrigger()”.

4.4.2 C/C++ Example

// Set an Immediate trigger. status = niRFSA_DisableStartTrigger(vsa);  ErrorCheckRFSA(vsa,status); 

4.4.3 C# Example

// Set an Immediate trigger. status = Rfsa.DisableStartTrigger(); ErrorCheckRFSA(Rfsa, status); 

4.4.4 Software Trigger

The RFSA supports a software trigger which arms the RFSA but does not start a capture until the

software trigger method is called. A C/C++ call to “niRFSA_ConfigureSoftwareEdgeStartTrigger()”

or a C# call to “ConfigureDigitalEdgeStartTrigger” enables the software trigger. A C/C++ call to

Page 18: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSA Basics

© 2015 Cobham - 18 -

“niRFSA_SendSoftwareEdgeTrigger” or a C# call to “SendSoftwareEdgeTrigger” sends the

software trigger that starts the IQ capture.

4.4.5 C/C++ Example

ViStatus status;  // Define a software trigger status = niRFSA_ConfigureSoftwareEdgeStartTrigger(vsa); ErrorCheckRFSA(vsa,status);  // RFSA now armed and waiting for trigger status = niRFSA_Initiate(vsa); ErrorCheckRFSA(vsa,status);  // Send software trigger status = niRFSA_SendSoftwareEdgeTrigger(vsa, NIRFSA_VAL_START_TRIGGER,""); ErrorCheckRFSA(vsa,status); 

4.4.6 C# Example

// Define a software trigger. Rfsa.ConfigureSoftwareEdgeStartTrigger(); ErrorCheckRFSA(Rfsa, status);  // Start capture status = Rfsa.Initiate();  ErrorCheckRFSA(Rfsa, status);             // Send software trigger status = Rfsa.SendSoftwareEdgeTrigger(niRFSAConstants.StartTrigger, ""); ErrorCheckRFSA(Rfsa, status); 

4.4.7 RF Level or Burst Trigger

To set a RF Level trigger or Burst trigger a C/C++ call to

“niRFSA_ConfigureIQPowerEdgeRefTrigger” or a C# call to “ConfigureIQPowerEdgeRefTrigger”

allows the RF level in dBm (absolute level), any trigger delay in samples and the polarity of the

trigger EDGE to be set. All start triggers should be disabled.

4.4.8 C/C++ Example

// Disable any start triggers status = niRFSA_DisableStartTrigger(vsa); ErrorCheckRFSA(vsa,status);  // Define the trigger level and a pre‐trigger ViReal64 triggerLevel = ‐20; // ‐20 dBm ViInt64 preTriggerSamples = (ViInt64)(100e‐6 * sampleRate); // 100uS worth.  status = niRFSA_ConfigureIQPowerEdgeRefTrigger(vsa,"0", triggerLevel, NIRFSA_VAL_RISING_EDGE, preTriggerSamples); ErrorCheckRFSA(vsa,status); 

Page 19: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSA Basics

© 2015 Cobham - 19 -

4.4.9 C# Example

// No Start Triggers status = Rfsa.DisableStartTrigger();  ErrorCheckRFSA(Rfsa, status);  double triggerLevel = ‐20; // ‐20 dBm long preTriggerSamples = (long)(100e‐6 * SampleRate); // 100uS worth.  // Set the trigger level, slope and pre trigger samples. status = Rfsa.ConfigureIQPowerEdgeRefTrigger("0", triggerLevel, niRFSAConstants.RisingEdge, preTriggerSamples); ErrorCheckRFSA(Rfsa, status);  // Define a software trigger. Rfsa.ConfigureSoftwareEdgeStartTrigger(); ErrorCheckRFSA(Rfsa, status); 

4.4.10 External Trigger

An external trigger is a trigger event supplied from an external source such as one of the PXI

trigger lines. A large number of options for the trigger source can be configured and the full list

can be found in the RFSA Help File. This can be defined in C/C++ with a call to

“niRFSA_ConfigureDigitalEdgeStartTrigger” and a C# with a call to

“ConfigureDigitalEdgeStartTrigger”.

4.4.11 C/C++ Example

// Set an external trigger on the rising edge of the PXI trigger line 0. status = niRFSA_ConfigureDigitalEdgeStartTrigger(vsa, NIRFSA_VAL_PXI_TRIG0_STR, NIRFSA_VAL_RISING_EDGE); ErrorCheckRFSA(vsa,status);  

4.4.12 C# Example

// Set an external trigger on the rising edge of the PXI trigger line 0. status = Rfsa.ConfigureDigitalEdgeStartTrigger(niRFSAConstants.Rtsi0Str, niRFSAConstants.RisingEdge); ErrorCheckRFSA(Rfsa, status); 

4.5 Starting the Capture and Retrieving IQ Samples

Once all the capture specific settings have been set a C/C++ call to “niRFSA_Initiate()” or a C#

call to “Initiate()” will arm the RFSA and start the IQ acquisition if either a free run trigger was

defined or the edge or external trigger conditions were met. The method returns immediately

even if the trigger conditions have not been met and a separate C/C++ call to

“niRFSA_CheckAcquisitionStatus” or a C# call to “CheckAcquisitionStatus()” can be used to

check the status of the capture.

Once the acquisition is complete the IQ data needs to be fetched. The RFSA returns the IQ data

as an array of complex (imaginary I and real Q) data.

Page 20: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSA Basics

© 2015 Cobham - 20 -

Before fetching the data the reference location within the acquired record from which to begin

fetching needs to be defined. This is achieved by setting the attribute

“NIRFSA_ATTR_FETCH_RELATIVE_TO” with one of the following values:

Value Description

NIRFSA_VAL_MOST_RECENT_SAMPLE (700) Fetching occurs relative to the most recently acquired data. The

value of the NIRFSA_ATTR_FETCH_OFFSET attribute must be

negative.

NIRFSA_VAL_FIRST_SAMPLE (701) Fetching occurs at the first sample acquired by the device. If the

device wraps its buffer, the first sample is no longer available. In

this case, NI-RFSA returns an error if the fetch offset is in the

overwritten data.

NIRFSA_VAL_REF_TRIGGER (702) Fetching occurs relative to the Reference Trigger. This value

behaves like NIRFSA_VAL_FIRST_SAMPLE if no Reference

Trigger is configured.

NIRFSA_VAL_FIRST_PRETRIGGER_SAMPLE (703) Fetching occurs relative to the first pretrigger sample acquired.

This value behaves like NIRFSA_VAL_FIRST_SAMPLE if no

Reference Trigger is configured.

NIRFSA_VAL_CURRENT_READ_POSITION (704) Fetching occurs after the last fetched sample.

Then a C/C++ call to “niRFSA_FetchIQSingleRecordComplexF32” or a C# call to

“FetchIQSingleRecordComplexF32” will fetch the complex data into the array specified as a

method argument. The method blocks until the record specified has completed its acquisition or

until a timeout specified as a method argument expires.

4.5.1 C/C++ Example

niRFSA_wfmInfo captureInfo; ViReal64 timeout = 1.0;  // VSA now armed and waiting for trigger ( if burst trigger or external trigger used ) or // starting acquisition ( if a free run trigger was setup )   status = niRFSA_Initiate(vsa);  ErrorCheckRFSA(vsa,status);  // Check No errors or warning occured. if(status == 0) {      // Create an array of Complex floats to store the IQ data returned from the RFSA.      NIComplexNumberF32 *capturedIQ = new NIComplexNumberF32[numSamples];       // Specifies the reference location within the acquired record from which to begin fetching. ( at the first sample acquired )      status = niRFSA_SetAttributeViInt32(vsa, VI_NULL, NIRFSA_ATTR_FETCH_RELATIVE_TO, NIRFSA_VAL_FIRST_SAMPLE);      ErrorCheckRFSA(vsa,status);       // Fetch IQ data      status = niRFSA_FetchIQSingleRecordComplexF32(vsa, VI_NULL, 0, ‐1, timeout,     capturedIQ, &captureInfo); // ‐1 = fetch all samples      ErrorCheckRFSA(vsa,status); 

Page 21: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSA Basics

© 2015 Cobham - 21 -

      // Check to see if the number of samples matches the number of samples returned.      if(status == 0 && captureInfo.actualSamples == numSamples)      {           // Fetch of IQ samples was successful. Now copy the complex values           // into a separate I and Q array.        for(int i = 0; i < numSamples; i++)        {          iBuffer[i] = capturedIQ[i].real;          qBuffer[i] = capturedIQ[i].imaginary;        }      }      else      {        std::cout << "An error occured during capture ( the number of samples returned does not match what was asked for )!" << std::endl;        status = niRFSA_Abort(vsa);             ErrorCheckRFSA(vsa,status);      }       // Free the allocated memory.      delete capturedIQ;       } else {   std::cout << "An error occured during capture!" << std::endl;   status = niRFSA_Abort(vsa);   ErrorCheckRFSA(vsa,status); }  

4.5.2 C# Example

niRFSA_wfmInfo captureInfo; double timeout = 10.0;  // Start capture status = Rfsa.Initiate(); ErrorCheckRFSA(Rfsa, status);  if (status == 0) {     // Create an array of Complex doubles to store the IQ data returned     // from the RFSA.     niComplexNumber[] capturedIQ = new niComplexNumber[numSamples];      // Specifies the reference location within the acquired record from      // which to begin fetching. ( at the first sample acquired )     status = Rfsa.SetFetchRelativeTo("0", niRFSAConstants.FirstSample);     ErrorCheckRFSA(Rfsa, status);      // Fetch IQ data                 status = Rfsa.ReadIQSingleRecordComplexF64("", timeout, capturedIQ, numSamples, out captureInfo);     ErrorCheckRFSA(Rfsa, status);      // Check to see if the number of samples matches the number of     samples returned.     if (status == 0 && captureInfo.actualSamples == numSamples)     { 

Page 22: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

© 2015 Cobham - 22 -

        // Fetch of IQ samples was successful. Now copy the complex         // values into a separate I and Q array.         for (int i = 0; i < numSamples; i++)         {             iBuffer[i] = capturedIQ[i].Real;             qBuffer[i] = capturedIQ[i].Imaginary;         }     }     else     {         Console.WriteLine("An error occured during capture ( the number of samples returned does not match what was asked for )!");         status = Rfsa.Abort();         ErrorCheckRFSA(Rfsa, status);     }  } else {     Console.WriteLine("An error occured during capture!");     status = Rfsa.Abort();     ErrorCheckRFSA(Rfsa, status); } 

Page 23: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSG Basics

© 2015 Cobham - 23 -

5 RFSG Basics

RFSG basics covers generating a CW tone, waveform playback (single, continuous and n-times )

and basic triggering. It does not cover advanced triggering, markers (or scripts ) or list mode /

sweep functionality.

5.1 Configuring RFSG

The RFSG operates in three distinct modes,

1. “Configuration mode” where it can be setup. ( No RF is output and settings are not

committed to the HW )

2. “Committed mode” where settings have been committed to the hardware ( No RF is

output )

1. “Generation mode” where it is running.

3. The basic premise is that prior to playing out a CW tone or playing a waveform the RFSG will

be taken into the “Configuration Mode” by calling Abort. Once the settings have been made a call

to either “Commit()” to commit then to the HW or a call to Initiate() will start the generation of the

waveform or CW tone. The RFSG state diagram can be seen in Figure 14.

Figure 14 - RFSG State Diagram

The RFSG can be setup to play a CW tone or a Waveform by calling the C/C++ method

“niRFSG_ConfigureGenerationMode()” or the C# method “ConfigureGenerationMode()” when in

“Configuration Mode”. It supports three parameters:

Page 24: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSG Basics

© 2015 Cobham - 24 -

C/C++ C# Description

NIRFSG_VAL_CW niRFSGConstants.Cw Configures the RF signal

generator to generate a

CW signal.

NIRFSG_VAL_ARB_WAVEFORM niRFSGConstants.ArbWaveform Configures the RF signal

generator to generate

arbitrary waveforms.

NIRFSG_VAL_SCRIPT niRFSGConstants.script Configures the RF signal

generator to generate

arbitrary waveforms as

directed by scripts.

For the purpose of this document the SCRIPT option shall not be covered, but more information

can be found in the RFSG help file.

5.2 Configuring the RFSG RF Parameters

Settings such as output level, frequency and output state can be changed once the RFSG is in

“Generation Mode”. The RFSG provides two approaches to configuring these parameters i) use a

helper method or ii) use attributes.

5.2.1 C/C++ Example

ViReal64 Frequency = 1e9;  // 1 GHz ViReal64 Level     = ‐20;  // ‐20 dBm  // Aborts generation & put VSG in configuration mode status = niRFSG_Abort(vsg); ErrorCheckRFSA(vsg,status);  // // Configure all settings that require the VSG to be in configuration mode //  // Configure frequency & level using higher level function status = niRFSG_ConfigureRF(vsg, Frequency, Level); ErrorCheckRFSA(vsg,status);  // Note level can also be configured using low level attributes. status = niRFSG_SetAttributeViReal64(vsg,VI_NULL, NIRFSG_ATTR_POWER_LEVEL, Level); ErrorCheckRFSA(vsg,status);  // Note frequency can also be configured using low level attributes. status = niRFSG_SetAttributeViReal64(vsg,VI_NULL, NIRFSG_ATTR_FREQUENCY, Frequency); ErrorCheckRFSA(vsg,status);  // Enable output 

Page 25: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSG Basics

© 2015 Cobham - 25 -

status = niRFSG_ConfigureOutputEnabled(vsg, VI_TRUE); ErrorCheckRFSA(vsg,status);  // Note output state can also be configured using low level attributes. status = niRFSG_SetAttributeViReal64(vsg,VI_NULL, NIRFSG_ATTR_OUTPUT_ENABLED, VI_TRUE); ErrorCheckRFSA(vsg,status); 

5.2.2 C#++ Example

int status;  double Frequency    = 1e9;  // 1 GHz double Level        = ‐20;  // ‐20 dBm  // Configure frequency & level using higher level function status = Rfsg.ConfigureRF(Frequency, Level); ErrorCheckRFSG(Rfsg, status);  // Note Level can also be set using a low level attribute. status = Rfsg.SetPowerLevel("0", Level); ErrorCheckRFSG(Rfsg, status);  // Note Frequency can also be set using a low level attribute. status = Rfsg.SetFrequency("0", Frequency); ErrorCheckRFSG(Rfsg, status);  // Enable output status = Rfsg.ConfigureOutputEnabled(true); ErrorCheckRFSG(Rfsg, status);  // Note output state can also be configured using low level attributes. status = Rfsg.SetOutputEnabled("0", true); ErrorCheckRFSG(Rfsg, status); 

5.3 Configuring the RFSG for CW Tone Generation

To generate a CW tone at a known frequency and level the following steps need to be followed.

1. Call Abort to take the RFSG into “Generation Mode”. 

2. Configure the RFSG for a CW Tone. 

3. Disable any start triggers that may have previously been configured. 

4. Set the Frequency, Level and Output state. 

5. Call Initiate. 

6. Check generation status. 

5.3.1 C/C++ Example

ViReal64 Frequency = 1e9;  // 1 GHz ViReal64 Level    = ‐20; // ‐20 dBm  // Aborts generation & put VSG in configuration mode status = niRFSG_Abort(vsg); ErrorCheckRFSA(vsg,status);  // 

Page 26: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSG Basics

© 2015 Cobham - 26 -

// Configure all settings that require the VSG to be in configuration mode //  // Set generation mode to CW status = niRFSG_ConfigureGenerationMode(vsg, NIRFSG_VAL_CW); ErrorCheckRFSA(vsg,status);  // Disable start trigger, so generation will commence immediately after _Initiate() called status = niRFSG_DisableStartTrigger(vsg); ErrorCheckRFSA(vsg,status);  // Configure frequency & level using higher level function status = niRFSG_ConfigureRF(vsg, Frequency, Level); ErrorCheckRFSA(vsg,status);  // Note level can also be configured using low level attributes. status = niRFSG_SetAttributeViReal64(vsg,VI_NULL, NIRFSG_ATTR_POWER_LEVEL, Level); ErrorCheckRFSA(vsg,status);  // Note frequency can also be configured using low level attributes. status = niRFSG_SetAttributeViReal64(vsg,VI_NULL, NIRFSG_ATTR_FREQUENCY, Frequency); ErrorCheckRFSA(vsg,status);  // Enable output status = niRFSG_ConfigureOutputEnabled(vsg, VI_TRUE); ErrorCheckRFSA(vsg,status);  // Note output state can also be configured using low level attributes. status = niRFSG_SetAttributeViReal64(vsg,VI_NULL, NIRFSG_ATTR_OUTPUT_ENABLED, VI_TRUE); ErrorCheckRFSA(vsg,status);  // Initiate generation (VSG now in generation mode) status = niRFSG_Initiate(vsg); ErrorCheckRFSA(vsg,status);  // Check Generation Status. ( returns 0 (generation active) ) status = niRFSG_CheckGenerationStatus(vsg, &done);  ErrorCheckRFSA(vsg,status); 

5.3.2 C# Example

int status; bool done; double Frequency    = 1e9;  // 1 GHz double Level        = ‐20;  // ‐20 dBm  // Aborts generation & put VSG in configuration mode status = Rfsg.Abort(); ErrorCheckRFSG(Rfsg, status);  // // Configure all settings that require the VSG to be in configuration mode 

Page 27: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSG Basics

© 2015 Cobham - 27 -

//  // Set generation mode to CW status = Rfsg.ConfigureGenerationMode(niRFSGConstants.Cw); ErrorCheckRFSG(Rfsg, status);  // Disable start trigger, so generation will commence immediately after _Initiate() called status = Rfsg.DisableStartTrigger(); ErrorCheckRFSG(Rfsg, status);  // Configure frequency & level using higher level function status = Rfsg.ConfigureRF(Frequency, Level); ErrorCheckRFSG(Rfsg, status);  // Enable output status = Rfsg.ConfigureOutputEnabled(true); ErrorCheckRFSG(Rfsg, status);  // Initiate generation (VSG now in generation mode) status = Rfsg.Initiate(); ErrorCheckRFSG(Rfsg, status);  // Check Generation Status. ( returns 0 (generation active) ) status = Rfsg.CheckGenerationStatus(out done); ErrorCheckRFSG(Rfsg, status); 

5.4 Configuring the RFSG for Waveform Generation

Note : This document does not describe how to extract IQ data from an COBHAM .aiq file.

To generate a waveform at a known frequency and level the following steps need to be followed.

1. Call Abort to take the RFSG into “Generation Mode”. 

2. Configure the power level type to be either “RMS” or “PEAK”. 

Average Power (default)

Indicates the desired power averaged in time. The driver maximizes the dynamic range by scaling the I/Q waveform so that its peak magnitude is equal to one. If you write more than one waveform, NI-RFSG scales each waveform without preserving the power level ratio between the waveforms.

Peak Power

Indicates the maximum power level of the RF signal averaged over one period of the RF carrier frequency (the peak envelope power). This setting requires the magnitude of the I/Q waveform to be less than or equal to one. When using peak power, the power level of the RF signal matches the specified power level at moments when the magnitude of the I/Q waveform equals one. If you write more than one waveform, the relative scaling between waveforms is preserved. In peak power mode, waveforms are scaled according to the NIRFSG_ATTR_ARB_WAVEFORM_SOFTWARE_SCALING_FACTOR attribute.

Page 28: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSG Basics

© 2015 Cobham - 28 -

3. Load the waveform into the RFSG. 

4. Set the sample rate in Hz of the playback of the waveform. 

5. Configure the RFSG for a ARB Waveform playback. 

6. Configure the play back for single or continuous playback. 

7. If the play back is single then define the number of times to play the waveform. 

8. Disable any start triggers that may have previously been configured. 

9. Set the Frequency, Level and Output state. 

10. Call Initiate. 

11. Check generation status. 

5.4.1 C/C++ Example

ViStatus status; ViBoolean done; ViReal64 Frequency    = 1e9; // 1 GHz ViReal64 Level    = ‐20; // ‐20 dBm ViReal64 aiqSampleRate  = 20e6; // 20 MHz. std::vector<ViReal64> I; std::vector<ViReal64> Q;  // Load in am IQ waveform from file that is specified with a IQ pair per line deliminated with a ',' ReadCsvFile("gsmtsc0.csv", I,Q); ViInt32 numSamples = I.size();  // Aborts generation & put VSG in configuration mode status = niRFSG_Abort(vsg); ErrorCheckRFSA(vsg,status);  // // Configure all settings that require the VSG to be in configuration mode //  // RMS mode will automatically rescale ARB files to maximise DAC dynamic range. // PEAK mode will treat the RF level as being the peak value, so the RMS value will usually be lower.  ARB files are not re‐scaled. status = niRFSG_ConfigurePowerLevelType(vsg, NIRFSG_VAL_PEAK_POWER); ErrorCheckRFSA(vsg,status);  // Write Arb file to RFSG. status = niRFSG_WriteArbWaveform(vsg, "gsmtsc0.csv", numSamples, &I[0], &Q[0], VI_FALSE);  ErrorCheckRFSA(vsg,status);  // Set ARB playback sample rate status = niRFSG_SetAttributeViReal64(vsg, VI_NULL, NIRFSG_ATTR_IQ_RATE, sampleRate); ErrorCheckRFSA(vsg,status);  // Set generation mode to ARB Waveform. status = niRFSG_ConfigureGenerationMode(vsg, NIRFSG_VAL_ARB_WAVEFORM); 

Page 29: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSG Basics

© 2015 Cobham - 29 -

ErrorCheckRFSA(vsg,status);  // Configure the ARB to playback continuously or a finite number of times. status = niRFSG_SetAttributeViBoolean(vsg, VI_NULL, NIRFSG_ATTR_ARB_WAVEFORM_REPEAT_COUNT_IS_FINITE, VI_TRUE); ErrorCheckRFSA(vsg,status);  // Configure number of times ARB file is played status = niRFSG_SetAttributeViInt32(vsg, VI_NULL, NIRFSG_ATTR_ARB_WAVEFORM_REPEAT_COUNT, 1000);  ErrorCheckRFSA(vsg,status);  // Disable start trigger, so generation will commence immediately after _Initiate() called status = niRFSG_DisableStartTrigger(vsg); ErrorCheckRFSA(vsg,status);  // Configure frequency & level using higher level function status = niRFSG_ConfigureRF(vsg, frequency, level); ErrorCheckRFSA(vsg,status);  // Enable output status = niRFSG_ConfigureOutputEnabled(vsg, VI_TRUE); ErrorCheckRFSA(vsg,status);  // Enable software start trigger status = niRFSG_ConfigureSoftwareStartTrigger(vsg); ErrorCheckRFSA(vsg,status);  // Initiate generation (VSG now in generation mode) status = niRFSG_Initiate(vsg); ErrorCheckRFSA(vsg,status);  // Check Generation Status. ( returns 0 (generation active) ) status = niRFSG_CheckGenerationStatus(vsg, &done);  ErrorCheckRFSA(vsg,status);  // VSG now in generation mode but awaiting a software trigger to commence ARB playback status = niRFSG_SendSoftwareEdgeTrigger(vsg, NIRFSG_VAL_START_TRIGGER, ""); // send software trigger ErrorCheckRFSA(vsg,status); 

5.4.2 C# Example

int status; bool done; double Frequency    = 1e9;  // 1 GHz double Level        = ‐20;  // ‐20 dBm double sampleRate   = 20e6; // 20 MHz double[] I; double[] Q;  // Load in am IQ waveform from file that is specified with a IQ pair per line deliminated with a ',' ReadCsvFile("gsmtsc0.csv", out I, out Q);  // Aborts generation & put VSG in configuration mode 

Page 30: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSG Basics

© 2015 Cobham - 30 -

status = Rfsg.Abort(); ErrorCheckRFSG(Rfsg, status);  // RMS mode will automatically rescale ARB files to maximise DAC dynamic range. // PEAK mode will treat the RF level as being the peak value, so the RMS value will usually be lower.  ARB files are not re‐scaled. status = Rfsg.ConfigurePowerLevelType(niRFSGConstants.PeakPower); ErrorCheckRFSG(Rfsg, status);  // Clear All wavefroms so we don't get an error if the waveform is already loaded. status = Rfsg.ClearAllArbWaveforms(); ErrorCheckRFSG(Rfsg, status);  // Write Arb file to RFSG. status = Rfsg.WriteArbWaveform("gsmtsc0", I.Length, I, Q, false); ErrorCheckRFSG(Rfsg, status);  // Set ARB playback sample rate status = Rfsg.SetIqRate("0", sampleRate); ErrorCheckRFSG(Rfsg, status);  // Set generation mode to ARB Waveform. status = Rfsg.ConfigureGenerationMode(niRFSGConstants.ArbWaveform); ErrorCheckRFSG(Rfsg, status);  // Configure the ARB to playback continuously or a finite numberof times. False for continuous playback true to play back n‐times. status = Rfsg.SetArbWaveformRepeatCountIsFinite("0", false); ErrorCheckRFSG(Rfsg, status);  // Configure number of times ARB file is played status = Rfsg.SetArbWaveformRepeatCount("0", 1000); ErrorCheckRFSG(Rfsg, status);  // Disable start trigger, so generation will commence immediately after _Initiate() called status = Rfsg.DisableStartTrigger(); ErrorCheckRFSG(Rfsg, status);  // Configure frequency & level using higher level function status = Rfsg.ConfigureRF(Frequency, Level); ErrorCheckRFSG(Rfsg, status);  // Enable output status = Rfsg.ConfigureOutputEnabled(true); ErrorCheckRFSG(Rfsg, status);  // Initiate generation (VSG now in generation mode) status = Rfsg.Initiate(); ErrorCheckRFSG(Rfsg, status);  // Check Generation Status. ( returns 0 (generation active) ) status = Rfsg.CheckGenerationStatus(out done); ErrorCheckRFSG(Rfsg, status); 

Page 31: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSG Basics

© 2015 Cobham - 31 -

5.5 Waveform Playback Triggers

Waveform playback can be configured so that it starts after the Initiate method has been called by

disabling any configured triggers, or upon receipt of a software trigger event, or from an external

signal.

5.5.1 Software Trigger

Before the “Inititiate()” method is called a C/C++ call to “niRFSG_ConfigureSoftwareStartTrigger ()“ or a C# call to “ConfigureSoftwareStartTrigger()” places the RFSG into a state where it will not

commence playback until the C/C++ method “niRFSG_SendSoftwareEdgeTrigge()r” or the C#

method “SendSoftwareEdgeTrigger()” is called.

5.5.2 C / C++ Example

// Enable software start trigger status = niRFSG_ConfigureSoftwareStartTrigger(vsg); ErrorCheckRFSA(vsg,status);  // Initiate generation (VSG now in generation mode) status = niRFSG_Initiate(vsg); ErrorCheckRFSA(vsg,status);  // Check Generation Status. ( returns 0 (generation active) ) status = niRFSG_CheckGenerationStatus(vsg, &done);  ErrorCheckRFSA(vsg,status);  // VSG now in generation mode but awaiting a software trigger to commence ARB playback status = niRFSG_SendSoftwareEdgeTrigger(vsg, NIRFSG_VAL_START_TRIGGER, ""); // send software trigger ErrorCheckRFSA(vsg,status); 

5.5.3 C# Example

// Enable software start trigger. status = Rfsg.ConfigureSoftwareStartTrigger(); ErrorCheckRFSG(Rfsg, status);  // Initiate generation (VSG now in generation mode) status = Rfsg.Initiate(); ErrorCheckRFSG(Rfsg, status);  // Check Generation Status. ( returns 0 (generation active) ) status = Rfsg.CheckGenerationStatus(out done); ErrorCheckRFSG(Rfsg, status);  // VSG now in generation mode but awaiting software trigger to commence ARB playback. status = Rfsg.SendSoftwareEdgeTrigger(niRFSGConstants.StartTrigger, ""); ErrorCheckRFSG(Rfsg, status); 

Page 32: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSG Basics

© 2015 Cobham - 32 -

5.5.4 External Trigger

Before the “Inititiate()” method is called a C/C++ call to

“niRFSG_ConfigureDigitalEdgeStartTrigger()“ or a C# call to “ConfigureDigitalEdgeStartTrigger()”

specifying the external source of the trigger event and the positive or negative edge that will

cause the trigger will place the RFSG into a state where it will not commence playback until a

trigger signal is received on the route specified.

5.5.5 C / C++ Example

// Enable external Edge start trigger ( from PXI trigger 0 ) status = niRFSG_ConfigureDigitalEdgeStartTrigger(vsg,NIRFSG_VAL_PXI_TRIG0_STR); ErrorCheckRFSA(vsg,status);  // Initiate generation (VSG now in generation mode) status = niRFSG_Initiate(vsg); ErrorCheckRFSA(vsg,status);  // Check Generation Status. ( returns 0 (generation active) ) status = niRFSG_CheckGenerationStatus(vsg, &done);  ErrorCheckRFSA(vsg,status);  // VSG now in generation mode but awaiting Edge trigger event on PXI trig 0 to commence ARB playback. 

5.5.6 C# Example

// Enable external Edge start trigger ( from PXI trigger line 0 ) status = Rfsg.ConfigureDigitalEdgeStartTrigger(niRFSGConstants.PxiTrig0Str, niRFSGConstants.RisingEdge); ErrorCheckRFSG(Rfsg, status);  // Initiate generation (VSG now in generation mode) status = Rfsg.Initiate(); ErrorCheckRFSG(Rfsg, status);  // Check Generation Status. ( returns 0 (generation active) ) status = Rfsg.CheckGenerationStatus(out done); ErrorCheckRFSG(Rfsg, status);  // VSG now in generation mode but awaiting Edge trigger event on PXI trig 0 to commence ARB playback 

5.6 Stopping Waveform Playback

To abort playback or return the RFSG to the “Configuration Mode” a C/C++ call to

“niRFSG_Abort()” or a C# call to “” will be required. If the waveform playback was set to finite and

playback has completed a call to Abort call is not needed.

5.6.1 C/C++Example

// Abort the current waveform playback. status = niRFSG_Abort(vsg); ErrorCheckRFSA(vsg,status); 

Page 33: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

© 2015 Cobham - 33 -

5.6.2 C# Example

// Aborts generation & put VSG in configuration mode status = Rfsg.Abort(); ErrorCheckRFSG(Rfsg, status);  

Page 34: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSA/RFSG Self Calibration

© 2015 Cobham - 34 -

6 RFSA/RFSG Self Calibration The NI 5644r/5645r/5646r is calibrated at the factory; however, a self-calibration should be performed in the following situations:

After first installing your NI 5644R into your chassis

After any module in the chassis is added, moved, or removed

When the system is in an environment where the ambient temperature varies

If the module temperature has drifted more than ±5 °C from the last performed self-calibration

In addition to the preceding scenarios, performing proactive and regular self-calibration helps control the effects of aging-related drifts.

ViReal64 minFrequency  = 500e6; // 500 MHz ViReal64 maxFrequency  = 2e9;   // 2 GHz ViReal64 minReferenceLevel  = ‐30;   // ‐30 dBm ViReal64 maxReferenceLevel  = 30;    //  +30 dBm ViReal64 minPowerLevel  = ‐100;  // ‐100 dBm ViReal64 maxPowerLevel  = 17;    // +17 dBm  // Perform self‐calibration with no calibration step omissions between 500 MHz and 2GHz and between ‐30 dBm to +30 dBm. status = niRFSA_SelfCalibrateRange(vsa,0,minFrequency,maxFrequency,minReferenceLevel,maxReferenceLevel);    ErrorCheckRFSA(vsa,status);  // Perform self‐calibration with no calibration step omissions between 500 MHz and 2GHz and between ‐80 dBm to +17 dBm. status = niRFSG_SelfCalibrateRange(vsg,0,minFrequency,maxFrequency,minPowerLevel,maxPowerLevel); ErrorCheckRFSG(vsg,status); 

Page 35: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

RFSA/RFSG Self Calibration

© 2015 Cobham - 35 -

Page 36: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

Example Code

© 2015 Cobham - 36 -

7 Example Code To accompany this Application note three examples have been written:

Example 1 – Example of how to boot and close down the VST. Available in C/C++ and C# .NET Example 2 – Example of how setup the VST for a single point IQ capture and measure the average power of the capture. Available in C/C++ and C# .NET Example 3 – Example of how to generate a CW tone at a certain power and frequency and how to load and playback an IQ waveform at a known power and level.

Page 37: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

Appendix A

© 2015 Cobham - 37 -

8 Appendix A

RFSA state diagram.

Page 38: VST Programming Guide - Cobham Wirelesscobhamwireless.com/.../VST-Programming-Guide-.pdf · The NI C# interface is a separate C# file (niRFSA.cs and niRFSG.cs) that defines a series

VST Basics Programming Guide

As we are always seeking to improve our products, the information in this document gives only a general indication of the product capacity, performance and suitability, none of which shall form part of any contract. We reserve the right to make design changes without notice. All trademarks are acknowledged. © Cobham 2015.

The most important thing we build is trust

For further information please contact:

Cobham Wireless

www.cobham.com/wireless