-

Configuring the OPC UA Client Connections

The connection configuration for the OPC UA client comprises the configuration of the OPC UA server connections and the mapping of the variables (process data items) declared in the PLCnext Engineer project to the OPC UA server variables. The configuration is stored to an XML file on the PLCnext Technology controller. The file is based on the standard UA schema for data types.

Further Info
For the schema documentation, see also the PLCnext Info Center.

The configuration of the server connections and their properties as well as the variable mapping is done in the 'Client Connections' editor. To open the editor, double-click the 'OPC UA' PLANT node and activate the editor in the editors group.

This topic contains the following sections:

Configuring the OPC UA server connections

The OPC UA client uses the server connections to communicate with the OPC UA servers and to access the remote server variables (see the section "Mapping variables in PLCnext Engineer" below). The PLCnext Technology device establishes the connection automatically as soon as the server is available. For each server that wants to communicate with the client, a corresponding connection must be configured. To be able to communicate with the server, the client requires information about the server such as the server URL, the security mode and security policy used to connect to the server.

In the 'Server' table (as shown in the example), each table row represents a server connection. For each server connection the following properties can be configured:

PropertyDescription
NameName that identifies the server connection that is used for the data exchange. The connection must be specified for each variable mapping you create (see the "Mapping variables in PLCnext Engineer" section below).
URLEndpoint URL of the OPC UA server to connect to. The client uses the URL to find and connect to the OPC UA server. The format is as follows (see also the examples in the figure above):

opc.tcp://IpAddress:Port

or

opc.tcp://hostname:Port

Optionally the port can be specified. If omitted, the default OPC UA discovery port 4840 is used.

Note
Currently, only the endpoint type opc.tcp is supported.

StateDisplays the status of the browse/read or import process of remote variables from the selected OPC UA server(s). The following status icons may appear:

Unknown. The data has not been read or imported from the OPC UA server.
The read/import process from the OPC UA server is in progress.
The data has been successfully read or imported.

The toolbar buttons above the server table are used to browse and read remote variables from selected OPC UA server(s) or import variables from a csv file for an OPC UA server (see the section below for a description). After the variables have been successfully read/imported, they are available for selection in the 'Remote variable identifier' column ('Variable Groups' table in the 'Client Connections' editor) via the role picker.
Username(Optional) User name to authenticate with the OPC UA server. If no username is entered, anonymous authentication towards the server is enabled.
Password(Optional) Password to authenticate with the OPC UA server. Only required if the username is specified.
Security modeSecurity mode used to connect to the OPC UA server. The security mode defines the level of security for the data being exchanged during client-server communication. You can choose one of the following modes:

  • 'None' - No security is applied. Data are exchanged unsecure.
  • 'Sign' - Data are signed but not encrypted.
  • 'Sign and Encrypt' - Data are signed and encrypted.
Security policy urlSecurity policy url used to connect to the OPC UA server. The security policy describes various algorithms and key lengths which are used to establish a secure connection between server and client. In accordance with the OPC UA specification, you can choose one of the following security policies (from top to bottom, the encryption and signature strength increases):

  • 'None' - No security is applied.
  • 'Basic 128 RSA15'
  • 'Basic 256'
  • 'Basic 256 SHA256'
  • 'AES 128 SHA256 RSA OAEP'
  • 'AES 256 SHA256 RSA PSS'
  • 'Best available' - Best available security policy provided by the OPC UA server is used.

Further Info
See also the 'Security Policies' descriptions in the "OPC UA Security Settings" topic.

In the 'Variable Groups' table, the group type ('Subscribe' or 'Write') and the cycle time (update interval in ms for a cyclic write or subscribe) are specified. The variable groups are used to organize the variable mappings (see the section "Mapping variables in PLCnext Engineer" below) . The variable mappings contain a local variable and a description how to find the remote variable made available by the OPC UA server. A variable group can contain one or more variable mappings.

When you add a variable group in the 'Variable Groups' table, the corresponding group appears under the 'Configuration' category on the left in the editor (as shown in the example above). The group name shows the configured group type and cycle time.

To delete a server connection from the 'Server' table, click in the first table cell and press <Del>.

Reading and importing remote variables from OPC UA server(s)

You can use the toolbar buttons above the server table or the context menu commands of a server connection to browse an OPC UA server and read its remote variables or to import remote variables from a CSV file for an OPC UA server.

The following buttons are available (the context menu of a server connection contains the corresponding commands):

ButtonDescription
Browses the OPC UA server(s) selected in the 'Server' table (multi-selection is possible) and reads the remote variables from the server(s). To establish the connection to an OPC UA server, the settings as configured for the server connection ('Security mode', 'Username', 'Password', etc.) are used.

The 'State' column (see the section above) shows the status of the browse and read process. The progress of the process is displayed in the 'Import Export Log' in the MESSAGES window. When an error occurs, an error message is displayed (in the 'Import Export Log' and as desktop notification) and the process is aborted.
Cancels the browsing and reading operation of remote variables from the OPC UA server(s) selected in the 'Server' table.
Imports remote variables from a CSV file for one selected OPC UA server. Clicking the button opens the file open dialog for browsing and selecting the CSV file. The progress of the process is displayed in the 'Import Export Log' in the MESSAGES window. An error message is displayed for each erroneous line. Erroneous lines are omitted. The import process is not aborted if the CSV file contains incorrect lines.

The CSV file must have the following format:

namespace;identifier;data type;short name

namespaceMandatory namespace that contains the URI (Uniform Resource Identifier) to which the node is assigned (see also the following section). Must be specified as follows:

nsu=<namespace name>

Example: nsu=http://phoenixcontact.com/OpcUA/PLCnext/GlobalDataSpace/
identifierMandatory type of the identifier of the NodeId in the format <identifier>=<value> (see also the following section).

Examples:
I=1
s=Arp.Plc.Eclr/_Remote_BOOLVar
data typeData type of the remote variable. Optional, if no short name is specified. Mandatory, if a short name is specified. If no data type is specified, the remote variable can be mapped to every local variable.
short nameOptional short name (clear name) of the remote variable. If the short name is specified, the data type is mandatory.

CSV example:

After the variables have been successfully read/imported, they are available for selection in the 'Remote variable identifier' column ('Variable Mappings' table in the 'Client Connections' editor) via the role picker. Only remote variables with a data type matching the data type of the corresponding local variable are offered for selection.

Data exchange between OPC UA client and OPC UA server

The data exchange between OPC UA client and OPC UA server is realized via variables (process data items). By mapping the local variables (variables defined in the PLCnext Engineer project) to the remote server variables, data between client and server can be exchanged (see the section below how to map variables). The OPC UA client either subscribes to the variables of the remote OPC UA server or writes the changed values of the local variables to the remote server variables.

After the OPC UA client has established a connection to the server, it scans the address space of the server to find the variables available from the server. The address space contains information that the server makes visible to the OPC UA clients. In the address space the server variable is represented by a node. Each node is identified by a unique NodeId. The NodeId consists of the following three elements:

Mapping variables in PLCnext Engineer

The mapping of the OPC UA client variables to the OPC UA server variables comprises the following steps:

OPC UA server/client supports UDTs

Arrays, structures, and UDTs with mixed data type elements on the OPC UA server are supported. Only remote variables with matching data types are offered for mapping to local variables. The data types must match down to the elementary level. After the variables have been mapped, the data types are not monitored, i.e., they can possibly be changed (on server side or client side).

The arrays are compared in every dimension and dimension depth. The number of dimensions and their depth must match otherwise the array elements are not read/imported.

Note
Arrays can have an undefined dimension depth (depth of array is unknown). In this case, the comparison results in an inequality and the variables cannot be assigned. You can deactivate the checking of arrays with an unknown depth when browsing the OPC UA server by setting the 'Disable checking of array dimensions of indeterminate size' option in the 'Extras > Options' dialog under the 'OPC UA | OPC UA Client Settings' category to 'Yes' (default setting is 'No').

The elementary data types provided by the OPC UA server are mapped to the IEC variables as follows:

Data type OPC UA serverIEC 61131
Boolean BOOL
SByteSINT
ByteUSINT, BYTE
Int16INT
UInt16UINT, WORD
Int32DINT
UInt32UDINT, DWORD
Int64LINT
UInt64ULINT, LWORD
FloatREAL
DoubleLREAL
StringSTRING, WSTRING
DateTimeLDATE, LDATE_AND_TIME, LTIME_OF_DAY
DurationTIME, LTIME

How to proceed:

  1. In the 'Variable Groups' table in the 'Client Connections' editor, click into an empty cell in the 'Cycle time' column and enter a cycle time value (value must be greater or equal to 1). In the 'Type' cell, select the group type ('Subscribe' or 'Write').

    When you confirm the cycle time value, the new variable group appears under the 'Configuration' category on the left in the editor (see the following example). The group name shows the configured group type and cycle time.

    Example

    To delete a variable group from the 'Variable Groups' table, click in the first table cell and press <Del>.
  2. To do the variable mapping, select the variable group under the 'Configuration' category. The configuration / variable group page with the variable mappings table is shown in the editor area (see the example below).
  3. In the 'Variable Mappings' table, configure the following properties for each variable mapping:

    PropertyDescription
    'Local variable'Local variable to be mapped to the OPC UA server variable.

    Click into an empty cell and select the desired variable from the variables list. The selection list provides all local and global variables, including structures and arrays as well as ports declared in your PLCnext Engineer project. (As long as no 'Remote variable identifier' is entered, the mapping is invalid.)
    'Data type'Read-only data type of the local variable.
    'Server'OPC UA server connection to be used for the data exchange.

    Select a connection from the connections list. The list provides all server connections you have configured in your project (see "Configuring the OPC UA server connections").
    'Remote variable identifier'Type of the identifier of the NodeId (see the description in the "Data exchange between OPC UA client and OPC UA server" section).

    Examples:

    I=10
    g=09087e75-8e5e-499b-954f-f2a9603db28a
    s=Arp.Plc.Eclr/_Remote_BOOLVar
    'Browse path'Read-only information on where the variable is located on the OPC UA server. The information is provided by the server.
    'Remote variable namespace'Namespace to which the node representing the OPC UA server variable belongs.

    Example: http://phoenixcontact.com/OpcUA/PLCnext/GlobalDataSpace/

    Example

Importing/exporting the OPC UA client connections configuration

You can export the configuration of the OPC UA client connections to an *.opcua file with the 'File > Export > Export OPC UA Client Connection(s)' command. The *.opcua file contains all data (connections, variable mappings, etc.) as configured in the 'Client Connections' editor. With the 'File > Import > Import OPC UA Client Connection(s)' command you can import an *.opcua file into the project. An error message is reported for each local variable that is contained in the import file but not declared in the current project.