help!! PLC and Python Communication

othmane

Member
Join Date
Apr 2019
Location
maroc
Posts
3
Hi, I need to create a Python script to exchange data with a PLC schneider modicon m580 via Ethernet cable, if anyone knows something and can help me I appreciate it.
 
M580 supports Modbus TCP/IP natively, it has a built in client.


M580 unfortunately does not support natively free TCP socket so you would have to use Modbus TCP or use a partner third party module like this one to be able to use the socket https://www.youtube.com/watch?v=hp2M94BNvh4
I never tried it but that's the answer I got from Schneider when I asked about the possibility of doing a standard and simple TCP communication with M580.

Using Modbus TCP/IP means implementing a Modbus server in your Python application. That means you will have to program or use existing library to meet the requirement of the protocol.

Modbus TCP is a client/server protocol. The client send a request including a function code and the server perform the request and give an answer.
 
Last edited:
yeah it does, i was actually wandering if it is possible to communicate with it without modbus only over ethernet tcp ip, python is gonna be a server so the script with sockets is pretty simple , but the configuration on unity pro is complicated
 
Modbus is not the best protocol out there, but to communicate you'd need to have A protocol and using Modbus, which is supported, is likely more reliable and easier than writing your protocol from scratch.

But that's just my opinion.
 
Using a raw socket would be simplier in his case than integrating a Modbus library or writing his own Modbus server. It' just not possible natively with the M580 while it is possible with the Siemens PLC, the Rockwell PLC and even some of other Schneider PLC (Premium and even maybe M251). That's the M580/M340 biggest problem I think.


The documentation of the M580 module is there http://www.niobrara.com/apps/pmeucm/tcpopen/PMEUCM_TCPOPEN.pdf


I don't know how much it cost and how well it works.
 
Last edited:
thanks guys, but do you have any idea how to write a python scripts of server modbus tcp
so i can send the data to my plc
and any way to configure the unity pro to receive the data
 
Using a raw socket would be simplier in his case than integrating a Modbus library or writing his own Modbus server.

I was under the impression that CPU supported ModbusTCP out of the box.

The Python library I linked does the Modbus server role quite well in my experience so far with conversions for data types and endianness as well.
 
thanks guys, but do you have any idea how to write a python scripts of server modbus tcp
so i can send the data to my plc
and any way to configure the unity pro to receive the data


Writing a Modbus server could take you weeks. The protocol isn't hard but you would need to implement yourself the protocol.

Take a look at the github link that cardosocea provided above. It probably contain all you need.

For the M580 side, you need to open your Unity project, go to tools tab, "open DTM navigator"

From there you will have access to the network configuration of your CPU. The M580 can do natively both EIP and Modbus/TCP. You add devices that you want to communicate with. Use "Generic Modbus device" when you add a device as Modbus does not need a description file. From there you give it an IP adress and define the communications (numbers of bytes/bits, type of data). Take a look at how to use the DTM.
 
I was under the impression that CPU supported ModbusTCP out of the box.

The Python library I linked does the Modbus server role quite well in my experience so far with conversions for data types and endianness as well.


The M580 does support Modbus TCP very well natively.


However, implementing Modbus within a Python application is much harder than using a raw socket which is very standard for a PC application.

Modbus is a protocol application that use the standard TCP stack. Schneider does not give us access to this stack. Modbus is on top of TCP.

If the thread starter just need to send characters to print, just need to display values on his PC, he doest not really need Modbus functions, registers, acknowledge, handshake, communication timeout.... If he needs IO extchanges for control, then Modbus is a much better pick than raw sockets.
 
Here two pictures to illustrate how to parameter the modbus requests on M580.

t1.png t2.png
 
Last edited:
However, implementing Modbus within a Python application is much harder than using a raw socket which is very standard for a PC application.
You're right, I was also looking at it from the point of view that there is already a Python module for Modbus comms.

If the thread starter just need to send characters to print, just need to display values on his PC

None of OP's comments so far indicate that he's looking to receive characters to print or display a single character/value.
He mentioned data exchange... now if he needs to transmit any more than a single value, he needs a protocol to do so.
So defining and programming a protocol via sockets is likely to take longer than using something already existing. Which is why I would think Modbus to be a better solution.
 
Hi guys.
I'm triying communicate a M580 with a printer by ethernet IP because I want to send from the plc information to be printed but I don't know how do it.
Can someone help me please?
 

Similar Topics

Hi, I need to create a Python script to exchange data with a PLC Siemens S7-1200 via Ethernet cable, if anyone knows something and can help me I...
Replies
38
Views
30,855
I have a network with 4 PLCs PLC1 is controllogix and PLCs 2-4 are compactlogix and they all need to communicate. The current way I have this...
Replies
8
Views
255
So to start off: I have no experience with PLC's, but I'm good at figuring stuff out, but I need some help to know if my PLC is just dead in the...
Replies
2
Views
110
Hi guys, I have no experience when working with AllenBradley PLC, but I hope someone could clarify the result of multiplication shown in the...
Replies
14
Views
2,178
To quickly test a plc output which is wired to a relay do I dob a cable between the output and 24vdc+ source I.e something with 24vdc+ live such...
Replies
6
Views
683
Back
Top Bottom