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

9E. C Languages
II. SOFTWARE GUIDES - 9. Driver488/SUB
II-152
Personal488 User’s Manual, Rev. 3.0
#include “iotmc60.h”
•
For Turbo C++ and Borland C++ compilers:
#include “iottx10.h”
#include “iot_main.h”
Notice that the header file
iot_main.h
must be in the module containing your
main ( )
function and
may not appear in any other modules.
The following declarations are assumed through the remainder of this discussion:
DevHandleT adc,adc2,ieee,dev; /*Device handles*/
int hundred [100];
/*Driver488/SUB status structure*/
char response [256];
/*Text buffer for Driver488/SUB responses*/
int i;
/*General purpose loop counter*/
float voltage;
/*Single reading variable*/
float sum;
/*Summation used to compute average*/
IeeeStatusT substat;
/*Driver488/SUB status structure*/
int sp, stadc;
/*Driver488/SUB and ADC488 spoll response*/
int errnum;
/*ADC488 error number*/
char errtext [64];
/*ADC488 error response*/
TermT noterm;
/*Driver488 terminator structure*/
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
(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:
ieee = OpenName (“IEEE”) ;
adc = OpenName (“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=OpenName (“ADC”))==-1) {
GetError (ieee,response);
dev=OpenName (“DEVIEEE”);
adc=MakeDevice (dev,”ADC”);
BusAddress (adc,14,-1);
}
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:
adc2=MakeDevice (adc,”ADC2”) ;
/ *Clone a new device */
BusAddress (adc2,10,-1) ;
// Set the bus address
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:
KeepDevice (adc2) ;
After executing the previous 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:
RemoveDevice (adc2) ;