Establishing communications – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual
Page 250

II. SOFTWARE GUIDES - 10. Driver488/W31
10F. Visual Basic
Personal488 User’s Manual, Rev. 3.0
II-235
Establishing Communications
The following program contains most of the function calls of Driver488/W31. The user interface of
this program is intentionally simple to highlight the Driver488/W31 operations. To centralize all of the
Driver488/W31-related code, the architecture of this example is not typical of a Visual Basic program.
This example operates the multichannel, 16-bit analog to digital converter; the ADC488.
In every Visual Basic program using Driver488/W31, a file of declarations must be merged into the
program, typically to the
GLOBAL.BAS
file. In the following example, those declarations have been
omitted from the listing for the sake of brevity.
With the associated source files, the following program can be built using the file
EXAMPLE2.MAK
found on the Driver488/W31 disk.
This example has two declarations that will be used later:
Declare Function FindWindow Lib “User” (ByVal data1$, ByVal data2$)As
Integer
Declare Function SendMessage Lib “User” (ByVal winHandle%,
ByValmessage%, ByVal wp%, ByVal lp As Long) As Integer
The following declarations are included in the General section of the form, and are assumed through
the remainder of the discussion:
Dim nl As String * 2
Dim mystring As String
Dim substat As IeeeStatus
Dim adc As Integer
Dim response As String * 256
Dim intResp(500) As Integer
Dim voltage As Single
Dim sum As Single
Dim noterm As terms
Dim sample As String * 7
For the sake of this discussion, assume that Driver488/W31 has been configured to start with a
configuration including the devices
IEEE
(IEEE 488 interface) and
ADC
(ADC488/8S connected to the
IEEE 488 interface). Additional interfaces and/or devices may also have been defined, as the driver
can support up to 4 interfaces and 56 devices simultaneously. To open the two devices of interest, we
use the following statements:
If the
ADC
was not configured within Driver488/W31, it can be optionally created “on the fly”, as
shown above. First
ioError
was used to
TURNOFF
automatic error reporting so that our application
can trap the error instead. If opening the name
ADC
failed, the handle of the device
wave
, which is
‘Open Driver488/W31
ieee% = OpenName(“IEEE”)
If (ieee% = -1) Then
MsgBox “Cannot initialize IEEE system”
End
End If
‘Open device named ADC
rv% = ioError (ieee%, TURNOFF)
devhandle% = OpenName (“wave”)
adc = OpenName(“ADC”)
If (adc = -1) Then
adc = MakeDevice(devhandle%, “ADC”)
If (adc = -1) Then
MsgBox “Can not initialize device ADC”
End
End If
End If
response = “”
rv% = GetError (1eee%, response)
rv% = BusAddress (adc, 14, -1)