Reputation: 83
I am trying to control an Agilent 33120A Arbitrary Waveform Generator using pyvisa under Ubuntu 13.04 (Raring Ringtail). I have installed and set up everything that is necessary to communicate with the instrument using our labs NI GPIB-USB-B adapter. The adapter firmware is loaded, and so are the kernel modules from linux-gpib.
I can successfully do some dry-runs, e.g. by running # ibtest
(command-line tool), I can write *IDN?
to the device, and I receive the device ID: 'HEWLETT-PACKARD,33120A,0,8.0-5.0-1.0'
. I also tested other commands successfully, like setting voltage and frequency, and so on. It works.
The problem is, pyvisa always throws a VisaIOError
... I have not clue how to get it to work. I run python-2.7 as root, so that (for now) I do not have to deal with any access privileges. This is the code and output:
import visa
>>> visa.vpp43.visa_library.load_library("/usr/lib/x86_64-linux-gnu/libvisa.so.0")
>>> visa.get_instruments_list()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/pyvisa/visa.py", line 254, in get_instruments_list
vpp43.find_resources(resource_manager.session, "?*::INSTR")
File "/usr/lib/python2.7/dist-packages/pyvisa/vpp43.py", line 583, in find_resources
instrument_description)
File "/usr/lib/python2.7/dist-packages/pyvisa/vpp43.py", line 398, in check_status
raise visa_exceptions.VisaIOError, status
pyvisa.visa_exceptions.VisaIOError: VI_ERROR_RSRC_NFOUND: Insufficient location information or the requested device or resource is not present in the system.
The library loads correctly. It is not even necessary, but I load the library explicitly to be safe. Obviously, pyvisa does not find any instrument. I also tried to explicitly open my instrument board=0, pad=10, sad=0
using either of these commands:
visa.instrument("GPIB::10")
visa.instrument("GPIB0::10")
visa.instrument("GPIB::10::0")
visa.instrument("GPIB0::10::0")
But the same exception as above is thrown.
Basically, everything is set up alright, but pyvisa does not see anything.
Used versions:
I am hoping for some suggestions.
Upvotes: 4
Views: 3488
Reputation: 7245
pyvisa
is a Python wrapper around NI-VISA. As far as I know it's not possible to use pyvisa
with linux-gpib
. But linux-gpib comes with its own Python wrappers. Simply import Gpib
and you're good to go, for example,
>>>import Gpib
>>>device = Gpib.Gpib(pad=10)
>>>device.write('*IDN?')
>>>device.read()
'HEWLETT-PACKARD,33120A,0,8.0-5.0-1.0'
I guess you're writing some kind of measurement script. Have a look at slave it might be usefull for you (disclaimer: I'm the author of slave
). It tries to simplify the device communication. Also it comes with its own wrappers for linux-gpib.
Upvotes: 2