Agilent Technologies N5183A MXG User Manual

Page 100

Advertising
background image

90

Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide

Programming Examples
GPIB Programming Interface Examples

lngDone=0; // Reset the operation complete flag

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:

error checking

clears the signal generator

resets the signal generator

the data questionable status register is enabled to read an unleveled condition

prompts user to manually set up the signal generator for an unleveled condition

queries the data questionable status register for any set bits and converts the string data to
numeric

based on the numeric value, program checks for a corresponding status check value

similarly checks for over or undermodulation condition

The following program example is available on the signal generator Documentation CD- ROM as
visaex9.cpp

.

//***************************************************************************************

// PROGRAM NAME:visaex9.cpp

//

Advertising
This manual is related to the following products: