Chapter 2 39
Programming Examples
GPIB Programming Examples
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 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.
The following program example is available on the PSG 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