Document toolboxDocument toolbox

2021.1.1560.3 OPC UA



Overview

This feature is used to make an OPCUA connection between Prespective(acts as a client) and an external OPC server to transport messages.

Figure 1: Architecture of the industrial system for the auto-configuration of OPC UA [1].

Ref: [1] Gutiérrez Guerrero, José Miguel & Holgado-Terriza, Juan. (2019). Automatic Configuration of OPC UA for Industrial Internet of Things Environments. Electronics. 8. 600. 10.3390/electronics8060600.


Where to find

The feature can be found under Prespective Menu > Logic > Add Logic Simulator > Adapter Settings > Adapter Target > OPC_UA

 


Feature Layout

The image below shows the complete feature layout of the OPCUA Adapter.

Gateway settings

 

Gateway settings

 

Adapter Target

Select a different adapter, please see respective documentation for more information

Adapter Setting (OPCUAServerSettings)

 

End Point URL

The endpoint of the OPCUA server.

Configuration File Path

The path to the configuration file that contains the the configuration XML (default is sample case, please use your own)

Namespace Index

The index in a namespace table that is managed by the OPC UA server. These are used by OPCUA to create unique identifiers that can help distinguish between different namespaces.

Identifier Type OPC

An identifier type is the type of the node ID that are used for the representation of a node in an OPC server.

Identifier types can either be numeric (a 32-bit integer), string, a GUID-globally unique identifier(128 bits), or opaque (a binary data blob).

Username

Is passed to the server for authentication if the field is not empty (not used by default)

Password

Is passed to the server for authentication when the UserName field is not empty (not used by default)

Content Life Cycle Settings

Not implemented for OPCUA

 


Fidelity

In order to get OPC variables in real-time the fidelity of the signal definition has to be set to 0.

To use a subscription set the fidelity to the number of seconds for the interval.

Default fidelity is -1 this is counted as 1.


How to use

Step 1

Add the Prelogic Simulator to your Unity scene and set the Adapter Target to OPC_UA

Step 2

Set up the MQTT adapter settings and the naming convention given in the snippets below according to the user’s choice respectively.

 

Step 3

Create a OPCTestComponent.cs script that derives from the Prelogic Component and contains all the input and output signal definitions. An example script is given in the subsequent section.

a) Create an empty game object and add to it the created MQTT signal definition script.

b) Make the game object a child to the PreLogic Simulator and after making sure all the settings are correct export the policy.

The PreLogic MQTT client can now subscribe and publish values to signals defined in the MQTT Signal Definition Script.


OPC UA variable naming

For the naming of OPCUA variables we have to create the NodeId.

https://documentation.unified-automation.com/

a) Example Node Id:

ns=4; i=1241

For this example, you have to configure your PreLogic Simulator as follows:

And your PrelogicComponent:

(Example Script)

public class OPCTestComponent : PreLogicComponent { public override List<SignalDefinition> SignalDefinitions => new List<SignalDefinition> { new SignalDefinition("1241", PLCSignalDirection.INPUT, SupportedSignalType.BOOL), }; }

b) Example Node Id (Tia Portal):

ns=3; s="OPC_UA_DB"."TestBOOLINPUT0"

For this example, you have to configure your PreLogic Simulator as follows:

And your Prelogic component:

(Example Script)

public class OPCTestComponent : PreLogicComponent { public override List<SignalDefinition> SignalDefinitions => new List<SignalDefinition> { new SignalDefinition("TestBOOLINPUT0", PLCSignalDirection.INPUT, SupportedSignalType.BOOL), }; }

Used Protocol

To communicate with the OPCUA adapter in Prespective you need to apply the following protocol:

  • The structure for the message is:

<PLCADDRESS/<VALUE>

  • Topic to write is the address defined by the PLC address in the signal naming

  • Value is the value that is within the range of the specified type


Supported Types

  • BOOL

  • BYTE

  • BYTEARRAY

  • SBYTE

  • WORD

  • DWORD

  • SHORT

  • USHORT

  • INT16

  • UINT16

  • INT32

  • UINT32

  • INT64

  • UINT64

  • REAL32

  • REAL64

  • STRING

  • STRUCT


Naming Rules

Setting up the component works as like any other prelogic component. The thing you have to take into account is how the PLC Address Path Format (or implicit naming rule) is configured. The output of this Address is the topic to which the component is reading and/or writing.

WARNING : < Make sure both paths are unique >

Each defined input writes the value to the PLC address path topic.

Each defined output reads the value from the PLC address path topic.

The PLC path separator has to be '/'

< Spaces are allowed but not recommended >

For an overview of all variables for signal naming, please go to the PreLogic component page.

Prespective Documentation