beautypg.com

Use of external devices – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual

Page 159

background image

9C. External Device Interfacing

II. SOFTWARE GUIDES - 9. Driver488/SUB

II-144

Personal488 User’s Manual, Rev. 3.0

scope = MakeDevice (dev,”SCOPE”);
if (scope == -1) {process error . . .}
err = BusAddress (scope,12,01);
if (err == -1) {process error . . .}
term.EOI = TRUE;
term.nChars = 0;
err = Term (scope,&term,BOTH);
if (err == -1) {process error. . .}

The above example defines the following: An external device named

DMM

(digital multimeter) as

device

16

with bus terminators of carriage return (

\r

), line feed (

\n

), and

EOI

; a second external

device named

ADC

(analog-to-digital converter) as device

14

with bus terminators of carriage return

and line feed (together as

\n

); and a third external device named

SCOPE

(oscilloscope) as device

12

with bus terminators of

EOI

only.

External devices defined in a configuration file are permanent. Their definitions last until they are
explicitly removed or until the configuration file is changed and Driver488/SUB is restarted. Devices
defined after installation are normally temporary. They are forgotten as soon as the program finishes.
The

KeepDevice

command can be used to make these devices permanent. The

RemoveDevice

command removes the definitions of devices even if they are permanent. These commands are
described in further detail in the “Section III: Command Reference” of this manual.

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/SUB, 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/SUB 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 acess 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”) ;
deviceList [0] = adc;

// Add adc to the list of devices

deviceList [1] = scope

// Add oscilloscope to the list of devices

deviceList [2] = -1 ;

// End of list marker

Abort(ieee) ;

// Send Interface Clear (IFC)

Output(scope, “SYST:ERR:?”);

// Read SCOPE error status

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

adc = MakeDevice (dev, “ADC”);
if (a == -1) {process error . . . }
err = BusAddress (adc,14,00);
if (err == -1) {process error . . .}
term,EOI = FALSE;
term.nChars = 1;
term.termChar [0] = ‘\n’;
err = Term (adc,&term,BOTH);
if (err == -1) {process error . . .}