' Program 3 : Querying the instrument state Version 1.0
'
' Platform : QuickBasic 4.5
'
' Description :
'
' This program will use queries to find out the current settings
' of the unit.
' This program assumes that the GPIB configuration is correct
' enough to be able to run example program 1 correctly.
'
' **************************************************************
' $INCLUDE: 'QBDECL.BAS' ' National Instruments include file.
CLS ' Clear the screen.
' Initialise the GPIB
CALL IBFIND("WK", wk%) ' Look for 'WK'.
CALL IBCLR(wk%) ' Clear the device.
' Select the required operating mode
CALL IBWRT(wk%, ":MEAS") ' Go to measurement mode.
CALL IBWRT(wk%, ":MEAS:TEST:AC") ' Select AC measurements.
' Start querying
freq = VAL(GPIBQuery$(wk%, ":MEAS:FREQ?")) ' Query the AC frequency.
level = VAL(GPIBQuery$(wk%, ":MEAS:LEV?")) ' Query the AC level.
range = VAL(GPIBQuery$(wk%, ":MEAS:RANGE?")) ' Query the range.
speed = VAL(GPIBQuery$(wk%, ":MEAS:SPEED?")) ' Query the speed.
' Print the status of the major settings.
PRINT "AC Frequency ="; freq; "Hz" ' Print the AC frequency.
PRINT "AC Drive level ="; level; "V" ' Print the AC level.
PRINT "AC Range ="; ' Print the AC range.
IF range = 0 THEN
PRINT " AUTO"
ELSE
PRINT range
END IF
PRINT "SPEED = "; ' Print the test speed.
SELECT CASE speed
CASE 3
PRINT "SLOW"
CASE 2
PRINT "MEDIUM"
CASE 1
PRINT "FAST"
CASE 0
PRINT "MAX"
END SELECT
END ' The end.
' This function sends the supplied query to the instrument
' and reads back the reply and strips the trailing characters
FUNCTION GPIBQuery$ (id%, Query$)
buf$ = SPACE$(80) ' Initialise the buffer.