beautypg.com

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

Page 101

background image

8I. Turbo Pascal

II. SOFTWARE GUIDES - 8. Driver488/DRV

II-86

Personal488 User’s Manual, Rev. 3.0

Writeln(IeeeOut,’OUTPUT 16;F0R0X’);

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:

VAR Reading: STRING;
Writeln(IeeeOut,’ENTER 16’);
Readln(IeeeIn,Reading);
Writeln(Reading);

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

Readln

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

program into the variable

Reading

.

Once the result has been received, any Turbo Pascal functions or statements can be used to modify or
interpret it. In this example, the result is in the form

NDCV+1.23456E-2

showing the range (

NDCV

)

and the numeric value of the reading (

+1.23456E-2

). The Turbo Pascal

Copy

function can be used to

strip off the range characters and keep only the numeric part (the fifth character and beyond), and the

VAL

procedure can be used to convert this string to a number:

VAR
voltage: REAL;
code: INTEGER;
Reading:=Copy(Reading,5,255);
Val(Reading,voltage,code);
Writeln(‘The read value is ‘,voltage);

These may be combined for efficiency:

Val(Copy(Reading,5,255),voltage,code);
Writeln(‘The read value is ‘,voltage);

All the power of Turbo Pascal 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:

VAR
sum: REAL;
i: INTEGER;
sum:=0.;
FOR i:=1 TO 10 DO BEGIN
Writeln(IeeeOut,’ENTER 16’);
Readln(IeeeIn,Reading);
Val(Copy(Reading,5,255),voltage,code);
sum:=sum+voltage;
END;
Writeln(‘The average of 10 readings is ‘,sum/10);

Buffer Transfers

Instead of using a

Readln(IeeeIn_)

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

Driver488/DRV to place the response directly into a data buffer of our choice. 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:

VAR r: ARRAY[0..1699] of CHAR;