Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rometsch/eea6633f830e9acd0d0e55a6906fe8f6 to your computer and use it in GitHub Desktop.
Save rometsch/eea6633f830e9acd0d0e55a6906fe8f6 to your computer and use it in GitHub Desktop.
Agilent 82357B GPIB interface programming on Ubuntu Linux

GPIB interfacing using Agilent 82357B on Ubuntu Linux

This is a fork of the original version to make the same setup run on a newer version of Ubuntu 16.04.2 LTS.

I initially had some problems installing on my laptop, so decided to boot Ubuntu 12.04.5 LTS, 3.13.0-32-generic from USB and work from there.

Download the linux-gpib package, unpack and build. Get python-setuptools first for later Python bindings support.

wget --content-disposition --no-check-certificate https://sourceforge.net/projects/linux-gpib/files/linux-gpib%20for%203.x.x%20and%202.6.x%20kernels/4.0.4/linux-gpib-4.0.4rc2.tar.gz/download
sudo apt-get update
sudo apt-get install python-dev libboost-python-dev python-setuptools --yes
tar xvfz linux-gpib-4.0.4rc2.tar.gz
cd linux-gpib-4.0.4rc2
./configure
make -j8
sudo make install
cd ..

Also download the firmware binary for the 82357B:

wget http://linux-gpib.sourceforge.net/firmware/gpib_firmware-2008-08-10.tar.gz
tar xvfz gpib_firmware-2008-08-10.tar.gz

Use fxload to upload firmware to the GPIB interface:

wget --content-disposition --no-check-certificate https://downloads.sourceforge.net/project/linux-hotplug/fxload/2008_10_13/fxload-2008_10_13.tar.gz
tar xvfz fxload-2008_10_13.tar.gz
cd fxload-2008_10_13
make
sudo make install
cd ..

Edit /etc/gpib.conf (as superuser) to say

board_type = "agilent_82357a"
name = "agi"

Load kernel module(s):

sudo modprobe gpib_common
sudo modprobe agilent_82357a

Insert the dongle into the USB port. Only the red "FAIL" LED should be on. Find the bus and device ID:

lsusb

e.g.

...
Bus 002 Device 005: ID 0957:0518 Agilent Technologies, Inc.
...

Plug the found bus and device ID into the command for fxload:

sudo fxload -D /dev/bus/usb/002/005  -t fx2 -I gpib_firmware-2008-08-10/agilent_82357a/measat_releaseX1.8.hex

Still only the "FAIL" LED is on.

The USB bus and device ID have now changed. Wait a moment and get the new ID:

lsusb

e.g.

...
Bus 002 Device 006: ID 0957:0518 Agilent Technologies, Inc.
...

Run fxload again with the new bus and device ID:

sudo fxload -D /dev/bus/usb/002/006  -t fx2 -I gpib_firmware-2008-08-10/agilent_82357a/measat_releaseX1.8.hex

All lights should be on.

Change permissions on /dev/gpib0 (ideally, you would manage this with a "gpib" usergroup instead):

sudo chmod 666 /dev/gpib0

Now, initialize the dongle. gpib_config has some trouble finding the library, so create a symbolic link first:

sudo ln -s /usr/local/lib/libgpib.so.0 /lib/libgpib.so.0
sudo gpib_config

Only the green "READY" LED should now be on.

Now, make an entry for your device in /etc/gpib.conf. Default HP3456B factory address is ASCII "V" (22 dec) for talk and "6" for listen

...
name = "hp3456a"
pad = 22
...

You can use ibtest to do some testing.

ibtest

A simple Python interface can now be made using the linux-gpib Python bindings. For more advanced applications, consider using the visa (PyVISA) libraries.

import gpib
dev = gpib.find("hp3456a")      # N.B. define device ID in ``/etc/gpib.conf``
print gpib.read(dev, 99)

References

[pyvisa]PyVISA https://pyvisa.readthedocs.io/en/stable/
[linux-gpib]linux-gpib : http://linux-gpib.sourceforge.net/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment