【问题标题】:Siemens Logo! 8 <-> pymodbus西门子标志! 8 <-> pymodbus
【发布时间】:2022-09-29 19:59:32
【问题描述】:

使用 Siemens Logo!Soft Comfort,我想连接 Siemens Logo! (8) 使用 pymodbus

siemens soft comfort 的网络输入设置(我还尝试了 Unit ID 255 和 Modbus 类型“DI”(数字输入))

电脑设置,(两个接口我都试过了)

Pymodbus 代码:

import time

client = ModbusTcpClient(\'192.168.0.3\')
print(client.connect())
while True:
    time.sleep(1)
    print(client.write_coil(1, True))
    time.sleep(1)
    print(client.write_coil(1, False))

输出:

True
Modbus Error: [Input/Output] [WinError 10054] An existing connection was forcibly closed by the remote host
Modbus Error: [Input/Output] [WinError 10054] An existing connection was forcibly closed by the remote host

    标签: python-3.x pymodbus siemens


    【解决方案1】:

    通过 PC 连接 Logo 有两种方式,Logo 充当 Modbus 服务器或 Modbus 客户端。

    标识!作为 Modbus 服务器:

    添加服务器连接:

    将选项完全留空:

    然后,您应该会在徽标底部看到一个小黄色插槽:

    无需进一步配置(图表编辑器可以留空)

    将此配置推送到徽标:

    如原始帖子中所述,将 modbus-tcp-messages 发送到徽标。 Logo!-Settings 中描述了要定位的线圈(它们从 1 开始,而 pymodbus 从 0 开始,因此您需要减去 1:

    所以如果我们要开启Q1:

    from pymodbus.client.sync import ModbusTcpClient
    
    client = ModbusTcpClient('192.168.0.3') # Default port is 502
    client.write_coil(address=8192, value=True) # Default unit_id is 1
    

    标识!作为客户

    添加客户端连接:

    输入要读取的值:

    运行一个 modbus 服务器,见Documentation

    【讨论】:

      猜你喜欢
      • 2021-09-13
      • 2018-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多