![](/images/new-backgrounds/1213257/21325771x1.webp)
equipped with a National Instruments3 GPIB interface board, with National Instruments Universal Language Interface drivers loaded. The commands that control the GPIB are similar to Hewlett Packard4 HP Basic commands. Most other controller board manufacturers provide basic output and input statements for communicating messages to a GPIB instrument.
Before using any of these samples, ensure that the GPIB address is set to 7, the interface command set is SB, the ULI.EXE driver is loaded, and the switch is connected to the computer via a GPIB cable.
The GPIB commands provided in this section do not always show the terminating sequence <CR><LF>; however, it is implied.
Sending Commands
This example sets the SB switch to channel 6 and turns on all the external relay drivers.
'set up the interface card and drivers OPEN "GPIB0" FOR OUTPUT AS #1 OPEN "GPIB0" FOR INPUT AS #2 PRINT #1, "ABORT"
'set terminating character to CR LF sequence PRINT #1, "GPIBEOS OUT CR LF"
PRINT #1, "GPIBEOS IN CR LF"
'sample commands"close 6; xdrs255"
PRINT #1, "OUTPUT 07;CLOSE 6;XDRS 255" ' sample queries
PRINT #1, "OUTPUT 07;CLOSE?" PRINT #1, "ENTER 07"
INPUT #2, a PRINT "channel ",a
PRINT #1, "OUTPUT 07;XDRS?" PRINT #1, "ENTER 07"
INPUT #2, a
PRINT "driver state ",a
END
Serial Polling the Status Register
This example changes the channel setting and reads the status register continuously until the output has settled.
PRINT #1, "OUTPUT 07;csb" | ' clearing the status byte clears the settling |
bit |
|
PRINT #1, "OUTPUT 07;CLOSE 12" | ' change channel |
sr = 0 | ' initialize sr variable to enter the while loop |
WHILE ((sr AND 4 ) =0) | ' loop until settled bit is true |
PRINT #1, "SPOLL 07" | ' serial poll SB switch |
INPUT #2, sr |
|
3National Instruments is a trademark of National Instruments.
4Hewlett Packard is a registered trademark of
Programming Guide – 31