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.

New Here? Please read this important info!!!


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

Reply
 
Thread Tools Display Modes
Old March 7th, 2020, 09:53 PM   #31
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 7,215
I have some old S7-300 code that uses Tsend and Trecv to implement a UDP transfer. It worked on a S7-300 with a built in Ethernet port.
I wrote two FBs. One would do a read and the other a write.
The Tsend and Trecv are basically the S7's version of socket commands.
The main problem I see with my code is that it uses a combination of LD and STL so it won't work with S7-1200s or S7-1500s as the STL is different.


I used a different header than a Modbus TCP header. My header is 16 bytes long and ensures all the data is word or dword aligned unlike Modbus TCP.
https://deltamotion.com/peter/S7/Pndp-udp.zip
This code was used only a few times and was ignored after Profinet came out.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old March 8th, 2020, 06:02 AM   #32
(8{)} ( .)
Lifetime Supporting Member
Israel

(8{)} ( .) is offline
 
(8{)} ( .)'s Avatar
 
Join Date: Apr 2004
Location: Israel
Posts: 604
What's your OS? Can't you use Node-Red? I seem to remember seeing an S7 connector. Modbus is there for sure (I've used it.)

Good Luck!

(8{)} (: .)


Yosi
  Reply With Quote
Old March 25th, 2020, 05:12 AM   #33
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)
  Reply With Quote
Old October 16th, 2020, 08:47 AM   #34
vsajay
Member
India

vsajay is offline
 
Join Date: Aug 2020
Location: Maharashtra
Posts: 1
Quote:
Originally Posted by Thomas_v2 View Post
Hi,
there are at least three possible ways to communicate with a S7-1200.

1) Using a raw TCP connection
On plc side this is called open communication.
You have to configure a connection (active or passive), and to program the communication functions TSEND/TRECV.
On python side you can use the usual python sockects.
Seems easy, but you remind that TCP is a stream and you have to consider the different endianess in a Siemens plc.

2) Using native S7 protocol with additional communication library
On plc side you have to do nothing.
On python side you need an additional communication library which implements the S7 protocol.
For python this could be this:
https://pypi.python.org/pypi/python-snap7/

You get only access to not-optimized datablocks in your S7-1200.

3) Using Modbus TCP
On plc side you have to program the modbus function blocks.
On python side you'll need a modbus TCP library.

How do I proceed with the 3rd option to communicate with a PLC through my python code using modbus TCP?
  Reply With Quote
Old October 16th, 2020, 03:20 PM   #35
Thomas_v2
Member
Germany

Thomas_v2 is offline
 
Join Date: Apr 2009
Location: Ger
Posts: 441
Quote:
Originally Posted by vsajay View Post
How do I proceed with the 3rd option to communicate with a PLC through my python code using modbus TCP?
You call the MB_SERVER block from the Siemens library in the S7-1200, enter the data area at the MB_HOLD_REG parameter. Then you can read or write this data from your Python program using a Modbus TCP client library like PyModbus using holding registers. The disadvantage is that the MB_SERVER by default allows the Client to read and write the process image of the S7-1200.
  Reply With Quote
Old October 17th, 2020, 09:02 PM   #36
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 7,215
I would look carefully at the snap solution Thomas posted a link to/
You don't want to use the TSEND and TRECV because then you would be writing the Ethernet code on both the PLC and whatever is running python.
Yes python can send data by bytes, words or what ever you want but python doesn't make it as easy as with C because python doesn't support structures. You need to pack data in python to build the header or learn how to unpack data to read the header.


It is easy to send a simple text message but harder to do something useful.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  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
PC and PLC Communication DiegoE LIVE PLC Questions And Answers 6 September 30th, 2014 08:56 AM
Universal PLC Monitor Nitay LIVE PLC Questions And Answers 11 August 15th, 2014 05:11 AM
PC <-> PLC & real time communication DINT2 LIVE PLC Questions And Answers 1 February 11th, 2014 03:21 PM
Communication between Simotion and Linux wim_ LIVE PLC Questions And Answers 1 April 16th, 2010 04:41 AM
A communication problem between a PLC and a PC through WLAN Decamber LIVE PLC Questions And Answers 3 October 15th, 2008 08:45 AM


All times are GMT -4. The time now is 06:07 AM.


.