90 Keysight Signal Generators Programming Guide
Programming Examples
GPIB Programming Interface Examples
340 OUTPUT Sig_gen;"OUTP OFF" ! Turns signal generator RF state off
350 OUTPUT Sig_gen;"OUTP?" ! Querys the operating state of the signal generator
360 ENTER Sig_gen;B ! Enter in the state (0 for off)
370 ! Print the on/off state of the signal generator to the controller display
380 IF B>0 THEN
390 PRINT "Signal Generator output is: on"
400 ELSE
410 PRINT "Signal Generator output is: off"
420 END IF
430 OUTPUT Sig_gen;"*IDN?" ! Querys for signal generator ID
440 ENTER Sig_gen;C$ ! Enter in the signal generator ID
450 ! Print the signal generator ID to the controller display
460 PRINT
470 PRINT "This signal generator is a ";C$
480 PRINT
490 ! The next command is a query for the signal generator's GPIB address
500 OUTPUT Sig_gen;"SYST:COMM:GPIB:ADDR?"
510 ENTER Sig_gen;D$ ! Enter in the signal generator's address
520 ! Print the signal generator's GPIB address to the controllers display
530 PRINT "The GPIB address is ";D$
540 PRINT
550 ! Print user prompts to the controller's display
560 PRINT "The signal generator is now under local control"
570 PRINT "or Press RUN to start again."
580 END
Queries Using NI-488.2 and Visual C++
This example uses the NI- 488.2 library to query different instrument states and conditions. Launch
Microsoft Visual C++ 6.0, add the required files, and enter the following code into your .cpp source
file. niex3.cpp performs the following functions:
• resets the signal generator
• queries the signal generator for various settings
• reads the various settings
The following program example is available on the signal generator Documentation CD- ROM as
niex3.cpp.
//*************************************************************************************
// PROGRAM NAME: niex3.cpp
//
// PROGRAM DESCRIPTION: This example demonstrates the use of query commands.
//
// The signal generator can be queried for conditions and instrument states.
// These commands are of the type "*IDN?" where the question mark indicates