'Python pyVISA GPIB connection issue

I'm trying to connect to a GPIB instrument using pyVISA but I get an error. I'm following the simple example on the pyVISA website: http://pyvisa.readthedocs.org/en/master/

I type the following code into the IPython console:

import visa
rm = visa.ResourceManager()
rm.list_resources()

Out[4]:
(u'USB0::0x0957::0x0D0B::MY49431510::INSTR',
 u'USB0::0x0957::0x17BC::MY52400338::INSTR',
 u'ASRL1::INSTR',
 u'ASRL2::INSTR',
 u'ASRL5::INSTR',
 u'ASRL6::INSTR',
 u'ASRL7::INSTR',
 u'ASRL8::INSTR',
 u'ASRL9::INSTR',
 u'ASRL10::INSTR')

However, my GPIB instruments do not show up, just the serial ports and my USB instruments. When I launch the Agilent Connection Expert (or NI MAX) I can see all my GPIB instruments and can communicate with them. I also am able to communicate with the instruments without issue with Matlab.

So when I try and connect to the instrument with the line:

inst = rm.open_resource('GPIB0::19::INSTR')

It throws an error: VisaIOError: VI_ERROR_INTF_NUM_NCONFIG (-1073807195): The interface type is valid but the specified interface number is not configured.

I've also tried to connect with the USB instruments that show up when I list the resources and they do not throw this error. However, when I try and do a simple query:

inst = rm.open_resource('USB0::0x0957::0x0D0B::MY49431510::INSTR')
inst.query("*IDN?")

Nothing gets returned and no errors get thrown.

I'm using Python(X,Y) 2.7.9.0 with Python version 2.7.9 32 bit

pyVISA version is 1.6.3 NI bitness is 32

Any guidance is appreciated as I'm new to Python.

Thanks



Solution 1:[1]

You probably need to start the resource manager with:

rm = ResourceManager('Path to library')

where Path to library is the location of the NI Vista Library.

Also try:

python -m visa info

to ensure that you have it installed with the same word length as the python version that you are running.

Solution 2:[2]

I was having the same issue, and did manage to fix it by setting the path address to: 'C:/Program Files/IVI Foundation/VISA/WinNT/agvisa/agbin/visa32.dll'. If you haven't found the solution, I hope it works for you as well.

Solution 3:[3]

I had exactly the same problem - USB resources showed up, GPIB resources didn't. I tried to open the resource exactly as you did, inst = rm.open_resource('GPIB0::22::INSTR') (with the GPIB address changed to that of one of my instruments) with exactly the same result. Some inspired random guessing led me to

inst = rm.open_resource('GPIB1::22::INSTR')

which worked perfectly! Once the instrument is open it shows up in the list of resources, as expected. I have no idea why the interface is seen as GPIB1.

I am using the Keysight/Agilent/HP IO libraries suite as my VISA library (the NI library is not installed), and an Agilent 82357B USB to GPIB interface. I did not have to do any customisation of my pyVisa installation to get this working. Which is nice.

Hope this helps!

Solution 4:[4]

I had the same problem (running 32-bit python 2.7 on a 64-bit win7), I got it fixed using

rm = ResourceManager('C:/Program Files (x86)/IVI Foundation/VISA/WinNT/agvisa/agbin/visa32.dll')

which is the 32-bit VISA path given in the "About Agilent IO Control" Information.

Solution 5:[5]

I have ni-visa and Agilent visa installed on my computer. However, pyvisa cannot access the Agilent 82357B device due to pointing to the wrong library.

I used this command to specify the right library, it worked for me. Couples of notes:

  • Find the right library for the device which is visa32.dll located in different installation directories depends on each visa packet.
  • Use forward slash for delimiting characters even it is on windows.
  • Specify visa packet in the command: rm = visa.ResourceManager('c:/....')

Solution 6:[6]

I had the same issue. The problem was that the automatically installed Windows driver was wrong and my device showed up as USB0::0x3923::0x702A::010A65AB::RAW in NI MAX.

It was solved by an update of the driver (device manager-> properties) from C:\Program Files\National Instruments\NI-488.2 (or where your driver is installed).

Now GPIB works also from python.

Solution 7:[7]

I observed same error report when running on a PC with visa library from Keysight. Replacing with visa dll from National Instruments solved the problem.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Steve Barnes
Solution 2 PCAR
Solution 3 Max
Solution 4 David
Solution 5 gboffi
Solution 6 Hristo Eftimov
Solution 7 HCi