16-50
IM 765501-01E
16.4.2 GP-IB Access Function
Attribute VB_Name = “GpibLib”
‘================================================================
‘
‘ GPIB Access Function
‘
‘ Board:
AT-GPIB/TNT IEEE488.2 by National Instruments.
‘
‘ Used modules:
Niglobal.bas and Vbib-32.bas by National Instruments
‘
‘================================================================
‘————————————————————————————————
‘
‘ Constant declaration Change them as necessary.
‘
‘————————————————————————————————
Const BOARD_ID = 0
‘ GPIB board ID
Const ADDRESS = 1
‘ GS610 GPIB address
Const TIMEOUT = T1s
‘ Timeout value
‘————————————————————————————————
‘
‘ Access Functions
‘
‘————————————————————————————————
‘ Open function
Function CommOpen() As Integer
Dim dev As Integer
dev = ildev(BOARD_ID, ADDRESS, 0, TIMEOUT, 1, XEOS + REOS + &HA)
If (dev >= 0) Then Call CommClear(dev)
CommOpen = dev
End Function
‘ Close function
Sub CommClose(dev As Integer)
Call ilonl(dev, 0)
End Sub
‘ Send function
Function CommSend(dev As Integer, msg As String) As Integer
If (ilwrt(dev, msg + Chr$(10), Len(msg) + 1) And (EERR Or TIMO)) Then
CommSend = -1
Else
CommSend = ibcntl
End If
End Function
‘ Receive function
Function CommRecv(dev As Integer, msg As String) As Integer
Dim ret As Integer
ret = ilrd(dev, msg, Len(msg))
If (ret And TIMO) Then
CommClear (dev)
CommRecv = -1
Else
If (ret And EERR) Then
CommRecv = -1
Else
CommRecv = ibcntl
End If
End If
End Function
16.4 Sample Programs