GPIB setup on Linux
- 3 Dec 2021 Revised by Kazuyuki Takeda
- 14 Mar 2019 Revised by Kazuyuki Takeda
- 12 Oct 2018 Revised by Kazuyuki Takeda
- 21 May 2018 Written by Kazuyuki Takeda
Introduction
We want to make remote control over the power supply for our cryogen-free superconducting magnet (SMS80C, Cryogenics) on the console software of Opencore NMR 2. I have attempted to program on Windows for a while, but never succeeded, and gave up. Now I decided to program on Linux.
Our GPIB
- Measurement computing
- USB-488
- Default primary address: 4
Driver compilation (Cent OS)
linux-gpib-4.1.0
linux-gpib-4.1.0
was downloaded from http://linux-gpib.sourceforge.net and extracted in an arbitrary working directory../configure
make
linux-gpib-4.2.0
- If you download the latest (at the time of writing, Mar 2019) version (linux-gpib-4.2.0) and try to compile in the same way as the above example, you may get an error
implicit declaration of function ‘of_find_node_by_path’
, and the compilation may stop. - A remedy is suggested here.
- In short, you need to open
drivers/gpib/Makefile
with a text editor and comment out the lineobj-y += fmh_gpib/
- Then, compilation should work.
Installation and setup
sudo make install
- And the kernel driver module is
ni_usb_gpib.ko
, and the board type, to be described in/etc/gpib.conf
, isni_usb_b
. - Driver file
ni_usb_gpib.ko
has been created upon successful compilation. To install, I went into the directory that contains it and ransudo modprobe ni_usb_gpib
. To verify the driver has really been installed, I checked withlsmod | grep gpib
. - Next, we needed to edit
/etc/gpib.conf
as follows:
interface {
minor = 0 /* board index, minor = 0 uses /dev/gpib0, minor = 1 uses /dev/gpib1, etc. */
board_type = "ni_usb_b" /* type of interface board being used */
name = "current" /* optional name, allows you to get a board descriptor using ibfind() */
pad = 0 /* primary address of interface */
sad = 4 /* secondary address of interface */
timeout = T10s /* timeout for commands */
eos = 0xda /* EOS Byte, 0xa is newline and 0xd is carriage return */
set-reos = yes /* Terminate read if EOS */
set-bin = no /* Compare EOS 8-bit */
set-xeos = no /* Assert EOI whenever EOS byte is sent */
set-eot = no /* Assert EOI with last byte on writes */
master = yes /* interface board is system controller */
}
- name =
current
should be arbitrary (optionally used foribfind
function). pad=0
andsad=4
were necessary, with the dip-switched primary address on the current controller being 4. And in the program coding, it was necessary to set pad to be 4. My guess is: the primary address to be set on the operating system is relevant to the GPIB-USB adapter (in our case, we are using a single adapter, so that the address is the youngest, i.e., zero), whereas on the software we are supposed to connect to the device (in our case, the magnet power supply whose address is set on the dip switch on the pear panel to be 4).- After saving the
gpib.conf
file, I ransudo gpib_config
, which makes setup according to the abovegpib.conf
file. - Found in
linux-gpib-4.1.0/lib/gpib_config
.
Without sudo…
Go to /dev
, and sudo chmod a+rw ./gpib0
.
TODO
To realize plug and play, udev needs to be configured to (i) change the mode of /dev/gpib0 to 0666, and (ii) implement gpib_config. I will try to work it out and update this page (12 Oct 2018).