This program creates a linear sweep for a sine wave. It sets the start and
stop frequency, and the sweep time. Here the instrument’s second channel
parameters are changed and additional the error queue is read out.
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
ViStatus errorStatus = 0;
ViSession viRm = 0, vi = 0;
/* Open session to GPIB device at address 10 */
errorStatus = viOpenDefaultRM(&viRm);
errorStatus = viOpen(viRm, "GPIB0::10::INSTR",
VI_NULL, 10000, &vi);
// Reset the function generator
viPrintf(vi, "*RST?\n");
// Clear error and status register
viPrintf(vi, "*CLS\n");
// Select waveshape
viPrintf(vi, ":FUNCtion2 SINusoid\n");
// Load impedance to 50Ohm
viPrintf(vi, ":OUTput2:LOAD 50\n");
// Amplitude to 1.0 Vpp
viPrintf(vi, ":VOLTage2 1.00\n");
// Set LINEar/LOG spacing
viPrintf(vi, "SWEep2:SPACing LINear\n");
// Sweep time is 1 second
viPrintf(vi, "SWEep2:TIME 1\n");
// Sweep start freq is 123Hz
viPrintf(vi, "FREQuency2:STARt 123\n");
// Sweep stop freq is 20kHz
viPrintf(vi, "FREQuency2:STOP 20e3\n");