fbpx

S7 Connection

Which Protocol is best for connecting S7 PLCs?

A solid data foundation is crucial in every IIoT solution because it defines what your algorithms and applications can offer your users and how fast you can iterate and extend your applications.

How does connectivity to your PLC decide how good your data foundation is? Depending on the protocol, you can collect more data points at higher sampling rates and achieve higher reliability. The overall IIoT solution depends on the breadth and depth of data you can reliably collect. A good predictive maintenance algorithm can work with motor temperature, torque, rpm, and current collected every 100ms but will struggle with just the motor rpm collected every 10s.

Assumptions

This post will consider Siemens S7 PLCs, specifically OPC UA, S7Com, and JsonRPC. We won’t discuss other communication methods driven by the PLC program, like Modbus TCP and Open User Communication (OUC). We will also assume that you are the machinery builder or have full access to the PLC (TIA) project to enable hardware settings (like PUT/GET access or the webserver). If not, you can still require your suppliers to use a specific protocol; otherwise, you are stuck with whatever is available.

OPC UA, S7 Com and JSON-RPC in detail

What is OPC UA?

OPC UA is the standard in Industry 4.0, created to standardize communication and even data models across different PLC/device manufacturers, machine builders, and end customers.

The main advantage of OPC UA is that it is open source and standardized, includes security features like encryption and authorization, and allows symbolic addressing (at least with S7-1500) of tags/variables.

What is S7-Com?

S7 Communication is a proprietary Siemens protocol that all S7 PLCs support. You will typically use it via ethernet on new machines, but you can even use it via Profibus or MPI interfaces of older PLCs. The officially documented use case is PLC-to-PLC communication (via PUT/GET instructions in the PLC program). However, S7-Com is also used internally for HMI to PLC communication or when you monitor a PLC program in the TIA Portal. There are two “flavors” of S7-Com, the normal S7-Com and S7-Com-Plus, introduced with the S7-1200/1500 PLC generation. We won’t consider S7-Com-Plus today because no open-source S7-Com-Plus clients are available.

The main advantages of S7 communication are broad support across older PLCs, no cost, and low complexity (The node.js client for OPC UA has ~212 000 lines of code, compared to ~ 2200 for the s7com client – FOOTNOTE?)

What is JSON-RPC?

JSON-RPC was introduced in the Siemens PLC world with the TIA Portal V16 (for S7-1500 and V17 for S7-1200) update. This update extended the integrated web server on the CPU with a JSON-RPC V2.0 API based on HTTP. JSON-RPC is a lightweight remote procedure call protocol and probably the most “IT-native” way to communicate with S7 PLCs.

The main advantages of the JSON-RPC are that the specification is open source, the communication is encrypted and authorized, and it can be easily used without additional dependencies in almost all programming languages (it just takes an HTTP Post request).

Why consider alternatives? Isn't OPC UA the gold standard?

Yes, OPC UA is the standard in PLC connection – but it also comes with some trade-offs:

  • Cost – You have to pay Siemens for the OPC UA Server License
  • Performance – Depending on your data structures, OPC UA can perform worse than the alternatives
  • Complexity – The implementation of an OPC UA client is significantly more complex than that of an S7 Communication client
  • Team structure – Using more IT-focused protocols can make it easier for IT guys to handle the PLC connectivity

Okay, so what is the best S7 connection protocol? As always, it depends:

What protocol has the best performance?

We tested all three protocols and benchmarked their performance as an indication. However, benchmarks can depend on your data structures and the specific client library you choose. If you are interested in knowing which protocol performs best for your specific data structures and your specific S7 model, shoot us a message. We can repeat the tests with your data structures or provide the benchmark code so you can repeat the tests with your PLC model.

Test clients -> node js

Test cases:

  • Bitmeldungen – 3000
  • Variables – 5000 Real, 5000 Integers
  • Read as Array
  • Single bit
  • Single variable

What protocol has the necessary features?

Security

A security concept for the overall machine and IIoT solution is important. We always recommend dedicated gateway hardware between the PLC and the IIoT backend, because the gateway can be updated with security fixes – while the PLC firmware usually is not updated. This gateway is then the seperation between networks. In this case the security between PLC and the Gateway located in the Machine Network

  • Cert update and time sync issues
  • Marginal security by encrypting that part of the communication

Symbolic addressing

  • S7 address shifts are tricky and deadly -> Use interface DBs that are extend only (reserve areas not recommended)
  • Important

Sind Sie an der Anbindung einer dieser Datenquellen interessiert?