Sign In
Celebrating 50years
divider line

IEEE-488 Interface Program In Quick Basic

GPIB Board Installation

1.  Install GPIB-PCII/IIA card using National Instruments instructions.

2.  Install NI-488.2 software (for DOS). Version 2.1.1 was used for the example.

3.  Verify that config.sys contains the command: device = \gpib-pc\gpib.com.

4.  Reboot the computer.

5.  Run IBTEST to test software configuration. Do not install the instrument before running IBTEST.

6.  Run IBCONF to configure the GPIB-PCII/IIA board and dev 12. Set the EOS byte to 0AH. See Figure 1. IBCONF modifies gpib.com.

7.  Connect the instrument to the interface board and power up the instrument. Verify address as 12 and terminators as CR LF.


NI GPIB Setup 

Figure 1. Typical National Instruments GPIB Configuration from IBCONF.EXE


Quick Basic Program

The IEEE-488 interface program below works with QuickBasic 4.0/4.5 or Qbasic on an IBM PC (or compatible) running DOS or in a DOS window. It assumes your IEEE-488 (GPIB) card is installed and operating correctly (refer to above paragraph). Use the following procedure to develop the Serial Interface Program in Quick Basic.


1.  Copy c:\gpib-pc\Qbasic\qbib.obj to the QuickBasic directory (QB4).

2.  Change to the QuickBasic directory and type: link /q qbib.obj,,,bqlb4x.lib; where x = 0 for QB4.0 and 5 for QB4.5 This one-time only command produces the library file qbib.qlb. The procedure is found in the National Instruments QuickBasic readme file Readme.qb.

3.  Start QuickBasic. Type: qb /l qbib.qlb. Start QuickBasic in this way each time the IEEE interface is used to link in the library file.

4.  Create the IEEE example interface program in QuickBasic. Enter the program exactly as presented in Table 1. Name the file "ieeeexam.bas" and save.

5.  Run the program.

6.  Type a command query as described in your instrument User's Manual, in the chapter called Remote Interface.

7.  Type "EXIT" to quit the program.



Table 1. Sample Quick Basic IEEE-488 Interface Program (See GPIB_QB.TXT)




'      This program works with QuickBasic 4.0/4.5 on an IBM PC or compatible.


'      The example requires a properly configured National Instruments GPIB-PC2 card. The REM

'      $INCLUDE statement is necessary along with a correct path to the file QBDECL.BAS.

'      CONFIG.SYS must call GPIB.COM created by IBCONF.EXE prior to running Basic. There must

'      be QBIB.QBL library in the QuickBasic Directory and QuickBasic must start with a link

'      to it. All instrument settings are assumed to be defaults: Address 12, Terminators

'      <CR> <LF> and EOI active.


'      To use, type an instrument command or query at the prompt. The computer transmits to

'      the instrument and displays any response. If no query is sent, the instrument responds

'      to the last query received. Type "EXIT" to exit the program.


       REM $INCLUDE: 'c:\gpib-pc\qbasic\qbdecl.bas'        'Link to IEEE calls

       CLS                                                 'Clear screen




       CALL IBFIND("dev12", DEV12%)                         'Open communication at address 12

       TERM$ = CHR$(13) + CHR$(10)                          'Terminators are <CR><LF>


LOOP2: IN$ = SPACE$(2000)                                   'Clear for return string


       LINE INPUT "ENTER COMMAND (or EXIT):"; CMD$          'Get command from keyboard

       CMD$ = UCASE$(CMD$)                                  'Change input to upper case

           IF CMD$ = "EXIT" THEN END                        'Get out on Exit

       CMD$ = CMD$ + TERM$


       CALL IBWRT(DEV12%, CMD$)                             'Send command to instrument


       CALL IBRD(DEV12%, IN$)                               'Get data back each time


       ENDTEST = INSTR(IN$, CHR$(13))                       'Test for returned string

           IF ENDTEST > 0 THEN                              'String is present if <CR> is seen

               IN$ = MID$(IN$, 1, ENDTEST - 1)              'Strip off terminators

               PRINT "RESPONSE:", IN$                       'Print return string


               PRINT "NO RESPONSE"                          'No string present if timeout

           END IF

       GOTO LOOP2                                           'Get next command