VSG60 API
Theory of Operation

There are two primary ways to generate waveforms with the VSG60 API:

  1. Basic Provide a complete waveform which the API will output once or repeat until stopped. This is the simplest method for generation. These methods are ideal for fixed frequency output waveforms up to many seconds in length.
  2. Complex Use the streaming functions which allow for long waveforms or complex sequences which might involve frequency hopping and level changes.

Opening a Device

Before any generation can occur, the device must be opened and initialized. Opening and initializing a device through the API is performed through the vsgOpenDevice or vsgOpenDeviceBySerial functions. These functions will perform the full initialization of the device and if successful, will return an integer handle which can be used to reference the device for the remainder of your program. See the list of all VSG60 devices connected to the PC via the vsgGetDeviceList function.

Basic Signal Generation

To output a static waveform, either once, or repeatedly, use basic signal generation.

Example

For a list of all examples, please see the examples/ folder in the SDK.

/*
* This example illustrates generating a pulse signal at a specific freq and level.
* This example is fully standalone.
*/
#include "vsg_api.h"
#include <cstdio>
#include <vector>
#include <Windows.h>
struct Cplx32f {
float re, im;
};
void vsg_example_basic_generation_2()
{
// Open device, get handle, check open result
int handle;
VsgStatus status = vsgOpenDevice(&handle);
if(status < vsgNoError) {
printf("Error: %s\n", vsgGetErrorString(status));
return;
}
// Configure generator
const double freq = 1.0e9; // Hz
const double sampleRate = 50.0e6; // samples per second
const double level = -10.0; // dBm
vsgSetFrequency(handle, freq);
vsgSetLevel(handle, level);
vsgSetSampleRate(handle, sampleRate);
// Create pulse with specific width and period, then continually loop the pulsed signal
const Cplx32f cplxOne = {1.0, 0.0}, cplxZero = {0.0, 0.0};
std::vector<Cplx32f> iq; // The I/Q waveform
const double pulseWidth = 1.0e-6; // 1us
const double pulsePeriod = 10.0e-6; // 10us
const int pulseOnSamples = pulseWidth * sampleRate;
const int pulseOffSamples = (pulsePeriod - pulseWidth) * sampleRate;
for(int i = 0; i < pulseOnSamples; i++) {
iq.push_back(cplxOne);
}
for(int i = 0; i < pulseOffSamples; i++) {
iq.push_back(cplxZero);
}
vsgRepeatWaveform(handle, (float*)&iq[0], iq.size());
// Will transmit until you close the device or abort
Sleep(5000);
// Stop waveform
vsgAbort(handle);
// Done with device
vsgCloseDevice(handle);
}
API functions for the VSG60A vector signal generator.
VSG_API const char * vsgGetErrorString(VsgStatus status)
VSG_API VsgStatus vsgCloseDevice(int handle)
VSG_API VsgStatus vsgSetSampleRate(int handle, double sampleRate)
VsgStatus
Definition: vsg_api.h:88
@ vsgNoError
Definition: vsg_api.h:112
VSG_API VsgStatus vsgSetLevel(int handle, double level)
VSG_API VsgStatus vsgOpenDevice(int *handle)
VSG_API VsgStatus vsgRepeatWaveform(int handle, float *iq, int len)
VSG_API VsgStatus vsgSetFrequency(int handle, double frequency)
VSG_API VsgStatus vsgAbort(int handle)

Usage

Basic signal generation involves configuring the generator and then using one of the following functions:

Waveforms are provided as interleaved I/Q complex pairs. The API can output the waveform once using the vsgOutputWaveform function, or continually generate the waveform using the vsgRepeatWaveform function.

The vsgOutputWaveform is a blocking function which returns once fully output. When a waveform is on repeat, any changes in configuration will cause the waveform to be paused, and then restarted once reconfiguration has completed.

Submitting a trigger or I/Q data through the vsgSubmitIQ function will stop any waveforms on repeat.

Calling vsgAbort will end any active waveforms on repeat.

Complex Signal Generation (Streaming)

For long waveform generation or for transmitting a complex sequence of events such as frequency hopping or triggers, a collection of functions are available in the API which allow a user to buffer a sequence of configuration and transmit events.

Example

For a list of all examples, please see the examples/ folder in the SDK.

/*
* This example illustrates how to use the streaming function of the API
* to generate a complex frqeuency hopping CW signal.
* This example is fully standalone.
*/
#include "vsg_api.h"
#include <cstdio>
#include <vector>
#include <Windows.h>
struct Cplx32f {
float re, im;
};
static double RandBetween(double f1, double f2)
{
double r = (double)rand() / (double)RAND_MAX;
return f1 + r * (f2 - f1);
}
void vsg_example_complex_freq_hopping()
{
// Open device, get handle, check open result
int handle;
VsgStatus status = vsgOpenDevice(&handle);
if(status < vsgNoError) {
printf("Error: %s\n", vsgGetErrorString(status));
return;
}
// Configure generator
const double sampleRate = 50.0e6; // samples per second
const double level = -10.0; // dBm
vsgSetLevel(handle, level);
vsgSetSampleRate(handle, sampleRate);
// Each frequency switch takes 200us
// We will output an 800us CW at each frequency for a hop period of 1ms
std::vector<Cplx32f> iq(800.0e-6 * sampleRate);
for(int i = 0; i < iq.size(); i++) {
iq[i].re = 1.0;
iq[i].im = 0.0;
}
// Number of 1ms hops to perform
int hops = 1000;
while(hops-- > 0) {
vsgSetFrequency(handle, RandBetween(990.0e6, 1010.0e6));
vsgSubmitIQ(handle, (float*)&iq[0], iq.size());
}
vsgFlushAndWait(handle);
// Done with device
vsgCloseDevice(handle);
}
VSG_API VsgStatus vsgFlushAndWait(int handle)
VSG_API VsgStatus vsgSubmitIQ(int handle, float *iq, int len)

Usage

The following functions can be buffered/queued:

Roughly 1/5th of a second of I/Q data can be buffered. If the buffer is full and vsgSubmitIQ data is called, the function blocks until space is available in the buffer.

Calling vsgAbort will cause all I/Q data in the buffer to be dumped and any pending frequency/level changes to be completed in the order received.

Closing the Device

When finished, you can close the device and free all resources related to the device with the vsgCloseDevice function. Once closed, the device will appear in the open device list again. It is possible to open and close a device multiple times during the execution of a program.

Recalibration

Recalibration is performed by calling the vsgRecal function which retrieves the current device temperature and recalibrates the device for the current device settings. This will interrupt any signal generation currently in progress.

Large temperature changes affect signal generation in the form of reduce amplitude accuracy and reduced spurious performance, and it is recommended to reconfigure the device after large environmental changes and during device warmup.

Recalibration can occur automatically during periods of activity that include frequency changes, but when generating the same signal for long periods of time, or after a long period of inactivity, a recalibration is recommended.