SIMATIC NET OPC UA S7server DOC V2 0 en

Download as pdf or txt
Download as pdf or txt
You are on page 1of 120

S7 Communication

between S7 CPU and


PC station
Siemens
S7 server services with SIMATIC NET OPC UA server Industry
Online
https://support.industry.siemens.com/cs/ww/de/view/67295801 Support
Legal information

Legal information
Use of application examples
Application examples illustrate the solution of automation tasks through an interaction of several
components in the form of text, graphics and/or software modules. The application examples are
a free service by Siemens AG and/or a subsidiary of Siemens AG (“Siemens”). They are non-
binding and make no claim to completeness or functionality regarding configuration and
equipment. The application examples merely offer help with typical tasks; they do not constitute
customer-specific solutions. You yourself are responsible for the proper and safe operation of the
products in accordance with applicable regulations and must also check the function of the
respective application example and customize it for your system.
Siemens grants you the non-exclusive, non-sublicensable and non-transferable right to have the
application examples used by technically trained personnel. Any change to the application
examples is your responsibility. Sharing the application examples with third parties or copying the
application examples or excerpts thereof is permitted only in combination with your own products.
The application examples are not required to undergo the customary tests and quality inspections
of a chargeable product; they may have functional and performance defects as well as errors. It is
your responsibility to use them in such a manner that any malfunctions that may occur do not
result in property damage or injury to persons.

Disclaimer of liability
Siemens shall not assume any liability, for any legal reason whatsoever, including, without
limitation, liability for the usability, availability, completeness and freedom from defects of the
application examples as well as for related information, configuration and performance data and
any damage caused thereby. This shall not apply in cases of mandatory liability, for example
under the German Product Liability Act, or in cases of intent, gross negligence, or culpable loss of
life, bodily injury or damage to health, non-compliance with a guarantee, fraudulent
non-disclosure of a defect, or culpable breach of material contractual obligations. Claims for
damages arising from a breach of material contractual obligations shall however be limited to the
© Siemens AG 2020 All rights reserved

foreseeable damage typical of the type of agreement, unless liability arises from intent or gross
negligence or is based on loss of life, bodily injury or damage to health. The foregoing provisions
do not imply any change in the burden of proof to your detriment. You shall indemnify Siemens
against existing or future claims of third parties in this connection except where Siemens is
mandatorily liable.
By using the application examples you acknowledge that Siemens cannot be held liable for any
damage beyond the liability provisions described.

Other information
Siemens reserves the right to make changes to the application examples at any time without
notice. In case of discrepancies between the suggestions in the application examples and other
Siemens publications such as catalogs, the content of the other documentation shall have
precedence.
The Siemens terms of use (https://support.industry.siemens.com) shall also apply.

Security information
Siemens provides products and solutions with industrial security functions that support the secure
operation of plants, systems, machines and networks.
In order to protect plants, systems, machines and networks against cyber threats, it is necessary
to implement – and continuously maintain – a holistic, state-of-the-art industrial security concept.
Siemens’ products and solutions constitute one element of such a concept.
Customers are responsible for preventing unauthorized access to their plants, systems, machines
and networks. Such systems, machines and components should only be connected to an
enterprise network or the Internet if and to the extent such a connection is necessary and only
when appropriate security measures (e.g. firewalls and/or network segmentation) are in place.
For additional information on industrial security measures that may be implemented, please visit
https://www.siemens.com/industrialsecurity.
Siemens’ products and solutions undergo continuous development to make them more secure.
Siemens strongly recommends that product updates are applied as soon as they are available
and that the latest product versions are used. Use of product versions that are no longer
supported, and failure to apply the latest updates may increase customer’s exposure to cyber
threats.
To stay informed about product updates, subscribe to the Siemens Industrial Security RSS Feed
at: https://www.siemens.com/industrialsecurity.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 2
Table of contents

Table of contents
Legal information ......................................................................................................... 2
1 Introduction ........................................................................................................ 5
1.1 Overview............................................................................................... 5
1.2 Plant configuration ................................................................................ 6
1.3 Principle of Operation ........................................................................... 8
1.3.1 S7 Server services ............................................................................... 8
1.3.2 As an S7 client, S7 CPU reads data from the PC station (S7
server) ................................................................................................ 11
1.3.3 S7 CPU, as S7 client, writes data to the PC station (S7 server) ........ 12
1.3.4 NodeId for access to the attributes of the data tags in S7 data
block DB1 ........................................................................................... 13
1.4 Components used .............................................................................. 14
2 Engineering ...................................................................................................... 15
2.1 Hardware setup .................................................................................. 15
2.2 Setting IP addresses and subnet mask .............................................. 16
2.2.1 IP address and subnet mask for the PC station ................................. 16
2.2.2 IP address and subnet mask for the S7 CPU .................................... 18
2.3 "Communication settings". ................................................................. 20
2.4 Overview............................................................................................. 24
2.5 Configuration ...................................................................................... 25
2.5.1 Create S7 CPU in STEP 7 (TIA Portal) .............................................. 25
© Siemens AG 2020 All rights reserved

2.5.2 Create PC station in STEP 7 (TIA Portal) .......................................... 30


2.5.3 Configuring a connection.................................................................... 36
2.5.4 Creating tags for the parameters of the instructions "PUT" and
"GET".................................................................................................. 50
2.5.5 Create send/receive data range ......................................................... 54
2.5.6 User program of the S7-CPU ............................................................. 64
2.6 Configuring the "Station Configuration Editor" ................................... 69
2.6.1 Manual configuration .......................................................................... 69
2.6.2 Configuring the "Station Configuration Editor" in TIA Portal .............. 73
2.6.3 XDB export: Exporting XDB from TIA Portal ...................................... 76
2.7 Loading configuration data ................................................................. 78
2.7.1 Load PC station configuration data .................................................... 78
2.7.2 Load S7 CPU configuration data ........................................................ 85
3 Operation .......................................................................................................... 89
3.1 Setting up SIMATIC S7 communication ............................................. 89
3.1.1 Establish connection to the S7 OPC UA server with OPC Scout
V10 ..................................................................................................... 89
3.1.2 Setting up access to the data in S7 data block DB1 with OPC
Scout .................................................................................................. 92
3.2 S7 CPU writes data to the PC station ................................................ 94
3.3 S7 CPU reads data from the PC station ............................................ 98
4 Useful information ......................................................................................... 102
4.1 SIMATIC NET OPC server ............................................................... 102
4.1.1 S7 OPC UA server ........................................................................... 102
4.1.2 S7OPT OPC UA server .................................................................... 103
4.1.3 SR OPC UA server ........................................................................... 104
4.1.4 DP OPC UA server ........................................................................... 105
4.2 Configuring a PC station .................................................................. 106
4.3 "Station Configuration Editor" ........................................................... 107
4.3.1 Overview........................................................................................... 108
4.3.2 Area of application & use cases ....................................................... 109

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 3
Table of contents

4.3.3 "Components" tab ............................................................................ 110


4.4 Data blocks ....................................................................................... 114
4.4.1 Data blocks with optimized access .................................................. 114
4.4.2 Data blocks with standard access .................................................... 114
4.5 Connection types .............................................................................. 114
4.5.1 Standard S7 connection ................................................................... 114
4.5.2 Optimized S7 connections................................................................ 115
4.6 OPC UA protocols ............................................................................ 115
4.6.1 XML Web services ........................................................................... 116
4.6.2 Pure (native) binary TCP protocol .................................................... 116
4.7 Structure of the namespace for OPC UA ......................................... 117
4.8 Scanning the OPC UA namespace .................................................. 117
4.8.1 "Browse" ........................................................................................... 117
4.8.2 "Read" .............................................................................................. 117
4.9 Reading and writing attribute values of nodes ................................. 117
4.9.1 "Read" .............................................................................................. 118
4.9.2 "Write" ............................................................................................... 118
5 Appendix ........................................................................................................ 119
5.1 Service and support ......................................................................... 119
5.2 Links and literature ........................................................................... 120
5.3 Change documentation .................................................................... 120
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 4
1 Introduction

1 Introduction
1.1 Overview
SIMATIC NET OPC server communication functions for OPC UA
The OPC server provides standardized access to the SIMATIC NET industrial
communications networks.
The SIMATIC NET OPC Server supports the interfacing of applications with any
automation components networked over PROFIBUS or Industrial Ethernet.
SIMATIC NET OPC server offers the following communication functions for
OPC UA:
• S7 communication
– S7 OPC UA server (see chapter 4.1.1)
– S7OPT OPC UA server (see chapter 4.1.2)
• Open communication services (SEND/RECEIVE)
– SR OPC UA server (see chapter 4.1.3)
• PROFIBUS DP
– DP OPC UA server (see chapter 4.1.4)

Services of the communication functions


© Siemens AG 2020 All rights reserved

The SIMATIC NET OPC server communication functions for OPC UA support the
following services, among others:
• Variable services
• Buffer-oriented services
• Block services
• Server services

Server service via S7 communication

Note The server services only function over standard S7 connections to S7 CPUs.

This application example demonstrates how to use the server service to exchange
data between PC station and S7 CPU. This service is supported by the following
communication functions:
• S7 communication

The following components are used in this application example:


• SIMATIC NET OPC UA server on the PC station
– S7 OPC UA server
• S7-300 CPUs, S7-400 CPUs, S7-1200 CPUs or S7-1200 CPUs

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 5
1 Introduction

1.2 Plant configuration


The following figures show typical plant configurations for Industrial Ethernet and
PROFIBUS in which the data communication between S7 CPU and PC station is
implemented using S7 server services via standard S7 connections.

Industrial Ethernet
Figure 1-1

PC station

Industrial Ethernet
© Siemens AG 2020 All rights reserved

S7-300 CPU/CP S7-1200 CPU

S7-1500
CPU/CP/CM

S7-400 CPU/CP

Unrestricted

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 6
1 Introduction

PROFIBUS
Figure 1-2

PC station

PROFIBUS
© Siemens AG 2020 All rights reserved

CM 1243-5
S7-300 CPU/CP
S7-1500
CPU/CP/CM

S7-400 CPU/CP

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 7
1 Introduction

1.3 Principle of Operation


1.3.1 S7 Server services

The PC station with an active OPC server for the S7 protocol (S7 OPC UA server)
provides the S7 data block DB1 for reading and writing, thereby becoming an S7
server. The S7 data block (DB 1) is 65535 bytes long. There are no symbolic
names nor structuring of the data block according to tags.
An S7 connection must be configured for reading and writing. As an S7 client, the
S7 CPU actively establishes the S7 connection. The PC station, as an S7 server, is
a passive participant while the S7 connection is established.
The following figure shows an overview of the application example.
Figure 1-3

PC station (S7 server)


OPC client
Data

SIMATIC NET OPC UA server:


S7 OPC UA server
© Siemens AG 2020 All rights reserved

DB1

S7 connection

S7 CPU
(S7 client)
Data:
- Memory byte: MB 0
- Data blocks: DB 3
- Process image: EB 0
- Temporary local data

Note The application example provides an introduction to using the S7 server service
with the SIMATIC NET S7 OPC UA server. Details are described in the SIMATIC
NET manuals (see \3\, \4\ and \5\).

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 8
1 Introduction

Figure 1-4

PG/PC S7 CPU

OPC client

Data
Data

User program
Access to NodeId
User program
PUT/GET instruction call

S7 OPC UA server
Node
© Siemens AG 2020 All rights reserved

Attribute
NodeId

S7 connection

OPC UA accesses objects and their sub-objects. Data tags, for example, are sub-
objects of an S7 connection object.
The following S7 connection objects exist:
• Productive S7 connections
These are used for data exchange between S7 CPU and PC station and are
generally configured with STEP 7.
• DEMO connection
This is used only for testing.
• @LOCALSERVER connection
Unrestricted
This provides the local S7 data blocks for the S7 server functionality.
Attributes define the objects in greater detail. Each individual access to an object,
sub-object and attribute uses its NodeId.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 9
1 Introduction

The OPC client accesses attributes of the data tags.


1. When using the S7 server services, the OPC client access the attributes of the
data tags in the S7 data block DB1 with the following commands:
– Read
– Write
2. Nodes are defined in the namespace of the S7 OPC UA server in order to
organize the objects and sub-objects.
3. In STEP 7 (TIA Portal), a user program is created for the S7 CPU in order to
access the S7 data block DB1 in the PC station. Call the "PUT" and "GET"
instructions in the S7 CPU user program in order to execute the following
commands:
– "PUT":
The S7 CPU, as S7 client, writes data to the PC station (S7 server).
– "GET":
As an S7 client, the S7 CPU reads data from the PC station (S7 server).
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 10
1 Introduction

1.3.2 As an S7 client, S7 CPU reads data from the PC station (S7 server)

The following figure shows how the S7 CPU, as an S7 client, reads data from the
PC station (S7 server).
Figure 1-5

PG/PC S7 CPU

OPC client

Byte 0
1 Byte 1

Byte 9 DB11:
Byte 0
Byte 1
Byte 2
User program …
Access to NodeId: Byte 99
S7:@LOCALSERVER.db1.0,b,10

3
© Siemens AG 2020 All rights reserved

User program
S7 OPC UA server
GET call with following
DB1: parameters:
NodeId of the Byte 0 • ID: 16#100
attributes for the Byte 1 • ADDR_1:
S7 server service Byte 2 2
p#DB1.DBX0.0 Byte 10

Byte 9 • RD_1:
p#DB11.DBX0.0 Byte 10

@LOCALSERVER connection

Table 1-1
No. Description
1. The OPC client writes to the attributes of the data tags in the S7 data block DB1.
The attributes are accessed via the NodeId.
2. The entire S7 block DB1 or parts of the S7 data block DB1 are mapped to the
NodeId.
3. The "GET" instruction is called in the S7 CPU user program.
The "GET" instruction reads data from the source range, specified at the
Unrestricted
parameter "ADDR_1":
• Source range: S7 data block DB1 in the PC station
The instruction enters the data into the target range, specified at parameter
"RD_1":
• Target range: DB11 in the S7 CPU

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 11
1 Introduction

1.3.3 S7 CPU, as S7 client, writes data to the PC station (S7 server)

The following figure shows how the S7 CPU, as an S7 client, writes data to the PC
station (S7 server).
Figure 1-6

PG/PC S7 CPU

OPC client

Byte 0
3 Byte 1

Byte 9 DB10:
Byte 0
Byte 1
Byte 2
User program …
Access to NodeId: Byte 99
S7:@LOCALSERVER.db1.0,b,10

1
© Siemens AG 2020 All rights reserved

User program
S7 OPC UA server
PUT call with following
DB1: parameters:
NodeId of the Byte 0 • ID: 16#100
attributes for the Byte 1 • ADDR_1:
S7 server service Byte 2 2
p#DB1.DBX0.0 Byte 10

Byte 9 • SD_1:
p#DB10.DBX0.0 Byte 10

@LOCALSERVER connection

Table 1-2
No. Description
1. The "PUT" instruction is called in the S7 CPU user program.
The "PUT" instruction the data from the source range, specified at parameter
"SD_1".
• Source range: DB10 in the S7 CPU
The "PUT" instruction writes data to the target range, specified at parameter
"ADDR_1".
• Target range: S7 data block DB1 in the PC station
2. The entire S7 block DB1 or parts of the S7 data block DB1 are mapped to the
NodeId.
3. The OPC client reads the attributes of the data tags in the S7 data block DB1.
The attributes are accessed via the NodeId.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 12
1 Introduction

1.3.4 NodeId for access to the attributes of the data tags in S7 data block
DB1

The following figure shows the NodeId for access to the attributes of the data tags
in the S7 data block DB1.
Figure 1-7

PG/PC

OPC client

User program
NodeId:

1 2 3 4 5 6

S7: @LOCALSERVER db1. 0, b, 10


© Siemens AG 2020 All rights reserved

Table 1-3
No. Description Value
1. Namespace URI S7
2. Local connection (within the PC station) @LOCALSERVER
3. Object DB1
4. Start address 0
5. Data type b (bytes)
6. Quantity 10

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 13
1 Introduction

1.4 Components used


The following hardware and software components were used to create this
application example:
Table 1-4
Components Quantity Item number Note
CPU 1513-1PN 1 6ES7513-1AL01-0AB0 Alternatively, you can
use one of the following
CPU 315-2 PN/DP 1 6ES7315-2EH14-0AB0
components:
• S7-1500 CPU
• S7-1200 CPU
• S7-300 CPU
• S7-400 CPU
• ET 200SP CPU
• ET 200S CPU
• ET 200pro CPU
• CP/CM
SIMATIC NET DVD V16 1 6GK1704-1LW16- In the Sales and
0AA0 Delivery Release you
will find the article
numbers for the
SIMATIC NET products
© Siemens AG 2020 All rights reserved

(see article 109775589).


STEP 7 V16 1 Package:
6ES7822-1AA06-0YA5
Download:
6ES7822-1AE06-0YA5

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 14
2 Engineering

2 Engineering
2.1 Hardware setup
The following figure shows the structure of the application example.
Figure 2-1

SIMATIC Field PG
CPU 1513-1 PN

IP address: 192.168.178.35
Subnet mask: 255.255.255.0

IP address: 192.168.178.34
Subnet mask: 255.255.255.0

Industrial Ethernet

The SIMATIC Field PG is deployed as a PC station, i.e. the SIMATIC NET PC


© Siemens AG 2020 All rights reserved

software is installed on the SIMATIC Field PG. The SIMATIC NET OPC server
provides the S7 data block DB1 on the PC station. Using the S7 server services
"PUT" and "GET", the S7 CPU access the S7 data block DB1 in the PC station.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 15
2 Engineering

2.2 Setting IP addresses and subnet mask


2.2.1 IP address and subnet mask for the PC station

In the Windows properties for the network adapter through which the PC station is
connected with the S7 CPU, set the IP address and subnet mask for the PC
station.
Figure 2-2
© Siemens AG 2020 All rights reserved

1. In the "Control Panel", open the "Network and Sharing Center" under "Network
and Internet".
2. Select the function "Change adapter settings".
3. Right-click on the corresponding network adapter and select the "Properties"
context menu.
The Properties dialog for network adapter opens.
4. Select the "Internet Protocol Version 4 (TCP/IPv4)" element and click the
"Properties" button.
The Properties dialog box for the "Internet Protocol Version 4 (TCP/IPv4)"
element will open.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 16
2 Engineering

5. Set the IP address and subnet mask and apply the settings with "OK".
– IP address: 192.168.178.34
– Subnet mask: 255.255.255.0

Note You will configure the IP address and subnet mask later during hardware
configuration for STEP 7.
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 17
2 Engineering

2.2.2 IP address and subnet mask for the S7 CPU

Opening the "Online & diagnostics" dialog


Figure 2-3
© Siemens AG 2020 All rights reserved

1. In the "Project tree" under "Online access" click the arrow to the left of the
network adapter that is connected with your S7 CPU.
2. Double-click the "Update accessible devices" command.
All devices available to the network adapter will be shown.
3. Click the arrow to the left of the S7 CPU to which you wish to assign an IP
address and subnet mask.
4. Double-click the command "Online & diagnostics".
The "Online & diagnostics" dialog will open.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 18
2 Engineering

Assigning IP address and subnet mask


Figure 2-4
© Siemens AG 2020 All rights reserved

1. Switch the S7 CPU to "STOP" mode.


2. Under "Functions", click "Assign IP addresses".
3. Enter the following IP address and subnet mask:
– IP address: 192.168.178.35
– Subnet mask: 255.255.255.0
4. Click "Assign IP address" to carry over the parameters.

Note • You will enter the IP address and subnet mask later during configuration.
• If you have an S7-1500 CPU, you can also set the IP address and subnet
mask on the display.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 19
2 Engineering

2.3 "Communication settings".


Open the program "Communication Settings" via the Windows Start Menu
"Siemens Automation > Communication Settings".
The "Communication Settings" program provides a number of ways to configure
and diagnose PC hardware components, PC user programs and the SIMATIC NET
OPC server.

Enabling protocols for the OPC server


The SIMATIC NET OPC server supports various protocols to the controller level.
All protocols are activated in the initial configuration.
You can disable protocols that you don't want to use.
Figure 2-5
© Siemens AG 2020 All rights reserved

1. In the navigation area, navigate to "SIMATIC NET configuration > OPC


Settings > OPC protocol selection".
2. Enable the protocol "S7" for OPC UA.
– "S7": SIMATIC S7 communication via PROFIBUS and Industrial Ethernet
3. Click the arrow icon next to the protocol "S7" to reach the advanced parameter
list for that protocol.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 20
2 Engineering

Setting parameters for the protocols


Figure 2-6
© Siemens AG 2020 All rights reserved

1. Port settings:
– If the checkbox is selected, the default setting is used for the specified port.
– If the checkbox is not selected, you can edit the input field for the port.
2. Security policies:
– If the checkbox is selected, unsecured connections (none) to the OPC
server are allowed.
– If the checkbox is not selected, no unsecured connections (none) to the
OPC server will be allowed.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 21
2 Engineering

3. Define which connections to the OPC server will be allowed and determine
whether the messages will be signed (Sign) or signed and encrypted
(SignAndEncrypted):
– secured connections based on the security policy "Basic128Rsa15"
– secured connections based on the security policy "Basic256"
– secured connections based on the security policy "Basic256Sha256"
– secured connections based on the security policy
"Aes128_Sha256_RsaOaep"
– secured connections based on the security policy
"Aes256_Sha256_RsaPss"
4. Check of the client certificates
– Always check certificates
Enabled: The certificates will always be checked.
Disabled: The certificates will not be checked.
– No strict certificate check
Enabled: Certain certificate checks will be ignored, e.g.
CertificateRevocationUnknown, CertificateIssuerRevocationUnknown,
NonceLengthCheck, TokenPolicyIdCheck.
Disabled: The certificates will be fully checked.
– Accept expired certificates
Enabled: The certificates will be accepted even if the time stamp of the
certificate is invalid, i.e. the certificates are not yet valid or have already
© Siemens AG 2020 All rights reserved

expired.
Disabled: The certificates are only accepted if the time stamp is valid.
5. Login settings
– If the checkbox is selected, the SIMATIC NET OPC server allows
anonymous login of OPC UA clients.
– If the checkbox is not selected, anonymous logins are not allowed. User
authentication with Windows login and password is then required.
Note
The SIMATIC NET OPC server uses the Windows user management for
user authentication. In the OPC client, log in to the SIMATIC NET OPC
server with your Windows user name and password.
6. Test and auxiliary tools
– Provide templates for item definitions:
If the checkbox is selected, the OPC server creates templates for item
definitions in its namespace, which can be used to easily define a new
Item.
– Make virtual module (Demo) available for simulations:
The SIMATIC NET OPC server gives you the ability to use the OPC
interface for tests, presentations and development work without a
communication module. For this purpose, the OPC server provides a
virtual module or "DEMO" connection, depending on the protocol (CP
simulation). This option enables activation of the simulation function
depending on the protocol.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 22
2 Engineering

"OPC UA certificates"
Figure 2-7

1. In the navigation area, navigate to "SIMATIC NET configuration > OPC


© Siemens AG 2020 All rights reserved

settings > OPC UA certificates".


Here, the certificates of the local OPC UA server and the certificates the
OPC clients used to identify themselves to the servers are displayed and
managed.
2. Accept the OPC client certificate, if applicable.

Unrestricted

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 23
2 Engineering

2.4 Overview
The following figure shows an overview of the steps performed during the
engineering stage.
• Configuration
• Configure the Station Configuration Editor
• Load PC station configuration data
• Load S7 CPU configuration data

There are multiple ways of performing the engineering step when configuring the
Station Configuration Editor and loading the PC station configuration data.
Performing either one of the options for the engineering step is sufficient.
This application example describes all possibilities for the engineering steps.

Figure 2-8

Configuration Create project in TIA Portal


• S7 CPUs
• PC station
© Siemens AG 2020 All rights reserved

• S7 connection
• "PUT" and "GET" instruction
• Send data and receive data

Configure the manual Configure the XDB export:


Station Station Export XDB from
Configuration Configuration TIA Portal
Editor Editor in TIA Portal

Load PC station Load configuration XDB import:


configuration data via TIA Portal Importing XDB in the Station
data Configuration Editor

Load S7 CPU Load configuration


configuration data via TIA Portal
data

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 24
2 Engineering

2.5 Configuration
2.5.1 Create S7 CPU in STEP 7 (TIA Portal)

Requirements
• STEP 7 (TIA Portal) is open.
• A new project is created, or an existing project is opened.

Insert device
1. Double-click the command "Add new device" in the "Project tree".
© Siemens AG 2020 All rights reserved

The dialog box "Add new device" opens.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 25
2 Engineering
© Siemens AG 2020 All rights reserved

2. Click the "Controllers" button.


3. Select the S7 CPU according to your hardware setup, e.g. CPU 1513-1 PN.
4. Enable the option "Open device view".
5. Under Version, select the firmware version of the S7 CPU.
6. Click the "OK" button.
The selected S7 CPU will be added.

Note If you enabled the option "Open device view", the "Device view" for the S7 CPU
will open automatically in the hardware and network editor.

Unrestricted

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 26
2 Engineering

Opening the device view


1. In the "Project tree", open the device folder of the S7 CPU.
2. Double-click on the "Device configuration" command.

The "Device view" of the S7 CPU opens in the hardware and network editor.
© Siemens AG 2020 All rights reserved

Unrestricted

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 27
2 Engineering

Setting address parameters


1. Select the S7 CPU in the device view.
The properties of the S7 CPU are displayed in the Inspector window.

2. In the "General" tab, navigate to "PROFINET interface [X1] > Ethernet


addresses".
© Siemens AG 2020 All rights reserved

3. Enter the following address parameters:


– IP address: 192.168.178.35
– Subnet mask: 255.255.255.0
4. Click on the "Add new subnet" button to create a new subnet, or select an
existing subnet.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 28
2 Engineering

Allow access via PUT/GET communication from a remote partner


For the S7-1500 CPUs and S7-1200 CPUs, it is necessary to allow access via
PUT/GET communication from a remote partner.
1. Open the device view of the S7 CPU.
2. Select the S7 CPU in the device view.
The properties of the S7 CPU are displayed in the Inspector window.
© Siemens AG 2020 All rights reserved

3. In the "General" tab, navigate to "Protection & Security > Connection


mechanisms".
4. Enable the function "Permit access with PUT/GET communication from remote
partner".

Unrestricted

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 29
2 Engineering

2.5.2 Create PC station in STEP 7 (TIA Portal)

Insert device
1. Double-click the command "Add new device" in the "Project tree".
© Siemens AG 2020 All rights reserved

The dialog box "Add new device" opens.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 30
2 Engineering
© Siemens AG 2020 All rights reserved

2. Click the "PC systems" button.


3. Select the user application "OPC server".
4. Enable the option "Open device view".
5. Set the version "SW V8.2..." for the user application "OPC server" in order to
enable a standard S7 connection to S7-1500 CPUs and S7-1200 CPUs
(firmware V4 or higher).
6. Click the "OK" button.
A PC station with the user application "OPC server" will be added.

Note If you enabled the option "Open device view", the "Device view" for the PC
Unrestricted
station will open automatically in the hardware and network editor.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 31
2 Engineering

Opening the device view


1. In the "Project tree", open the device folder of the PC station
2. Double-click on the "Device configuration" command.
© Siemens AG 2020 All rights reserved

The "Device view" of the PC station opens in the hardware and network editor.

Unrestricted

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 32
2 Engineering

Configuring the PC station


Configure the PC station in the device view.
Figure 2-9

1. The OPC server has been automatically added in slot 2.


© Siemens AG 2020 All rights reserved

2. Insert a communications module, e.g. "IE general", into slot 1 of the PC station
by dragging and dropping.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 33
2 Engineering

Setting address parameters


1. In the device view, select the communications module "IE general".
The properties of the communications module are displayed in the Inspector
window.
© Siemens AG 2020 All rights reserved

2. In the "General" tab, navigate to "PROFINET interface [X1] > Ethernet


addresses".
3. Enter the following address parameters:
– IP address: 192.168.178.34
– Subnet mask: 255.255.255.0
4. Click on the "Add new subnet" button to create a new subnet, or select an
existing subnet.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 34
2 Engineering

Setting the name of the PC station


1. Select the PC station in the device view.
The properties of the PC Station are displayed in the Inspector window.

2. In the "General" tab, navigate to "General".


3. Enter the name of the PC station, e.g. "PC system".
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 35
2 Engineering

2.5.3 Configuring a connection

S7 CPU and PC station are created in the same project


Add S7 connection
1. Double-click "Devices & networks" in the "Project tree".

The graphical area of the "Network view" opens in the hardware and network
editor.
© Siemens AG 2020 All rights reserved

2. In the function bar, click "Connections" to enable the connection mode.


3. Select the connection type "S7 connection" in the nearby dropdown menu.
All devices that are relevant to an S7 connection are highlighted in color in the
"Network view".
4. Click and drag the mouse from the OPC server to the S7 CPU.
5. Release the mouse button on the target device in order to create the
S7 connection between the OPC server and the S7 CPU.

Unrestricted

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 36
2 Engineering

Result:
A specified S7 connection is created and is configured on both sides.
• The connection path is highlighted.

• The S7 connection is entered in the connection table.


© Siemens AG 2020 All rights reserved

• The OPC server is a passive participant as the connection is established. The


S7 CPU actively establishes the S7 connection.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 37
2 Engineering

Setting connection parameters:


1. In the connection table, select the S7 connection that uses the OPC server as
local endpoint.
The properties of the S7 connection are displayed in the Inspector window.

2. In the "General" tab under "Special connection properties", disable the function
"Active connection establishment".

3. In the "General" tab under "OPC", the function "Maintain connection


permanently" is enabled.
© Siemens AG 2020 All rights reserved

4. In the connection table, select the S7 connection that uses the S7 CPU as
local endpoint.
The properties of the S7 connection are displayed in the Inspector window.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 38
2 Engineering

5. In the "General" tab under "Special connection properties", enable the function
"Active connection establishment".

6. The local ID of the S7 connection can be modified in the "General" tab under
"Local ID".
You will specify the local ID later at the "ID" input parameter for the instructions
"PUT" and "GET".
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 39
2 Engineering

S7 CPU and PC station are created in different projects


Add S7 connection in the PC station:
1. Double-click "Devices & networks" in the "Project tree".

The graphical area of the "Network view" opens in the hardware and network
editor.
© Siemens AG 2020 All rights reserved

2. In the function bar, click "Connections" to enable the connection mode.


3. Select the connection type "S7 connection" in the nearby dropdown menu.
All devices that are relevant to an S7 connection are highlighted in color in the
"Network view".
4. Right click on the OPC server.
The context menu opens.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 40
2 Engineering

5. Select "Add new connection".

The "Add new connection" dialog will open.


© Siemens AG 2020 All rights reserved

6. Specify the following connection parameters: "Unspecified".


7. Enter the local ID for the S7 connection, e.g. "S7 connection PC".
The local ID is visible in the OPC client if the OPC client has established a
connection to the SIMATIC NET OPC UA server.
8. Click "Add" to add the unspecified S7 connection; click the "Close" button to
close the dialog.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 41
2 Engineering

Result:
An unspecified S7 connection is created.
• The connection path is highlighted.

• The S7 connection is entered in the connection table.


© Siemens AG 2020 All rights reserved

Note If the connection parameters are not yet fully set up, the S7 connection will be
shown with errors in the connection table.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 42
2 Engineering

Setting connection parameters:


1. Select the S7 connection in the connection table.
The properties of the S7 connection are displayed in the Inspector window.
2. In the "General" tab under "General", enter the IP address of the
communication partner, e.g. 192.168.178.35 (IP address of the S7 CPU).
© Siemens AG 2020 All rights reserved

3. In the "General" tab under "Special connection properties", disable the function
"Active connection establishment", as the PC station is a passive participant
when the connection is established.

4. In the "General" tab under "Address details", define the partner TSAP.
The partner TSAP is composed as follows:
– "Connection res. (hex)", e.g. 10.
– CPU slot, e.g.:
S7-1500 CPU / S7-1200 CPU: 1
S7-300 CPU: 2
S7-400 CPU: 3

Unrestricted

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 43
2 Engineering

Note
For partner TSAP, use the local TSAP of the S7 CPU.
When configuring the connection in the S7 CPU, enter the local TSAP of the
SIMATIC NET OPC server as partner TSAP.
5. In the "General" tab under "OPC", the function "Maintain connection
permanently" is enabled.
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 44
2 Engineering

Add S7 connection in the S7 CPU


1. Double-click "Devices & networks" in the "Project tree".
Figure 2-10

The graphical area of the "Network view" opens in the hardware and network
editor.
© Siemens AG 2020 All rights reserved

2. In the function bar, click "Connections" to enable the connection mode.


3. Select the connection type "S7 connection" in the nearby dropdown menu.
All devices that are relevant to an S7 connection are highlighted in color in the
"Network view".
4. Right-click on the S7 CPU.
The context menu opens.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 45
2 Engineering

5. Select "Add new connection".


Figure 2-11

The "Add new connection" dialog will open.


© Siemens AG 2020 All rights reserved

6. Specify the following connection parameters: "Unspecified".


7. Select the local ID for the S7 connection, e.g. 100 (hex).
You will specify the local ID later at the "ID" input parameter for the instructions
"PUT" and "GET".
8. Click "Add" to add the unspecified S7 connection; click the "Close" button to
close the dialog.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 46
2 Engineering

Result:
An unspecified S7 connection is created.
• The connection path is highlighted.

• The S7 connection is entered in the connection table.


© Siemens AG 2020 All rights reserved

Note If the connection parameters are not yet fully set up, the S7 connection will be
shown with errors in the connection table.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 47
2 Engineering

Setting connection parameters:


1. Select the S7 connection in the connection table.
The properties of the S7 connection are displayed in the Inspector window.
2. In the "General" tab under "General", enter the IP address of the
communication partner, e.g. 192.168.178.34 (IP address of the PC station).
© Siemens AG 2020 All rights reserved

3. In the "General" tab under "Address details", disable the option


"SIMATIC-ACC" and select the local connection resource, e.g. 10.

Note
When configuring the connection in the PC station, enter the local TSAP of the
S7 CPU as partner TSAP.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 48
2 Engineering

4. In the "General" tab under "Address details", enter the partner TSAP.

Note
For partner TSAP, use the local TSAP of the SIMATIC NET OPC server.
5. In the "General" tab under "Special connection properties", enable the function
"Active connection establishment" so that the S7 CPU will actively establish the
connection.
© Siemens AG 2020 All rights reserved

6. The local ID of the S7 connection can be modified in the "General" tab under
"Local ID".
You will specify the local ID later at the "ID" input parameter for the instructions
"PUT" and "GET".

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 49
2 Engineering

2.5.4 Creating tags for the parameters of the instructions "PUT" and "GET"

Insert a data block (DB) with the following tags in order to enter parameters for the
instructions "PUT" and "GET".
1. Navigate in the "Project tree" to the device folder of the S7 CPU.
2. Open the "Program blocks" folder.
3. Double-click the "Add new block" command.
© Siemens AG 2020 All rights reserved

The dialog "Add new block" opens.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 50
2 Engineering

4. Make the following settings and then confirm your entries with the "OK" button.
© Siemens AG 2020 All rights reserved

– Click the "Data block" button.


– Select the "Global DB" type.
– Enter the name of the DB, e.g. "InOut".
– Activate the "Automatic" radio button for automatic number assignment.
The number of the global DB is assigned by TIA Portal.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 51
2 Engineering

5. Double-click the newly inserted global DB "InOut".

The data block opens.


6. Double-click "<Add new>" to create tags.
© Siemens AG 2020 All rights reserved

7. Create the following tags to populate the input/output parameters of the "PUT"
and "GET" instructions. The following PLC data types are used.
Table 2-1
Tag PLC data type Description
put typePut Tags for parameter entry of the
"PUT" instruction
get typeGet Tags for parameter entry of the
"GET" instruction
diagnostic typeDiagnostic Tags to save the status of the
"PUT" and "GET" instructions in
the event of an error.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 52
2 Engineering

PLC data type "typePut"


The following table shows the structure of the "typePut" PLC data type.
Table 2-2
Parameter Data type Start value Description
request Bool false Control parameter for the "PUT"
instruction
done Bool false State parameter
error Bool false State parameter
id Word 16#0 Addressing parameter to specify
the connection to the
communication partner.
status Word false State parameter

PLC data type "typeGet"


The following table shows the structure of the "typeGet" PLC data type.
Table 2-3
Parameter Data type Start value Description
request Bool false Control parameter for the "GET"
instruction
© Siemens AG 2020 All rights reserved

done Bool false State parameter


error Bool false State parameter
id Word 16#0 Addressing parameter to specify
the connection to the
communication partner.
status Word false State parameter

PLC data type "typeDiagnostic"


The following table shows the structure of the "typeDiagnostic" PLC data type.
Table 2-4
Parameter Data type Start value Description
statusPut Word 16#0 Parameter to save the status of
the "PUT" instruction in the event
of an error.
statusGet Word 16#0 Parameter to save the status of
the "GET" instruction in the event
of an error.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 53
2 Engineering

2.5.5 Create send/receive data range

Overview
The following tags are created in the S7 CPU.
• Data block (DB) with standard access in order to save the data (receive data
area) that are read from the PC station
• Data block (DB) with standard access in which the data written to the PC
station are saved (send data area)

Add data block (DB) with standard access for send data
1. Navigate in the "Project tree" to the device folder of the S7 CPU.
2. Open the "Program blocks" folder.
3. Double-click the "Add new block" command.
© Siemens AG 2020 All rights reserved

The dialog "Add new block" opens.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 54
2 Engineering

4. Make the following settings and then confirm your entries with the "OK" button.
© Siemens AG 2020 All rights reserved

– Click the "Data block" button.


– Select the "Global DB" type.
– Enter the name of the DB, e.g. "SendData".
– Activate the "Automatic" radio button for automatic number assignment.
The number of the global DB is assigned by TIA Portal.
5. Double-click the newly inserted global DB "SendData".

The data block opens.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 55
2 Engineering

6. Double-click "<Add new>" to create tags.

7. Create a tag of data type "Array".


An "Array" is a data structure which consists of a fixed number of components
of the same data type. This application example uses the data type "Byte" for
the components.
8. In the "Project tree", right-click the newly inserted global DB "SendData".
© Siemens AG 2020 All rights reserved

The context menu opens.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 56
2 Engineering

9. Select "Properties".
© Siemens AG 2020 All rights reserved

The Properties dialog for the DB will open.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 57
2 Engineering

10. Make the following settings in the "General" tab under "Attributes" and then
apply the settings by clicking "OK".
© Siemens AG 2020 All rights reserved

– Disable the function "Optimized block access".


– Enable the function "Data block accessible from OPC UA".

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 58
2 Engineering

Add data block (DB) with standard access for receive data
1. Navigate in the "Project tree" to the device folder of the S7 CPU.
2. Open the "Program blocks" folder.
3. Double-click the "Add new block" command.
© Siemens AG 2020 All rights reserved

The dialog "Add new block" opens.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 59
2 Engineering

4. Make the following settings and then confirm your entries with "OK".
© Siemens AG 2020 All rights reserved

– Click the "Data block" button.


– Select the "Global DB" type.
– Enter the name of the DB, e.g. "RecvData".
– Activate the "Automatic" radio button for automatic number assignment.
The number of the global DB is assigned by TIA Portal.
5. Double-click the newly inserted global DB "RecvData".

The data block opens.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 60
2 Engineering

6. Double-click "<Add new>" to create tags.

7. Create a tag of data type "Array".


An "Array" is a data structure which consists of a fixed number of components
of the same data type. This application example uses the data type "Byte" for
the components.
8. In the "Project tree", right-click the newly inserted global DB "RecvData".
© Siemens AG 2020 All rights reserved

The context menu opens.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 61
2 Engineering

9. Select "Properties".
© Siemens AG 2020 All rights reserved

The Properties dialog for the DB will open.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 62
2 Engineering

10. Make the following settings in the "General" tab under "Attributes" and then
apply the settings by clicking "OK".
© Siemens AG 2020 All rights reserved

– Disable the function "Optimized block access".


– Enable the function "Data block accessible from OPC UA".

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 63
2 Engineering

2.5.6 User program of the S7-CPU

The following figure shows an overview of the user program in the S7 CPU.
Figure 2-12

DB10
OB 1 PUT
"SendData"

DB11
GET
"RecvData"

User program System blocks Data blocks


© Siemens AG 2020 All rights reserved

Parameter assignment for "PUT"


In order to receive data to the S7 data block DB1 in the PC station, call the "PUT"
instruction in the user program of the S7 CPU, e.g. in OB 1.
The following figure illustrates the call of the instruction "PUT" in OB 1.
Figure 2-13

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 64
2 Engineering

The following table shows the parameters of the instruction "PUT".


Table 2-5
Parameter Declaration Data type Start value Description
REQ Input Bool false Control parameters:
Enables data exchange at
rising edge
ID Input Word 16#100 Addressing parameter to
specify the connection to
the communication
partner (S7 OPC UA
server).
ADDR_1 InOut Remote P#DB1.DBX0.0 Pointer to the range in the
byte 10 communication partner
that should be written to.
Because the remote
pointer accesses the
S7 data block DB1 in the
PC station, DB1 must be
specified.
SD_1 InOut Remote P#DB10.DBX0.0 Pointer to the range in the
byte 10 CPU containing the data
to be sent.
DONE Output Bool false Additional parameters:
• 0: The request has
© Siemens AG 2020 All rights reserved

not yet been started


or is still being
executed.
• 1: Job completed
with no errors.
ERROR Output Bool false Additional parameters:
• 0: There is neither a
warning nor an error.
• 1: There is an error.
The "STATUS"
parameter provides
detailed information
on the type of error.
STATUS Output Word 16#0 State parameter
Detailed information is
available in the manual
SIMATIC STEP 7
Basic/Professional V16
and SIMATIC WinCC V16
or in the TIA Portal Online
Help.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 65
2 Engineering

Fill the parameters of the "PUT" instruction with the tags created in chapter 2.5.4.
The following table lists the assignment of the parameters of the "put" tags to the
parameters of the "PUT" instruction.
Table 2-6
Parameters, Parameters of Start value Note
"PUT" instruction the "get" tags
REQ request false Set the "request" parameter to
"TRUE" in order to start a
request to write data. The
write request is started at a
rising edge. Reset the
"request" parameter to
"FALSE" if the write request
was completed with "DONE" =
"1" or "ERROR" = "1" in order
to be able to start a new write
request.
ID id 16#100 Enter the local ID of the
connection that you defined
when configuring the
connection.
ADDR_1 − P#DB1.DBX0.0 Pointer to the range in the
byte 10 communication partner that
should be written to.
Because the remote pointer
© Siemens AG 2020 All rights reserved

accesses the S7 data block


DB1 in the PC station, DB1
must be specified.
SD_1 − P#DB10.DBX0.0 Pointer to the range in the
byte 10 CPU containing the data to be
sent.
DONE Bool false State parameter
ERROR Bool false State parameter
STATUS Word false State parameter

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 66
2 Engineering

Parameter "GET"
In order to read data from S7 data block DB1 in the PC station, call the "GET"
instruction in the user program of the S7 CPU, e.g. in OB 1.
The following figure illustrates the call of the instruction "GET" in OB 1.
Figure 2-14
© Siemens AG 2020 All rights reserved

The following table shows the parameters of the instruction "GET".


Table 2-7
Parameter Declaration Data type Start value Description
REQ Input Bool false Control parameters:
Enables data exchange at
rising edge
ID Input Word 16#100 Addressing parameter to
specify the connection to
the communication
partner (S7 OPC UA
server).
ADDR_1 InOut Remote P#DB1.DBX0.0 Pointer to the range in the
byte 10 communication partner
that should be read.
Because the remote
pointer accesses the
S7 data block DB1 in the
PC station, DB1 must be
specified.
SD_1 InOut Remote P#DB10.DBX0.0 Pointer to the range in the
byte 10 CPU in which the data
that are read will be
stored.
NDR Output Bool false Additional parameters:
• 0: The request has
not yet been started
or is still being
executed.
• 1: Job completed
with no errors.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 67
2 Engineering

Parameter Declaration Data type Start value Description


ERROR Output Bool false Additional parameters:
• 0: There is neither a
warning nor an error.
• 1: There is an error.
The "STATUS"
parameter provides
detailed information
on the type of error.
STATUS Output Word 16#0 State parameter
Detailed information is
available in the manual
SIMATIC STEP 7
Basic/Professional V16
and SIMATIC WinCC V16
or in the TIA Portal Online
Help.

Fill the parameters of the "GET" instruction with the tags created in chapter 2.5.4.
The following table lists the assignment of the parameters of the "get" tags to the
parameters of the "GET" instruction.
Table 2-8
Parameters, Parameters of Start value Note
© Siemens AG 2020 All rights reserved

"GET" instruction the "get" tags


REQ request false Set the "request" parameter to
"TRUE" in order to start a
request to read data. The read
request is started at a rising
edge. Reset the "request"
parameter to "FALSE" if the
read request was completed
with "NDR" = "1" or "ERROR"
= "1" in order to be able to
start a new read request.
ID id 16#100 Enter the local ID of the
connection that you defined
when configuring the
connection.
ADDR_1 − P#DB1.DBX0.0 Pointer to the range in the
byte 10 communication partner that
should be read.
Because the remote pointer
accesses the S7 data block
DB1 in the PC station, DB1
must be specified.
SD_1 − P#DB10.DBX0.0 Pointer to the range in the
byte 10 CPU in which the data that are
read will be stored.
DONE Bool false State parameter
ERROR Bool false State parameter
STATUS Word false State parameter

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 68
2 Engineering

2.6 Configuring the "Station Configuration Editor"


2.6.1 Manual configuration

Note Insert the components in the same order as in the component image that you
created in TIA Portal in the PC station "Device view". If the configuration differs
from the list, the configuration data that you download from TIA Portal to the PC
station will not be adopted correctly.
When configuring for the first time it is necessary to enter the station name.

1. Double-click the corresponding icon on your desktop to start the "Station


Configuration Editor".
2. Click the "Station Name" button.
© Siemens AG 2020 All rights reserved

The "Station name" dialog will open.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 69
2 Engineering

3. Enter the station name, e.g. "PC system".


It is imperative that the name in the "Station Configuration Editor" matches the
name that you assigned when configuring the PC station with TIA Portal.
4. Click "OK" to confirm the settings.
5. Click the "Add" button.
© Siemens AG 2020 All rights reserved

The "Add Component" dialog box opens.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0,Unrestricted
07/2020 70
2 Engineering

6. Make the following settings in order to add the "OPC server" user application.
– "Type": "OPC Server"
– Index: 1

7. Make the following settings in order to add the "IE General" component.
© Siemens AG 2020 All rights reserved

– "Type": "IE General"


– Index: 2
– "Parameter assig.":
Select the network adapter via which the PC station is connected to
communicates with the S7 CPU.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 71
2 Engineering

Result
The added components and the station name will be displayed in the "Station
Configuration Editor":
• Station name: "PC system"
• Index 1: "OPC server"
• Index 2: "IE General"
• Index 125: "Stationmanager"
"Stationmanager" will be automatically added at this index by the system.
Figure 2-15
© Siemens AG 2020 All rights reserved

The following status icons for the components show that the configuration data are
not yet loaded:

• The component is available in the current configuration of the PC station.


• The component has a configuration that is derived from a default parameter
set. The default parameter set allows a component to be accessible via
network without further configuration immediately after its installation. Make
sure that the default parameter set you use has parameters that match the
other network parameter settings.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 72
2 Engineering

• The component exists in the current configuration of the PC station but it was
not created in the project engineering. Depending upon the intended
application, the component must still be configured in STEP 7 and the
configuration data must be loaded.

Once you have manually configured the "Station Configuration Editor", load the PC
station's configuration data (see chapter 2.7.1).

2.6.2 Configuring the "Station Configuration Editor" in TIA Portal

1. Right-click on the device folder of the PC station.


© Siemens AG 2020 All rights reserved

The context menu opens.


2. Select "Configure PC station online".

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 73
2 Engineering

The "Configure" dialog will open.


© Siemens AG 2020 All rights reserved

3. Select the network adapter via which the PC station communicates with the
S7 CPU, then click "Update".
4. Click "Configure" in order to transfer the configuration of the PC station to the
Station Configuration Editor.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 74
2 Engineering

5. The message "Transfer completed successfully" will appear once the transfer
has completed successfully.
6. Click "Close" to finish the dialog.

Result
In the "Station Configuration Editor", the components and the station name are
created according to the configuration in TIA Portal:
• Station name: "PC system"
• Index 1: "OPC server"
• Index 2: "IE General"
• Index 125: "Stationmanager"
"Stationmanager" will be automatically added at this index by the system.
Figure 2-16
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 75
2 Engineering

The following status icons for the components show that the configuration data are
not yet loaded:

• The component is available in the current configuration of the PC station.


• The component has a configuration that is derived from a default parameter
set. The default parameter set allows a component to be accessible via
network without further configuration immediately after its installation. Make
sure that the default parameter set you use has parameters that match the
other network parameter settings.

• The component exists in the current configuration of the PC station, but it was
not created in the project engineering. Depending upon the intended
application, the component must still be configured in STEP 7 and the
configuration data must be loaded.

Once you have configured the "Station Configuration Editor" in TIA Portal, load the
PC station's configuration data (see chapter 2.7.1).

2.6.3 XDB export: Exporting XDB from TIA Portal

1. Open the "Device view" of the PC station.


2. Select the PC station.
© Siemens AG 2020 All rights reserved

The Inspector window displays the properties of the PC station.

3. In the "General" tab, navigate to "XDB configuration".


4. Activate the following functions:
– "S7RTM is installed (for example SIMATIC NET PC software)"
– "Generate XDB file"
5. Click on the "Browse..." button to set the path where the XDB file will be stored.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 76
2 Engineering

6. Select the PC station in the "Project tree".

7. Click on the "Compile" button in the function bar.


© Siemens AG 2020 All rights reserved

Result
The XDB configuration file will be generated and saved in the directory that you set
when configuring the PC station.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 77
2 Engineering

2.7 Loading configuration data


2.7.1 Load PC station configuration data

For productive operation, you require not only the component configuration but
also the project engineering data for the communication connections and possibly
also for the tag symbols. You can load the configuration data to the PC station in
the following ways:
• Loading via TIA Portal in online mode
• XDB import: Importing XDB in the Station Configuration Editor

Loading via TIA Portal in online mode


The online mode allows you to download the configuration data directly to a
PC station attached to the network, or to load the data to the local PC station if you
are using this as the Engineering PC.

Note Loading via TIA Portal in online mode will only successfully install the
communication services on your PC station if the component layout in the project
engineering data is identical to the layout in the configuration data on the
PC station.
© Siemens AG 2020 All rights reserved

Requirements:
• Engineering PC and PC station are in the same subnet.
• You set the same IP address and subnet mask for the PC station network
adapter as you did in the hardware configuration (see chapter 2.2.1).

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 78
2 Engineering

Compiling:
Figure 2-17

1. Select the PC station in the "Project tree".


© Siemens AG 2020 All rights reserved

2. Click on the "Compile" button in the function bar.

Unrestricted

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 79
2 Engineering

Load:
1. Open the "Device view" of the PC station.
© Siemens AG 2020 All rights reserved

2. Right-click the PC station.


The context menu opens.
3. Select the "Download to device > Hardware configuration" command.
The "Extended download to device" or "Load preview" dialog opens
automatically.
Note
The "Extended download to device" dialog is only opened automatically if the
access path to the PC station has to be reset.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 80
2 Engineering
© Siemens AG 2020 All rights reserved

4. In the "Extended download to device" dialog, make the following settings:


– Type of PG/PC interface: PN/IE
– PG/PC interface: Network adapter of the PC station
– Connection to interface/subnet: Subnet of the PC station, e.g. PN/IE_1
5. Select the option "Show devices with the same addresses".
6. Click the "Start search" button.
7. Select the Station Manager as target device.
8. Click "Load".
The "Load preview" dialog window opens.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 81
2 Engineering

9. Click the "Load" button to start the load process.

Result:
The PC station configuration data have been loaded successfully.
Figure 2-18
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 82
2 Engineering

• The components are in "RUN" mode. This is shown with the icon in the
"Run/Stop" column.
• The following status icon for the component shows that the configuration data
have been loaded successfully.

– The component is present and configured in the current configuration of


the PC station.
– The component is ready for operation!
• The configured S7 connection is loaded. This is shown with the icon in the
"Conn" column.

XDB import: Importing XDB in the Station Configuration Editor


1. Open the Station Configuration Editor.
2. Click "Import Station" to download the configuration data to the PC station.
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 83
2 Engineering

Result:
The PC station configuration data have been loaded successfully.
Figure 2-19
© Siemens AG 2020 All rights reserved

• The station has the same name as in the component image that you generated
in TIA Portal in the "Device view" for the PC station.
• The components are in "RUN" mode. This is shown with the icon in the
"Run/Stop" column.
• The following status icon for the component shows that the configuration data
have been loaded successfully.

– The component is present and configured in the current configuration of


the PC station.
– The component is ready for operation!
• The configured S7 connection is loaded. This is shown with the icon in the
"Conn" column.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 84
2 Engineering

2.7.2 Load S7 CPU configuration data

Requirements
• Engineering PC and S7 CPU are in the same subnet.
• You set the same IP address and subnet mask for the S7 CPU as you did in
the hardware configuration (see chapter 2.2.2).

Compiling
Figure 2-20
© Siemens AG 2020 All rights reserved

1. Select the S7 CPU in the "Project tree".


2. Click on the "Compile" button in the function bar.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 85
2 Engineering

Downloading
1. Select the S7 CPU in the "Project tree".
© Siemens AG 2020 All rights reserved

2. Click on the "Download to device" button in the function bar.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 86
2 Engineering

The "Extended download to device" or "Load preview" dialog opens


automatically.
Note
The "Extended download to device" dialog is only opened automatically if the
access path from the PG/PC to the S7 CPU has to be reset.
© Siemens AG 2020 All rights reserved

3. In the "Extended download to device" dialog, make the following settings to


access the S7 CPU over TCP/IP:
– Type of PG/PC interface: PN/IE
– PG/PC interface: PG/PC network adapter:
– Connection to interface/subnet: Subnet of the S7 CPU, e.g. PN/IE_1
4. Select the "Show all compatible devices" option.
5. Click the "Start search" button.
6. Select the S7 CPU as the target device.
7. Click "Load".
The "Load preview" dialog window opens.
8. Click the "Load" button to start the load process.

Unrestricted

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 87
2 Engineering

The "Load results" dialog opens.


9. Click "Finish" to finish downloading.
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 88
3 Operation

3 Operation
3.1 Setting up SIMATIC S7 communication

Note It is only possible to use the S7 server services via standard S7 connections to
S7 CPUs.

Using the S7 server services, the S7 CPU accesses the S7 data block DB1 in the
PC station over standard S7 connections.
In order to access the data that the S7 OPC UA server provides in the S7 data
block, you will need an OPC client. In this example, "OPC Scout V10" from
SIMATIC NET will be used as OPC client.

3.1.1 Establish connection to the S7 OPC UA server with OPC Scout V10

1. Start OPC Scout V10 from the Windows Start Menu item "Siemens Automation
> OPC Scout V10".
2. In the "Server explorer" under "UA server", right-click "Local UA server".
© Siemens AG 2020 All rights reserved

The context menu opens.


3. Click "Update browsing".

The enabled and available connections will be displayed.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 89
3 Operation

4. Right-click the S7 connection under "UA server > Local UA server >
OPC.SimaticNET.S7".

The context menu opens.


5. Click "Connect".
© Siemens AG 2020 All rights reserved

The "User authentication change" dialog opens.


6. A user authentication with Windows login and password will be needed in order
to establish the S7 connection.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 90
3 Operation

7. It is possible to log in anonymously if you enabled the option "Allow


anonymous logins to the OPC UA server" in the "Communication settings".
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 91
3 Operation

3.1.2 Setting up access to the data in S7 data block DB1 with OPC Scout

Use OPC Scout V10 to access the following nodes in the S7 OPC UA server:
• S7: @LOCALSERVER.db1.0,b,10

1. In the "Server explorer", navigate to "UA server > Local UA server >
OPC.SimaticNET.S7 > opc.tcp://<Computer name>:550101
[OPC.SimaticNET.S7] > Objects > S7: > @LOCALSERVER > blocks > db".
Templates for access to the S7 data block DB1 in the PC station will be
displayed here.
© Siemens AG 2020 All rights reserved

Unrestricted

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 92
3 Operation

2. Drag and drop the desired template into the DA view of OPC Scout V10 to
access the S7 data block DB1 in the PC station.
This application example uses the template "template byte array".

3. Modify the template. This application example accesses 10 bytes starting at


address 0 in DB1.

4. Click the "Monitoring ON" button to observe the node's data.


© Siemens AG 2020 All rights reserved

Note The S7 server services can only be used via standard S7 connections.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 93
3 Operation

3.2 S7 CPU writes data to the PC station


Requirements
• The "PUT" instruction is called in the user program of the S7 CPU.
• The following data block (DB) is created in the user program with standard
access.
– DB10: This data block contains that data which will be written to the S7
data block DB1 in the PC station.
• You have created a watch table in STEP 7 V16 (TIA Portal) containing the tags
below, and opened it.
– Tag to control the write request
– Tags whose values will be written to the PC station
• The connection from the PC station to the S7 CPU has been established (see
chapter 3.1.1).
• Access to the data in the S7 data block DB1 with OPC Scout V10 has been set
up (see chapter 3.1.2)
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 94
3 Operation

Overview
Figure 3-1

PC station S7 station

STEP 7 V16 S7 CPU


DB10
watch table
Byte 0
PUT
Byte 1
1 Write Byte 2
Byte 3
Byte 4
Byte 5
SIMATIC NET OPC Scout V10 Byte 6
Byte 7
Byte 8
2 Monitor Byte 9

Source area

S7 UA server

Node DB1
© Siemens AG 2020 All rights reserved

Byte 0
Byte 1
Byte 2
Byte 3
Byte 4
Byte 5
Byte 6
Byte 7
Byte 8
Byte 9

Target area

1. Write data (DB10 "SendData") to STEP 7 V16


2. Monitor node data in OPC Scout V10

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 95
3 Operation

Writing in STEP 7 V16 (TIA Portal)


Figure 3-2
© Siemens AG 2020 All rights reserved

1. Click the "Monitor all" button.


2. In the "Modify value" column, enter values that you wish to save in
DB10 "SendData" (source area).
3. Set the "REQ" input of the "PUT" instruction to "TRUE" via the tag
"InOut".put.request in order to start a write request.
4. Click on "Modify all selected values once and now."

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 96
3 Operation

Result
• The modify values are saved in DB10 "SendData" (source area). The values
are displayed in the "Monitor" column.

• The vales saved in DB10 "SendData" are written to the S7 data block DB1 in
the PC station (target area).
© Siemens AG 2020 All rights reserved

Note Reset the "REQ" input of the "PUT" instruction via the tag "InOut".put.request if
the write request was completed with "DONE" = "1" or "ERROR" = "1" so that
you can start a new write request.

Monitoring with OPC Scout V10


OPC Scout displays the values that were written by the S7 CPU to the S7 data
block DB1 in the "Value" column.
Figure 3-3

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 97
3 Operation

3.3 S7 CPU reads data from the PC station


Requirements
• The "GET" instruction is called in the user program of the S7 CPU.
• The following data block (DB) is created in the user program with standard
access.
– DB11: This DB stores that data that were read from the S7 data block DB1
in the PC station.
• You have created a watch table in STEP 7 V16 (TIA Portal) containing the tags
below, and opened it.
– Tag to control the read request
– Tags where the values read from the PC station are stored
• The connection from the PC station to the S7 CPU has been established (see
chapter 3.1.1).
• Access to the data in the S7 data block DB1 with OPC Scout V10 has been set
up (see chapter 3.1.2)
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 98
3 Operation

Overview
Figure 3-4

PC station S7 station

STEP 7 V16 S7 CPU


watch table

1 Monitor

SIMATIC NET OPC Scout V10

Write 2

S7 UA server
Node DB11
DB1 GET Byte 0
Byte 0 Byte 1
Byte 1 Byte 2
© Siemens AG 2020 All rights reserved

Byte 2 Byte 3
Byte 3 Byte 4
Byte 4 Byte 5
Byte 5 Byte 6
Byte 6 Byte 7
Byte 7 Byte 8
Byte 8 Byte 9
Byte 9
Target area
Source area

1. Write data of the node in OPC Scout V10


2. Monitor data (DB11 "RecvData") in STEP 7 V16

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 99
3 Operation

Writing with OPC Scout V10


Figure 3-5

1. In the DA view of OPC Scout V10, enter new values for the node in the "New
Value" column.
2. Click "Write" to write the node's data with new values.
The values are written to the S7 data block DB1 in the PC station (source
area).
3. Click the "Monitoring ON" button.

Result
© Siemens AG 2020 All rights reserved

The values of the S7 data block DB1 (source area) are displayed in the "Value"
column.
Figure 3-6

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 100
3 Operation

Monitoring in STEP 7 V16 (TIA Portal)


Figure 3-7

1. Click the "Monitor all" button.


2. Set the "EN_R" input of the "GET" instruction to "TRUE" with the tag
"InOut".get.request in order to start a read request.
© Siemens AG 2020 All rights reserved

3. Click on "Modify all selected values once and now."

Result
The values read from the S7 data block DB1 (source area) are stored in the
S7 CPU in DB11 "RecvData" (target area). The values are displayed in the "Modify
value" column.
Figure 3-8

Note Reset the "REQ" input of the "GET" instruction via the tag "InOut".get.request if
the read request was completed with "NDR" = "1" or "ERROR" = "1" so that you
can start a new read request.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 101
4 Useful information

4 Useful information
4.1 SIMATIC NET OPC server
4.1.1 S7 OPC UA server

The S7 OPC UA server supports S7 communication via Industrial Ethernet and


PROFIBUS.

Connection type
The S7 OPC UA server supports the following connection type:
• Standard S7 connection (see chapter 4.5.1).

Communication services
The S7 OPC UA server supports the following communication services:
Table 4-1
Communication service Description
Variable services Functions for reading and writing one or more S7 tags.
© Siemens AG 2020 All rights reserved

Buffer-oriented services Program-controlled transfer of larger blocks of data.


Block services Transfer of a loadable data range to and from S7.
Server functionality The PC can be used as a server for data buffers and data
blocks.
S7 password function Setting a password for access to protected blocks.
OPC UA events, conditions Processing of S7 messages and S7 diagnostic events.
and alarms
History data on OPC UA Access to history S7 data tags that are archived in a
database for up to 360 hours.

Note The S7 OPC UA server communication services listed in Table 4-1 are available
for Industrial Ethernet and PROFIBUS.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 102
4 Useful information

4.1.2 S7OPT OPC UA server

The S7OPT OPC UA server supports S7 communication via Industrial Ethernet


with the S7-1200 (V4 onward) and S7-1500.

Connection type
The S7OPT OPC UA server supports the following connection type:
• Optimized S7 connection (see chapter 4.5.2).

Communication services
The S7OPT OPC UA server supports the following communication services:
Table 4-2
Communication service Description
Variable services Functions for reading and writing one or more S7 tags
via standard access and access to optimized data
blocks.
OPC UA events, conditions and Processing of PLC messages.
alarms
History data on OPC UA Access to history S7OPT data tags that are archived
© Siemens AG 2020 All rights reserved

in a database for up to 360 hours.


S7 CPU protection level concept Setting a password for secured connection
establishment and access to the S7-1200 and
S7-1500 stations.

Note The S7OPT OPC UA server communication services listed in Table 4-2 are only
available for Industrial Ethernet.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 103
4 Useful information

4.1.3 SR OPC UA server

The SR OPC UA server makes it possible to use open communication services


(SEND/RECEIVE) via Industrial Ethernet with OPC UA. The SR OPC UA server is
authorized for communication with S7 devices. In addition, it also enables the user
to communicate with external devices.

Connection type
The SR OPC UA server supports the following connection type:
• TCP Connection
• ISO-on-TCP connection
• ISO transport connection

Type of connection
The type of SR connection methods that is possible via an SR connection is set in
STEP 7. The connection can either:
• only Fetch
• only Write

© Siemens AG 2020 All rights reserved

only Send/Receive

Communication services
The SR OPC UA server supports the following communication services:
Table 4-3
Communication service Description
Tag service Reading and writing of data tags for S5 data blocks and
ranges (S5-compatible communication) requires that a
Fetch or Write connection first be configured.
The data tags on a Fetch connection are only read. On a
Write connection, the data tags are written only. If a
communication partner's data blocks must not only be read
but also written, then you must configure two corresponding
connections which will be managed fully independently by
the OPC UA server.
Buffer send/receive service Buffer-oriented services allow program-controlled transfer of
larger blocks of data. These services are also known as
SEND/RECEIVE services. Data transfer with the OPC UA
server is implemented with tags:
• Tags that receive blocks of data
• Tags that send blocks of data
A default size for the blocks of data is specified in the
configuration. When sending tags, the length can be
restricted. Partial access within the blocks of data is
possible.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 104
4 Useful information

4.1.4 DP OPC UA server

The DP OPC UA server supports DP master class 1. The DP master class 1


performs cyclic communication to the DP slaves.
The DP OPC UA server supports the DP slave function DP-V0.

Process tags for the DP master with OPC UA


The DP OPC UA server for DP master mode offers process tags for the following
services:
• Services for the master class 1 access and monitoring of DP inputs and
outputs
• Sync/Freeze:
Acyclic sending of control telegrams to slave groups
• Fast Logic for:
– CP 5613 A2 and CP 5614 A2 (only DP master):
Automatic monitoring of slave data
– CP 5623 and CP5624 (only DP master):
Automatic monitoring of slave data
• Diagnostic tags:
Evaluation of static diagnostic information
© Siemens AG 2020 All rights reserved

Process tags for the DP slave with OPC UA


The DP OPC UA server for DP slave mode offers process tags for the following
services:
• Tag services for access to local slave data, access to the inputs and outputs of
the slave
• Diagnostic tags:
Evaluation of static diagnostic information of the slave

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 105
4 Useful information

4.2 Configuring a PC station


Overview
Figure 4-1

1 Engineering

Load configuration data:


• via TIA Portal (local or remote)
• Station import (XDB file)
© Siemens AG 2020 All rights reserved

Virtual rack in the PC station

OPC
server

Configuration

Index 1 Index 2

Industrial Ethernet

Unrestricted

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 106
4 Useful information

Engineering
In TIA Portal you will configure the PC station with the necessary components:
• Network adapter: e.g. "IE General"
• User application, e.g. "OPC Server"
Set all necessary addresses and parameters, such as IP address and subnet mask
for the network adapter.

Configuration
Using the "Station Configuration Editor" you will insert the components into the
virtual slots of the PC station and assign addresses and parameters to them.
To allow communication between the components in the PC station and to receive
project engineering data, each component is assigned a unique identification
number. The identification number for components in a PC station is the index. In
much the same way as the slot of a module in an S7 CPU, the index corresponds
to a virtual slot in a PC station.

4.3 "Station Configuration Editor"


Using the "Station Configuration Editor" you have access to the component
management of the "Stationmanager" in the PC station.
© Siemens AG 2020 All rights reserved

You need the "Station Configuration Editor" for the initial configuration and project
engineering as well as maintenance of a PC station.
The "Station Configuration Editor" is the user interface for Station Manager.

Note The "Station Configuration Editor" is always available and running on the PC
station where you installed the "SIMATIC NET PC Software".

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 107
4 Useful information

4.3.1 Overview

The following figure shows the layout of the "Station Configuration Editor".
Figure 4-2

1
© Siemens AG 2020 All rights reserved

1. Components:
The components are the modules and the applications involved in
communications in the PC station. These components require configuration
and project engineering data.
2. Station Manager:
The Station Manager holds the configuration and project engineering data for
the components in the component management (database).
Apart from component configuration, the "Station Configuration Editor" can also be
used for diagnostic purposes.

Unrestricted

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 108
4 Useful information

4.3.2 Area of application & use cases

Initial configuration (commissioning)


When a component is put into operation for the first time, an initial configuration is
necessary. This initial configuration is performed for all newly installed
components. The initial configuration sets an index (the "virtual slot number") of the
component.
After initial configuration of the components, the PC station is prepared to receive
the project engineering data. This step can be compared to inserting the
components into the rack of an S7 station.

Project engineering and maintenance


Changes in the project engineering and configuration data can be downloaded to
the PC station from TIA Portal (local and remote). As an alternative, it is possible to
transfer data using an XDB file.
Using the "Station Configuration Editor", you can check the effects in the
"Components" tab. The "Diagnostics" tab provides you with information on the
operating state at all times.
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 109
4 Useful information

4.3.3 "Components" tab

In the "Components" tab, you will find the essential functions for configuring a PC
station.
• Assigning the station name
• Creating new components
• Applying the component configuration and project engineering data
• Checks and diagnostics
• Setting the operating mode
The current mode is displayed in the title bar of the "Station Configuration
Editor".
– Offline mode
In offline mode, you can make changes to the configuration only by
entering them directly or by importing the station (XDB file). The "Online
Mode" button is visible; you can press it in order to enter online mode.
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 110
4 Useful information

– Online mode
In online mode, you have the ability to download project engineering data
directly to the PC station using TIA Portal. You can perform an XDB import
at any time. You can also specify (as an option) whether you want the
"offline mode" to be set following the import.
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 111
4 Useful information

• Disable and enable station:


As an administrator you have the ability to secure the PC station's
configuration data against changes.
– Click the "Disable Station" button to lock the PC station.
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 112
4 Useful information

– Click the "Enable Station" button to unlock.


© Siemens AG 2020 All rights reserved

It is not possible to change the configuration data while the station is locked. The
following functions are locked:
• Station import (XDB file)
• Downloading the PC station via TIA Portal (local or remote)
• Modifying the PC station in the "Station Configuration Editor"

The current status is displayed in the "Mode" field.


• RUN: The PC station is disabled for changes.
• RUN_P: The PC station is enabled for changes.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 113
4 Useful information

4.4 Data blocks


STEP 7 (TIA Portal) offers data blocks with the following access options for
S7-1500 and S7-1200 automation systems:
• Data blocks with optimized access
• Data blocks with standard access

The S7-300 and S7-400 automation systems only support data blocks with
standard access.

4.4.1 Data blocks with optimized access

Data blocks with optimized access have no predefined structure. In the declaration,
the data elements contain no fixed address within the data block but rather a
symbolic name. The elements are arranged in the block's available storage space
so that no gaps in the storage occur. This achieves optimal utilization of the
storage space.
The tags in this data block are identified by their symbolic names. Enter the
symbolic names of the tags in order to address them.
Optimized block access has the following advantages:
• Increase your engineering efficiency using purely symbolic addressing.
© Siemens AG 2020 All rights reserved

• Achieve higher performance in your automation system from optimized block


access.

4.4.2 Data blocks with standard access

Data blocks with standard access have a fixed structure. In the declaration, the
data elements contain a fixed address within the data block as well as a symbolic
name. The address is shown in the "Offset" column.
The tags in this data block can be addressed symbolically and absolutely.

4.5 Connection types


4.5.1 Standard S7 connection

The S7 server services only function over standard S7 connections. In order to


facilitate a standard S7 connection for S7-1200 CPUs and S7-1500 CPUs, you
must carry out the following steps:
• In the PC station's hardware configuration, set the version "SW V8.2…" for the
user application "OPC server" (see chapter 2.5.2).
• In the S7 CPU's hardware configuration, enable the function "Permit access
with PUT/GET communication from remote partner" (see chapter 2.5.1).
• Disable the attribute "Optimized block access" for the data blocks (see
chapter 2.5.5).
Network access with the S7 server services occurs with the "S7" protocol.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 114
4 Useful information

4.5.2 Optimized S7 connections

From version V12 onward, the SIMATIC NET OPC UA server can access
optimized data blocks of the S7-1200 CPU (firmware V4 or higher) and of the
S7-1500 CPU. Optimized data blocks no longer use absolute addresses. It is only
possible to access the tags using their symbolic names. This makes optimized data
blocks more generic, which reduces the possible sources of errors.
The optimized data blocks are located in the namespace of the
SIMATIC NET OPC UA server in the "SYM" folder of the S7-1200 station or
S7-1500 station.
Optimized data blocks are accessed over the network using the new "S7Opt"
protocol.
The default setting makes all S7 connections to S7-1200 CPUs (firmware V4 or
higher) and S7-1500 CPUs optimized S7 connections. S7 connections to S7-1200
CPUs and S7-1500 CPUs are configured in the same manner as with the S7-300
CPUs and S7-400 CPUs, but there are limitations:
• Optimized S7 connections and optimized data blocks can only be used via
OPC UA. DCOM-based clients cannot access optimized data blocks.
• The SIMATIC NET PC software must be V12 or higher.
• Smaller quantity structure for CP1613 A2. Only 40 optimized S7 connections
are possible for this CP.
© Siemens AG 2020 All rights reserved

4.6 OPC UA protocols


At the lowest level, the communications protocol of OPC UA is TCP-based and can
therefore be used cross-platform even on embedded systems. A secure, encrypted
transmission is required in all cases.
According to the standard, the following protocol options are available on the OPC
UA interface:
• Simple XML/SOAP with "HTTP" via port 80 or with "HTTPS" via port 443.
• Binary TCP via port 4840 and other ports, such as port 55101 to port 55105 if
other servers are involved.

The protocol can be selected using the URL address of the OPC UA server on the
OPC UA user interface. You have the following two options available.
• OPC UA XML web services by specifying a URL, for example:
– http://<hostname>:80
– https://<hostname>:443
• Pure (native) binary TCP protocol by specifying:
– opc.tcp://<hostname>:4840

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 115
4 Useful information

4.6.1 XML Web services

XML can be used very easily with common development environments for OPC UA
applications.
The firewall is usually already set to enable port 80 for HTTP and port 443 for
HTTPS or these ports can be enabled easily in it. This means that Internet access
is usually possible for the use of XML Web services without extra configuration.

4.6.2 Pure (native) binary TCP protocol

In OPC UA, the "OPC UA native binary" protocol has the highest transmission
speed because data is transmitted compressed and little packaging information
needs to be used. It requires the least additional effort. For example, no XML
parser is required as is necessary for SOAP and HTTP.
The format is standardized down to the binary level. This stabilizes the data
exchange between the OPC UA client and server since there are no degrees of
freedom (such as blanks or comments in XML) present.
The specially defined TCP port 4840 is used for communication in the "OPC UA
native binary" protocol, while SIMATIC NET OPC server still uses port 55101 to
port 55105, depending on the protocol. These ports can be enabled or disabled in
a firewall.
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 116
4 Useful information

4.7 Structure of the namespace for OPC UA


The name space of OPC UA no longer consists of just folders, items and
properties. It is a network of nodes with additional information and links.
The nodes are used both for the user data (instances) and for other information
such as type descriptions of data (types). The nodes of OPC UA can be subdivided
as follows:
• Types
These are the node types specified in the OPC UA specification and, where
necessary, by the relevant vendor, which are explicitly defined with respect to
their properties and attributes. There are four basic types as follows:
– ObjectTypes
– VariableTypes
– ReferenceTypes
– DataTypes
The types serve as the type description for the instances.
• Instances
These are the instances of the objects of your real project. Depending on the
type of node, they obtain their properties by referencing the various types.
The root of your OPC UA server organizes both the types and the instances. This
organizing includes the definition of additional nodes.
© Siemens AG 2020 All rights reserved

A node can have the following properties:


• Attributes that can be read
• Methods that can be called
• Events that can be signaled
Many standard nodes are defined in the OPC UA specification. Other node types
may be added by specific manufacturers. The namespace is shown as a tree
structure in OPC Scout V10.

4.8 Scanning the OPC UA namespace


The "Browse" and "Read" services are available for scanning the OPC UA
namespace.
The response returns the requested value (reference, property or attribute).

4.8.1 "Browse"

This service is used to obtain the references (links) of a node.

4.8.2 "Read"

This service is used to obtain one or more attributes of one or more nodes.

4.9 Reading and writing attribute values of nodes


The two services "Read" and "Write" are available to read and write the attribute
values of nodes.

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 117
4 Useful information

4.9.1 "Read"

This service is used to obtain one or more attributes of one or more nodes. With
structured attribute values, whose elements are indexed as in an array, clients can
read the entire set of indexed values, and they can read specific ranges or
individual elements.
How up-to-date the values are is decided by the "maxAge" parameter.

4.9.2 "Write"

This service is used to write values to one or more attributes of one or more nodes.
With structured attribute values, whose elements are indexed as in an array, clients
can write the entire set of indexed values, and they can write specific areas or
individual elements.
The service request remains pending until the values have been written or until it is
recognized that the values cannot be written.
Access for "Read" and "Write" uses the NodeId of the node or nodes. The NodeId
is the identifier of a node in the namespace of OPC UA.
© Siemens AG 2020 All rights reserved

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 118
5 Appendix

5 Appendix
5.1 Service and support
Industry Online Support
Do you have any questions or need assistance?
Siemens Industry Online Support offers round the clock access to our entire
service and support know-how and portfolio.
The Industry Online Support is the central address for information about our
products, solutions and services.
Product information, manuals, downloads, FAQs, application examples and videos
– all information is accessible with just a few mouse clicks:
https://support.industry.siemens.com

Technical Support
The Technical Support of Siemens Industry provides you fast and competent
support regarding all technical queries with numerous tailor-made offers
– ranging from basic support to individual support contracts. Please send queries
to Technical Support via Web form:
www.siemens.com/industry/supportrequest
© Siemens AG 2020 All rights reserved

SITRAIN – Training for Industry


We support you with our globally available training courses for industry with
practical experience, innovative learning methods and a concept that’s tailored to
the customer’s specific needs.
For more information on our offered trainings and courses, as well as their
locations and dates, refer to our web page:
www.siemens.com/sitrain

Service offer
Our range of services includes the following:
• Plant data services
• Spare parts services
• Repair services
• On-site and maintenance services
• Retrofitting and modernization services
• Service programs and contracts
You can find detailed information on our range of services in the service catalog
web page:
https://support.industry.siemens.com/cs/sc

Industry Online Support app


You will receive optimum support wherever you are with the "Siemens Industry
Online Support" app. The app is available for Apple iOS, Android and Windows
Phone:
https://support.industry.siemens.com/cs/ww/en/sc/2067

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 119
5 Appendix

5.2 Links and literature


Table 5-1
No. Subject
\1\ Siemens Industry Online Support
https://support.industry.siemens.com
\2\ Link to the article page of the application example
https://support.industry.siemens.com/cs/ww/en/view/67295801
\3\ SIMATIC NET PC Software Industrial Communication with PG/PC Volume 1 -
Basics (system manual)
https://support.industry.siemens.com/cs/ww/en/view/77376110
\4\ SIMATIC NET: PC software Industrial Communication with PG/PC Volume 2 -
Interfaces
https://support.industry.siemens.com/cs/ww/en/view/77378184
\5\ SIMATIC NET: PC software Commissioning PC Stations - Manual and Quick Start
https://support.industry.siemens.com/cs/ww/en/view/77377601

5.3 Change documentation


© Siemens AG 2020 All rights reserved

Table 5-2
Version Date Change
V1.0 05/2014 First version
V2.0 06/2020 Complete revision

S7 server services with SIMATIC NET OPC UA server


Article ID: 67295801, V2.0, 07/2020 120

You might also like