Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

PyVISA cannot communicate with Keithley2400 using Prologix GPIB-USB

Hello,

 

Any help is greatly appreciated! I have looked into other NI solutions, but I believe my situation is different due to using the Prologix GPIB-USB with the PyVISA wrapper not working where as the serial library does work. My current setup involves python code in PyCharm IDE(I will paste the code snippet below), a Prologix GPIB-USB adapter connected to my laptop and the Keithley2400 SourceMeter. Connecting to the Keithley2400 via serial library in python works. The keithley can be written commands no problem with this library. There is a pymeasure wrapper I would like to use though and it uses pyvisa which uses NI-VISA, hence I am posting here because I think it is NI-VISA I need help with. I want to note that I only started having issues last Friday, which leads me to believe there may be a bug in the newest NI-VISA version which was released last Wednesday (I have NI-VISA 2023 Q4). I have used the Pymeasure wrapper multiple times over the past year with no issues like this. 

 

Things I have noted:

  • The Prologix cable is detected by the computer and NI-VISA as ASRL3::INSTR (aka COM3). There should be a GPIB portion involved, but trying even just COM3, NI-VISA can't communicate with via python or via NI-MAX.
  • As stated above the python serial library to write prologix commands (ex. ++auto 1) works as expected
  • I am using Anaconda3 as my interpreter and have run pyvisa-info and have pasted the results below. You will see the current key error appearing to be a missing gpib library. I haven't found a gpib32.dll. I am not sure which file I would manually upload, how to do that, or what next steps should be taken
  • You will see there a is also a PyUSB backend error, which seems a little strange, but hopefully that can be dealt with after the GPIB issue
  • In terms of running the code snippet below, the error is
    • vpmeter.use_front_terminals() pyvisa.errors.InvalidSession: Invalid session handle. The resource might be closed.
  • There are other odd things that happen too:
    • VI_ERROR_SYSTEM_ERROR (-1073807360): Unknown system error (miscellaneous error). [This shows up once or twice when listing the resources]
    • The command to list resources shows the (assuming correct) USB address of the scope and then a few other ASRLx::INSTR : Not known  where x is the COM port number. So it at least detects the USB of the Prologix is connected to the laptop

 

pyvisa-info:

UserWarning: GPIB library not found. Please manually load it using _load_lib(f
ilename). All GPIB functions will raise OSError until the library is manually loaded.
warnings.warn(message)
Machine Details:
Platform ID:  
Processor: Intel64 Family 6 Model 154 Stepping 4, GenuineIntel

Python:
Implementation: CPython
Executable: C:\Users\xx\Anaconda3\python.exe
Version: 3.9.13
Compiler: MSC v.1916 64 bit (AMD64)
Bits: 64bit
Build: Aug 25 2022 23:51:50 (#main)
Unicode: UCS4

PyVISA Version: 1.13.0

Backends:
ivi:
Version: 1.13.0 (bundled with PyVISA)
#1: C:\WINDOWS\system32\visa32.dll:
found by: auto
bitness: 64
Vendor: National Instruments
Impl. Version: 24119296
Spec. Version: 7340032
#2: C:\WINDOWS\system32\visa64.dll:
found by: auto
bitness: 64
Vendor: National Instruments
Impl. Version: 24119296
Spec. Version: 7340032
py:
Version: 0.7.0
ASRL INSTR: Available via PySerial (3.5)
TCPIP INSTR: Available
Resource discovery:
- VXI-11: ok
- hislip: ok
TCPIP SOCKET: Available
USB INSTR:
PyUSB does not seem to be properly installed.
Please refer to PyUSB documentation and
install a suitable backend like
libusb 0.1, libusb 1.0, libusbx,
libusb-win32 or OpenUSB.
No backend available
USB RAW:
PyUSB does not seem to be properly installed.
Please refer to PyUSB documentation and
install a suitable backend like
libusb 0.1, libusb 1.0, libusbx,
libusb-win32 or OpenUSB.
No backend available
VICP INSTR:
Please install PyVICP to use this resource type.
GPIB INSTR:
gpib_ctypes is installed but could not locate the gpib library.
Please manually load it using:
gpib_ctypes.gpib.gpib._load_lib(filename)
before importing pyvisa.
GPIB INTFC:
gpib_ctypes is installed but could not locate the gpib library.
Please manually load it using:
gpib_ctypes.gpib.gpib._load_lib(filename)
before importing pyvisa.

 

Code:

 

 

import pyvisa as visa
from pymeasure.instruments.keithley import Keithley2400
import pymeasure.adapters

adapter = pymeasure.adapters.PrologixAdapter('ASRL3::INSTR')
vpmeter = Keithley2400(adapter.gpib(25))
print(pymeasure.instruments.list_resources())
vpmeter.use_front_terminals() #code fails here

 

 

0 Kudos
Message 1 of 27
(3,663 Views)

This question is better fit to ask Prologix as this topic is in no way related to NI

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 27
(3,654 Views)

Thank you for replying back! I do believe it is an NI-VISA problem because that is the backend PyVisa is using. The Prologix cable has always worked before in this setup and still currently works when using serial.write. The NI-VISA library is having issues and it does appear I have no gpib-32.dll file

0 Kudos
Message 3 of 27
(3,647 Views)

Looks like there is a open topic in PyVISA about supporting Prologix GPIB-USB
https://github.com/pyvisa/pyvisa/issues/112

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 4 of 27
(3,631 Views)

Thanks again for getting back! I appreciate your help on this stubborn issue.

 

Prologix actually does already have pyvisa connection in the library Pymeasure, which is what I use. Pymeasure uses PyVisa for communication. PyVisa can use any (most) VISA backend libraries and the one recommended is NI-VISA which is what I use. This is not unique to only Python as NI-MAX also cannot communicate to the instrument. Using python and the Prologix cable, I am completely able to communicate using the serial.write library, but the goal is to use Pymeasure/PyVisa. I had been using this cable and pymeasure for a while now and it was working perfectly until a week ago. The issue lies in NI-VISA because that is the backend pyVisa is using. You can see in the pyvisa-info log that there is no gpib library. I suspect these issues will resolve if I can figure out how and why it was deleted. 

0 Kudos
Message 5 of 27
(3,629 Views)

Prologix GPIB (GPIB-USB Controller) is a product loaded with an FTDI serial chip, and Prologix GPIB itself appears to be a serial I/F from VISA.
Therefore, NI's GPIB-related libraries (such as ni4882.dll and gpib-32.dll) are not used at all when using Prologix products. (Also, these dlls will not be installed on your computer unless you install NI-488.2.)
Controlling Prologix GPIB itself requires sending commands to Prologix itself via serial.
https://prologix.biz/downloads/PrologixGpibUsbManual-6.0.pdf

From this, I think that PyMeasure does not support communication using Prologix, so you will need to create the code to control Prologix and the instrument from PyVISA on your own.

0 Kudos
Message 6 of 27
(3,608 Views)

After looking into it, it seems that there is a dedicated command for using Prologix I/F with PyMeasure.
See here.

https://pymeasure.readthedocs.io/en/latest/api/adapters.html#prologix-adapter

Message 7 of 27
(3,604 Views)

Yes, these are the commands and library I am using! I actually use it for the Keithley and Prologix as there is a pymeasure.adapters and a pymeasure.instruments. Your suggestion then would be to install the latest version of NI-488.2? I have NI-VISA and I do not have any gpib library whatsoever (that I could find) in either System32 or SysWOW64. Wouldn't NI-VISA place nigpib.dll during download? Either way I will see if I can get the latest NI-488.2 and will report back.

 

Thanks everyone for the input!

0 Kudos
Message 8 of 27
(3,598 Views)

Since Prologix is serial communication and not GPIB (and it's not an NI product either) installing NI-488.2 won't change the situation.(It's just a signal-level conversion between serial and GPIB in the Prologix hardware.)
Installing NI-488.2 is worthwhile when using NI's GPIB I/F.

 

 

 

 

Message 9 of 27
(3,593 Views)

Hmmm..... I  think I see what you're saying. Even with it being serial based, it seems based on the output of my pyvisa-info, I need a gpib library to feed to NI-VISA backend for pyvisa to work properly. It doesn't look like I have one. I was thinking if I could get the one from NI-488.2 perhaps I can use this to appease pyvisa. Is this not the right way to think about it? Fixing the issue from the pyvisa-info regarding the gpib dll is the only fix I can think of to get pymeasure working again.

0 Kudos
Message 10 of 27
(3,583 Views)