beautypg.com

Configuration of the 195 dmm, Taking readings, Buffer transfers – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual

Page 72

background image

II. SOFTWARE GUIDES - 8. Driver488/DRV

8E. Microsoft C

Personal488 User’s Manual, Rev. 3.0

II-57

Configuration of the 195 DMM

Once the system is initialized we are ready to start issuing bus commands. The IEEE 488 bus has
already been cleared by the Interface Clear (

IFC

) sent by the

RESET

command, so we know that all bus

devices are waiting for the controller to take some action. To control an IEEE 488 bus device, we
output an appropriate device-dependent command to that device. For example, the

F0R0X

command

line below sets the 195 to read DC volts with automatic range selection:

ieeewt(“output 16;F0R0X\n”);

The

OUTPUT

command takes a bus device address (

16

in this case) and data (

F0R0X

) and sends the data

to the specified device. The address can be just a primary address, such as

12

, or

05

, or it can include

a secondary address:

1201

. Note that both the primary address and, if present, the secondary address

are two-digit decimal numbers. A leading zero must be used, if necessary to make a two-digit address.

Taking Readings

Once we have set the 195’s operating mode, we can take a reading and display it:

float voltage;
ieeewt(“enter 16\n”);
ieeescnf(“%*4s%e”,&voltage);
printf(“The read value is %g\n”,voltage);

The

ENTER

command takes a bus address (with an optional secondary address) and configures that bus

device so that it is able to send data (addressed to talk). No data is actually transferred, however, until
the

IEEESCNF

statement requests the result from Driver488/DRV at which time data is transferred to

the program into the variable

voltage

. A typical reading from a 195 might be

NDCV+1.23456E-2

,

consisting of a four character prefix followed by a floating point value. The format passed to

IEEESCNF

causes it to skip the four character prefix (

%*4s

) and then convert the remaining string into

the float variable

voltage

.

All the power of C may be used to manipulate, print, store, and analyze the data read from the
IEEE 488 bus. For example, the following statements print the average of ten readings from the 195:

Buffer Transfers

Instead of using an

IEEERD(_)

function to receive the data from a device, we can direct

Driver488/DRV to place the response directly into a data buffer of our choosing. For example, each
reading from the 195 consists of 17 bytes: a four-byte prefix and an eleven-byte reading followed by
the two-byte command terminator. So, we can collect 100 readings in a 1700-byte array. To do this,
we must first allocate the required space in an array:

char hundred[1700];

Now that we have allocated a place for the readings, we can direct Driver488/DRV to put readings
directly into

hundred

with the

ENTER #count BUFFER

command:

ieeeprtf(“ENTER 16 #1700 BUFFER %d:%d\n”,
segment(hundred),offset(hundred));

This command consists of the keyword

ENTER

, followed by the bus device address (

16

), a number sign

(

#

), the number of bytes to transfer (

1700

), and the keyword

BUFFER

, followed by the memory address

of the buffer. The buffer address is specified as

segment:offset

where

segment

and

offset

are

int i;
float sum;
sum=0.0;
for (i=0; i<10; i++) {
ieeewt(“enter 16\n”);
ieeescnf(“%*4s%e”,&voltage);
sum=sum+voltage;
}
printf(“The average of 10 readings is %g\n”,sum/10.0);