Appendix H
Sample Programs
© National Instruments Corp.
H-9
GPIB-232CT User Manual
Programming Steps
Step 1.
stat
Function
In Applesoft BASIC, you must redirect input and output to the serial port
before attempting to communicate with the GPIB-232CT. Place the
following statements at the beginning of your program:
D$ = CHR$(4)
D$,"PR#1"
D$,"IN#1"
Step 2. Serial Port Functions
Send serial port initialization programming messages, if necessary. For this
example, this step is not necessary.
Step 3. GPIB Initialization Functions
Send GPIB initialization programming messages, if necessary. For this
example, this step is not necessary.
Step 4. Communicate with
rd
and
wrt
Functions
Communicate with the device using
rd
and
wrt
programming messages.
Here is the heart of the program:
10 D$ = CHR$ (4)
20 PRINT D$; "PR#2": REM INPUT FROM SLOT #2 (MODEM)
30 PRINT D$; "IN#2": REM OUTPUT TO SLOT #2 (MODEM)
40 PRINT
60 PRINT "WRT 6":
REM WRITE STRING TO DEVICE 6
70 PRINT "CTT?;"
90 PRINT "RD 20 6": REM READ UP TO 20 BYTES FROM
95
REM DEVICE 6
100 INPUT "";RESP$:
REM INPUT FREQUENCY AND BYTE
105
REM COUNT
110 PRINT D$;"PR#0": PRINT RESP$: PRINT D$;"PR#2"
140 PRINT D$;"PR#0"