Interview Davide Nardella English
Creator of Snap7 open source library for communicate with Siemens PLC
"I'm the software manager of MASMEC SPA, an italian company working in the field of industrial automation and biomedic technologies"
Can you introduce yourself?
I'm the software manager of MASMEC SPA, an italian company working in the field of industrial automation and biomedic technologies.
Our core business is building high speed assembly lines for the automotive industry. The software department that I coordinate consists of 20 employees.
Our clients are big corporates that produce cars and automotive components in all over the world.
What is the origin of Snap7 project?
Snap7 was born to meet the hi-speed requirements of our production. A station in a plant of 3.5 sec/piece has not more than 100 ms of time to know from a server if a piece must be worked or not and this interval cannot be hidden by other operations.
After two years of internal use I decided to publish snap7 as open source library first because I currently use open source software and I wanted to contribute to the community, second for the feedback from the users about bugs and improvements that help me to improve the product.
What is Snap7?
Snap7 is a communication library that allows your application to exchange data with Siemens S7-CPU. It's multi-platform, currently Windows, Linux, BSD, Solaris, OSX are supported and it's multi-architecture, 32/64 bit for Intel/AMD/Sparc and 32 bit for ARM and MIPS. It's fully thread safe and supports asynchronous data exchange. It's non only a communication driver, i.e the client that connects to a PLC, it contains other two object : the server and the partner.The first simulates a communication processor (CP), accepts S7 connections by external clients, and replies to their requests.This means that the data areas of your application, array, structs and so on, can be seen by a commercial HMI/OPC/SCADA as standard DB.I.e. you can connect a commercial HMI panel to your PC/Raspberry which is recognized (also by Simatic Manager) as a S7 315-2PN/DP CPU.The partner implements the BSend/BRecv protocol to get unsolicited data from the PLC, i.e the plc sends the data when it wants. This is usefull when hundreds of PLC need to store data in the most efficient way.
Finally Snap7 is deployed with many high level wrappers that help you to import the functions in your preferred language. Currently you can find wrappers for C, C++, Delphi/Lazarus, .NET (C#/VB), LabVIEW, Python, Node.JS. There is also an user that is working on a Ruby wrapper.
There are other two projects related to Snap7 : Moka7 and Settimino.The first is the Java port of Snap7, it's not an adapter but a set of pure standard-java classes that can be used in your program under all platforms that support Java, including Android.The second is the rewrote part of the client for Arduino, optimized for a small footprint. You can find it to http://settimino.sourceforge.net/.
What are main features of new snap7 version?
In the last release, aside small bugfixes and improvements, were introduced:
- The support for big-endian architecture (SPARC and MIPS).
- The support for Arduino-YUN.
- Some helper classes to map s7 types into .NET/C/Pascal native types and vice versa and that perform the big-endian/little-endian conversion.
- Extensive tests under Windows 10 technical preview.
Snap7 is an active project, I plan to support new architectures as ARM-V8 (64 bit) as I have an hardware to work with and new OS as iOS as I have a bit of free time...
What PLC model can we use with snap7?
Snap7 can communicate with all Siemens S7-Family PLC including, with some small limitations, S71200, S71500 and LOGO 0BA7/0BA8.It works well also with 100% compatible S7 CPU as VIPA.
What are differences between OPC server and Snap7 driver?
OPC server is an OLE/COM/DCOM object that offers a standard interface for communicating with all PLC.Its model is a proven industrial standard and provides to your application an high level layer for abstracting from the plc vendor specific data structures.
If you write an HMI/SCADA/Data collection application working with Siemens S7 you can switch to Rockwell family (buying another OPC server) without modifying your source code, if some adaptations are needed it's because you poorly designed your data model.Snap7 is a native driver, it communicates only with S7 PLC family. It's deployed as binary library that you can link, statically or dynamically, with your application.Snap7 is Siemens data-aware, it speaks of DB, Merkers and so on, if you need to reuse your application for communicating with another PLC family, you need to change the communication layer.
What are the advantages of Snap7 ?
OPC is a commercial (and sometime expensive) product, also its official specifications are not free.OPC is heavy, into the simplest implementation it's composed by an abstraction layer and a native driver, its efficiency is vendor specific.
The industrial rhythm is different from the consumer software rhythm, the choice of adopting a Microsoft "volatile" standard (OLE) had heavily conditioned OPC architecture.If you look to the future you should be aware that today Miscrosoft consider as obsolete ole/com/dcom model.To overcome these limitations and to be cross-platform some new technologies were introduced OPC UA and OPC XML-DA, still more heavy. Snap7 is fast, it can exchange a telegram in 5 ms, it was designed from the outset to be cross-platform and multi architecture, it can only communicate with S7 PLC but this can be made with virtually any OS that supports the ethernet layer.
Snap7 is lite, no installation/administration is required, no third-party libraries are needed, you can write portable applications that runs from a pendrive and after a disaster recovery, also a junior it-technician can setup your application. If the OS can at least breathe Snap7 can work.Finally, snap7 is free and open source with a flexible licence that allows you to use it with no limitations in your commercial application.I know for a fact that some big companies (that I cannot name here) are migrating their server racks from OPC to Snap7, think about the cost saving on hundreds of licenses.
What application can we do with Node Js and Snap7?
Sorry but I don't know Node Js but there is a very expert user that wrote a wrapper for it.The best way is to visit it to https://github.com/mathiask88/node-snap7
You will find the source code and a lot of documentation.
How can we use Snap7 with Arduino or Raspberry Pi board?
Raspberry Pi and almost all other small Linux based ARM boards are fully supported by Snap7.There are no difference using snap7 under Ubuntu or Raspbian or Windows, if your application, or part of it, is multi-platform, you can use Snap7 library without changing a line of code.For Arduino, as said, there is the Settimino project, a source code Arduino-style library that you can import with Arduino IDE.