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

1,875 views
Skip to first unread message

Akash Banaulikar

unread,
Mar 25, 2020, 4:44:48 AM3/25/20
to pymodbus
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)

Akshay Bhavsar

unread,
Mar 26, 2020, 12:39:54 AM3/26/20
to pymo...@googlegroups.com
Hi Akash,

This library doesn't support for the 6 digit modbus addressing. 
U need to try with 5 digit addressing like instead of this 403705 u can use 43705

please check and let me know if this works

Regards,
Akshay

--
You received this message because you are subscribed to the Google Groups "pymodbus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pymodbus+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pymodbus/b857dede-9d84-4401-b1ed-a7149dacfd1f%40googlegroups.com.


--
DataGlen Technologies Pvt. Ltd.

#862, 2nd Floor, GMR Heights,"D" Block, Karnataka Bank Main Road, 
Sahakarnagar, Bangalore - 560 092. | Ph:080-48526626   
https://goo.gl/maps/H3DN57zRHyw
Message has been deleted

Akash Banaulikar

unread,
Mar 26, 2020, 5:09:49 AM3/26/20
to pymodbus
On Thursday, March 26, 2020 at 10:09:54 AM UTC+5:30, Akshay Bhavsar wrote:
> Hi Akash,
>
>
> This library doesn't support for the 6 digit modbus addressing. 
> U need to try with 5 digit addressing like instead of this 403705 u can use 43705
>
>
> please check and let me know if this works
>
>
> Regards,
>
> Akshay
>
>
>
> On Wed, Mar 25, 2020 at 2:14 PM Akash Banaulikar <akashban...@gmail.com> wrote:
> 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)
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups "pymodbus" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an email to pymo...@googlegroups.com.
>
> To view this discussion on the web visit https://groups.google.com/d/msgid/pymodbus/b857dede-9d84-4401-b1ed-a7149dacfd1f%40googlegroups.com.
>
>
>
> --
>
>
>
> DataGlen Technologies Pvt. Ltd.
> http://www.dataglen.com
>
>
>
> #862, 2nd Floor, GMR Heights,"D" Block, Karnataka Bank Main Road, 
> Sahakarnagar, Bangalore - 560 092. | Ph:080-48526626   
> https://goo.gl/maps/H3DN57zRHyw

Thankyou Akshay sir for quick reply
Sir i want to read from a counter register whose modbus address is 403705 so making it 43705 will work as that zero is for padding only. 43705 is same as 403705
And have you used this library before?
If yes then please guide me through this
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
15852136924331282126447.jpg

Akshay Bhavsar

unread,
Mar 26, 2020, 5:22:11 AM3/26/20
to pymo...@googlegroups.com
Hi Akash,

Assuming the PLC has modbus TCP server running , yes this will work .
I have worked on pymodbus , i found difficulty while reading the 6 digit register address.
For 5 digit address it will work good.

use modscan tool first to check if ur getting data from PLC.


this is the link for modscan i hope u will find out how to use it. its easy..

Regards,
Akshay

To unsubscribe from this group and stop receiving emails from it, send an email to pymodbus+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pymodbus/bc1e806e-d03b-4b5a-b0aa-b25d9e033f32%40googlegroups.com.

Akash Banaulikar

unread,
Mar 26, 2020, 5:32:55 AM3/26/20
to pymodbus
Thankyou again sir
I have used modscan before and it is working properly with my plc reading required registers from plc.
I don't know if that 5 digit address will work with modscan.
Can u tell me for which plc did you use pymodbus library??

Akash Banaulikar

unread,
Mar 26, 2020, 5:37:18 AM3/26/20
to pymodbus
If possible sir please tell me your procedure for connecting and reading data from plc via python.
I don't have a plc right now so i will not be able to check modscan.
And please specify any of the simulators if any which i can use for testing

Akshay Bhavsar

unread,
Mar 26, 2020, 5:39:34 AM3/26/20
to pymo...@googlegroups.com
Try with this code


"""
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
client = ModbusClient('ip_address', port='port no')
connection = client.connect()

v = client.read_holding_registers('addresss', 'size', unit='unint_id')
"""

Regards,
Akshay,





--
You received this message because you are subscribed to the Google Groups "pymodbus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pymodbus+u...@googlegroups.com.

Akash Banaulikar

unread,
Mar 26, 2020, 5:41:49 AM3/26/20
to pymodbus
Actually sir pymodbus was not working in my case so i am using pymodbustcp library
https://pypi.org/project/pyModbusTCP/
Is there any difderence between this library and the library you specified?

Akash Banaulikar

unread,
Mar 26, 2020, 8:14:30 AM3/26/20
to pymodbus
thanks sir
This code works fine for reading holding registers
```

from pymodbus.client.sync import ModbusTcpClient as ModbusClient
client = ModbusClient('ip_address', port='port no')
connection = client.connect()

v = client.read_holding_registers('addresss', 'size', unit='unint_id')

```
But how can i write to holding registers as write function only supports input regs and not holding registers

Reply all
Reply to author
Forward
0 new messages