Sample Program
7-3
IM 701730-17E
7
7.3
Initialize/Error/Execute
----------------------------------------------------------------------------------------
Option Explicit
Dim StartFlag As Integer 'Start Flag
Dim Dev As Long 'Device ID
Dim Query(3) As String 'Query String
Dim WaveBuffer(20070) As Integer 'WaveData Buffer(GPIB)
----------------------------------------------------------------------------------------
Private Function InitGpib() As Long
Dim address As String 'GPIB Address
Dim eos As Long 'EOS
Dim eot As Long 'EOI
Dim timeout As Long 'Timeout
Dim sts As Long
address = "1" 'Address = 1
eos = TERM_LF 'Terminator = LF
eot = SET_TRUE 'EOI = Enable
timeout = 100 'Timeout = 10s
sts = TmInitialize(1, address, Dev) 'GPIB Initialize(GPIB Address = 1)
If (sts <> CTL_OK) Then
Call DisplayError(Dev)
InitGpib = 1
Exit Function
End If
sts = TmDeviceClear(Dev) 'GPIB Device Clear
If (sts <> CTL_OK) Then
Call DisplayError(Dev)
InitGpib = 1
GoTo PostProcces
End If
sts = TmSetTerm(Dev, eos, eot) 'Terminator = LF, EOI = Enable
If (sts <> CTL_OK) Then
Call DisplayError(Dev)
InitGpib = 1
GoTo PostProcces
End If
sts = TmSetTimeout(Dev, timeout) 'Timeout = 10s
If (sts <> CTL_OK) Then
Call DisplayError(Dev)
InitGpib = 1
GoTo PostProcces
End If
InitGpib = 0
Exit Function
PostProcces:
Call CloseDevice 'Device Clear
End Function
----------------------------------------------------------------------------------------
Private Function InitUsb() As Long
Dim id As String 'USB ID
Dim eos As Long 'EOS
Dim eot As Long 'EOI
Dim timeout As Long 'Timeout
Dim sts As Long
id = "1" 'ID = 1
eos = TERM_LF 'Terminator = LF
eot = SET_TRUE 'EOI = None(GPIB Only)
timeout = 100 'Timeout = 10s
sts = TmInitialize(3, id, Dev) 'USB Initialize(USB ID = 1)
If (sts <> CTL_OK) Then
Call DisplayError(Dev)
InitUsb = 1
Exit Function
End If
sts = TmSetTerm(Dev, eos, eot) 'Terminator = LF, EOI = Enable
If (sts <> CTL_OK) Then
Call DisplayError(Dev)
InitUsb = 1
GoTo PostProcces
End If
sts = TmSetTimeout(Dev, timeout) 'Timeout = 10s
If (sts <> CTL_OK) Then
Call DisplayError(Dev)
InitUsb = 1
GoTo PostProcces
End If
InitUsb = 0
Exit Function
7.3 Initialize/Error/Execute