Configuring Your GPIB Driver to Match Your System


One of the most common problems that a GPIB software developer has is configuring the software to match the requirements of each test system. Because one driver operates with a variety of systems, configuring your driver must be easy. National Instruments NI-488 software offers several methods of configuration so you can choose the method that is best for your application. This document describes each of the configuration methods available with the NI-488 MS-DOS software.


GPIB Configuration Options

There are three methods using the NI-488 software for changing the default configuration options of your system. They are as follows:

  • Run the configuration utility IBCONF.
  • Execute a special batch file (.BAT) that changes the IBCONF file dynamically.
  • Use special configuration functions from within your application program.

The following sections explain the methods for changing the driver configuration characteristics and the advantages of each method.


Method 1: The Configuration Utility IBCONF

IBCONF.EXE is a screen oriented, interactive program that passes two groups of features to the driver. The first group consists of the characteristics of the devices attached to the GPIB interface. Each device has the following characteristics:

  • A symbolic name (such as DEV5, PLOTTER, or METER).
  • A primary GPIB address and, if used, a secondary address.
  • A time limit imposed when executing certain functions. This time limit ensures that transfers do not hang up the GPIB indefinitely.
  • A data termination method when executing device calls–by an End-Of-String (EOS) character, an End Or Identify (EOI) signal, and/or byte count.
  • An enable or disable repeat addressing parameter for back-to-back function calls to a device.

The second group consists of the characteristics of each GPIB interface board in the computer. The NI-488 driver can control up to two GPIB interface boards. Each GPIB interface board has the following characteristics:

  • A symbolic name (either GPIB0 or GPIB1).
  • A primary GPIB address and, if used, a secondary address.
  • The capacity to be designated as the System Controller of the devices on its bus and specific actions to perform as System Controller.
  • A time limit when executing certain functions.
  • A GPIB data termination method when executing board functions–by an EOS character, an EOI signal, and/or byte count.
  • An interrupt line that the board uses, if any.
  • A DMA channel that the board uses, if any.
  • Timing speed (T1 delay) when transferring data.

The advantages to executing and modifying IBCONF manually are that you have total flexibility in configuring each device, and you do not have to add configuration code to each application program.


Method 2: IBCONF Batch Mode

The IBCONF batch mode offers an alternate method for modifying the configuration parameters of the NI-488 driver. In batch mode, the configuration information is contained in a configuration file that you create. To load the configuration information from the file that you have created, you type the following command:

ibconf -b filename <Enter>

where filename is the name of the configuration file, for example, sample.cfg. There must be at least one space between -b and filename.

You will not see the IBCONF device map, but will see a prompt requesting to update the loaded GPIB driver in memory. Answering yes eliminates the need to reboot the computer after the changes are made. However, you can eliminate the prompt so that the driver is automatically updated by executing IBCONF with the -d option. This automatically configures the loaded version of the driver.

Batch mode is useful for both GPIB developers that distribute executable programs and GPIB end users. For developers that have an installed base of programs, using this batch mode of IBCONF is an easy way to ensure proper configuration without having to make any changes to their existing programs. The user simply executes the batch file and the GPIB devices are automatically configured. Programmers can develop batch files for each of their programs.

The batch file can be edited using any text editor. The batch file is a free-form text file consisting of pairs of items. Each item must be separated by at least one space or new line character–this is the only format restriction. The first item of a pair is a mnemonic that represents a board or device characteristic, or a board/device map configuration function (for example, rename, connect, disconnect) to be configured. The second item of a pair is the value to which the first item (mnemonic) should be set. For example, to rename dev8 in the device map to scanner, enter the following line of code in the batch file:

To enable automatic serial polling for gpib0, enter the following line of code:

find board0 spoll yes

All the characteristics found in the actual IBCONF file can be altered using the batch mode method, including the base I/O address, interrupt setting, and DMA channel. You can also connect and disconnect devices from the GPIB interface boards just as you can do using the IBCONF device map. Table 1 contains a list of all the valid pairs of configuration items. Any value that can be entered as a number can be entered in decimal or hexadecimal. Hexadecimal numbers must be preceded with 0x (for example, decimal 64 would be written as 0x40).

Table 1. Batch Mode Command Pairs
First Item
Second Item
find find board or device board# or device#
pad primary GPIB address number
sad secondary GPIB address number
tmo timeout settings number or mnemonic
eos EOS byte number
reos terminate read on EOS yes or no
xeos set EOI with EOS on write yes or no
bin type of compare on EOS 7-bit or 8-bit
eot set EOI with last byte of write yes or no
sc system controller (board only) yes or no
sre assert REN when SC (board only) yes or no
spoll enable auto serial polling (board only) yes or no
tmng timing (board only) 2usec, 500nsec,
e488_2 enable 488.2 protocols (board only) yes or no
cic_prot CIC protocol (board only) yes or no
int interrupt setting (board only) number
port base I/O address (board only) number
dma DMA channel (board only) number
raddr repeat addressing (device only) yes or no
name rename a device (device only) device name
connect connect a device to a board (device only) board#
disconnect disconnect a device from a board (device only) no value
type switch the current board to PC2 or PC2A mode pc2 or pc2a

The following example is a sample configuration file along with a step-by-step explanation of each entry.

Example: scanner.cfg sample configuration file

Requirements :

  1. Change the name of the first device to scanner.
  2. Change the name of the third device to scope.
  3. Change the configuration of board0 (gpib0).
    • Primary address to 2 (pad 2)
    • Timeout setting to T30s (tmo T30s)
    • EOS byte to hex 1E (eos 0x1E)
    • System Controller capability to NO (sc no)
    • Type of compare on EOS to 8-bit (bin 8-bit)
    • GPIB bus timing speed to 350 nsec (tmng 350nsec)

Configuration File :


Method 3: Special Configuration Functions

A third method for configuring devices is to dynamically configure them within the application program using special configuration functions. As described earlier, configuring a GPIB system requires knowledge of the bus and of the devices to which it is connected. Developers of application software can dynamically configure the driver so that novice users do not have to understand or edit IBCONF. This method is also ideal for running many different system configurations with the same GPIB interface board. Configuration changes made in the program only apply while the program is running. Upon termination, the configuration parameters are restored to their original settings. This method of configuration is not only more efficient, but also makes it very easy, because it comes in the form of subroutine function calls.

The IBCONFIG Function
By using the most powerful configuration function, ibconfig, you can dynamically configure all the software parameters found in IBCONF by simply adding ibconfig function calls to the application program. You can ensure that the driver is configured correctly regardless of the settings in IBCONF. The configuration parameters of ibconfig can be divided into two groups: board parameters and device parameters. Board parameters, for example, enable/disable hardware interrupts or enable/disable automatic serial polling. Device parameters can enable/disable repeat addressing.

You can also select primary and secondary addressing, timeout, and End-Of-String termination using ibconfig. However, the traditional NI-488 configuration functions ibpad (change primary address), ibsad (change secondary address), ibtmo (change timeout setting), ibeos (set End-Of-String character), and ibeot (set END termination message) are still supported. The following portion of code shows how the ibconfig function is used.

REM QuickBASIC 4.5 Example
REM The following code sets up a device for GPIB operation. 
REM $INCLUDE: 'qbdecl.bas' 
CALL ibfind ("dev1", dev%)

REM Change primary address to 7. 
option% = IbcPAD:value% = 7 
CALL ibconfig(dev%, option%, value%)

REM Change timeout to 10 seconds. 
option% = IbcTMO:value% = 13 
CALL ibconfig (dev%, option%, value%)

The IBLN Function
The ibln function checks for a Listener at the specified address. This is similar to the NI-488.2™ routine FindLstn, except that the parameter is a single device address, not an array of addresses. ibln is useful for scanning several addresses to find out which Listeners are on the bus. Once you know what the address is, you can use ibconfig to change the primary address of that device in the driver.

The following portion of QuickBASIC code scans for Listeners at all GPIB primary addresses (with no secondary addresses) on the bus and reports which devices were found.

REM $INCLUDE: 'qbdecl.bas' 
DIM Device%(30) 
cnt% = 0 
REM The following call opens dev1 as a generic device. 
REM You need a unit descriptor to call ibln.
CALL ibfind("dev1", dev%) 
REM Because you are not looking for secondary addresses, set 
REM the sad parameter to 0. sad% = 0 
REM Now scan the 30 possible primary addresses.  Notice that 
REM you are not checking address 0 because it is the default
REM address of the GPIB Controller, which should always be 
REM listening.
FOR i% = 1 to 30

CALL ibln(dev%, i%, sad%, listen%)

REM Check the response to see if a Listener is present at the 
REM address specified by i%.  If a device is listening, save
REM the address into the array Device%(), which is a listing
REM of all active Listeners. 
REM Increment the count as each Listener is found.

IF listen% = 1 THEN
Device%(cnt%) = i%
cnt% = cnt% + 1

REM Now print out the active addresses.
PRINT "Devices are present at the following addresses" 
FOR j% = 0 to cnt% - 1 
PRINT "A device is at GPIB Address "; Device%(j%) 

The IBDEV Function
In traditional NI-488 applications, the ibfind function is used to open devices for communication. ibfind returns a number (the unit descriptor) so GPIB calls can be made to that device. To use ibfind, however, the device name must be pre-configured in IBCONF, otherwise, ibfind will fail. As you can see, this is a shortcoming if you do not know the device name.

By using the ibdev function instead of the ibfind function, you can open and initialize a device without knowing its name. ibdev is similar to ibfind, except you do not pass a device name as one of the arguments in the function. ibdev simply opens the first unopened user-configurable device that it finds and returns a unit descriptor that is used in ibconfig, ibln, and all other device-level calls. After calling ibdev to obtain a unit descriptor, you may also need to call ibconfig to configure communication characteristics not configured using ibdev.

An example of how to use ibdev is shown below.

REM bd.index% is either 0 for gpib0 or 1 for gpib1. 
bd.index% = 0
REM pad% is the primary address of the device you wish to
REM open. Suppose that in the above program, you determine 
REM that there was one listening device at address 7. 
pad% = Device%(0) : sad% = 0 
REM For the other parameters that must be specified, set 
REM the timeout to 10 seconds, enable the END message on 
REM writes, and disable any EOS termination. 
tmo% = 13 : eot% = 1 : eos% = 0 
REM When calling ibdev, the value returned in ud% is the 
REM unit descriptor. 
CALL ibdev(bd.index%, pad%, sad%, tmo%, eot%, eos%, ud%)



This document has described two alternate methods for configuring a GPIB system other than the traditional IBCONF method: the batch mode method and the programming method. Both of these new methods transparently configure the driver with little or no effort from the end user. Using batch mode, you can create a batch file that configures the settings in IBCONF without an end user having to actually edit the IBCONF file. Using NI-488 configuration functions, you can dynamically configure the driver by adding functions to the program. Three of the most powerful NI-488 configuration functions (ibconfig, ibln, and ibdev) can find a particular Listener and change all the configuration settings found in IBCONF within your application program.