104 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide
Programming Examples
GPIB Programming Interface Examples
viPrintf(vi, "*RCL 1\n"); // Recalls stored register
#1 state
viPrintf(vi, "*OPC?\n"); // Checks for operation
complete
while (!lngDone)
viScanf (vi ,"%d",&lngDone); // Waits for setup to
complete
// Print user information
printf("The signal generator has been returned to it's Register
#1 state\n");
printf("Press Enter to continue\n");
printf("\n"); // Prints new line character
getch(); // Waits for user input
lngDone=0; // Reset the operation
complete flag
viPrintf(vi, "*RST\n"); // Resets the signal
generator
viPrintf(vi, "*OPC?\n"); // Checks for operation
complete
while (!lngDone)
viScanf (vi ,"%d",&lngDone); // Waits for setup to
complete
// Print user information
printf("Press Local on instrument front panel to return to
manual mode\n");
printf("\n"); // Prints new line character
// Close the sessions
viClose(vi);
viClose(defaultRM);
}
Reading the Data Questionable Status Register Using VISA and C
In this example, the signal generator’s data questionable status register is
read. You will be asked to set up the signal generator for error generating
conditions. The data questionable status register will be read and the program
will notify the user of the error condition that the setup caused. Follow the user
prompts presented when the program runs. Launch Microsoft Visual C++ 6.0,
add the required files, and enter the following code into your .cpp source file.
visaex9.cpp performs the following functions: