'**************************************************************************** 'Module GPIB 'This module contains I/O subroutines for the GPIB board. ' 'Zachary Wolf '9/20/95 '**************************************************************************** 'Keep the GPIB file number in a common block COMMON SHARED /gpib/ gpibinP%, gpiboutP% SUB gpibclr '**************************************************************************** 'This subroutine clears the GPIB system. It is primarily used with the 'extender boxes. ' 'Zachary Wolf '11/29/95 '**************************************************************************** 'Send the abort command to clear the system PRINT #gpiboutP%, "ABORT" END SUB SUB gpibclrdev (addr$) '**************************************************************************** 'This subroutine clears a given GPIB device. ' 'Input: ' addr$, GPIB address (in a string) of the device to clear ' 'Zachary Wolf '2/21/96 '**************************************************************************** 'Perform the device clear PRINT #gpiboutP%, "CLEAR " + addr$ END SUB SUB gpibin (addr$, msg$) '**************************************************************************** 'This subroutine inputs a message string from a given GPIB device. 'INPUT expects characters, as from a keyboard or file. Thus, reading 'the returned information into a string is a valid thing to do. Also, 'the returned information can be a mixture of numbers and letters (giving 'channels, units, etc.). Numeric values can be extracted from the string. ' 'Input: ' addr$, GPIB address (in a string) to get the message from ' msg$, the input message ' 'Zachary Wolf '2/21/96 '**************************************************************************** 'Input the message PRINT #gpiboutP%, "ENTER " + addr$ LINE INPUT #gpibinP%, msg$ END SUB SUB gpibinit (ieeein%, ieeeout%) '**************************************************************************** 'This subroutine opens the communication files to the GPIB board. It then 'clears and resets the board. ' 'Output: ' ieeein%, file for gpib input ' ieeeout%, file for gpib output ' 'Zack Wolf '2/22/94, 9/20/95 '**************************************************************************** 'Open a file to get data from the GPIB board. ieeein% = FREEFILE OPEN "\dev\ieeein" FOR INPUT AS #ieeein% 'Open a file to talk to the GPIB board. ieeeout% = FREEFILE OPEN "\dev\ieeeout" FOR OUTPUT AS #ieeeout% 'Reset the GPIB board. IOCTL #ieeeout%, "BREAK" PRINT #ieeeout%, "RESET" 'Enable no data available error detection. PRINT #ieeeout%, "FILL ERROR" 'Set the timeout period PRINT #ieeeout%, "TIME OUT 20" 'Display a message PRINT PRINT "Resetting the GPIB..." 'Display software information PRINT #ieeeout%, "HELLO" LINE INPUT #ieeein%, a$ PRINT a$ 'Display the status PRINT #ieeeout%, "STATUS" LINE INPUT #ieeein%, a$ PRINT a$ 'Save the file info gpibinP% = ieeein% gpiboutP% = ieeeout% END SUB SUB gpibout (addr$, cmd$) '**************************************************************************** 'This subroutine outputs a command string to a given GPIB device. ' 'Input: ' addr$, GPIB address (in a string) to send the command to ' cmd$, command to send to the device ' 'Zachary Wolf '2/21/96 '**************************************************************************** 'Send the command PRINT #gpiboutP%, "OUTPUT " + addr$ + ";" + cmd$ END SUB SUB gpibspoll (addr$, value$) '**************************************************************************** 'This subroutine does a serial poll on a given GPIB device. 'The GPIB system returns a number between 0 and 255 representing the '8 bit value. This is converted to a string to have a consistent interface. 'The value can be extracted with the VAL() command. ' 'Input: ' addr$, GPIB address (in a string) of the device to serial poll ' value$, the numeric value of the 8 bits returned from the device ' 'Zachary Wolf '2/21/96 '**************************************************************************** 'Perform the serial poll PRINT #gpiboutP%, "SPOLL " + addr$ INPUT #gpibinP%, value$ END SUB SUB gpibterm (termin$, termout$) '**************************************************************************** 'This subroutine sets the input and output GPIB terminators. ' 'Input: ' termin$, input terminator ' termout$, output terminator ' 'Zachary Wolf '2/21/96 '**************************************************************************** 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN " + termin$ PRINT #gpiboutP%, "TERM OUT " + termout$ END SUB SUB gpibtimeout (nseconds%) '**************************************************************************** 'This subroutine sets the GPIB time-out period. ' 'Input: ' nseconds%, time-out period in seconds ' 'Zachary Wolf '5/21/96 '**************************************************************************** 'Send the command PRINT #gpiboutP%, "TIME OUT " + LTRIM$(STR$(nseconds%)) END SUB SUB gpibtrigger (addr$) '**************************************************************************** 'This subroutine sends a trigger signal to a given GPIB device. ' 'Input: ' addr$, GPIB address (in a string) to send the command to ' 'Zachary Wolf '2/29/96 '**************************************************************************** 'Send the command PRINT #gpiboutP%, "TRIGGER " + addr$ END SUB