Sample Programs
Appendix H
GPIB-232CT User Manual
H-6
© National Instruments Corp.
Programming Steps
Step 1.
stat
Function
In BASIC, before reading or writing to the serial port, a device must be
opened
. Place the following BASIC statement at the beginning of your
program to open and configure the serial port (COM1) and name it device
#1
.
OPEN "COM1:9600,n,7,1" as #1
You will now use
PRINT #1
to redirect strings to the serial port.
Now, send the
stat
function if you want status information returned after
every programming message. To do this, include the following code in
your program:
PRINT #1, "stat c n"
After you send this programming message, you can expect four lines of
data at the serial port (each line is terminated by <CR><LF>). For now,
call a subroutine to check the status. You can write this later. Add the
following line to call the subroutine:
GOSUB
status
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.