Example: OPC UA Client
Product: CODESYS OPC UA
This example shows how to use the IEC 61131-3 interface of the CODESYS OPC UA Client. It contains function blocks to connect to and exchange data with other OPC UA servers. It also includes two visualizations to operate the cited function blocks via a user interface and to check server certificates.
Description
The example contains a project with two applications: UAClientDemo
and UAServerData
.
The UAClientDemo
application contains function blocks for using the CODESYS OPC UA client.
UAConnection
: To establish the connection to any OPC UA ServerUABrowse
: To send browse requests to an OPC UA ServerUASubscription
: To generate OPC UA subscriptionsUAMonitoredItem
: To monitor OPC UA variables (“Monitored Items”)UAAttributes
: To send read/write commands to the OPC UA ServerUAMethod
: To call OPC UA methodsUAClient
: State machine for the OPC UA Client to establish and terminate connections. The function block is the basis for the visualization.
The UAServerData
application publishes a data set about the CODESYS OPC UA Server.
Additional information
The example contains two visualizations:
CheckCertificate
provides a user interface to accept server certificates one time and then establish a secure connection. The CODESYS Security Agent can be used to permanently trust server certificates.Visualization
provides a user interface to operate the CODESYS OPC UA Client using the UAClient function block.
Important
The connection to OPC UA servers is possible only via an IP address and not a host name.
To establish secure server–client communication, the CODESYS Security Agent has to be used to generate a client certificate on the controller before the connection is established.
System requirements and restrictions
Programming system | CODESYS Development System (version 3.5.17.0 or higher) |
Runtime system | CODESYS Control Win (version 3.5.17.0) |
Add-on components | CmpOPCUAClient runtime system component |
Note
DOWNLOAD Project
After installing the package, you will find the sample project in the directory C:\Users\<user>\CODESYS Examples\OPC UA Client Example
.