【问题标题】:Read SDM120 kwh meter with modbus over tcp/ip通过 tcp/ip 使用 modbus 读取 SDM120 kwh 电表
【发布时间】:2020-12-02 04:08:04
【问题描述】:

我想通过 tcp/ip 使用 modbus 读取 SDM120 kwh 电表的寄存器。我有一个可以运行的 Windows 程序 Simply Modbus。发送到仪表的字节串是“00 01 00 00 00 06 01 04 00 00 00 01”。

我从寄存器 30001 得到结果

但是当我尝试使用 modpoll 执行此操作时,相同的字节字符串会导致另一个答案。

C:\modpoll-3.9\win>modpoll.exe -m tcp -c 1 -r 1 -t3 -1 -p 26 10.40.3.209
modpoll 3.9 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2020 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP, FC4
Slave configuration...: address = 1, start reference = 1, count = 1
Communication.........: 10.40.3.209, port 26, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, input register table

-- Polling slave...
[1]: 17245

当我添加开始寄存器 30001 时,字节串不同 00 01 00 00 00 06 01 04 75 30 00 01 并且我得到一个超时:

C:\Users\adm_ago\Downloads\modpoll-3.9\win>modpoll.exe -m tcp -c 1 -r 30001 -t3 -1 -p 26 10.40.3.209
modpoll 3.9 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2020 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP, FC4
Slave configuration...: address = 1, start reference = 30001, count = 1
Communication.........: 10.40.3.209, port 26, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, input register table

-- Polling slave...
Reply time-out!

我做错了什么?

【问题讨论】:

    标签: modbus-tcp


    【解决方案1】:

    SDM120 docs I found 使用“Modicon Convention Notation”(也称为其他名称)。 Modpoll 使用了more recent standard,所以你需要将'30001'转换过来;前导 3 表示它是一个保持寄存器,“0001”表示寄存器 1(我可以从 SDM120 文档中的 'Modbus Protocol StartAddress Hex' 列中看到这是正确的)。

    Simply Modbus发送的原始字节串00 01 00 00 00 06 01 04 00 00 00 01可以是parsed to

    |-------|------------------------|---------------------------------|
    | Bytes | Description            | Value                           |
    |-------|------------------------|---------------------------------|
    | 00 01 | Transaction identifier | 0x0001 (1)                      |
    | 00 00 | Protocol identifier    | 0 = MODBUS protocol             |
    | 00 06 | Length                 | 0x0006 (6)                      |
    | 01    | Unit identifier        | 0x01 (1)                        |
    | 04    | Function code          | 0x04 (4) - Read Input Registers |
    | 00 00 | Starting address       | 0x0001 (1)                      |
    | 00 01 | Quantity               | 0x0001 (1)                      |
    |-------|------------------------|---------------------------------|
    

    所以您运行的第一个命令modpoll.exe -m tcp -c 1 -r 1 -t 3 -1 -p 26 10.40.3.209 应该检索您需要的寄存器(但是 SDM120 文档还指出“每个参数都保存在两个连续的 16 位寄存器中”,因此您需要检索两个寄存器;我会试试-t 3:float,但你可能还需要-f)。 Modbus 协议适用于 16 位寄存器(输入/保持寄存器),但没有指定如何组合这些寄存器来保存更大的整数或浮点数; SDM 120 文档指出这些被编码为“32 位 IEEE754”,但我看不到任何提及 endianness

    我本来希望收到一个“非法数据地址”来响应您的第二个查询,但这些并不总是返回。因此,为了完整起见,两个不同命令发送不同“字节串”的原因是它们不同(一个请求寄存器 1,另一个请求不存在的寄存器 30000)。

    Modbus 寻址可能会令人困惑 - 我建议阅读 this article 中的“Modbus:当 40001 真正表示 1,或 0 真正表示 1”部分,其中解释了一些问题。

    【讨论】:

      猜你喜欢
      • 2021-12-21
      • 2019-01-20
      • 2020-12-23
      • 2020-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-06
      相关资源
      最近更新 更多