我的目标是使用 modbus rtu 在树莓派上使用 Python 脚本从 Schneider 读出 PM5100。
我已经能够使用 modbus 为另一个仪表(SDM220)做到这一点,它工作得很好,但我似乎无法在这个仪表上做到这一点。
PM5100 我配置为:
slave adr:1
波特:19200
奇偶校验:无
我认为布线应该没问题,GND 和屏蔽没有连接,但 D1 和 D0 带有 RS485 到 USB 连接器。
简单代码:
#!/usr/bin/python3
import minimalmodbus
mb = minimalmodbus.Instrument("/dev/ttyUSB0", 1)
mb.serial.baudrate = 19200
mb.debug = True
val = mb.read_float(3212,3,4)
print(val)
这会生成错误 InvalidResponseError:
MinimalModbus debug mode. Will write to instrument (expecting 13 bytes back): 01 03 0C 8C 00 04 86 B2 (8 bytes)
MinimalModbus debug mode. Clearing serial buffers for port /dev/ttyUSB0
MinimalModbus debug mode. No sleep required before write. Time since previous read: 439371243.54 ms, minimum silent period: 2.01 ms.
MinimalModbus debug mode. Response from instrument: 7F 7E DE CE F7 F3 13 (7 bytes), roundtrip time: 0.1 ms. Timeout for reading: 50.0 ms.
Traceback (most recent call last):
File "1.py", line 9, in <module>
val = mb.read_float(3212,3,4)
File "/usr/local/lib/python3.7/dist-packages/minimalmodbus.py", line 717, in read_float
payloadformat=_Payloadformat.FLOAT,
File "/usr/local/lib/python3.7/dist-packages/minimalmodbus.py", line 1245, in _generic_command
payload_from_slave = self._perform_command(functioncode, payload_to_slave)
File "/usr/local/lib/python3.7/dist-packages/minimalmodbus.py", line 1330, in _perform_command
response, self.address, self.mode, functioncode
File "/usr/local/lib/python3.7/dist-packages/minimalmodbus.py", line 1867, in _extract_payload
raise InvalidResponseError(text)
minimalmodbus.InvalidResponseError: Checksum error in rtu mode: 'ó\x13' instead of '\\>' . The response is: '\x7f~ÞÎ÷ó\x13' (plain response: '\x7f~ÞÎ÷ó\x13')
那么,我做错了什么?
- 不确定我是否使用了正确的寄存器,但它也不适用于其他号码。
- 错误的图书馆?会很奇怪,因为它适用于其他仪表(SDM220)
- 我尝试更改为“read_register”并更改参数但没有运气
欢迎有任何经验、提示、猜测或答案的人回复。谢谢!
来源:
PM5100:https
://www.se.com/be/nl/product/METSEPM5100/pm5100-meetcentrale---tot-15de-h---1do-33-alarmen--paneelmontage/
注册列表:https: //www.se.com/ww/en/download/document/PM5100-PM5300_PublicRegisterList/
RS485 转 USB:https ://www.bol.com/be/nl/p/usb-to-rs485-485-converter- adapter-support-win7-xp-vista-linux-mac-os-wince5-0/9300000012988342/?Referrer=ADVNLGOO002013-G-120928976848-S-1076696512011-9300000012988342&gclid=Cj0KCQiAsqOMBhDFARIsAFBTN3epmK66KNj2IufWmjeGY_nkGep_roirDZxfyLu0H3UaVYvewlDRMx4aAhgwEALw_wcB
minimalModbus: https://minimalmodbus.readthedocs.io/ zh/stable/readme.html