8-42
IM 704420-01E
8.9.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 CtsFlag As Integer
'CTS Flag Dim term As String
'Terminator
Dim Query(12) 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
"
8.9 Sample Program