Timeout while using SCPI commands for Keithley 2230 power supply

1.3k views Asked by At

Blockquote

I'm using a Keithley 2230 triple channel DC power supply for lab automation with PyVISA. I want to select the particular channel and set the voltage accordingly. I have attached the program as well as the error.

I have done the following research but I was not successful.

PyVISA SCPI commands and queries (issue with value update)

Python SCPI avoiding fixed delays (synchronization issue)

Program:

import visa

rm = visa.ResourceManager()
str = 'USB0::0x05E6::0x2230::9102008::INSTR'
inst = rm.open_resource(str)
print inst.query("*IDN?")
######### print the selected channel ##########
print inst.query("INSTrument:SELect?")
######### selected the perticular channel ##########
print inst.query("INSTrument:SELect 2")

Commands I got from the official link of keithley DD power supply:

http://assets.tequipment.net/assets/1/26/Documents/Keithley/2220_30_1/2220_30_1_doc_4.pdf

Output Log:

Keithley instruments, 2230-30-1, 9102008, 1.15-1.04

CH1

Traceback (most recent call last):
  File "C:/Users/PycharmProjects/trails/keithley2230.py", line 9, in <module>
    print inst.query("INSTrument:SELect 2")
  File "C:python-2.7.9\lib\site-packages\pyvisa\resources\messagebased.py", line 384, in query
    return self.read()
  File "C:\python-2.7.9\lib\site-packages\pyvisa\resources\messagebased.py", line 309, in read
    message = self.read_raw().decode(enco)
  File "C:\python-2.7.9\lib\site-packages\pyvisa\resources\messagebased.py", line 283, in read_raw
    chunk, status = self.visalib.read(self.session, size)
  File "C:\python-2.7.9\lib\site-packages\pyvisa\ctwrapper\functions.py", line 1569, in read
    ret = library.viRead(session, buffer, count, byref(return_count))
  File "C:\python-2.7.9\lib\site-packages\pyvisa\ctwrapper\highlevel.py", line 180, in _return_handler
    raise errors.VisaIOError(ret_value)
pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
1

There are 1 answers

0
Sandy On

The error was coming because of this query:

print inst.query("INSTrument:SELect?")

Instead I used print inst.write("INSTrument:SELect?").

I am attaching the code snippet for the future users :-)

import visa
import pyvisa

rm = visa.ResourceManager()
print rm.list_resources()
str = 'USB0::0x05E6::0x2230::9102008::INSTR'
inst = rm.open_resource('USB0::0x05E6::0x2230::9102008::INSTR')


print inst.query("*IDN?")

print inst.write("OUTPUT ON")

inst.write("INSTrument:SELect CH1")
print inst.query("INSTrument:SELect?")
print inst.write("OUTPut:ENABle 1")
print inst.write("APPLY CH1,1.11V,1.5A")