Pregunta

I am running a process on a S7-1200 plc and I need it to send a start signal to my python script, after the script is done running it needs to send something back to the plc to initiate the next phase. Oh, and it has to be done in ladder.

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

¿Fue útil?

Solución

After failing with libnodave and OPC, I created a TCON,TSEND and TRECV communication thing. It transmits a byte over TCP and it works.

Otros consejos

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

Update:

Video walkthrough on how to set it up: https://youtu.be/yJNEsI5KJxs

I would use libnodave on PC side to change value of some M tag or a DB tag in a PLC. You can easily make a ladder rung which will monitor this tag and execute further actions. Although libnodave doesn't support Python natively, you can find a python wrapper here.

Well, a quick google of 'python rs232' turned up some site talking about doing robotics controls through rs232 using pySerial. So if you know how to hook your widget up to rs232, you could go that route.

There is a commercial library called "S7connector" by Rothenbacher GmbH (obviously it's not the "s7connector" on sourceforge). It is for the .NET framework, so could be used with IronPython.

It does work with S7-1200 PLCs. You just have to make sure a DB you want to read from / write to is not an optimized S7-1200 style DB, but a S7-300/400 compatible one, an option which you can set when creating a DB in TIA portal. This lib also allows to read and write all I/O ports - the "shadow registers" (not sure what they're called officially) and directly as well, overriding the former.

There are several Modbus TCP Clients available for Python, I have used pyModbusTCP successfully. TIA Portal the IDE for the S7-1200 has Modbus Server function that you can load to your PLC that will allow you to read and write directly to the PLC.

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

Ther best way to communicate with S7-1200 PLC cpu's is with OPC UA or Classic OPC (ommonly known as OPC DA. ) Libnodave is made for S7-300 and S7-400 not for S71200 (2.x firmware).

If you use a third party solution to communicate with S7-1200 (or S7-1500) you have to decrease the security level at the PLC by allowing the put and get mechanism. Put and get are pure evil to use. You open the memory of the CPU for every process. Don’t use them anymore. Siemens should actually block this.

This applies for all firmware release for S7-1200. Siemens pushes people you use OPC UA as default communication from PLC. What makes sense, because OPC UA is the protocol for industry 4.0 and IIoT.

Edit: rewrite everything. Info was heavily outdated. If you use a firmware 2 or 3 1200, consider replacement or upgrade. These versions are no longer supported and contains the worm issue.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top