14-46
IM 253421-01E
14.5 Sample Program
This section describes sample programs for a IBM PC/AT and compatible system with
National Instruments AT-GPIB/TNTIEEE-488.2 board. Sample programs in this manual
are written in Quick BASIC version 4.0/4.5.
'*************************************************************************
'* *
'* sample program 1 for the WT200 *
'* *
'*************************************************************************
'* *
'* Used to set measurement condition/ranges for normal mesurement mode, *
'* and read and display the following data each time measured/computed *
'* data is updated. *
'* *
'* Voltage(V), current(A), active power(W), voltage frequency(VHz) *
'* *
'*************************************************************************
REM $INCLUDE: 'qbdecl.bas'
DECLARE SUB gpiberr (msg$)
DIM D$(4)
CALL IBDEV(0, 1, 0, T10s, 1, 0, DEV%)
IF (DEV% <= 0) THEN CALL gpiberr("Ibdev error")
' interface clear
CALL IBCLR(DEV%)
IF (ibsta% AND EERR) THEN CALL gpiberr("Ibclr error")
' set measurement condition
WRT$ = "SAMPLE:HOLD OFF"
CALL IBWRT(DEV%, WRT$)
IF (ibsta% AND EERR) THEN CALL gpiberr("Ibwrt error")
WRT$ = "MODE RMS"
CALL IBWRT(DEV%, WRT$)
IF (ibsta% AND EERR) THEN CALL gpiberr("Ibwrt error")
WRT$ = "FILTER OFF"
CALL IBWRT(DEV%, WRT$)
IF (ibsta% AND EERR) THEN CALL gpiberr("Ibwrt error")
WRT$ = "SCALING OFF;AVERAGING OFF"
CALL IBWRT(DEV%, WRT$)
IF (ibsta% AND EERR) THEN CALL gpiberr("Ibwrt error")
' set measurement range
WRT$ = "VOLTAGE:RANGE 150V"
CALL IBWRT(DEV%, WRT$)
IF (ibsta% AND EERR) THEN CALL gpiberr("Ibwrt error")
WRT$ = "CURRENT:RANGE 5A"
CALL IBWRT(DEV%, WRT$)
IF (ibsta% AND EERR) THEN CALL gpiberr("Ibwrt error")
' set function/element of display C to measure frequency of element 1
WRT$ = "DISPLAY3:FUNCTION VHZ;ELEMENT 1"
CALL IBWRT(DEV%, WRT$)
IF (ibsta% AND EERR) THEN CALL gpiberr("Ibwrt error")
' set communication output items
' 1. V, A, W -> ON, others -> OFF
' 2. VHz -> ON
WRT$ = "MEASURE:ITEM:PRESET NORMAL"
CALL IBWRT(DEV%, WRT$)
IF (ibsta% AND EERR) THEN CALL gpiberr("Ibwrt error")
WRT$ = "MEASURE:ITEM:VHZ:ELEMENT1 ON"
CALL IBWRT(DEV%, WRT$)
IF (ibsta% AND EERR) THEN CALL gpiberr("Ibwrt error")
' set filter to detect completion of refreshing data
WRT$ = "STATUS:FILTER1 FALL"
CALL IBWRT(DEV%, WRT$)
IF (ibsta% AND EERR) THEN CALL gpiberr("Ibwrt error")