我正在尝试使用Raspberry Pi 3 Model B来读取Allen Bradly PLC的值。我正在使用Pymodbus Modbus TCP协议在它们之间进行通信。
当我运行测试客户端时,我得到了……
我自己没有使用艾伦布拉德利,但我确实使用了大量的其他PLC,但它们的工作方式大致相同。
您不像在路由器中那样打开端口,而是激活PLC中的modbus连接。大多数情况下它是一个设置,但如果Allen Bradley使用他们自己的专有总线系统(例如Saia S-Bus),你有时需要一个特定的功能块来启用modbus。
例如,快速谷歌搜索显示在micrologix 1400中有一个复选框,用于在某些通道设置下启用modbus tcp。
检查PLC是否有启用modbus主站/客户端的设置(主站=串行或RTU,客户端= TCP但有时制造商不区分它们)。
要测试Raspberry Pi,您可以下载一个modbus服务器模拟器并进行轮询。
要用其他东西来测试PLC,你可以下载一个modbus客户端/主站。我个人使用QmodMaster,它是免费的,适用于测试目的(搜索谷歌)。
此外,请确保使用正确的功能代码进行轮询。这可能会令人困惑,因为保持寄存器(寻址4xxxx)使用功能代码03.输入寄存器(寻址3xxxx)使用功能代码04。
modbus网关用于启用串行modbus(RTU或ASCII)通过TCP进行通信。
如果两个设备都有modbus tcp,则不需要网关。例如,如果您的设备只有有线Modbus(RS232 / 485/422),则可以将其连接到网关,将网关连接到TCP。