cinnbuns
cinnbuns

Reputation: 21

Connecting to instrument via GPIB using PyVISA in Python

I am working on the acquisition of electrical contact resistance, for which I will be using a Keithley 2400 sourcemeter and a Keithley 2182a nanovoltmeter. Both of the instruments are connected to a Windows computer via USB with a Keithley KUSB-488b adapter.

I am working with Python, the Pyvisa module, and the National Instruments backend (NI VISA) to create a script that will allow me to conduct the measurements needed. However I am running into trouble communicating with the instruments. I have run a couple of simple scripts, based on the official documentation provided by the developers of Pyvisa, but am unable to connect with either instrument. The following simple block of code may aid my explanation:

>>> import pyvisa
>>> rm = pyvisa.ResourceManager()
>>> rm.list_resources()
('ASRL3::INSTR', 'ASRL4::INSTR', 'ASRL8::INSTR', 'ASRL14::INSTR')
>>> inst = rm.open_resource(' # Instrument address here # ')
>>> print(inst.query("*IDN?")

The result in line 4 should give me a list of the addresses of my instruments. However, none of these are correct, hence I get a timeout error (VI_ERROR_TMO) when I try the four addresses provided by line 4. The expected output in line 4 of this simple code block would be the GPIB addresses of both instruments, as per the documentation. I tried using the KI-488 Diagnostics Tool to communicate with both devices. Both of which I successfully communicated with. The SMU's address is GPIB::24 and the nanovoltmeter is GPIB::7.

I also tried passing the GPIB addresses that I obtained from the diagnostic tools in more complex scripts (current sweep). However this resulted in

pyvisa.errors.VisaIOError: VI_ERROR_LIBRARY_NFOUND (-1073807202)

I searched online for similar errors, most of which are an outcome of missing dll or incorrect bitness. However this is not my case, since a simple python -m visa info proves that the backends implemented are correct. I also tried passing the resourcemanager( path ), however that was also unsuccessful.

Additionally I tried installing Keithley I/O Layer, but I was unsuccessful nonetheless. Also, in the Keithley communicator both devices do in fact appear with their corresponding GPIB address. The issue is working with Python and the proper address.

Upvotes: 2

Views: 5442

Answers (1)

Kadabash
Kadabash

Reputation: 21

I was able to resolve a similar problem with the same KUSB-488B adapter by using the the "Keysight IO Libraries Suite" from Keysight's website instead of NI-VISA.

On my PC running Windows 10 (19.09, 64-bit) I did the following:

  • Uninstall the KUSB-488B driver from the Device Manager.
  • Uninstall NI-VISA, reboot.
  • Remove all remaining items mentioning "VISA", "NI", "GPIB" or "488" in the list of installed programs in Windows' settings app. Reboot.
  • Install the latest KUSB-488B driver. During installation, choose the "Keithley command compatible" option (there is another one for NI, but I forgot what it was called). Reboot.
  • Install the "Keysight IO Libraries Suite", version "2020 Update 1". Reboot.

Now I was able to see the device in the "Keysight Connection Expert", which is Keysight's analogue to "NI-MAX".
After installing Anaconda Python (64-bit) and running pip install pyvisa, I could control the instruments without any errors.

Upvotes: 2

Related Questions