Sample Program
7-3
IM 760101-11E
7
7.3
Initialization, Error, and Functions for
Execution
----------------------------------------------------------------------------------------
Option Explicit
Dim StartFlag As Integer 'Start Flag
Dim addr As Integer 'GPIB Address
Dim Timeout As Integer 'Timeout
Dim Dev As Integer 'Device ID(GPIB)
Dim term As String 'Terminator
Dim Query(1100) As String 'Query String
Dim Dummy As Integer
----------------------------------------------------------------------------------------
Private Function InitGpib() As Integer
Dim eos As Integer 'EOS
Dim eot As Integer 'EOI
Dim brd As Integer 'GPIB Board ID
Dim sts As Integer
eos = &HC0A 'Terminator = LF
eot = 1 'EOI = Enable
term = Chr(10)
Timeout = T10s 'Timeout = 10s
brd = ilfind("GPIB0")
If (brd < 0) Then
Call DisplayGPIBError(brd, "ilfind")
InitGpib = 1
Exit Function
End If
Dev = ildev(0, addr, 0, Timeout, eot, eos)
If (Dev < 0) Then
Call DisplayGPIBError(Dev, "ildev")
InitGpib = 1
Exit Function
End If
sts = ilsic(brd) 'Set IFC
If (sts < 0) Then
Call DisplayGPIBError(sts, "ilsic")
InitGpib = 1
Exit Function
End If
InitGpib = 0
End Function
----------------------------------------------------------------------------------------
Private Sub DisplayGPIBError(ByVal sts As Integer, ByVal msg As String)
Dim wrn As String
Dim ers As String
Dim ern As Integer
If (sts And TIMO) Then
wrn = "Time out" + Chr(13)
Else
wrn = ""
End If
If (sts And EERR) Then
ern = iberr
If (ern = EDVR) Then
ers = "EDVR:System error"
ElseIf (ern = ECIC) Then
ers = "ECIC:Function requires GPIB board to be CIC"
ElseIf (ern = ENOL) Then
ers = "ENOL:No Listeners on the GPIB"
ElseIf (ern = EADR) Then
ers = "EADR:GPIB board not addressed correctly"
ElseIf (ern = EARG) Then
ers = "EARG:Invalid argument to function call"
ElseIf (ern = ESAC) Then
ers = "ESAC:GPIB board not System Controller as required"
ElseIf (ern = EABO) Then
ers = "EABO:I/O operation aborted(timeout)"
ElseIf (ern = ENEB) Then
ers = "ENEB:Nonexistent GPIB board"
ElseIf (ern = EDMA) Then
ers = "EDMA:DMA error"
ElseIf (ern = EOIP) Then
ers = "EOIP:I/O operation started before previous operation completed"
ElseIf (ern = ECAP) Then
ers = "ECAP:No capability for intended operation"
ElseIf (ern = EFSO) Then
ers = "EFSO:File system operation error"
ElseIf (ern = EBUS) Then
ers = "EBUS:GPIB bus error"
ElseIf (ern = ESTB) Then
ers = "ESTB:Serial poll status byte queue overflow"
ElseIf (ern = ESRQ) Then
ers = "ESRQ:SRQ remains asserted"
Содержание wt1600
Страница 1: ...Digital Power Meter Communication Interface IM 760101 11E 4th Edition ...
Страница 131: ...7 2 IM 760101 11E 7 2 Sample Program Image ...
Страница 138: ...Sample Program 7 9 IM 760101 11E 7 7 4 Output of Normal Measurement Data ...
Страница 142: ...Sample Program 7 13 IM 760101 11E 7 7 5 Output of Harmonic Measurement Data ...