YOKOGAWA WT110 User Manual page 197

Digital power meter
Table of Contents

Advertisement

Appendix 2.5 Sample Program
Appendix 2.5 Sample Program
App2-40
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.
'*********************************************************************
'*
WT110/WT130
'*
After having set the measurement conditions/measurement range,
'*
output the following data:voltage(V),current(A),active power(W), *
'*
voltage frequency(VHz) of element 1.
'*
'*********************************************************************
REM $INCLUDE: 'qbdecl4.bas'
N = 4
DIM D$(N)
BORD$ = "GPIB0": CALL IBFIND(BORD$, BD%)
IF BD% < 0 THEN GOTO ERRDISP
CALL IBSIC(BD%): GOSUB ERRCHK
DEVICE$ = "WT": CALL IBFIND(DEVICE$, WT%)
IF WT% < 0 THEN GOTO ERRDISP
CALL IBCLR(WT%): GOSUB ERRCHK
V% = 1: CALL IBSRE(BD%, V%)
CLS
' Setting measurement conditions
' Hold OFF, Measurement mode = RMS, Filter OFF, Scaling OFF, Averaging OFF
CMD$ = "SAMPLE:HOLD OFF": CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
CMD$ = "MODE RMS": CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
CMD$ = "FILTER OFF": CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
CMD$ = "SCALING OFF": CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
CMD$ = "AVERAGING OFF": CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
' Setting measurement range(150V/5A)
CMD$ = "VOLTAGE:RANGE 150V;:CURRENT:RANGE 5A"
CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
' Sets display C to VHz1 in order to measure the voltage frequency of element 1
CMD$ = "DISPLAY3:FUNCTION VHZ;ELEMENT 1"
CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
' Sets the communication output items.(V1,A1,W1,VHz1 ON, all others OFF)
CMD$ = "MEASURE:ITEM:PRESET CLEAR": CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
CMD$ = "MEASURE:ITEM:V:ELEMENT1 ON": CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
CMD$ = "MEASURE:ITEM:A:ELEMENT1 ON": CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
CMD$ = "MEASURE:ITEM:W:ELEMENT1 ON": CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
CMD$ = "MEASURE:ITEM:VHZ:ELEMENT1 ON": CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
' Sets the filter to detect the end of data updating
CMD$ = "STATUS:FILTER1 FALL"
CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
BUF$ = SPACE$(200)
' Reads the measurement data and displays them (10 times)
FOR I = 1 TO 10
CMD$ = "STATUS:EESR?"
CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
CALL IBRD(WT%, BUF$): GOSUB ERRCHK
' Waiting until data are finished updating
CMD$ = "COMMUNICATE:WAIT 1"
CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
CMD$ = "MEASURE:VALUE?"
CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
CALL IBRD(WT%, BUF$): GOSUB ERRCHK ' Reads measurement data
K = 1
FOR J = 1 TO N
IF J < N THEN S = INSTR(K, BUF$, ",") ELSE S = INSTR(K, BUF$, CHR$(10))
D$(J) = MID$(BUF$, K, S - K)
K = S + 1
NEXT J
' Shows the measurement data per function
PRINT "V1", D$(1)
PRINT "A1", D$(2)
PRINT "W1", D$(3)
PRINT "VHz1", D$(4)
NEXT I
PRGEND:
CALL IBLOC(WT%)
END
'
' When IBFIND call failed
ERRDISP:
PRINT " ===== No such board or device name ===== "
GOTO PRGEND
'
' GP-IB error check
ERRCHK:
IF IBSTA% >= 0 THEN RETURN
PRINT " ===== Error ===== "
GOTO PRGEND
Microsoft QuickBASIC 4.0/4.5 Version
' Array D$(4) is prepared for receiving data
' bit0(UPD)
' Clears the extended event register
' Requests output of measurement data
'V1
'A1
'W1
'VHz1
' End
*
*
*
*
IM 253401-01E

Advertisement

Table of Contents
loading

This manual is also suitable for:

Wt130

Table of Contents