我的任务是在我的母版项目中使用TDK-LAMBDA Z +电源来提供恒定电流并将电压读数存储在文件中。但是,我目前无法与电源通信。目前我正在尝试使用PyVISA连接电源,并安装了后端NI-VISA驱动程序。
当尝试查询电源时,操作在操作完成之前超时,下面是我的代码和一些其他信息。我目前正在使用64位python 3,并尝试使用USB连接与PSU进行通信。
import visa
rm = visa.ResourceManager('@ni')
print(rm.list_resources()) # Correctly detects the psu ('ASRL3::INSTR',)
inst = rm.open_resource('ASRL3::INSTR', baud_rate=19200)
inst.write_termination = '\r'
inst.read_termination = '\r'
print(inst.query("*IDN?"))
这给了我以下错误:
Warning (from warnings module):
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\pyvisa\ctwrapper\functions.py", line 1227
ret = library.viOpenDefaultRM(byref(session))
VisaIOWarning: VI_WARN_CONFIG_NLOADED (1073676407): The specified configuration either does not exist or could not be loaded. VISA-specified defaults will be used.
Traceback (most recent call last):
File "C:\Users\User\Desktop\Drivers\code.py", line 13, in <module>
print(inst.query("*IDN?"))
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\pyvisa\resources\messagebased.py", line 564, in query
return self.read()
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\pyvisa\resources\messagebased.py", line 413, in read
message = self._read_raw().decode(enco)
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\pyvisa\resources\messagebased.py", line 386, in _read_raw
chunk, status = self.visalib.read(self.session, size)
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\pyvisa\ctwrapper\functions.py", line 1584, in read
ret = library.viRead(session, buffer, count, byref(return_count))
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\pyvisa\ctwrapper\highlevel.py", line 188, in _return_handler
raise errors.VisaIOError(ret_value)
pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
运行&gt;&gt;&gt; python -m签证信息会产生以下结果
C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\pyvisa\ctwrapper\functions.py:1227: VisaIOWarning: VI_WARN_CONFIG_NLOADED (1073676407): The specified configuration either does not exist or could not be loaded. VISA-specified defaults will be used.
ret = library.viOpenDefaultRM(byref(session))
Machine Details:
Platform ID: Windows-10-10.0.16299-SP0
Processor: Intel64 Family 6 Model 142 Stepping 9, GenuineIntel
Python:
Implementation: CPython
Executable: C:\Users\User\AppData\Local\Programs\Python\Python37\python.exe
Version: 3.7.0b4
Compiler: MSC v.1913 64 bit (AMD64)
Bits: 64bit
Build: May 2 2018 19:02:22 (#v3.7.0b4:eb96c37699)
Unicode: UCS4
PyVISA Version: 1.10.0.dev0
Backends:
ni:
Version: 1.10.0.dev0 (bundled with PyVISA)
#1: C:\WINDOWS\system32\visa64.dll:
found by: auto
bitness: 64
Vendor: National Instruments
Impl. Version: 5243905
Spec. Version: 5243136
#2: C:\WINDOWS\system32\visa32.dll:
found by: auto
bitness: 64
Vendor: National Instruments
Impl. Version: 5243905
Spec. Version: 5243136
我同时使用64位Python和64位VISA。
print(rm)
Resource Manager of Visa Library at C:\WINDOWS\system32\visa64.dll
import sys
print(sys.version)
3.7.0b4 (v3.7.0b4:eb96c37699, May 2 2018, 19:02:22) [MSC v.1913 64 bit (AMD64)]
我们将非常感谢这方面的任何帮助。我几天来一直在努力解决这个问题,并且没有设法使它发挥作用。
修改
强制脚本使用64位版本的VISA,仍然无效。
rm = visa.ResourceManager('C:\\WINDOWS\\system32\\visa64.dll')
答案 0 :(得分:0)
我似乎已经解决了这个问题,PSU包含一个USB转串口驱动程序,便于通信。由于PSU通过USB连接,但充当串行设备。但是,包含的驱动程序似乎不够,在安装其他USB到串行驱动程序后,我现在可以与PSU通信。