1

块引用

我正在使用 Keithley 2230 三通道直流电源与PyVISA进行实验室自动化。我想选择特定的通道并相应地设置电压。我附上了程序以及错误。

我做了以下研究,但没有成功。

PyVISA SCPI 命令和查询(值更新问题)

Python SCPI 避免固定延迟(同步问题)

程序:

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")

我从 keithley DD power supply 官方链接得到的命令:

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

输出日志:

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.
4

1 回答 1

0

由于此查询而出现错误:

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

相反,我使用了print inst.write("INSTrument:SELect?").

我正在为未来的用户附上代码片段:-)

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")
于 2017-01-05T10:42:42.470 回答