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

Akashban

Member
Join Date
Mar 2020
Location
Goa
Posts
5
I'm working on an DELTA PLC project and I'm trying to use modbus library to connect to plc
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 wriying 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?

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)

403705 is modbus address of counter c120 in dvpse plc
 
Hi Akashban, I am a little lost on what the question actually is... you can't read modbus registers from the PLC (slave)?


Firstly most PLC will use port 502 as the default port, you are using 9999 by the look. Secondly the function call only seems to include the starting register number and the number of registers, but there is no Unit Identifier (I assume it is using 1).


Are you able to view the modbus message the python script is sending, it should look something like this based on what you have specified:


0001 0000 0006 01 03 0E79 0001
 
Thankyou psnikita for a quick reply
Actually foe now i am using a python link tcp simulator and not the plc so the port 9999 is only for simulation purpose
And from that simulator i am readingonly 1 address so i wrote 1 there as syntax is read_holding_registers(starting address, no of registers, unit)
And with simulator i can see something like this
Tx[35 AE 00 00 00 06 01] 03 00 00 05
and similar for Rx
My plans are
1.i have ladder program written into delta plc
2.plc has tcp/ip suppprt
3.i have written a client code in python which is specified above
4.my question is if i connect a plc with pc and provide plc ip address and port in python code and also the mosbus address of counter register
So are this things suffient to read from plc? Or do i have to perform something extra
I have also tested this python code with python tcp link simulator and it works fine there
Kindly help
 
Last edited:
Hello again Akashban,


I see, in that case the only thing you will need to do is ensure modbus TCP is enabled on the PLC and have the counter mapped to the holding register you are planning to read it from. The PLC will reply to the request the same way the software will.
 

Similar Topics

Hi everyone, I'm working on a project where I need to exchange data between a Siemens S7-1200 PLC and an Allen-Bradley MicroLogix 1400 PLC. The...
Replies
8
Views
484
Hi I'm currently doing a college course in robotics and automation and a question we were asked was. A software application used by production...
Replies
10
Views
3,613
Hi, i have fx5u plc. Want to communicate with citect scada. Have tried multiple protocol but it's not communicated. Can any one help in this topic.
Replies
4
Views
1,778
Can anyone help me getting this communications connection set up between KINCO GL100 and KINCO K508-40AR? I am using Port 1(RS485) on the KINCO...
Replies
1
Views
3,255
Can anyone help me getting this comms connection set up? I am using Port 2 on the Versamax ICU200UDR005-DK, set in SNP with port settings Baud...
Replies
4
Views
1,520
Back
Top Bottom