How can i communicate between delta plc with Ethernet support and python pymodbustcp

1.8k Views Asked by At

please help me My first test is with a Delta DVP-12SE11R PLC and the connection is with the Modbus TCP/IP protocol. I have a python code written using pymodbustcp module. I have tested that code with a modbus slave simulator and it is working properly. Reading and writing required registers on simulator. My question is when i connect a plc hardware to PC and provide ip address of plc and port number to python code and it will start reading and writing the registers i specified in code or am i missing somethings that are required for communication?

This is what i am using:

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)

I did check using a python link tcp simulator and it works perfactly with the simulator.

1

There are 1 best solutions below

0
On

Im not a expert, but in your code, you need to change "localhost" for the plc ip address, beacause "localhost" = 127.0.0.1 in your own computer and not your plc.

i have another idea: if youre already change the plc ip address in your code, the plc is in the same network? , if you are working in other network you need work in the same network

finally, the port: 9999 is correct? normally for modbusTCP port is 502 by default, you can change the port like you need, but you need check the port :D

greetings