spec

Software for Diffraction

nigpib

National Instruments GPIB Controllers

DESCRIPTION

spec supports a number of National Instruments GPIB controllers on a variety of platforms. The support is available using spec's built-in code (highly recommended), kernel-level drivers supplied by National Instruments (on Linux, driver release 0.8.6 or prior, or driver release 2.9 or later) or freely available open-source drivers. If the linux-gpib open-source driver from Source Forge is installed, GPIB controllers from other vendors can also be used with the spec's NI GPIB support. In addition, spec supports the National Instruments VME-GPIB module via spec's built-in code.

NI GPIB on Linux With Built-In Support

The easiest and recommended configuration for using National Instruments PCII, PCIIA, AT-GPIB and PCI-GPIB cards and GPIB-ENET and VME-GPIB modules with spec is the built-in support. (AT-GPIB and PCI-GPIB/rev 01 support available as of spec release 5.07.02-01, GPIB-ENET and GPIB-ENET/100 as of release 5.07.02-04, GPIB-ENET/1000 as of release 5.10.02-3, all PCI-GPIB as of spec release 5.7.02-06, VME-GPIB as of spec release 5.08.03-10). The built-in support means no kernel-level driver is used, so there is no dependency on Linux kernel version. No additional software needs to be installed and no additional modules or libraries need to be linked with spec. In fact, it is recommended not to install any of the National Instruments Linux software drivers or libraries.

Configuration is along the following lines for the particular devices:

Interface Configuration

   GPIB DEVICE  ADDR <>MODE                        <>TYPE
 0  YES        0x2b8             Nat Inst PCII (built-in)
 0  YES        0x2e0            Nat Inst PCIIA (built-in)
 0  YES        0x2c0          Nat Inst AT-GPIB (built-in)
 0  YES          1:3         Nat Inst PCI-GPIB (built-in)
 0  YES       0x2100         Nat Inst VME-GPIB (built-in)
 0  YES  host               Nat Inst GPIB-ENET (built-in)

For the ISA cards (PCII, PCIIA, AT-GPIB), the board's base address must be configured. The built-in support operates through user-level access to the I/O ports and registers. No interrupts are involved, and no DMA is used. For the ISA cards, the IRQ and DMA jumpers can be left open. All data transfers between spec and the controllers are done using polled I/O. For most applications, the built-in support works well.

For the PCI cards, the ADDR field can contain zero, or numbers identifying the PCI bus and slot number. The latter configuration is useful if more than one PCI-GPIB card is installed. If the ADDR is zero, the boards are assigned to the GPIB unit in the order in which they are discovered. PCI bus and slot numbers can be found using the Linux utility /sbin/lspci. Note, though, that utility displays hexadecimal numbers while spec's configuration uses decimal.

For the GPIB-ENET module, an IP address or resolvable host name must be entered as the DEVICE.

The VME-GPIB module has two GPIB connectors, so can be configured as two GPIB controllers for spec. For each controller, ADDR is the base address set via the DIP switches on the controller card plus 0x100 for GPIB port A and plus 0x180 for GPIB port B. Thus, for the default VME address of 0x2000, one would configure the ADDR parameter as 0x2100 for port A and 0x2180 for port B.

No GPIB drivers should be used or installed for any GPIB controllers that spec will be accessing using the built-in support. Installing such drivers may conflict with spec's use of the board.

NI GPIB On Linux With the NI Driver

spec supports some versions of the Linux drivers that National Instruments provides for the PCI-GPIB and AT-GPIB/TNT cards and the GPIB-ENET models. However, spec's built-in support, described above, is usually the best choice.

Old versions of the National Instruments drivers can downloaded from ftp.ni.com in the directory support/gpib/linux. The most recent driver package (circa August 2014) is available from the download pages at the NI website at ni.com/download/ni-488.2-3.2/4916/en.

With the old drivers for the PC cards, spec supports the 0.x series drivers (last version 0.8.6). Those drivers work with Linux kernels through release 2.4. Versions 2.2 though 2.8 of the NI driver packages are not compatible with spec. Version 2.9 of the NI driver can be linked with spec release 5.10.02-3, although use has not been well tested. Version 3.2 of the NI driver can be linked as of spec release 6.02.08.

Old versions of the NI software for use with the GPIB-ENET module, namely the nienet-linux-1.1.tar.gz or nienet-linux-1.2.tar.gz packages, can also be used. The GPIB-ENET support works at user level and doesn't depend on kernel version. Again, the NI 2.2 through 2.8 driver packages that also contain GPIB-ENET support are not compatible with spec.

The NI driver distribution contains instructions for installation, which should be followed. Note, though, there is no need to run the ibconf utility to configure the driver for spec for the PC cards (although ibconf must be used with the GPIB-ENET device to initialize the /etc/gpibrc file.) spec does all GPIB access from the board level device, normally /dev/gpib0. No other special device files are needed. spec also sets the device parameters, such as timeouts and end-of-string behavior, as needed at run time.

For the 0.x and 2.9 drivers and the nienet-linux packages, spec needs to be linked with the cib.o file included in the driver distribution. When running the spec installation script Install, enter the appropriate path for the file's location when presented with the following:

Choices for Extra object files are:

 1) no    - no additional object files
 2) other - your choice

If there are additional site-dependent objects files, such
as those provided by hardware vendors, enter the names here.

Choose Extra object files (no)? /usr/local/nigpib/cib.o

For version 3.2 of the NI driver, choose instead the file ni4882.o, along these lines:

Choose Extra object files (no)? /usr/local/natinst/ni4882/lib64/ni4882.o

In addition, for version 3.2 drivers, add -dl as extra library flags:

Choose Extra library flags (no)? -dl

If spec has already been installed, remove the file spec in the spec distribution directory before running the installation script to insure that the spec executable gets relinked.

When running the configuration editor, select either of the following options for the PCI cards:

Interface Configuration

   GPIB     DEVICE ADDR <>MODE                       <>TYPE
 0  YES /dev/gpib0                      Nat Inst with cib.o
 0  YES /dev/gpib0             Nat Inst with cib.o (shared)

For the Ethernet device, choose from the following:

Interface Configuration

   GPIB  DEVICE ADDR <>MODE                               <>TYPE
 0  YES   gpib0                    Nat Inst GPIB-ENET with cib.o
 0  YES   gpib0           Nat Inst GPIB-ENET with cib.o (shared)

The "shared" version allows the GPIB interface to be shared among more than one instance of spec running on the same platform. spec uses kernel semaphores and shared memory to coordinate access to the driver. If only one instance of spec is using the GPIB interface, then one can avoid a little overhead by selecting the non-shared configuration.

Using Both GPIB-ENET and PCI Cards With Old NI Drivers

If using the version 0.x NI drivers for the PCI-GPIB (not necessary, if the spec's built-in support is used), it would normally not be possible to use both the PCI-GPIB card and the ENET-GPIB device at the same time. Both devices require linking with different NI cib.o files, which results in a name-space conflict. However, there is a workaround for spec, at least for NI driver releases 0.8.6 and earlier.

The spec distribution contains a script called makeCIB in the distribution directory that will create a file called CIB.c. Such a file is a modified version of the National Instruments cib.c, with the function names starting with ib replaced with names starting with IB, and the 488.2 functions (unused by spec) eliminated. See the comments in the makeCIB file for more information on creating the CIB.c file.

Beginning with release 0.8.4, NI has dropped the cib.c file from the driver package. However, the version of cib.c from early driver packages (0.8.3, for example) can be used.

One then links spec with both this new CIB.o file and the cib.o file included with the GPIB-ENET distribution. In the spec configuration file, you select the "with CIB.o" device for the PC card GPIB interfaces.

Using the Source-Forge GPIB Driver

The Source Forge Linux GPIB project GPIB drivers work with spec using the "Nat Inst with cib.o" configuration options described above. The package distribution is available at the project's home at http://linux-gpib.sourceforge.net along with documentation. (The Source Forge GPIB project is the successor to the deprecated linux-lab GPIB project used with spec prior to the release of a driver by National Instruments.)

To install the linux-gpib driver you need first to have the Linux kernel source installed. To properly configure the sources to match the running kernel, change to the appropriate /usr/src/linux- directory and run the commands:

make mrproper
make oldconfig
make dep

Note, the Linux kernel is something of a moving target. Instructions for building compatible modules change often. Check the "how-to" files associated with the linux-gpib driver for current instructions.

Next, you can go the directory with the extracted linux-gpib sources and execute the commands:

./configure
make
make install

Finally, to link the linux-gpib library with spec, go to the spec distribution directory. Enter the complete path name of the library, such as /usr/local/lib/libgpib.so, as an "extra object file" option to the spec Install script. (The spec linking won't work with a -lgpib type of argument due to the idiosyncrasies of the spec linking.)

Be sure to configure appropriate entries in /etc/gpib.conf for the card(s) to be controlled by spec. Entries should be configured along the lines of

interface {
      minor = 0
      board_type = "ni_pci"
      name = "gpib"
      pad = 0
      master = yes
}

for the National Instruments PCI-GPIB card. Important points are that the interface should be configured as the master, the primary address of the master should be zero as in pad = 0, and the value in the name field will be the string that must appear in the DEVICE field in the spec configuration editor, as in the following:

Interface Configuration

   GPIB     DEVICE ADDR <>MODE                       <>TYPE
 0  YES       gpib                      Nat Inst with cib.o

(Even though the text reads "Nat Inst with cib.o", it is the correct configuration for using the Source Forge linux-gpib driver with a libgpib.so libary!)

Next, make sure the new driver is loaded with the command:

modprobe tnt4882

Also, be sure to run the gpib_config utility after installing the driver.

If all works, the following lines can be added to /etc/modules.conf so that the driver is loaded automatically when needed, and you won't need to use modprobe or gpib_config after rebooting:

alias char-major-160 gpib_common
alias char-major-160-0 tnt4882
post-install tnt4882 /usr/local/sbin/gpib_config --minor 0

Note, the Source Forge GPIB library supports GPIB cards from vendors other than National Instruments, and those cards should also be usable with spec.