How connect Arduino based PLC with Siemens PLC equipped with Ethernet port

On this post it is showed how to connect Industrial Shields Arduino based PLC (M-Duino‘s) with a Siemens PLC equipped with Ethernet port or communication processor. Any PLC is supported except for old S5 family. To do that we have to use Settimino. Settimino is an open source Ethernet library for interfacing Arduino with Siemens S7 PLC’s. CPU’s 1200/1500 LOGO 0BA7 and S7200 are also supported. Download Settimino from the link.

Once we have all the requirements, we can proceed to explain how it works. The main class is S7Client object that is able to connect and transfer data between Arduino based PLC and Siements PLC. Ethernet W5100 chip support 4 clients and uses a one data buffer for the entire client because just one can be connected at the same time. This data buffer can contain just one PDU (see the Siemens communication to know what that means).

The PDU variable is global, this means that is visible from the sketch. See an example (consult the syntax of the S7Client to get a better understanding).

We are saying that the client can access to the database 24, read 64 bytes from 0 to 64 and handle into the internal buffer.

To write we have to do it on the same way putting data to PDU.DATA[] and then call WriteArea().

S7Helper

The Siemens data is Big-enidan and the Arduino data is Little-endian. S7Helper is an object that allows to extract values right to left with an intermediate format memory bytes. The name of the request is S7.

To optimize even more the print, tree memory models are available: small, normal and extended.

Even though extended model works perfectly on Arduino Leonardo and Arduino Mega, it is possible that you wish reduce even more the using memory. For example, Settimino Client can control the Stop mode or Run mode of the PL, but if you just need read/write data you don’t need this feature.

To establish memory model that you need simply to modify the directive on the beginning of the Settimino.h writing:

#define _SMALL
or
#define _NORMAL
or
#define _EXTENDED

The small model has the minimum group of functions to connect to a PLC and reading/writing data.

The normal mode has the S7Helper.

Finally the extended model has also the remaining extended functions.

By default Settimino is released as Extended.

Configuration S7 1200:

On DB properties you must select “Access optimized to the block” on attribute tab.

On protection area of the PLC properties you just must select “Complete access (without protection)” and “Allow access PUT/GET communication from PLC, HMI, OPC… “