S7 User Block For The OPC UA Client of A SIMATIC S7-1500
S7 User Block For The OPC UA Client of A SIMATIC S7-1500
S7 User Block For The OPC UA Client of A SIMATIC S7-1500
OPC UA client of a
SIMATIC S7-1500
Siemens
SIMATIC S7-1500 / FW V2.6 / OPC UA client module Industry
Online
https://support.industry.siemens.com/cs/ww/en/view/109762770 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 2019 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.
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 2
Table of contents
Table of contents
Legal information ......................................................................................................... 2
1 Introduction ........................................................................................................ 4
1.1 Overview............................................................................................... 4
1.2 How it works ......................................................................................... 5
1.3 Components used ................................................................................ 8
2 Engineering ........................................................................................................ 9
2.1 Block description .................................................................................. 9
2.1.1 Interface description ............................................................................. 9
2.1.2 Functional description ........................................................................ 11
2.1.3 Functional sequence .......................................................................... 13
2.1.4 Device diagnostics ............................................................................. 17
2.2 Project planning and programming .................................................... 19
2.2.1 Activate OPC UA Client ...................................................................... 19
2.2.2 Creating an OPC UA Client Interface ................................................. 20
2.2.3 Parameterizing the OPC UA Client Module ....................................... 24
2.3 Commissioning and operation of the example ................................... 27
2.3.1 Commissioning the example .............................................................. 27
2.3.2 Description of the user interface ........................................................ 27
2.3.3 Operation of the example ................................................................... 28
3 Useful information ........................................................................................... 32
© Siemens AG 2019 All rights reserved
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 3
1 Introduction
1 Introduction
1.1 Overview
As of firmware V2.6 of the SIMATIC S7-1500 PLC family, an OPC UA client is
introduced into the control system. With this extension you can implement M2M
communication completely via OPC UA on a SIMATIC S7-1500 controller.
In contrast to the OPC UA server of the controller, the OPC UA client is
programmed via many system function blocks and not only configured. The client
supports all common security policies and modes as well as user authentication via
username and password or anonymously.
With this application example we create for you the S7 user block "OpcUaClient",
which summarizes the most important functions of the OPC UA system function
blocks, accelerates the implementation for you and simplifies the programming.
The OPC UA server in the example is an S7-1500 controller with a simple
simulation program for process values. Alternatively, you can use any other OPC
UA server.
Figure 1-1
S7 S7 system
User block "OpcUaClient" function blocks
© Siemens AG 2019 All rights reserved
S7 user program
S7-1500
OPC UA
The following access types are supported by the OPC UA client and the user block:
• Registered Read
• Registered Write
• Registered Method Call
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 4
1 Introduction
– OPC_UA_ConnectionGetStatus
Figure 1-2
OPC_UA_ OPC_UA_
OPC_UA_ WriteList ReadList
Connect
OPC_UA_
OPC_UA_ OPC_UA_ Connection
OPC_UA_
MethodCall Namespace GetStatus
NodeGet
GetIndexList
HandleList OPC_UA_
Method
OPC_UA_ Release
HandleList
MethodGet OPC_UA_
HandleList OPC_UA_
Disconnect
NodeRelease
HandleList
OpcUa
Client
S7 User block
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 5
1 Introduction
The following table gives you an overview of the functions of the individual SFBs
within the S7 user block "OpcUaClient":
Table 1-1
SFB Function
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 6
1 Introduction
Functional sequence
After you have parameterized and called up the block, you only need four input
parameters to control the OPC UA functions: "enable", "read", "write" and
"callMethod".
Via the input parameter "connect" you establish and terminate a
connection/session. The "read" input starts a read job, the "write" input a write job.
"CallMethod" calls a method on the connected OPC UA server.
The device diagnoses and maintains the connection to the server for you and
reconnects automatically if the connection is terminated. In the event of
malfunction, you will be informed via the block outputs.
Figure 1-3
Input
"enable"
TRUE FALSE
NodeRelease
Connect
HandleList
© Siemens AG 2019 All rights reserved
Namespace MethodRelease
GetIndexList HandleList
NodeGet
Disconnect
HandleList
Set
Block
MethodGet Set
HandleList Block
outputs outputs
Input
Input Input Connection
"call
"read" "write" GetStatus
Method"
Set
Block
outputs
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 7
1 Introduction
Hinweis The included projects for TIA Portal V15.1 (S7-1500 FW 2.6) and V16 (from S7
1500 FW 2.8) differ in the connection monitoring process. Make sure to select
the appropriate project and firmware.
If you use TIA Portal V16 with an S7-1500 with FW 2.6, use the project for TIA
Portal V15 and upgrade it to TIA Portal V16.
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 8
2 Engineering
2 Engineering
2.1 Block description
2.1.1 Interface description
The following table explains the input and InOut parameters of the block:
Table 2-1
Parameters Data type Description
enable Bool TRUE = Establish connection
FALSE = disconnection
read Bool Starts read job with positive edge
write Bool Starts write job with positive edge
methodHdlIndex Int The method to be called from the method
list
callMethod Bool Calls the method of "methodHdlIndex" with
positive edge
connectionInfo "OPC_UA_Session Connection Information for Session Setup
ConnectInfo" with the OPC UA Server
serverEndpointUrl String The Endpoint URL of the OPC UA Server
namespaceUris Variant Pointer to the memory area of the queried
namespace URIs.
namespaceIndexes Variant Pointer to the memory area of the queried
namespace indexes.
readNodeIds Variant Pointer to the array of "OPC_UA_NodeId"
of the node IDs to be read.
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 9
2 Engineering
Note If you use several methods, you must adapt the InOut parameters
"inputArguments" and "outputArguments" to the methods to be called at runtime.
Therefore note chapter "3.4 Tips & tricks".
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 10
2 Engineering
The S7 user module "OpcUaClient" implements the OPC UA client functions for
you. The module contains step chains in which the OPC UA system function
modules are called and evaluated. The block requires the client interface
configured in the TIA Portal, which provides all information for OPC UA
communication. For further information on the client interface, refer to section 2.2.2
Creating an OPC UA Client Interface.
The following illustrations explain the dependencies and workflow between the
OPC UA system function modules in general:
1
© Siemens AG 2019 All rights reserved
1
1
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 11
2 Engineering
1 1
3 3
1
4
© Siemens AG 2019 All rights reserved
1 1
3 4
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 12
2 Engineering
The following explanations explain the sequence of functions within the block
"OpcUaClient":
Connection setup
The system function block "OPC_UA_Connect" is executed to establish the
connection. This module establishes a connection to the server and activates
a session. After successful connection establishment, the block returns a
"Connection Handle". This handle references the existing connection/session for all
further OPC UA functions.
After the block has established the connection, the system function block
"OPC_UA_NamespaceGetIndex" is executed. This block returns the namespace
indexes for the nodes configured in the client interface. The indexes are mandatory
for the addressing of the nodes in the later course.
The nodes of the read, write and method lists are then registered on the server. For
this, the system function modules "OPC_UA_NodeGetHandleList" and
"OPC_UA_MethodGetHandleList" are executed. For each registered node,
a handle is returned that is needed to read or write the node later.
Figure 2-5
User „OpcUaClient“ System function
program block
© Siemens AG 2019 All rights reserved
connectionInfo
serverEndpointUrl ConnectionHdl
namespceUris
readNodeIds
writeNodeIds OPC_UA_NamespaceGetIndex()
objNodeIds
methodNodeIds
NamespaceIndexes
OPC_UA_NodeGetHandleList()
NodeHdls
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 13
2 Engineering
Connection monitoring
For connection monitoring, the system function block
"OPC_UA_ConnectionGetStatus" is called cyclically (5 s) after you have
successfully established a connection. After each call, the data supplied by the
block is evaluated in order to diagnose connection breakdowns or other errors.
Further information on connection monitoring can be found in section 3.1
Connection monitoring in the "OpcUaClient" block.
Figure 2-6
User „OpcUaClient“ System function
program block
connect = TRUE
OPC_UA_ConnectionGetStatus()
T = 5s ConnectionStatus
ServerState
ServiceLevel
© Siemens AG 2019 All rights reserved
Read variables
To read the variables from the server, the system function module
"OPC_UA_ReadList" is executed. The block uses the handles registered during
connection establishment to read the variables via the RegisteredRead service.
The SFB returns the values of each node. In addition, a status code and a time
stamp are output for each node. The user block "OpcUaClient" evaluates the status
codes for you and sets the corresponding outputs in case of an error ("error" =
"TRUE"; "errorId" = "71", "status" = "<StatusCode>").
Figure 2-7
User “OpcUaClient” System function
program block
readNodeHdls
readData
Variable
NodeStatusList
TimeStamps
done = TRUE
readData
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 14
2 Engineering
Writing Variables
To write the variables to the server, the system function module
"OPC_UA_WriteList" is executed. The block uses the handles registered during
connection establishment to write the variables via the "RegisteredWrite" service.
The SFB returns one status code per written node. The user block "OpcUaClient"
evaluates the status codes for you and sets the corresponding outputs in case of
an error ("error" = "TRUE"; "errorId" = "72", "status" = "<StatusCode>").
Figure 2-8
User “OpcUaClient” System function
program block
writeNodeHdls
writeData
NodeStatusList
done = TRUE
Call methods
To execute the method on the server, the system function module
© Siemens AG 2019 All rights reserved
methodHdlIndex
methodHdls
inputArguments outputArguments
MethodResult
done = TRUE
outputArguments
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 15
2 Engineering
Disconnection
The system function block "OPC_UA_Disconnect" is executed to terminate the
connection. This block closes the connection to the server, deactivates the existing
session and releases used resources of the client CPU.
Before the connection is terminated, the system function modules
"OPC_UA_NodeReleaseHandleList" and "OPC_UA_MethodReleaseHandleList"
are executed. These SFBs release the handles that were created by the server for
all nodes of the read, write and method lists when the connection was established.
Figure 2-10
User "OpcUaClient" System function
program block
OPC_UA_MethodReleaseHandleList()
OPC_UA_Disconnect()
© Siemens AG 2019 All rights reserved
connected = FALSE/
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 16
2 Engineering
available at output "diagnostics". The values of this structure remain until the next
error.
The following table explains the error sources for the status codes of the interface
parameter "status":
Table 2-5
Status code Source of errors
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 17
2 Engineering
16#8671 "OPC_UA_NodeReleaseHandleListe").
Error during release of write list (SFB
16#8672 "OPC_UA_NodeReleaseHandleListe").
Error during release of method list (SFB
16#8673 "OPC_UA_MethodReleaseHandleListe").
16#86F4 Error during read of read list; List not registered
16#86F6 Error during method call from method list; List not registered
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 18
2 Engineering
To be able to use the functions of the OPC UA client, you have to activate the
client in the properties of the CPU. Proceed as follows:
1. Navigate in the project tree in TIA Portal to the "Device configuration" of your
CPU.
2. Navigate in the Inspector window to "OPC UA > Client > General" ("OPC UA >
© Siemens AG 2019 All rights reserved
Client > General") and activate the checkbox "Activate OPC UA client".
3. Then confirm that you have the required license for OPC UA. Navigate to
"Runtime licenses" and select the appropriate license in the category "OPC
UA".
Note Depending on the used SIMATIC S7-1500 CPU you need a suitable OPC UA
license ("small", "medium" or "large"). See section 3.3 Quantity Structure and
Licenses of the OPC UA Client.
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 19
2 Engineering
To use the OPC UA functions of the S7 function blocks, you must first create a
client interface. The interface contains all relevant information required by the client
module "OpcUaClient". The TIA Portal stores this information in two automatically
generated data blocks:
• "<InterfaceName>_Configuration"
This DB contains the connection information, node IDs and data types.
• "<InterfaceName>_Data"
The values read or to be written are stored in this DB. The DB also contains a
status list for the individual variables.
2. Enter a session name ("Session name"), the "Address" and the "Port" of the
server in the inspector window under "Properties > Configuration > Connection
parameters" ("Properties > Configuration > Connection parameter"). Also
assign a useful "session timeout" and the desired "monitoring time".
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 20
2 Engineering
1. In the TIA Portal workspace, navigate to Data access > Read lists in the left
pane, and double-click Add new read list.
2. You now have two options for filling the reading list:
Via an imported server interface as an XML file (a) or via an online connection
directly to a server (b).
In the Source of server data drop-down list on the right side of the workspace,
select one of the two options.
a. Click the Import interface button if you are using the Imported interface
option. In the dialog that appears, select the XML file of your server
interface and confirm with "Import".
b. Click the "Connect to online server" button if you are using the "Online"
option.
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 21
2 Engineering
Note Make sure that the OPC UA server is accessible from your engineering station
before establishing an online connection.
© Siemens AG 2019 All rights reserved
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 22
2 Engineering
3. Drag and drop the variables of the server interface to be read into the read list.
After each change in the OPC UA-Client interface you must recompile the CPU
so that the parameters are transferred into the data blocks.
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 23
2 Engineering
Parameterize block
Parameterize the interface of the block "OpcUaClient" in your user program as
follows:
1. Call the block in a cyclic OB and create a new instance.
© Siemens AG 2019 All rights reserved
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 24
2 Engineering
2. Connect the parameters for control and diagnosis of the block. Create suitable
variables for this.
Block parameters Data type
connect Bool
read Bool
write Bool
callMethod Bool
connected Bool
done Bool
busy Bool
error Bool
status DWord
diagnostics "typeFbDiagnostics"
Connection
connectionInfo "<InterfaceName>_Configuration".Connection.ConnectInfo
serverEndpointUrl "<InterfaceName>_Configuration".Connection.
serverEndpointUrl
namespaceUris "<InterfaceName>_Configuration".Namespaces.
NamespaceUris
namespaceIndexes "<InterfaceName>_Configuration".Namespaces.
ServerNameSpaceIndexes
connectionHdl (Optional) "<InterfaceName>_Configuration".Connection.
ConenctionHdl
Read
readNodeIds "<InterfaceName>_Configuration".ReadLists.
<ReadListName>.Nodes
readNodeHdls "<InterfaceName>_Configuration".ReadLists.
<ReadListName>.NodeHdls
readData "<InterfaceName>_Data".<ReadListName>.Variable
Write
writeNodeIds "<InterfaceName>_Configuration".WriteLists.
<WriteListName>.Nodes
writeNodeHdls "<InterfaceName>_Configuration".WriteLists.
<WriteListName>.NodeHdls
writeData "<InterfaceName>_Data".<WriteListName>.Variable
CallMethod
objNodeIds "<InterfaceName>_Configuration".MethodLists.
<MethodListName>.ObjectNodes
methodNodeIds "<InterfaceName>_Configuration".MethodLists.
<MethodListName>.MethodNodes
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 25
2 Engineering
4. Mark your CPU in the project navigation and click on the icon "Download to
device" to load the project into your CPU.
© Siemens AG 2019 All rights reserved
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 26
2 Engineering
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 27
2 Engineering
2. Click on the "Monitor all" icon in the workspace to observe the variables of the
controller live.
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 28
2 Engineering
3. First connect your client to the server by setting the variable "opcUaConnect"
in the "Inputs" area to "TRUE". To do this, right-click the variable and select
Tax > Tax at 1 ("Modify > Modify to 1").
Further information about the diagnosis of the block can be found in section
2.1.4 Device diagnostics.
After you have connected your client to the OPC UA server, you can perform the
© Siemens AG 2019 All rights reserved
following operations:
• Read variables from server
• Writing Variables to the Server
• Execute method
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 29
2 Engineering
2. Write the OPC UA variables of the server by setting the variable "OpcUaWrite"
in the "Inputs" area to "TRUE". To do this, right-click the variable and select
Tax > Tax at 1 ("Modify > Modify to 1").
Further information about the diagnosis of the block can be found in section
2.1.4 Device diagnostics.
© Siemens AG 2019 All rights reserved
Further information about the diagnosis of the block can be found in section
2.1.4 Device diagnostics.
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 30
2 Engineering
3. Observe the values in the "Data Read" area. If you have previously specified a
value for "endValue" and set "startCounting", then the value "actValue"
changes every second. Check the value change with further read requests.
the Inputs section to TRUE. To do this, right-click the variable and select Tax >
Tax at 1 ("Modify > Modify to 1").
Further information about the diagnosis of the block can be found in section
2.1.4 Device diagnostics.
4. Check the new PLC time on the display of your server CPU.
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 31
3 Useful information
3 Useful information
3.1 Connection monitoring in the "OpcUaClient" block
Connection monitoring for S7-1500 FW 2.6
The following diagram describes the error handling of the implemented connection
monitoring by the system function block "ConnectionGetStatus" (CGS):
Figure 3-1
Connection
setup
T = 5s
Connection
monitoring
(CGS)
© Siemens AG 2019 All rights reserved
3 2
Status:
Yes CS 0 Yes
SS: 0 16#A000_0105
SL: 16#FF 16#80AE_0000
No No
Table 3-1
No. Description
1. After a connection has been successfully established from the "OpcUaClient"
block to a server, the system function block "OPC_UA_ConnectionGetStatus" is
called periodically (5 seconds) to monitor the connection to the server.
2. If the "Connection Handle" to the server is invalid, you get an error at the SFB
"OPC_UA_ConnectionGetStatus" ("Error" = "TRUE"). A new connection is
established for the associated "Status" = "16#A000_0105" or "16#80AE_0000".
Other values indicate errors that must be corrected by the user before a new
connection can be established. In this case, the outputs of the block
"OpcUaClient" are set and the SFB is executed again. For more information on
the outputs, see the TIA online help (F1).
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 32
3 Useful information
No. Description
3. If a valid "Connection Handle" to the server exists, the SFB
"OPC_UA_ConnectionGetStatus" is successfully executed ("Done" = "TRUE"). In
this case the block "OpcUaClient" evaluates the outputs "ConnectionStatus"
(CS), "ServerState" (SS) and "ServiceLevel" (SL). The values CS = "0", SS = "0"
and SL = "16#FF" indicate a correct connection, the block "OpcUaClient" is ready
to execute further jobs. Other values indicate errors that must be corrected by the
user before a new connection can be established. In this case, the outputs of the
block "OpcUaClient" are set and the SFB is executed again. For more
information on the outputs, see the TIA online help (F1).
1 Connect
T = 5s
Connection
monitoring
(CGS)
3
2 Error = TRUE Done = TRUE Output:
Outputs:
Connection-
Done/Error
Status
0 1 2
4 5
Connection-
Connected Shutdown
Error
Set block
Disconnect
outputs
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 33
3 Useful information
Table 3-2
No. Description
1. After a connection from the block "OpcUaClient" to a server has been
established successfully, the system function block
"OPC_UA_ConnectionGetStatus" is executed periodically (5 seconds) to monitor
the connection to the server.
2. If the block "OPC_UA_ConnectionGetStatus" returns an error ("Error" = TRUE)
during connection monitoring, it is to be assumed that a underlaying read job of
the nodes "ServerState" and "ServiceLevel" is currently taking place. In this case
the block must be executed again.
3. If the connection monitoring via the block "OPC_UA_ConnectionGetStatus" is
successful ("Done" = TRUE), the block output "ConnectionStatus" must be
evaluated:
"0": Connection established ("UACS_Connected")
"1": Connection interrupted ("UACS_ConnectionError")
"2": Disconnected ("UACS_Shutdown")
4. When the cause of a connection error is solved ("UACS_ConnectionError" >
"UACS_Connected") the OPC UA client of a SIMATIC S7-1500 reactivates the
connection automatically.
5. When the cause of a connection error is solved but the session on the server has
already been deactivated ("UACS_ConnectionError" > "UACS_Shutdown") the
connection must be terminated (SFB "OPC_UA_Disconnect") and then re-
established (SFB "OPC_UA_Connect").
© Siemens AG 2019 All rights reserved
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 34
3 Useful information
Call structure
The following figure shows the call hierarchy of the S7 user program of the CPU
"OpcUaServer":
Figure 3-3
OPCMethod InstOPC
Main SetMachine MethodSet
Time MachineTime
Counter InstCounter
OpcUa
© Siemens AG 2019 All rights reserved
Interface
(Instance)
OB1 cycle S7 function blocks data blocks:
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 35
3 Useful information
Note Despite the "Medium" license, the SIMATIC S7-1500 CPU 1507S offers the
"Large" quantity structure.
© Siemens AG 2019 All rights reserved
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 36
3 Useful information
4. Then, depending on the selected method, assign an input and output argument
to the temporary variables using the "VariantPut" statement:
IF methodHdlIndex = 1 THEN
VariantPut(SRC:="OpcUaClientInterface_Data".methodList.
Method1.Inputs, DST:=#TempVarIn);
VariantPut(SRC:="OpcUaClientInterface_Data".methodList.
Method1.Outputs, DST:=#TempVarOut);
END_IF;
IF methodHdlIndex = 2 THEN
VariantPut(SRC:="OpcUaClientInterface_Data".methodList.
Method2.Inputs, DST:=#TempVarIn);
VariantPut(SRC:="OpcUaClientInterface_Data".methodList.
Method2.Outputs, DST:=#TempVarOut);
END_IF;
This procedure enables you to change the assignment of the module interfaces at
runtime. Follow the procedure above to assign the appropriate input and output
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 37
3 Useful information
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 38
4 Appendix
4 Appendix
4.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 2019 All rights reserved
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
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 39
4 Appendix
OPC UA PLC-Client
Entry-ID: 109762770, V1.1, 10/2019 40