Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在支持以太网的delta plc和python pymodbustcp之间进行通信_Python_Python 2.7_Plc_Pymodbus3_Pymodbustcp - Fatal编程技术网

如何在支持以太网的delta plc和python pymodbustcp之间进行通信

如何在支持以太网的delta plc和python pymodbustcp之间进行通信,python,python-2.7,plc,pymodbus3,pymodbustcp,Python,Python 2.7,Plc,Pymodbus3,Pymodbustcp,请帮帮我 我的第一个测试是使用Delta DVP-12SE11R PLC,连接是Modbus TCP/IP协议。我有一个使用pymodbustcp模块编写的python代码。我已经用modbus从站模拟器测试了该代码,它工作正常。在模拟器上读取和写入所需的寄存器。我的问题是,当我将plc硬件连接到PC,并向python代码提供plc的ip地址和端口号时,它将开始读取和写入我在代码中指定的寄存器,还是缺少通信所需的某些内容 这就是我正在使用的: from pyModbusTCP.client im

请帮帮我 我的第一个测试是使用Delta DVP-12SE11R PLC,连接是Modbus TCP/IP协议。我有一个使用pymodbustcp模块编写的python代码。我已经用modbus从站模拟器测试了该代码,它工作正常。在模拟器上读取和写入所需的寄存器。我的问题是,当我将plc硬件连接到PC,并向python代码提供plc的ip地址和端口号时,它将开始读取和写入我在代码中指定的寄存器,还是缺少通信所需的某些内容

这就是我正在使用的:

from pyModbusTCP.client import ModbusClient
c=ModbusClient(host='localhost',port=9999,auto_open=True)

regs=c.read_holding_registers(403705,1)
print("reading register values")


if regs:
    print(regs)
else:
    print("error")

print("write value to register")
a=int(input())
c.write_single_register(403705,a)

我确实使用python link tcp模拟器进行了检查,它与模拟器配合得很好。

您能通过tcp管理与硬件PLC的连接吗?我计划做类似的项目,并寻找可能性。您能通过TCP管理与硬件PLC的连接吗?我计划做类似的项目,并寻找可能性。