You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old March 25th, 2020, 04:15 AM   #1
Akashban
Member
India

Akashban is offline
 
Join Date: Mar 2020
Location: Goa
Posts: 5
How can i communicate between delta plc with Ethernet support and python with pymodbu

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_ope n=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
  Reply With Quote
Old March 25th, 2020, 11:13 PM   #2
Psnikta
Member
Australia

Psnikta is offline
 
Join Date: Mar 2020
Location: QLD
Posts: 7
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
  Reply With Quote
Old March 26th, 2020, 04:20 AM   #3
Akashban
Member
India

Akashban is offline
 
Join Date: Mar 2020
Location: Goa
Posts: 5
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 by Akashban; March 26th, 2020 at 04:28 AM. Reason: Extra things added
  Reply With Quote
Old March 26th, 2020, 06:03 AM   #4
Psnikta
Member
Australia

Psnikta is offline
 
Join Date: Mar 2020
Location: QLD
Posts: 7
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.
  Reply With Quote
Old March 26th, 2020, 06:27 AM   #5
Akashban
Member
India

Akashban is offline
 
Join Date: Mar 2020
Location: Goa
Posts: 5
Okay thankyou very much.
I will try that
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
PLC and Python Communication, HELP DiegoE LIVE PLC Questions And Answers 32 March 25th, 2020 04:12 AM


All times are GMT -5. The time now is 04:03 AM.


.