2017-01-05 65 views
0

塊引用超時而使用SCPI爲吉時利2230電源命令

我使用實驗室自動化的Keithley 2230三通道的直流電源與PyVISA。我想選擇特定的通道並相應地設置電壓。我附加了程序以及錯誤。

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

PyVISA SCPI commands and queries (issue with value update)

Python SCPI avoiding fixed delays (synchronization issue)

計劃:

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

命令我從吉時利DD電源的官方鏈接了:

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. 
+0

什麼'打印rm.list_resources()'產生? – TigerhawkT3

+0

如果你查詢通道2,然後再通道1發生了什麼? – TigerhawkT3

+0

打印rm.list_resources()農產品(u'USB0 :: 0x05E6 :: 0x2230 :: 9102008 :: INSTR 'u'ASRL3 :: INSTR',u'ASRL10 :: INSTR「) – Sandy

回答

0

錯誤來了,因爲查詢:

print inst.query("INSTrument:SELect?") 
Instead I used 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")