How can I communicate between Siemens S7-1200 and python?

I run the process on S7-1200 plc, and I need it to send a start signal to my python script, after executing the script, it should send something back to plc to initiate the next step. Oh, and that has to be done in the stairs.

Is there a quick and dirty way to send things through profibus, or am I better off using just something RS232?

+8
source share
7 answers

After abandoning libnodave and OPC, I created a connection with TCON, TSEND, and TRECV. It transmits a byte through TCP, and it works.

+4
source

I would go with SNAP7 and python-snap7 libraries. An example of how to install it on Raspberry pi can be found on this blog: http://simplyautomationized.blogspot.com/2014/12/raspberry-pi-getting-data-from-s7-1200.html

Update:

Setup video walkthrough: https://youtu.be/yJNEsI5KJxs

+5
source

I would use libnodave on the PC side to change the value of some M tag or DB tag in the PLC. You can easily make a staircase that will control this tag and perform further actions. Although libnodave does not support Python natively, you can find the python shell here .

+4
source

Well, a quick google from "python rs232" has some kind of website talking about how to control robots through rs232 using pySerial . Therefore, if you know how to connect your widget to rs232, you can go along this route.

+2
source

A commercial library called "S7connector" from Rothenbacher GmbH (obviously this is not a "s7connector" at sourceforge). This is for the .NET platform, so it can be used with IronPython.

It works with PLC S7-1200. You just need to make sure that the database with which you want to read / write is not an optimized S7-1200 database, but a S7-300 / 400 compatible version that you can install when creating the database on the TIA portal. This library also allows you to read and write all I / O ports - "shadow registers" (not sure if they are called officially) and directly, as well as overriding the first one.

+2
source

Several Modbus TCP clients are available for Python, I have successfully used pyModbusTCP. The TIA portal for the IDE for S7-1200 has a Modbus server function that you can download to your PLC, which allows you to read and write directly to the PLC.

https://support.industry.siemens.com/cs/ww/en/view/83130159

+2
source

The best way to communicate with the S7-1200 PLC processor is OPC UA or Classic OPC (also known as OPC DA). Libnodave is for the S7-300, and the S7-400 is not for the S71200 (firmware 2.x).

If you are using a third-party solution to communicate with the S7-1200 (or S7-1500), you will have to lower the security level in the PLC by allowing the “put” and “receive” mechanism. Lay and receive pure evil in use. You open processor memory for each process. Do not use them anymore. Siemens must actually block this.

This applies to all firmware versions for the S7-1200. Siemens is pushing the people you use OPC UA as the default connection from the PLC. Which makes sense because OPC UA is a protocol for industry 4.0 and IIoT.

Edit: rewrite everything. The information was very outdated. If you are using firmware 2 or 3 1200, consider replacing or updating. These versions are no longer supported and contain a worm issue.

+1
source

Source: https://habr.com/ru/post/914368/


All Articles