beautypg.com

Use of external devices, Extensions for multiple interfaces – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual

Page 220

background image

II. SOFTWARE GUIDES - 10. Driver488/W31

10C. External Device Interfacing

Personal488 User’s Manual, Rev. 3.0

II-205

Use of External Devices

When using subroutine Application Program Interface (API) functions, it is first necessary to obtain a
device handle for the device(s) with which you wish to interact.

When using Driver488/W31, the

OpenName

function must be the first function called in the program.

It takes the name of the device to open and returns a handle for the specified interface board or device.
Every other function can then use that handle to access the device.

The following program illustrates how Driver488/W31 might communicate with an analog-to-digital
converter (

adc

) and an oscilloscope (

scope

):

DevHandleT ieee;

// handle to access the interface board ieee

DevHandleT adc;

// handle to access a ADC488

DevHandleT scope;

// handle to access the scope

DevHandleT deviceList[5];

// array containing a list of device handles;

int err;

Communication with a single device:

adc = OpenName (“ADC”);

If you use several devices, you must open each one.

ieee = OpenName(“IEEE”);
scope = OpenName(“SCOPE”);

// Add adc to the list of devices

deviceList[0] = adc;

// Add oscilloscope to the list of devices

deviceList[1] = scope

// End of list marker

deviceList[2] = -1;

Abort(ieee);

// Send Interface Clear (IFC)

Output(scope,"SYST:ERR?");

// Read SCOPE error status

Enter(scope,data);
printf(data);

Output(adc,"A0 C1 G0 R3 T0 X");

// Set up ADC488

Enter(adc,data);
printf(data);

ClearList (deviceList) ;

// Send a Selected Device Clear (SDC) to a list

Close (adc) ;

// Close ADC488. Handle is now unavailable for
// access.

If we tried to call

Output

by sending the handle

adc

without first opening the name

ADC

, an error

would result and

Output

would return a

-1

as shown below:

result = Output (adc, “A0 C1 G0 R3 T0 X”);
printf (“Output returned: %d.\n”,result);

should print:

Output returned: -1.

As mentioned above, named devices have another advantage: they automatically use the correct bus
terminators and time out. When a named device is defined, it is assigned bus terminators and a time
out period. When communicating with that named device occurs, Driver488/W31 uses these
terminators and time out period automatically. Thus

Term

commands are not needed to reconfigure the

bus terminators for devices that cannot use the default terminators (which are usually carriage-return
line-feed

EOI

). It is still possible to override the automatic bus terminators by explicitly specifying the

terminators in an

Enter

or

Output

command, or to change them semi-permanently via the

Term

command. For more information, see the

Enter

,

Output

, and

Term

commands described in

“Section III: Command References.”

Extensions For Multiple Interfaces

Driver488/W31 allows the simultaneous control of multiple interfaces each with several attached
devices. To avoid confusion, external devices may be referred to by their “full name” which consists of
two parts. The “first name” is the hardware interface

name

, followed by a colon separator (

:

). The

“last name” is the external device

name

on that interface. For example, the “full name” of

DMM

might

be

IEEE:DMM

.