Agilent Technologies N5183A MXG Portable Generator User Manual


 
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide 103
Programming Examples
LAN Programming Interface Examples
// Open SICL instrument handle using VXI-11 protocol
sprintf(instNameBuf, "lan[%s]:inst0", instrumentName);
id = iopen(instNameBuf);// Open instrument session
itimeout(id, 1000);// Set 1 second timeout for operations
printf("Setting frequency to 1 Ghz...\n");
iprintf(id, "freq 1 GHz\n");// Set frequency to 1 GHz
printf("Waiting for source to settle...\n");
iprintf(id, "*opc?\n");// Query for operation complete
iscanf(id, "%d", &opcResponse); // Operation complete flag
if (opcResponse != 1)// If operation fails, prompt user
{
printf("Bad response to 'OPC?'\n");
iclose(id);
exit(1);
}
iprintf(id, "FREQ?\n");// Query the frequency
iscanf(id, "%t", &buf);// Read the signal generator frequency
printf("\n");// Print the frequency to the display
printf("Frequency of signal generator is %s\n", buf);
ipromptf(id, "*IDN?\n", "%t", buf);// Query for id string
printf("Instrument ID: %s\n", buf);// Print id string to display
iclose(id);// Close the session
return 0;
}
VXI-11 Programming Using VISA and C++
The following program uses the VXI-11 protocol and the VISA library to control the signal generator.
The signal generator is set to a –5 dBm power level and queried for its ID string. Before running this
code, you must set up the interface using the Agilent IO Libraries IO Config utility. vxivisa.cpp
performs the following functions:
sets signal generator to a –5 dBm power level
queries signal generator for an ID string
•error checking
The following program example is available on the signal generator Documentation CD-ROM as
vxivisa.cpp.
//****************************************************************************************
// PROGRAM FILE NAME:vxivisa.cpp
// Sample test program using the VISA libraries and the VXI-11 protocol
//