請問以 VB + GPIB 與儀器(Agilent 4268A)進行溝通, 為何每次執行後,按Trigger 按鈕到第 28 次後,即出現以下訊息:敬請各位先進不吝賜教,謝謝!
出現異常訊息如下:
Unable to write to device
ibsta=&H8100
iberr=0<EDVR>
程式碼如下:
Const BDINDEX = 0 ' Board Index
'Const PRIMARY_ADDR_OF_DMM = 1 ' Primary address of device
'Const PRIMARY_ADDR_OF_DMM = 2
Const NO_SECONDARY_ADDR = 0 ' Secondary address of device
Const TIMEOUT = T10s ' Timeout value = 10 seconds
Const EOTMODE = 1 ' Enable the END message
Const EOSMODE = 1 ' Disable the EOS mode
Const ARRAYSIZE = 1024 ' Size of read buffer
Dim ErrMsg As String * 100
Dim Dev As Integer
Dim ErrorMnemonic
Dim ValueStr As String * ARRAYSIZE
Dim Response As Integer
Dim sendstr As String
Private Sub Command1_Click()
End Sub
Private Sub GPIBCleanup(msg$)
' After each GPIB call, the application checks whether the call
' succeeded. If an NI-488.2 call fails, the GPIB driver sets the
' corresponding bit in the global status variable. If the call
' failed, this procedure prints an error message, takes the device
' offline and exits.
ErrorMnemonic = Array("EDVR", "ECIC", "ENOL", "EADR", "EARG", _
"ESAC", "EABO", "ENEB", "EDMA", "", _
"EOIP", "ECAP", "EFSO", "", "EBUS", _
"ESTB", "ESRQ", "", "", "", "ETAB")
ErrMsg$ = msg$ & Chr(13) & "ibsta = &H" & Hex(ibsta) & Chr(13) _
& "iberr = " & iberr & " <" & ErrorMnemonic(iberr) & ">"
MsgBox ErrMsg$, vbCritical, "Error"
ilonl Dev%, 0
End
End Sub
Private Sub Form_Load()
Const PRIMARY_ADDR_OF_DMM = 1
Dev% = ildev(BDINDEX, PRIMARY_ADDR_OF_DMM, NO_SECONDARY_ADDR, _
TIMEOUT, EOTMODE, EOSMODE)
If (ibsta And EERR) Then
ErrMsg = "Unable to open device" & Chr(13) & "ibsta = &H" & _
Chr(13) & Hex(ibsta) & "iberr = " & iberr
MsgBox ErrMsg, vbCritical, "Error"
End
End If
' The application resets the GPIB portion of the device by calling
' ilclr.
ilclr Dev%
End Sub
Private Sub Trigger_Com_Click()
Dim displaystr As String
Dim CapVal, DFval As String
Debug.Print "trig cap"
Const PRIMARY_ADDR_OF_DMM = 1 ' Primary address of device
Dev% = ildev(BDINDEX, PRIMARY_ADDR_OF_DMM, NO_SECONDARY_ADDR, _
TIMEOUT, EOTMODE, EOSMODE)
ilclr Dev%
sendstr = ":TRIG:SOUR BUS ; *TRG"
ilwrt Dev%, sendstr, Len(sendstr)
If (ibsta And EERR) Then
Call GPIBCleanup("Unable to write to device")
End If
' The application reads the ASCII string from the multimeter into
' the ValueStr variable.
ilrd Dev%, ValueStr, Len(ValueStr)
If (ibsta And EERR) Then
Call GPIBCleanup("Unable to read from device")
End If
displaystr = Left$(ValueStr, ibcntl - 1)
CapVal = Mid(displaystr, 4, 12)
DFval = Mid(displaystr, 17, 12)
Text1(0).Text = Val(CapVal) * 10 ^ 9
Text1(1).Text = Val(DFval)
End Sub