{"id":13105,"date":"2025-02-17T17:00:06","date_gmt":"2025-02-17T16:00:06","guid":{"rendered":"https:\/\/codestryke.com\/?p=13105"},"modified":"2025-11-05T12:01:20","modified_gmt":"2025-11-05T11:01:20","slug":"s7-connection","status":"publish","type":"post","link":"https:\/\/codestryke.com\/s7-connection\/","title":{"rendered":"S7 Connection"},"content":{"rendered":"<p>[vc_row full_width=&#8221;stretch_row_content&#8221; disable_element=&#8221;yes&#8221; kd_background_image_position=&#8221;vc_row-bg-position-top&#8221; el_class=&#8221;single-project-intro&#8221; top_section_title=&#8221;&#8221; bottom_section_title=&#8221;&#8221; css=&#8221;.vc_custom_1762340016424{padding-right: 100px !important;padding-left: 350px !important;}&#8221;][vc_column width=&#8221;1\/6&#8243;]<header class=\"kd-section-title col-lg-12 text-left  subtitle-below-title    vc_custom_1606239828771\" ><h5 class=\"separator_off\" style=\"font-size: 18px;margin-bottom:10px;\">Client<\/h5><h6 class=\"subtitle\" style=\"color: #696969;font-size:16px;\">KeyDesign<\/h6><\/header><header class=\"kd-section-title col-lg-12 text-left  subtitle-below-title   \" ><h5 class=\"separator_off\" style=\"font-size: 18px;margin-bottom:10px;\">Project<\/h5><h6 class=\"subtitle\" style=\"color: #696969;font-size:16px;\">Great Work Done<\/h6><\/header>[\/vc_column][vc_column width=&#8221;2\/3&#8243;]<header class=\"kd-section-title col-lg-12 text-left  subtitle-below-title    vc_custom_1606239824317\" ><h5 class=\"separator_off\" style=\"font-size: 18px;margin-bottom:10px;\">Project Description<\/h5><h6 class=\"subtitle\" style=\"color: #696969;font-size:16px;\">At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore.<\/h6><\/header>[\/vc_column][vc_column width=&#8221;1\/6&#8243;]<header class=\"kd-section-title col-lg-12 text-left  subtitle-below-title    vc_custom_1606239941635\" ><h5 class=\"separator_off\" style=\"font-size: 18px;margin-bottom:10px;\">Categories<\/h5><\/header>[vc_column_text css_animation=&#8221;fadeIn&#8221;]<\/p>\n<ul>\n<li>Branding<\/li>\n<li>Software<\/li>\n<li>Design<\/li>\n<\/ul>\n<p>[\/vc_column_text][\/vc_column][\/vc_row][vc_row disable_element=&#8221;yes&#8221; kd_background_image_position=&#8221;vc_row-bg-position-top&#8221; css=&#8221;.vc_custom_1740066679112{margin-top: 25px !important;margin-bottom: 25px !important;}&#8221;][vc_column][vc_separator][\/vc_column][\/vc_row][vc_row full_width=&#8221;stretch_row&#8221; disable_element=&#8221;yes&#8221; kd_background_image_position=&#8221;vc_row-bg-position-top&#8221; css=&#8221;.vc_custom_1762176226559{padding-bottom: 80px !important;}&#8221;][vc_column css=&#8221;.vc_custom_1541586968176{padding-right: 40px !important;}&#8221; offset=&#8221;vc_col-lg-6&#8243;][vc_row_inner kd_background_image_position=&#8221;vc_row-bg-position-top&#8221;][vc_column_inner width=&#8221;1\/2&#8243; css=&#8221;.vc_custom_1541586958015{padding-right: 0px !important;padding-left: 0px !important;}&#8221;]<header class=\"kd-section-title col-lg-12 text-left  subtitle-below-title kd-animated fadeIn  \" data-animation-delay=200><h2 class=\"separator_off\" >Which Protocol is best for connecting S7 PLCs?<\/h2><\/header>[vc_column_text]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.[\/vc_column_text][\/vc_column_inner][vc_column_inner width=&#8221;1\/2&#8243;][vc_column_text]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.[\/vc_column_text][\/vc_column_inner][\/vc_row_inner][\/vc_column][vc_column css=&#8221;.vc_custom_1541586975592{padding-left: 40px !important;}&#8221; offset=&#8221;vc_col-lg-6&#8243;][vc_custom_heading text=&#8221;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.&#8221; font_container=&#8221;tag:p|font_size:18|text_align:left|line_height:1.6&#8243; use_theme_fonts=&#8221;yes&#8221; css_animation=&#8221;fadeIn&#8221; css=&#8221;.vc_custom_1762175997657{margin-top: 5px !important;}&#8221;][\/vc_column][\/vc_row][vc_row kd_background_image_position=&#8221;vc_row-bg-position-top&#8221; css=&#8221;.vc_custom_1740067412561{margin-bottom: 25px !important;}&#8221;][vc_column]<header class=\"kd-section-title col-lg-12 text-left  subtitle-below-title   \" ><h2 class=\"separator_off\" >Which Protocol is best for connecting S7 PLCs?<\/h2><\/header>[vc_column_text]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.[\/vc_column_text][vc_column_text]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.[\/vc_column_text][\/vc_column][\/vc_row][vc_row kd_background_image_position=&#8221;vc_row-bg-position-top&#8221; css=&#8221;.vc_custom_1740067412561{margin-bottom: 25px !important;}&#8221;][vc_column]<header class=\"kd-section-title col-lg-12 text-left  subtitle-below-title   \" ><h2 class=\"separator_off\" >Assumptions<\/h2><\/header>[vc_column_text]This post will consider Siemens S7 PLCs, specifically OPC UA, S7Com, and JsonRPC. We won&#8217;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.[\/vc_column_text][\/vc_column][\/vc_row][vc_row kd_background_image_position=&#8221;vc_row-bg-position-top&#8221; css=&#8221;.vc_custom_1740067419658{margin-bottom: 25px !important;}&#8221;][vc_column]<header class=\"kd-section-title col-lg-12 text-left  subtitle-below-title   \" ><h2 class=\"separator_off\" >OPC UA, S7 Com and JSON-RPC in detail<\/h2><\/header><header class=\"kd-section-title col-lg-12 text-left  subtitle-below-title   \" ><h3 class=\"separator_off\" >What is OPC UA?<\/h3><\/header>[vc_column_text]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.<\/p>\n<p>The <strong>main advantage<\/strong> 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.[\/vc_column_text][\/vc_column][\/vc_row][vc_row kd_background_image_position=&#8221;vc_row-bg-position-top&#8221; css=&#8221;.vc_custom_1740067564728{margin-bottom: 25px !important;}&#8221;][vc_column]<header class=\"kd-section-title col-lg-12 text-left  subtitle-below-title   \" ><h3 class=\"separator_off\" >What is S7-Com?<\/h3><\/header>[vc_column_text]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 &#8220;flavors&#8221; of S7-Com, the normal S7-Com and S7-Com-Plus, introduced with the S7-1200\/1500 PLC generation. We won&#8217;t consider S7-Com-Plus today because no open-source S7-Com-Plus clients are available.<\/p>\n<p>The <strong>main advantages<\/strong> 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 &#8211; FOOTNOTE?)[\/vc_column_text][\/vc_column][\/vc_row][vc_row kd_background_image_position=&#8221;vc_row-bg-position-top&#8221; css=&#8221;.vc_custom_1740067564728{margin-bottom: 25px !important;}&#8221;][vc_column]<header class=\"kd-section-title col-lg-12 text-left  subtitle-below-title   \" ><h3 class=\"separator_off\" >What is JSON-RPC?<\/h3><\/header>[vc_column_text]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 &#8220;IT-native&#8221; way to communicate with S7 PLCs.<\/p>\n<p>The <strong>main advantages<\/strong> 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).[\/vc_column_text][\/vc_column][\/vc_row][vc_row kd_background_image_position=&#8221;vc_row-bg-position-top&#8221; css=&#8221;.vc_custom_1740067564728{margin-bottom: 25px !important;}&#8221;][vc_column]<header class=\"kd-section-title col-lg-12 text-left  subtitle-below-title   \" ><h3 class=\"separator_off\" >Why consider alternatives? Isn't OPC UA the gold standard?<\/h3><\/header>[vc_column_text]Yes, OPC UA is the standard in PLC connection &#8211; but it also comes with some trade-offs:[\/vc_column_text]<ul class=\"kd-icon-list\" ><li class=\"kd-icon-list-item\"><div class=\"kd-icon-wrapper icon-simple\" ><i class=\"fas fa-money-bill\" ><\/i><\/div><span class=\"kd-list-text\" style=\"color: #7d7d7d;\"><strong>Cost<\/strong> &#8211; You have to pay Siemens for the OPC UA Server License<\/span><\/li><li class=\"kd-icon-list-item\"><div class=\"kd-icon-wrapper icon-simple\" ><i class=\"fas fa-chart-line\" ><\/i><\/div><span class=\"kd-list-text\" style=\"color: #7d7d7d;\"><strong>Performance<\/strong> &#8211; Depending on your data structures, OPC UA can perform worse than the alternatives<\/span><\/li><li class=\"kd-icon-list-item\"><div class=\"kd-icon-wrapper icon-simple\" ><i class=\"fas fa-clipboard-list\" ><\/i><\/div><span class=\"kd-list-text\" style=\"color: #7d7d7d;\"><strong>Complexity<\/strong> &#8211; The implementation of an OPC UA client is significantly more complex than that of an S7 Communication client<\/span><\/li><li class=\"kd-icon-list-item\"><div class=\"kd-icon-wrapper icon-simple\" ><i class=\"fas fa-users\" ><\/i><\/div><span class=\"kd-list-text\" style=\"color: #7d7d7d;\"><strong>Team structure<\/strong> &#8211; Using more IT-focused protocols can make it easier for IT guys to handle the PLC connectivity<\/span><\/li><\/ul>[vc_column_text]Okay, so what is the best S7 connection protocol? As always, it depends:[\/vc_column_text][\/vc_column][\/vc_row][vc_row kd_background_image_position=&#8221;vc_row-bg-position-top&#8221; css=&#8221;.vc_custom_1740067564728{margin-bottom: 25px !important;}&#8221;][vc_column]<header class=\"kd-section-title col-lg-12 text-left  subtitle-below-title   \" ><h3 class=\"separator_off\" >What protocol has the best performance?<\/h3><\/header>[vc_column_text]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.<\/p>\n<p><strong>Test clients<\/strong> -&gt; node js<\/p>\n<p><strong>Test cases:<\/strong>[\/vc_column_text]<ul class=\"kd-icon-list\" ><li class=\"kd-icon-list-item\"><div class=\"kd-icon-wrapper icon-simple\" ><i class=\"fas fa-chevron-right\" ><\/i><\/div><span class=\"kd-list-text\" style=\"color: #7d7d7d;\">Bitmeldungen &#8211; 3000<\/span><\/li><li class=\"kd-icon-list-item\"><div class=\"kd-icon-wrapper icon-simple\" ><i class=\"fas fa-chevron-right\" ><\/i><\/div><span class=\"kd-list-text\" style=\"color: #7d7d7d;\">Variables &#8211; 5000 Real, 5000 Integers<\/span><\/li><li class=\"kd-icon-list-item\"><div class=\"kd-icon-wrapper icon-simple\" ><i class=\"fas fa-chevron-right\" ><\/i><\/div><span class=\"kd-list-text\" style=\"color: #7d7d7d;\">Read as Array<\/span><\/li><li class=\"kd-icon-list-item\"><div class=\"kd-icon-wrapper icon-simple\" ><i class=\"fas fa-chevron-right\" ><\/i><\/div><span class=\"kd-list-text\" style=\"color: #7d7d7d;\">Single bit<\/span><\/li><li class=\"kd-icon-list-item\"><div class=\"kd-icon-wrapper icon-simple\" ><i class=\"fas fa-chevron-right\" ><\/i><\/div><span class=\"kd-list-text\" style=\"color: #7d7d7d;\">Single variable<\/span><\/li><\/ul>[\/vc_column][\/vc_row][vc_row kd_background_image_position=&#8221;vc_row-bg-position-top&#8221; css=&#8221;.vc_custom_1740067564728{margin-bottom: 25px !important;}&#8221;][vc_column]<header class=\"kd-section-title col-lg-12 text-left  subtitle-below-title   \" ><h2 class=\"separator_off\" >What protocol has the necessary features?<\/h2><\/header><header class=\"kd-section-title col-lg-12 text-left  subtitle-below-title   \" ><h3 class=\"separator_off\" >Security<\/h3><\/header>[vc_column_text]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 &#8211; 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[\/vc_column_text]<ul class=\"kd-icon-list\" ><li class=\"kd-icon-list-item\"><div class=\"kd-icon-wrapper icon-simple\" ><i class=\"fas fa-chevron-right\" ><\/i><\/div><span class=\"kd-list-text\" style=\"color: #7d7d7d;\">Cert update and time sync issues<\/span><\/li><li class=\"kd-icon-list-item\"><div class=\"kd-icon-wrapper icon-simple\" ><i class=\"fas fa-chevron-right\" ><\/i><\/div><span class=\"kd-list-text\" style=\"color: #7d7d7d;\">Marginal security by encrypting that part of the communication<\/span><\/li><\/ul>[\/vc_column][\/vc_row][vc_row kd_background_image_position=&#8221;vc_row-bg-position-top&#8221; css=&#8221;.vc_custom_1740067564728{margin-bottom: 25px !important;}&#8221;][vc_column]<header class=\"kd-section-title col-lg-12 text-left  subtitle-below-title   \" ><h3 class=\"separator_off\" >Symbolic addressing<\/h3><\/header><ul class=\"kd-icon-list\" ><li class=\"kd-icon-list-item\"><div class=\"kd-icon-wrapper icon-simple\" ><i class=\"fas fa-chevron-right\" ><\/i><\/div><span class=\"kd-list-text\" style=\"color: #7d7d7d;\">S7 address shifts are tricky and deadly -&gt; Use interface DBs that are extend only (reserve areas not recommended)<\/span><\/li><li class=\"kd-icon-list-item\"><div class=\"kd-icon-wrapper icon-simple\" ><i class=\"fas fa-chevron-right\" ><\/i><\/div><span class=\"kd-list-text\" style=\"color: #7d7d7d;\">Important<\/span><\/li><\/ul>[\/vc_column][\/vc_row][vc_row gap=&#8221;5&#8243; content_placement=&#8221;bottom&#8221; kd_background_image_position=&#8221;vc_row-bg-position-top&#8221; css=&#8221;.vc_custom_1762340324607{margin-right: -300px !important;margin-bottom: -100px !important;margin-left: -300px !important;border-right-width: 300px !important;border-left-width: 300px !important;padding-top: 15px !important;padding-bottom: 10px !important;background-color: #eef9fc !important;background-position: center !important;background-repeat: no-repeat !important;background-size: cover !important;border-radius: 50px !important;}&#8221; top_section_title=&#8221;&#8221; bottom_section_title=&#8221;&#8221; css_tablet_portrait=&#8221;.vc_custom_1762340324607{margin-bottom: -100px !important;}&#8221; css_mobile=&#8221;.vc_custom_1762340324607{margin-bottom: -100px !important;}&#8221; el_id=&#8221;Kontakt&#8221; el_class=&#8221;call-to-action-section&#8221;][vc_column css=&#8221;.vc_custom_1762340283279{padding-right: 130px !important;padding-left: 130px !important;}&#8221; css_tablet_landscape=&#8221;.vc_custom_1762340283279{padding-right: 50px !important;padding-left: 50px !important;}&#8221; css_tablet_portrait=&#8221;.vc_custom_1762340283279{padding-right: 30px !important;padding-left: 30px !important;}&#8221; css_mobile=&#8221;.vc_custom_1762340283280{padding-right: 30px !important;padding-left: 30px !important;}&#8221;]<div class=\"kd-calltoaction\" >\n                <div class=\"container\">\n                  <div class=\"cta-text-container kd-animated fadeIn\" data-animation-delay=\"200\"><div class=\"cta-text\"><h2 style=\"color: #313b46;\">Sind Sie an der Anbindung einer dieser Datenquellen interessiert?<\/h2><\/div>\n                    <\/div>\n                    <div class=\"cta-btncontainer\"><a href=\"https:\/\/codestryke.com\/kontakt\/\"  title=\"Kontakt\" class=\"tt_button tt_primary_button btn_primary_color hover_solid_white button-action-link icon_right kd-animated zoomIn\" data-animation-delay=\"200\">Kontakt<span class=\"fas fa-angle-right iconita\" ><\/span><\/a><\/div>\n                <\/div>\n            <\/div>[\/vc_column][\/vc_row]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[vc_row full_width=&#8221;stretch_row_content&#8221; disable_element=&#8221;yes&#8221; kd_background_image_position=&#8221;vc_row-bg-position-top&#8221; el_class=&#8221;single-project-intro&#8221; top_section_title=&#8221;&#8221; bottom_section_title=&#8221;&#8221; css=&#8221;.vc_custom_1762340016424{padding-right: 100px !important;padding-left: 350px !important;}&#8221;][vc_column width=&#8221;1\/6&#8243;][\/vc_column][vc_column width=&#8221;2\/3&#8243;][\/vc_column][vc_column width=&#8221;1\/6&#8243;][vc_column_text css_animation=&#8221;fadeIn&#8221;] Branding Software Design [\/vc_column_text][\/vc_column][\/vc_row][vc_row [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":13244,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[134],"tags":[],"class_list":["post-13105","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"_links":{"self":[{"href":"https:\/\/codestryke.com\/wp-json\/wp\/v2\/posts\/13105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codestryke.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codestryke.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codestryke.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codestryke.com\/wp-json\/wp\/v2\/comments?post=13105"}],"version-history":[{"count":10,"href":"https:\/\/codestryke.com\/wp-json\/wp\/v2\/posts\/13105\/revisions"}],"predecessor-version":[{"id":13253,"href":"https:\/\/codestryke.com\/wp-json\/wp\/v2\/posts\/13105\/revisions\/13253"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codestryke.com\/wp-json\/wp\/v2\/media\/13244"}],"wp:attachment":[{"href":"https:\/\/codestryke.com\/wp-json\/wp\/v2\/media?parent=13105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codestryke.com\/wp-json\/wp\/v2\/categories?post=13105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codestryke.com\/wp-json\/wp\/v2\/tags?post=13105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}