IM 253401-01E
App2-41
App
Appendix 2.5 Sample Program
Communication Commands 2
‘*********************************************************************
‘* WT110/WT130 *
‘* Executes harmonic analysis for element 1 and displays the *
‘* following: *
‘* * Frequency of the PLL source(=voltage of element 1) *
‘* * Harmonic distortion factor of the current(ATHD) *
‘* * Rms values of the 1st to 50th order current *
‘* * Fundamental(1st order) and harmonic analysis values(2nd to *
‘* 50th order)currents *
‘* Microsoft QuickBASIC 4.0/4.5 Version *
‘*********************************************************************
REM $INCLUDE: ‘qbdecl4.bas’
N = 53
DIM D$(N) ‘ Array D$(53) is prepared for receiving data
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
‘ Settings related to harmonic analysis
‘ Element=1, PLL source=V1, Computation method of harmonic distortion=IEC
CMD$ = “HARMONICS:STATE ON;ELEMENT 1;SYNCHRONIZE V,1;THD IEC”
CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
‘ Sets the communication output items.
‘ Sets all functions OFF. Sets only necessary functions ON.
CMD$ = “MEASURE:HARMONICS:ITEM:PRESET CLEAR”
CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
CMD$ = “MEASURE:HARMONICS:ITEM:SYNCHRONIZE ON;ATHD ON;A 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
‘ Reads the analysis data and displays them (10 times)
FOR I = 1 TO 10
CMD$ = “STATUS:EESR?” ‘ Clears the extended event register
CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
BUF$ = SPACE$(255)
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?” ‘ Requests output of analysis data
CALL IBWRT(WT%, CMD$): GOSUB ERRCHK
BUF$ = SPACE$(1000)
CALL IBRD(WT%, BUF$): GOSUB ERRCHK ‘ Reads analysis data
K = 1
FOR J = 1 TO N ‘ Order of output data
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
‘ Displaying analysis data
PRINT “V1 FREQ”, D$(1) ‘ Frequency of PLL source
PRINT “A1 THD(IEC)”, D$(2) ‘ Harmonic distortion of current
PRINT “A1 RMS”, D$(3) ‘ Rms values of the 1st to 50th order
FOR J = 1 TO N-3 STEP 2 ‘ Fundamental/higher harmonics analysis values
PRINT “A1 Order” + STR$(J), D$(J + 3), ‘ odd numbered component
PRINT “A1 Order” + STR$(J + 1), D$(J + 4) ‘ even numbered component
NEXT J
NEXT I
PRGEND:
CALL IBLOC(WT%)
END ‘ 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