OPC UA with SIMATIC S7-1500 and Node-RED · • SIMATIC CPU 1512C-1 PN with Software, PM 1507 and...
Transcript of OPC UA with SIMATIC S7-1500 and Node-RED · • SIMATIC CPU 1512C-1 PN with Software, PM 1507 and...
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved.
Learn-/Training Document
Siemens Automation Cooperates with Education (SCE) | As of Version V15.1
siemens.com/sce
TIA Portal Module 092-303 OPC UA with SIMATIC S7-1500 and Node-RED
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 2
sce-092-303-opc-ua-s7-1500-node-red-en.docx
Matching SCE Trainer Packages for this Learn-/Training Document
SIMATIC controllers with SIMATIC STEP 7 BASIC V15.1
• SIMATIC ET 200SP Distributed Controller CPU 1512SP F-1 PN Safety
Order no.: 6ES7512-1SK00-4AB2
• SIMATIC CPU 1516F PN/DP Safety with Software
Order no.: 6ES7516-3FN00-4AB2
• SIMATIC S7 CPU 1516 PN/DP with Software
Order no.: 6ES7516-3AN00-4AB3
• SIMATIC CPU 1512C-1 PN with Software
Order no.: 6ES7512-1CK00-4AB6
• SIMATIC CPU 1512C-1 PN with Software and PM 1507
Order no.: 6ES7512-1CK00-4AB1
• SIMATIC CPU 1512C-1 PN with Software and CP 1542-5 (CP PROFIBUS)
Order no.: 6ES7512-1CK00-4AB7
• SIMATIC CPU 1512C-1 PN with Software, PM 1507 and CP 1542-5 (CP PROFIBUS)
Order no.: 6ES7512-1CK00-4AB2
SIMATIC STEP 7 Software for Training
• SIMATIC STEP 7 Professional V15.1 - Single License
Order no.: 6ES7822-1AA05-4YA5
• SIMATIC STEP 7 Professional V15.1 - 6+20 User Classroom License
Order no.: 6ES7822-1BA05-4YA5
• SIMATIC STEP 7 Professional V15.1 - 6+20 User Upgrade License
Order no.: 6ES7822-1AA05-4YE5
• SIMATIC STEP 7 Professional V15.1 - Student License for 20 Users
Order no.: 6ES7822-1AC05-4YA5
Open Source Plattform
• SIMATIC IOT2020 with Intel Quark x1000, 512 MB RAM, 1 x Ethernet, 1 x USB
Order no.: 124-4037 – orderable via RS Components rs-components.com
• SIMATIC IOT2040 with Intel Quark x1020 (+Secure Boot),
1 GB RAM, 2 x Ethernet, 2 x RS232/485, 1 x USB, RTC
Order no.: 6ES7647-0AA00-1YA2
• SIMATIC IOT2000EDU S7 Software Controller runs with IOT2020 and IOT2040
Order no.: 6ES7671-0LE00-0YB0
• SIMATIC IO-Shield: SIMATIC IOT2000 Input/Output Module
with 5 DE, 2 DA, 2 AE, ARDUINO Shield for IOT2020/2040
Order no.: 6ES7647-0KA01-0AA2
• 3rd Party IO-Shield: IKHDS-Powershield for IOT2020/2040
with 6 DE, 5 DA (Relais), 1 DA (PWM), 2 AE, 1 AA
Order no.: 100301 – orderable via KAFTAN media UG kaftan-media.com/iot2000
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 3
sce-092-303-opc-ua-s7-1500-node-red-en.docx
Note that these trainer packages are replaced with successor packages when necessary.
An overview of the currently available SCE packages is available at: siemens.com/sce/tp
Continued training
For regional Siemens SCE continued training, get in touch with your regional SCE contact
siemens.com/sce/contact
Additional information regarding SCE
siemens.com/sce
Information regarding use
The SCE Learn-/Training Document for the integrated automation solution Totally Integrated Automation
(TIA) was prepared for the program "Siemens Automation Cooperates with Education (SCE)" specifically
for training purposes for public educational facilities and R&D institutions. Siemens does not guarantee the
contents.
This document is only to be used for initial training on Siemens products/systems. This means it can be
copied in whole or in part and given to trainees/students for use within the scope of their training/course of
study. Disseminating or duplicating this document and sharing its content is permitted within public training
and advanced training facilities for training purposes or as part of a course of study.
Exceptions require written consent from Siemens. Send all related requests to
Offenders will be held liable. All rights including translation are reserved, particularly if a patent is granted
or a utility model or design is registered.
Use for industrial customer courses is explicitly not permitted. We do not consent to commercial use of the
Learn-/Training Document.
We wish to thank the TU Dresden and the Michael Dziallas Engineering Corporation and all other involved
persons for their support during the preparation of this Learn-/Training Document.
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 4
sce-092-303-opc-ua-s7-1500-node-red-en.docx
Table of contents
1 Goal ...................................................................................................................................................... 5
2 Requirement ......................................................................................................................................... 5
3 Required hardware and software ......................................................................................................... 6
4 Theory ................................................................................................................................................... 7
4.1 Node-RED in general .................................................................................................................... 7
4.2 General OPC UA information* ...................................................................................................... 8
4.2.1 Overview ............................................................................................................................... 8
4.2.2 What is OPC? ....................................................................................................................... 8
5 Task .................................................................................................................................................... 10
6 Planning .............................................................................................................................................. 10
7 Structured step-by-step instructions ................................................................................................... 11
7.1 Retrieve an existing TIA Portal project ....................................................................................... 11
7.2 Save, compile, and download the S7 station .............................................................................. 12
7.3 Set the IP addresses of the SIMATIC IOT2000 controller .......................................................... 13
7.4 Open the Node-RED user interface ............................................................................................ 14
7.5 Installation of the required nodes ............................................................................................... 15
7.6 Create the new speed setpoint ................................................................................................... 19
7.7 Access to the OPC UA server .................................................................................................... 22
7.8 Debug output of the setpoint ...................................................................................................... 26
7.9 Change the setpoint via OPC UA ............................................................................................... 28
7.10 Check the setpoint in STEP 7 ..................................................................................................... 32
7.11 Visualization via the dashboard .................................................................................................. 33
7.12 Set the setpoint via the dashboard ............................................................................................. 36
7.13 Check the current setpoint in STEP 7 ........................................................................................ 39
7.14 Checklist – step-by-step instructions .......................................................................................... 40
8 Additional information ......................................................................................................................... 41
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 5
sce-092-303-opc-ua-s7-1500-node-red-en.docx
OPC UA with SIMATIC S7-1500 and Node-RED
1 Goal
The following pages show how the data of a SIMATIC S7-1500 can be accessed across platforms
using OPC UA and Node-RED.
2 Requirement
This module is based on the two modules "SCE_EN_092-302 Node-RED with IOT2000" and
"SCE_EN_092-300 OPC UA with SIMATIC S7-1500 as OPC Server".
In addition, IOT2000 requires a working Internet connection. The easiest way to do this is to set
the IOT to DHCP and connect it to a suitable router.
In the case of IOT2040, you can configure the X1 interface statically (e.g. 192.168.0.1/24) and
connect the X2 interface to the router. This is preset to DHCP. The subnets for X1 and X2 must
not overlap!
Note:
– Controllers and programming station must be located in the same Ethernet network. Ensure
that all nodes are correctly addressed. Each address must be unique!
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 6
sce-092-303-opc-ua-s7-1500-node-red-en.docx
3 Required hardware and software
1 Engineering station: Requirements include hardware and operating system
2 SIMATIC STEP 7 Professional software in TIA Portal – V15.1 or higher
3 OPC Scout software – V10 or higher
4 SIMATIC IOT2000 Controller, e.g. IOT2040
5 SIMATIC S7-1500 controller, e.g. CPU 1516F-3 PN/DP –
Firmware V2.1 or higher with memory card
6 Ethernet-Verbindung zwischen Engineering Station und Steuerungen
4 SIMATIC IOT2000 controller with Node-RED
1 Engineering station
6 Ethernet connection
2 SIMATIC STEP 7 Professional (TIA
Portal) V15.1 or higher
3 OPC Scout V10
or higher
5 SIMATIC S7-1500 controller – Firmware V2.1 or higher
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 7
sce-092-303-opc-ua-s7-1500-node-red-en.docx
4 Theory
4.1 Node-RED in general
Node-RED is a free tool or development environment for interconnecting diverse hardware devices,
APIs and online services. The software was originally developed by IBM and later released as
open source software. Since then it has been continuously developed and is available free of
charge to all users.
The program offers a web interface which can be used for flow-based programming, similar to
function block diagram (FBD) or ladder diagram (LAD) programming of Siemens controllers. The
individual blocks available are called "nodes" here and are comparable to FCs or FBs. They offer
inputs and outputs with which the individual nodes can be connected.
Data is transferred between the blocks in the form of messages. Each message consists of a title
called a topic and a content called a payload. These messages are displayed as JSON (JavaScript
Object Notation).
In addition to the standard nodes, there is an active community that develops additional nodes and
makes these freely available. The public library is available on the Node-RED website:
flows.nodered.org
Node-RED is written in JavaScript and there is also the possibility to develop your own nodes.
Documentation for this is available on the documentation page of the project: nodered.org/docs/
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 8
sce-092-303-opc-ua-s7-1500-node-red-en.docx
4.2 General OPC UA information*
4.2.1 Overview
OPC Foundation is an interest group of well-known manufacturers for the definition of standard
interfaces. In recent years, it has defined a large number of software interfaces to standardize the
information flow from the process level to the management level. According to the different
requirements within an industrial application, different OPC (=Open Platform Communications)
specifications have been developed in the past: Data Access (DA), Alarm & Events (A&E),
Historical Data Access (HDA) and Data eXchange (DX). Access to process data is described in
the DA specification. A&E describes an interface for event-based information, including
acknowledgment. HDA describes functions for archived data. In addition, DX defines a lateral
server-to-server communication.
Based on the experience with these classic OPC interfaces, the OPC Foundation defined a new
platform, called OPC Unified Architecture (UA). The aim of this standard is the generic description
and uniform access to all information which is to be exchanged between systems or applications.
This includes the functionality of all previous OPC interfaces. Furthermore, this has generated the
option of natively integrating the interface into the appropriate system. This is irrespective of which
operating system the system is operated on and irrespective of the programming language in which
the system was created.
4.2.2 What is OPC?
In the past, OPC was a collection of software interfaces for data exchange between PC applications
and process devices. These software interfaces were defined according to the rules of Microsoft
COM (Component Object Model) and were thus easy to integrate in Microsoft operating systems.
COM and DCOM (Distributed COM) provides the functionality of the interprocess communication
and organizes the information exchange between applications, even across computer boundaries
(DCOM). This allows an OPC client (COM client) to exchange information with an OPC server
(COM server) using mechanisms of the Microsoft operating system.
The OPC server provides process information of a device at its interface. The OPC client interfaces
with the server and can access the provided data.
* From SIEMENS application example "Client example for the OPC UA server of a SIMATIC S7-
1500" Entry ID: 109737901, V1.0, 06/2018
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 9
sce-092-303-opc-ua-s7-1500-node-red-en.docx
The use of COM or DCOM means that OPC server and clients can only be operated on a Windows
PC or in the local network and these usually have to use proprietary protocols to communicate with
the corresponding automation system. For network communication between client and server,
additional tunneling tools often have to be used to get through firewalls or to bypass the
complicated DCOM configuration. Moreover, the interface can only be accessed natively with C++
applications. NET or JAVA applications can only access via a wrapper layer. In practice, these
limitations lead to additional communication and software layers, which increase the configuration
effort and complexity.
Due to the widespread use of OPC, the standard is increasingly used for general coupling of
automation systems and no longer only for the original application as a driver interface in HMI and
SCADA systems to access process information.
To solve these limitations in practice and to meet the additional requirements, in the last seven
years the OPC Foundation has defined a new platform with the name OPC Unified Architecture.
This provides a uniform basis for the exchange of information between components and systems.
OPC UA is available as IEC 62541 standard and therefore forms the basis for other international
standards.
OPC UA offers the following features:
– Combination of all previous OPC features and information, such as DA, A&E and HDA, in a
generic interface.
– Use of open and platform-independent protocols for the interprocess and network
communication.
– Internet access and communication through firewalls.
– Integrated access control and security mechanisms at protocol and application level.
– Extensive mapping possibilities for object-oriented models; objects can have variables and
methods.
– Extensible type system for objects and complex data types.
– Transport mechanisms and modeling rules form the basis for other standards.
– Scalability from small embedded systems to enterprise applications and from simple DA
address spaces to complex, object-oriented models.
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 10
sce-092-303-opc-ua-s7-1500-node-red-en.docx
5 Task
In this module, a speed setpoint is specified from Node-RED in an application of SIMATIC S7-
1500.
The setpoint is manipulated via OPC UA, whereby Node-RED is used as an OPC UA client. At the
end, the setpoint can now be directly changed in Node-RED with the browser via a dashboard.
The project from the "SCE_EN_092-300_OPC UA with SIMATIC S7-1500 as OPC Server" module
is used as the application for SIMATIC S7-1500.
6 Planning
The S7-1500 controller must be loaded with the project from the 092-300 module.
The OPC UA client is set up from the Node-RED programming environment, using the node node-
red-contrib-opcua. This is installed from the Internet using the palette in Node-RED.
The new setpoint is set by the operator via the nodes from the node-red-dashboard package.
This is also installed directly from the Internet.
The correct node ID of the OPC UA variable for the speed setpoint can be determined via Siemens
OPC Scout.
Changes to the setpoint can be checked with the SIMATIC STEP 7 Professional software in the
TIA Portal.
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 11
sce-092-303-opc-ua-s7-1500-node-red-en.docx
7 Structured step-by-step instructions
You can find instructions on how to implement planning below. If you have advanced knowledge,
the numbered steps are sufficient. Otherwise, it is recommended that you follow the individual
steps of the instructions.
7.1 Retrieve an existing TIA Portal project
→ Before you can load the "sce-092-300-opc-ua-s7-1500..." project from the "SCE_EN_092-
300_OPC UA with SIMATIC S7-1500 as OPC Server" module, you have to retrieve it. To
retrieve an existing project, exit the project and select the respective archive under → Project
→ Retrieve. Then confirm your selection with "Open". (→ Project → Retrieve → Select a .zap
archive … → Open)
→ With the next step, you select the target directory where the retrieved project will be stored.
Confirm your selection with "OK". (→ Target directory … → OK)
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 12
sce-092-303-opc-ua-s7-1500-node-red-en.docx
7.2 Save, compile, and download the S7 station
→ Click on the "CPU_1516F [CPU1516F-3 PN/DP]" folder, compile the complete station and
save the project. After successful compilation and saving, download the station to the controller.
(→ CPU_1516F [CPU1516F-3 PN/DP] → → → )
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 13
sce-092-303-opc-ua-s7-1500-node-red-en.docx
7.3 Set the IP addresses of the SIMATIC IOT2000 controller
Since both the S7-1500 controller and IOT2000 were set to the same IP address in the
"SCE_EN_014-101 Hardware Configuration IOT2000EDU" and "SCE_EN_092-300 OPC UA with
SIMATIC S7-1500 as OPC Server" modules, change the IP of SIMATIC IOT2000 to 192.168.0.2.
To do this, you can follow the instructions in section 4.3 in the "SCE_EN_014-101 Hardware
Configuration IOT2000EDU" module.
The file /etc/network/interfaces on an IOT2040 should look like this:
Note:
– Remember to restart the IOT so that the file changes take effect.
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 14
sce-092-303-opc-ua-s7-1500-node-red-en.docx
7.4 Open the Node-RED user interface
Open a connection to the Node-RED web interface via the browser. The interface can be accessed
unencrypted via the IP of the IOT2000 and port 1880.
→ Start your browser and open the development environment.
(→ http://192.168.0.2:1880/)
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 15
sce-092-303-opc-ua-s7-1500-node-red-en.docx
7.5 Installation of the required nodes
The tasks in this document require nodes that are not included in the node-red package.
→ Open the menu and select Manage palette
→ Select the Install tab
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 16
sce-092-303-opc-ua-s7-1500-node-red-en.docx
→ Search for the node-red-dashboard module in the search modules field and install the
module by clicking install.
Note:
– Node-RED or the IOT must be able to access the Internet for the installation!
→ Confirm the installation of the node by clicking Install
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 17
sce-092-303-opc-ua-s7-1500-node-red-en.docx
→ Repeat the procedure for the node-red-contrib-opcua module.
Note:
– Node-RED or the IOT must be also able to access the Internet for this installation!
→ Close the palette by clicking Close
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 18
sce-092-303-opc-ua-s7-1500-node-red-en.docx
→ Check that the new nodes are available in the node list on the left.
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 19
sce-092-303-opc-ua-s7-1500-node-red-en.docx
7.6 Create the new speed setpoint
To be able to access a variable via OPC UA, a message is first required in the flow. The topic of
the message must contain the desired OPC UA Node ID. The message should be generated at
regular intervals.
→ Drag the inject node from the input area into the editor.
Note:
– The "inject" node is displayed in the flow with its "timestamp" payload.
→ Double-click the inserted inject node to open its properties.
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 20
sce-092-303-opc-ua-s7-1500-node-red-en.docx
→ Determine the OPC UA Node ID of the speed setpoint using the OPC Scout.
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 21
sce-092-303-opc-ua-s7-1500-node-red-en.docx
→ Enter the OPC UA Node ID of the speed setpoint as the topic and add the Float data type. (→
Topic: ns=3;s="SPEED_MOTOR"."Speed_Setpoint"; datatype=Float)
→ Under Repeat, select interval (→ Repeat: interval)
→ Set the interval to 1 second (→ every: 1 seconds)
→ Enter "Inject Setpoint" as the name (→ Name: "Inject Setpoint")
→ Confirm the changes by clicking Done: (→ Done)
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 22
sce-092-303-opc-ua-s7-1500-node-red-en.docx
7.7 Access to the OPC UA server
Now that a message is available in the flow, it can be sent to the OPC UA server for SIMATIC S7-
1500. The "OpcUa Client" node in the flow is used for this.
This node receives messages and sends the topic of the message as node ID and the payload as
content to the configured OPC UA endpoint. The node can perform various actions on the OPC
UA endpoint, such as reading or writing.
→ Filter the node list with "opcua". (→ : opcua)
→ Drag the "OpcUa client" node into the editor.
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 23
sce-092-303-opc-ua-s7-1500-node-red-en.docx
→ Connect the output of the Inject Setpoint node to the input of the OPC UA Client node.
→ Double-click on the OPC UA Client node to open its properties.
→ Ensure the action is set to READ. (→ Action: READ)
→ Set the name of the node to "OPC UA read". (→ Name: "OPC UA read")
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 24
sce-092-303-opc-ua-s7-1500-node-red-en.docx
→ Create a new OPC UA endpoint by clicking next to the Endpoint field: (→ Endpoint: "Add
new OpcUa-Endpoint…" → ).
→ Determine the address of the OPC UA endpoint of the S7-1500 via the CPU properties in the
TIA Portal.
→ Enter the OPC UA server on the S7-1500 as the endpoint: (→ Endpoint:
opc.tcp://192.168.0.1:4840).
→ Click Add. to create the new OPC UA endpoint. (→ Add)
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 25
sce-092-303-opc-ua-s7-1500-node-red-en.docx
→ Click on Done to confirm the current changes to the "OPC UA Client" node. (→ Done)
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 26
sce-092-303-opc-ua-s7-1500-node-red-en.docx
7.8 Debug output of the setpoint
The flow just created injects a message every second and passes it to the OPC UA client, which
then sends a read command to the S7-1500. The OPC UA client node provides the result of this
read command at its output as a message
The debug console on the right provides the easiest way to display messages from the flow. This
method can be used at any point in the flow and is very helpful for troubleshooting.
→ Drag the debug node from the output category into the editor.
Note:
– The "debug" node is displayed here with its "msg payload" payload.
→ Connect the new node to the output of the OPC UA read node.
→ Click Deploy to activate the changes and the flow. (→ Deploy)
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 27
sce-092-303-opc-ua-s7-1500-node-red-en.docx
→ The debug tab on the right should now show the NodeID and the corresponding value from
the controller:
Note:
– Any error messages of the flow also appear here, e.g. if the NodeID was not found or the data
type was entered incorrectly in the topic. The debug output can be deactivated and reactivated
live by the small green box to the right of the debug node.
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 28
sce-092-303-opc-ua-s7-1500-node-red-en.docx
7.9 Change the setpoint via OPC UA
Once the setpoint has been successfully read from the CPU via OPC UA, it should also be actively
manipulated.
→ Create a new inject node.
Note:
– The "inject" node is displayed in the flow with its "timestamp" payload.
→ Determine the OPC UA Node ID of the speed setpoint using the OPC Scout.
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 29
sce-092-303-opc-ua-s7-1500-node-red-en.docx
→ Double-click the new inject node to open its properties.
→ Under Payload, select the Number option and enter a value. (→ Payload: Number: 10)
→ Set the OPC UA Node ID and the data type of the speed setpoint as the topic again. (→ Topic:
ns=3;s="SPEED_MOTOR"."Speed_Setpoint";datatype=Float)
→ Under Name, enter a descriptive name for the node. (→ Name: "New Setpoint")
→ Confirm the settings with Done. (→ Done)
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 30
sce-092-303-opc-ua-s7-1500-node-red-en.docx
→ Create another OPC UA client node.
→ Connect the output of New Setpoint to the new OPC UA client node.
→ Go to the properties of the new OPC UA client node.
→ Under Endpoint, select the existing endpoint. (→ Endpoint: opc.tcp://192.168.0.1:4840)
→ Set the action to WRITE. (→ Action: WRITE)
→ Set the name of the node to "OPC UA write". (→ Name: "OPC UA write")
→ Confirm the settings with Done. (→ Done)
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 31
sce-092-303-opc-ua-s7-1500-node-red-en.docx
→ Activate the changes in the flow with Deploy. (→ Deploy)
→ Then trigger a manual injection of the new message by clicking on the blue box to the left of
New Setpoint.
→ If the command is executed correctly, the updated setpoint should be displayed in the debug
area.
Note:
– Ensure that the debug node is activated!
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 32
sce-092-303-opc-ua-s7-1500-node-red-en.docx
7.10 Check the setpoint in STEP 7
The current setpoint can also be checked using STEP 7.
→ In the TIA Portal, open the data block SPEED_MOTOR.
→ Monitor the SPEED_MOTOR data block by clicking .
→ The current value can subsequently be read in the Monitor value column.
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 33
sce-092-303-opc-ua-s7-1500-node-red-en.docx
7.11 Visualization via the dashboard
In addition to reading the setpoint from the S7-1500 CPU, the flow now also successfully writes a
static setpoint to the S7-1500.
The dashboard is now used to visualize and dynamically specify the speed setpoint. You first have
to create a tab and a group on the dashboard before you can display elements.
→ Open the Dashboard tab on the right. (→ dashboard)
→ Within the dashboard tab, select the Layout tab. (→ Layout)
→ Use to add a new tab to your dashboard. (→ )
→ Create a new group within Tab 1 using . (→ )
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 34
sce-092-303-opc-ua-s7-1500-node-red-en.docx
→ Drag a text node from the dashboard category into the flow.
→ Connect it to the output of the OPC UA read node.
→ Open the properties of the new text node.
→ Set the group to the [Tab 1] Group 1 you have just created. (→ Group: [Tab 1]
Group 1)
→ Set Size to 1x1. (→ Size: 1x1)
→ Delete the content of the Label field. (→ Label: empty)
→ Enter a name for the element under Name, e.g. Setpoint. (→ Name: Setpoint)
→ Confirm the changes with Done. (→ Done)
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 35
sce-092-303-opc-ua-s7-1500-node-red-en.docx
→ Click Deploy to activate the changes to the flow.
→ Click on the Dashboard tab to the right to open the dashboard. (→ )
Note:
– The dashboard updates itself automatically. If the setpoint is changed in the CPU, the new
value should be displayed here automatically.
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 36
sce-092-303-opc-ua-s7-1500-node-red-en.docx
7.12 Set the setpoint via the dashboard
The setpoint is changed using the slider node in the dashboard. As a control element, this node
has an output that injects a message with the new value into the flow when there is a change. This
message can now be written to the PLC using the OPC UA client.
→ Return to the Node-RED Editor and add a slider node to the flow.
→ Connect the output of the OPC UA read node to the slider node. This ensures that the slider
is always set to the value currently being read.
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 37
sce-092-303-opc-ua-s7-1500-node-red-en.docx
→ Go to the properties of the slider node.
→ Under Group, select [Tab 1] Group 1 again. (→ Group: [Tab 1] Group 1)
→ Set Size to 5x1. (→ Size: 5x1)
→ Delete the content of the Label field. (→ Label: empty)
→ Set the Range to min. -50, max. 50 and step 1. (→ Range → min.: -50 → max.: 50 → step 1)
→ Set OUTPUT to Only on release. (→ Output: Only on release)
→ Deselect the item "If msg arrives on input, pass through to output". (→ If msg arrives on
input pass through to output: deselected)
→ Enter the NodeID and the data type of the speed setpoint as Topic.
(→ Topic: ns=3;s="SPEED_MOTOR"."Speed_Setpoint";datatype=Float)
→ Under Name, enter a meaningful name for the element, e.g. Setpoint Control. (→ Name:
Setpoint Control)
→ Confirm the changes with Done. (→ Done)
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 38
sce-092-303-opc-ua-s7-1500-node-red-en.docx
→ Link the output of the Setpoint Control node to the input of the OPC UA write node.
→ Remove the new Setpoint node. (→ Select new Setpoint node → Press Del)
→ Click Deploy to activate the changes to the flow.
→ Go to the dashboard and use the slider to change the speed setpoint.
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 39
sce-092-303-opc-ua-s7-1500-node-red-en.docx
7.13 Check the current setpoint in STEP 7
Use STEP 7 to check again whether the speed setpoint on the CPU has been changed.
→ In the TIA Portal, open the data block SPEED_MOTOR
→ Monitor the SPEED_MOTOR data block by clicking .
→ The current value can subsequently be read in the Monitor value column.
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 40
sce-092-303-opc-ua-s7-1500-node-red-en.docx
7.14 Checklist – step-by-step instructions
The following checklist helps trainees/students to independently check whether all steps of the
step-by-step instruction have been carefully completed and enables them to successfully complete
the module on their own.
No. Description Checked
1 IP settings of the SIMATIC IOT2000 controller adapted
2 "node-red-dashboard" node installed
3 "node-red-contrib-opcua" node installed
4 Speed setpoint read from the S7-1500
5 Speed setpoint statically written to the S7-1500
6 Current setpoint checked in STEP 7
7 Speed setpoint visualized on the dashboard
8 Speed setpoint changed via slider
9 Current setpoint checked in STEP 7
Table 1.1
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 41
sce-092-303-opc-ua-s7-1500-node-red-en.docx
8 Additional information
More information for further practice and consolidation is available as orientation, for example:
Getting Started, videos, tutorials, apps, manuals, programming guidelines and trial software /
firmware, under the following link:
siemens.en/sce/opc
Preview "Additional information"
Learn-/Training Document | TIA Portal Module 092-303, Edition 08/2019 | Digital Industries, FA
For unrestricted use in educational / R&D institutions. © Siemens 2019. All rights reserved. 42
sce-092-303-opc-ua-s7-1500-node-red-en.docx
Further Information
Siemens Automation Cooperates with Education siemens.com/sce
SCE Learn-/Training Documents
siemens.com/sce/documents
SCE Trainer Packages
siemens.com/sce/tp
SCE Contact Partners
siemens.com/sce/contact
Digital Enterprise
siemens.com/digital-enterprise
Industrie 4.0
siemens.com/future-of-manufacturing
Totally Integrated Automation (TIA)
siemens.com/tia
TIA Portal
siemens.com/tia-portal
SIMATIC Controller
siemens.com/controller
SIMATIC Technical Documentation
siemens.com/simatic-docu
Industry Online Support
support.industry.siemens.com
Product catalogue and online ordering system Industry Mall
mall.industry.siemens.com
Siemens
Digital Industries, FA
P.O. Box 4848
90026 Nuremberg
Germany
Subject to change and errors
© Siemens 2019
siemens.com/sce