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

9G. Pascal
II. SOFTWARE GUIDES - 9. Driver488/SUB
II-168
Personal488 User’s Manual, Rev. 3.0
The following declarations are assumed throughout the remainder of this discussion.
var
adc,ieee,dev,adc2 : Integer;
{ Device handles }
code : Integer;
{ Return Code }
hundred : array [0..99] of Integer;
{ Driver488/SUB status structure }
response : string;
{ Text buffer for Driver488/SUB responses }
i: Integer;
{ General purpose loop counter }
voltage : Real;
{ Single reading variable }
sum : Real;
{ Summation used to compute average }
substat : IeeeStatusrec;
{ Driver488/SUB status structure }
nilptr : pointer;
{ General purpose pointer }
lrv : Longint;
{ General purpose long return value }
sp,stadc,
{ Driver488/SUB and ADC488 spoll response }
errnum : Integer;
{ ADC488 error number }
errtext : string;
{ ADC488 error response }
Establishing Communications
For the sake of this discussion, assume that Driver488/SUB has been configured to start with a
configuration including the devices
IEEE
(IEEE 488 interface) and
ADC
(an 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 four interfaces and 56 devices simultaneously. To open the two devices of interest,
we use the following statements:
ieee: = ioOpenName (‘IEEE’);
adc: = ioOpenName (‘ADC’);
If the
ADC
was not configured within Driver488/SUB, it can be optionally created “on the fly.” First,
verify that opening the
ADC
failed, then use the
GetError
command to clear the error condition
generated by this failure. Next, use the handle of the device
DEVIEEE
, which is always available within
Driver488/SUB, to clone a new device called
ADC
using the
MakeDevice
command. Lastly, the IEEE
bus address
14
is assigned to the
ADC
:
if adc = -1 then begin
rv: = ioGetError (ieee, response);
dev: = ioOpenName (‘DEVIEEE’);
adc: = ioMakeDevice (dev,’ADC’);
rv: = ioBusAddress (adc,14,-1);
end;
If other devices were needed for the application at hand, they could either be defined in the startup
configuration for Driver488/SUB or they could be created “on the fly” from the application:
dev: = ioOpenName (‘DEVIEEE’);
adc2: = ioMakeDevice (dev,’ADC2’) ;
rv: = ioBusAddress (adc2,14,-1) ;
The new device
ADC2
is configured to reside at a different bus address so that the two devices may be
distinguished. There is one other important difference between
ADC
and
ADC2
at this point.
ADC2
is a
temporary device; that is, as soon as the creating application closes,
ADC2
ceases to exist. If our intent
was to create a device that could be accessed after this application ends, we must tell Driver488/SUB
this:
rv: = ioKeepDevice (adc2);
After executing the above statement,
ADC2
is marked as being permanent; that is, the device will not be
removed when the creating application exists. If we later wish to remove the device, however, we can
do so explicitly:
rv: = ioRemoveDevice% (adc2);