概括
我正在使用此 USB 转 RJ45 电缆将我的 Windows 10 开发人员工作站连接到EPEver Tracer 3210an 太阳能充电控制器。
我正在使用带有minimalmodbus
模块的 Python 3.8.6 来尝试连接到设备、检索数据和控制设备参数。
预期结果
充电控制器返回光伏 (PV) 面板的输入电压。
实际结果
MinimalModbus debug mode. Create serial port COM4
MinimalModbus debug mode. Will write to instrument (expecting 7 bytes back): '\x01\x041\x00\x00\x01?6' (01 04 31 00 00 01 3F 36)
MinimalModbus debug mode. Clearing serial buffers for port COM4
MinimalModbus debug mode. No sleep required before write. Time since previous read: 105406.00 ms, minimum silent period: 1.75 ms.
MinimalModbus debug mode. Response from instrument: '' () (0 bytes), roundtrip time: 1015.0 ms. Timeout for reading: 1000.0 ms.
Traceback (most recent call last):
File "tempCodeRunnerFile.python", line 17, in <module>
pv_voltage = ins.read_register(PV_VOLTAGE, 2, 4, False)
File "C:\Users\TrevorSullivan\scoop\apps\python\current\lib\site-packages\minimalmodbus.py", line 441, in read_register
return self._generic_command(
File "C:\Users\TrevorSullivan\scoop\apps\python\current\lib\site-packages\minimalmodbus.py", line 1170, in _generic_command
payload_from_slave = self._perform_command(functioncode, payload_to_slave)
File "C:\Users\TrevorSullivan\scoop\apps\python\current\lib\site-packages\minimalmodbus.py", line 1240, in _perform_command
response = self._communicate(request, number_of_bytes_to_read)
File "C:\Users\TrevorSullivan\scoop\apps\python\current\lib\site-packages\minimalmodbus.py", line 1406, in _communicate
raise NoResponseError("No communication with the instrument (no answer)")
minimalmodbus.NoResponseError: No communication with the instrument (no answer)
代码
import minimalmodbus
import serial
ins = minimalmodbus.Instrument('COM4', 1, debug=True)
ins.serial.baudrate = 115200
ins.serial.bytesize = 8
ins.serial.stopbits = 1
ins.serial.parity = serial.PARITY_NONE
ins.serial.timeout = 1
ins.mode = minimalmodbus.MODE_RTU
ins.clear_buffers_before_each_transaction = True
PV_VOLTAGE = 0x3100
pv_voltage = ins.read_register(PV_VOLTAGE, 2, 4, False)
print(pv_voltage)
我试过的
- 改用
pymodbus
模块 - 试过
easymodbus
模块 - 将波特率更改为
9600
- 尝试使用
ASCII
模式而不是RTU
(99% 确信它需要RTU
模式) - 将串行设备上的 COM 端口从更改
COM3
为COM4
- 重新启动计算机
- 将 MT-50 显示器连接到充电控制器(完美运行)
- 将设置更改
parity
为其他值(偶数、奇数、空格等)
问题
- 如何成功地将我的开发人员工作站连接到充电控制器?
- 这条电缆有没有可能已经死了?
- 我还能做些什么来测试电缆以确保其正常工作?
- 我还能做些什么来测试充电控制器以确保其响应?