Use of external devices, Direct i/o with dos devices – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual
Page 63

8C. External Device Interfacing
II. SOFTWARE GUIDES - 8. Driver488/DRV
II-48
Personal488 User’s Manual, Rev. 3.0
are normally temporary. They are forgotten as soon as the program finishes. The
KEEP DEVICE
and
KEEP DOS NAME
commands can be used to make these devices permanent. The
REMOVE DEVICE
and
REMOVE DOS NAME
commands remove 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
Once we have configured the external devices, we can refer to devices by name. For example, using
the Character Command Language, the following program allows Driver488/DRV to communicate
with a digital multimeter:
200 PRINT#1,"CLEAR DMM"
210 PRINT#1,"OUTPUT DMM;VDC"
220 PRINT#1,"ENTER DMM"
230 INPUT#2,VOLTAGE
300 PRINT#1,"TRIGGER SCOPECMD"
320 PRINT#1,"ENTER SCOPE #1000 BUFFER 11";DS%;":";VARPTR(ARRAY)
In these commands we
CLEAR
the
DMM
, configure it for DC volts, take a reading and store it in the
variable
VOLTAGE
. Next, we
TRIGGER
the
SCOPE
at its command address and then read from its binary
data channel into an array. While these commands are hypothetical, they show how device names can
be used wherever a device address is allowed.
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 communication with that named device occurs, Driver488/DRV uses these
terminators and time out period automatically. Thus
TERM
statements 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. For more information, see the
ENTER
,
OUTPUT
, and
TERM
commands described in “Section III: Command References.”
Direct I/O with DOS Devices
DOS Devices can be opened as files for direct communication. For example, we can configure two
names to refer to a plotter with an IEEE 488 bus address of
05
:
400 PRINT #1,"MAKE DEVICE PLOTTER BUSADDRESS 05"
410 PRINT #1,"MAKE DOS NAME PLOT=PLOTTER"
420 PRINT #1,"MAKE DOS NAME PLOTIN=PLOTTER"
Then we can open them, one for input and one for output:
430 OPEN “PLOT” FOR OUTPUT AS #3
440 OPEN “PLOTIN” FOR INPUT AS #4
Two different names are used to communicate with the plotter because, in BASIC, the same file cannot
be used for both input and output. In other languages, it might be possible to use the same file (with the
same device name) for both input and output. Also note that BASIC normally has a limit of 3 open
files. To open more than 3 files (as in this example; 2 for Driver488/DRV commands, and 2 for the
plotter), BASIC must be started with the parameter
/F:n
(where
n
is the number of files). See your
BASIC manual for more details.
For clarity, the DOS Device names are not the same as External Device names. In normal use, one of
the DOS Device names might be chosen to be the same as an External Device name to show that they
communicate with the same External Device. Of course, the two DOS Device names must be different.
Once the files are opened, we can communicate
commands to the plotter and
INPUT
responses
from the plotter without using the Driver488/DRV
OUTPUT
or
ENTER
commands. When a named
device is used as a file, the
OUTPUT
and
ENTER
commands occur automatically.
500 PRINT#3,"IN; SP1; PA1000,1000;" ‘Send plot commands
510 PRINT#3,"OE;" ‘Request plotter status
520 INPUT#4,ST$ ‘Read plotter status