Buffer transfers – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual
Page 83

8G. QuickBASIC
II. SOFTWARE GUIDES - 8. Driver488/DRV
II-68
Personal488 User’s Manual, Rev. 3.0
and the numeric value of the reading (
+1.23456E-2
). The BASIC
MID$
function can be used to strip
off the range characters and keep only the numeric part (the fifth character and beyond), and the
VAL
function can be used to convert this string to a number:
740 N$=MID$(R$,5)
741 N=VAL(N$)
742 PRINT “The read value is”;N
These may be combined for efficiency:
740 PRINT “The read value is”;VAL(MID$(R$,5))
All the power of BASIC 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:
810 SUM=0
820 FOR I=1 TO 10
830 PRINT#1,"ENTER 16"
840 INPUT#2,R$
850 SUM=SUM+VAL(MID$(R$,5))
860 NEXT I
870 PRINT “The average of ten readings is”;SUM/10
Buffer Transfers
Instead of using an
INPUT#2
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 string.
To do this, we must first allocate the required space in a string variable:
910 R$=SPACE$(1700)
And then we must tell Driver488/DRV where
R$
is located in memory.
In QuickBASIC 4.0, the
VARSEG
function allows us to determine the segment address of a variable.
DS%=VARSEG(R$)
Now that we know the segment address of
R$
, we can get its offset address by using
SADDR
:
RDESC=0
RDESC=SADDR
Notice that we first create
RDESC
by setting it to zero. This prevents
R$
from being moved as a result
of creating
RDESC
after calling
SADDR
.
Now we have the segment and offset of
R$
, we can pass it directly to Driver488/DRV with the
ENTER #count BUFFER
command:
PRINT#1,"ENTER16 #1700 BUFFER"; DS%; “:”;RDESC
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
each 16-bit numbers and the colon (
:
) is required to separate them. The
segment
value we need, is the
BASIC data segment value that we have just acquired into
DS%
with
GET.SEGMENT
. The
offset
value is the offset of the string in that data segment, which is
RDESC
.
Once the data has been received, we can print it out:
980 PRINT R$
The program can continue with other work while the transfer occurs. For example, the program could
process the previous set of data while collecting a new set into a different buffer. To allow the program
to continue, specify
CONTINUE
in the command:
PRINT#1,"ENTER16 #1700 BUFFER"; DS%; “:”;RDESC; “CONTINUE”