Both OPC UA and IEC 61131-3 allow the definition of enumerations on a data type or on a variable instance.

In OPC UA the enumerated data types are defined as subtypes of Enumeration. The data has an EnumStrings Property that contains the possible string values. The value is transferred as integer on the wire where the integer defines the index into the EnumStrings array. The index is zero based and has no gaps. Another option is to provide the possible string values in the Property EnumValues. This option is used if individual integer values are assigned to the string. The used option depends on the way the string enumeration is defined in the Controller program. If integer values are assigned to the string values the Property EnumValues is used to represent the enumeration values. If the integer value is zero based and has no gaps the EnumStrings Property should be used since the processing on the client side is more efficient.

The definition on a variable instance is using the MultiStateDiscreteType Variable Type which defines also the EnumStrings or the EnumValues Property containing the enumeration values as string array.

Example for an enumerated data type declaration in IEC 61131-3:

TYPE

ANALOG_SIGNAL_TYPE : (SINGLE_ENDED, DIFFERENTIAL) ;

END_TYPE

Example for use of an enumeration in a Ctrl Variable instantiation in IEC 61131-3:

VAR

Y : (Red, Yellow, Green) ;

END_VAR

The IEC 61131-3 enumeration data type declaration is mapped to an OPC UA Enumeration data type. The representation in the address space is formally defined in Table 29.

Table 29 – Enumeration Data Type Definition

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

Subtype of the Enumeration defined in OPC 10000-5 i.e. inheriting the InstanceDeclarations of that Node.

HasProperty

Variable

EnumString

String [ ]

PropertyType

Optional

HasProperty

Variable

EnumValues

EnumValueDataType [ ]

PropertyType

Optional

The Property EnumString is defined in OPC 10000-5

The Property EnumValues is defined in OPC 10000-5.

The IEC 61131-3 enumeration in a Ctrl Variable declaration is mapped to a MultiStateDiscreteType Variable Type defined in OPC 10000-8.

IEC 61131-3 defines the subrange for all integer data types (ANY_INT) which excludes real values.

OPC UA has no standard concept to limit the range on the data type.

Example for a subrange data type declaration in IEC 61131-3:

TYPE

ANALOG_DATA : INT (-4095..4095) ;

END_TYPE

Example for use of a subrange in a Ctrl Variable instantiation in IEC 61131-3:

VAR

Z : SINT (5..95) ;

END_VAR

The IEC 61131-3 subrange is mapped to two OPC UA properties defined in Table 30.

Table 30 – Subrange Property Definition

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

Instance of any Variable Type or a Data Type Node.

HasProperty

Variable

SubrangeMin

Number

PropertyType

Mandatory

HasProperty

Variable

SubrangeMax

Number

PropertyType

Mandatory

The Property SubrangeMin contains the lower bound of the subrange. The data type depends on the elementary data type used for the subrange.

The Property SubrangeMax contains the upper bound of the subrange. The data type depends on the elementary data type used for the subrange.

The IEC 61131-3 subrange data type is mapped to an OPC UA number data type derived from the corresponding elementary data types defined in Table 27. The data type has the two Properties defined in Table 30. The IEC example in this chapter is mapped to an OPC UA data type with the name ANALOG_DATA which is a subtype of Int16.

The IEC 61131-3 subrange in a Ctrl Variable declaration is mapped to the two Properties defined in Table 30. The Properties are children of the OPC UA Variable representing the Ctrl Variable.

OPC UA provides the information if a value is an array in the Variable Attributes ValueRank and ArrayDimensions. Every data type can be exposed as array. Arrays can have multiple dimensions. The dimension is defined through the Attribute ValueRank. Arrays can have variable or fixed lengths. The length of each dimension is defined by the Attribute ArrayDimensions. The array index starts with zero.

IEC 61131-3 allows the declaration of array data types with one or multiple dimensions and an index range instead of a length.

OPC UA has no standard concept for defining special array data types or exposing index ranges.

Example for an array data type declaration in IEC 61131-3:

TYPE

ANALOG_16_INPUT_DATA : ARRAY [1..16] OF INT ;

END_TYPE

Example for use of an array in a Ctrl Variable instantiation in IEC 61131-3:

VAR

MyArray : ARRAY [1..16] OF INT;

END_VAR

The IEC 61131-3 array data type is mapped to three OPC UA properties defined in Table 31.

Table 31 – Array Data Type Property Definition

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

Instance of any VariableType or a DataType Node.

HasProperty

Variable

Dimensions

UInt32

PropertyType

Mandatory

HasProperty

Variable

IndexMin

Int32 [ ]

PropertyType

Mandatory

HasProperty

Variable

IndexMax

Int32 [ ]

PropertyType

Mandatory

The Property Dimensions contains the number of dimensions of the array.

The Property IndexMin contains an array of lower bounds, one for each array dimension.

The Property IndexMax contains an array of upper bounds, one for each array dimension.

The IEC 61131-3 array data type is mapped to an OPC UA data type derived from the corresponding elementary data types defined in Table 27. The data type has the two Properties defined in Table 31. The IEC example in this chapter is mapped to an OPC UA data type with the name ANALOG_16_INPUT_DATA which is a subtype of Int16.

The IEC 61131-3 array in a Ctrl Variable declaration is mapped to the two Properties defined in Table 31. The Properties are children of the OPC UA Variable representing the Ctrl Variable.

IEC 61131-3 structure data types are mapped as subtypes of the OPC UA DataType Structure. OPC UA servers must explicitly describe how structured DataTypes are encoded / decoded and provide this information to the client which is using it while reading / writing structure data.

The following example of an IEC 61131-3 structure data type declaration (using Structured Text) will be used for further illustrations. This structure data type comprises three structure elements of different elementary data types.

TYPE ExampleIEC611313Structure:

STRUCT

IntStructureElement: INT;

RealStructureElement: REAL;

BoolStructureElement: BOOL;

END_STRUCT;

END_TYPE

The following Figure 22 shows the deprecated mapping of the above example. This mapping is deprecated since it is deprecated in OPC UA V1.04.

image026.png

Figure 22 – Deprecated Mapping of structure data types

Ctrl servers must support the binary encoding (“Default Binary”). Additionally, other encodings may be provided (not shown in above figure). A Server may provide, for backward compatibility, the deprecated DataTypeDictionary Variable describing all necessary DataTypes. Each DataType is represented by a DataTypeDescription Variable. Optionally, a Property DictionaryFragment may be available, allowing clients not to read the complete DataTypeDictionary in order to get the information about only a single DataType (not shown in above figure).

image027.png

Figure 23 – Mapping of structure data types

Ctrl servers shall support the binary encoding (“Default Binary”). Additionally, other encodings may be provided (not shown in above figure). Since OPC UA V1.04 a structured DataType provides the new attribute DataTypeDefinition. This attribute is defined in OPC 10000-6 – F.12. Implementations shall use this new attribute instead of the deprecated DataTypeDictionary.

A Server provides on a structured DataType Node the DataTypeDefinition attribute describing all elements and their order in this structure.

The Value of the DataTypeDefinition Attribute for a DataType Node describing ExampleIEC611313Structure is shown in Table 32.

Table 32 – Value of the DataTypeDefinition

Name

Type

Description

defaultEncodingId

NodeId

NodeId of the “ExampleIEC611313Structure_Encoding_DefaultBinary” Node.

baseDataType

NodeId

“i=22” [Structure]

structureType

StructureType

Structure_0 [Structure without optional fields]

fields [0]

StructureField

name

String

“IntStructureElement”

description

LocalizedText

Description of IntStructureElement

dataType

NodeId

“i=4” [Int16]

valueRank

Int32

-1 (Scalar)

isOptional

Boolean

False

fields [1]

StructureField

Name

String

“RealStructureElement“

Description

LocalizedText

Description of RealStructureElement

dataType

NodeId

“i=10” [Float]

valueRank

Int32

-1 (Scalar)

isOptional

Boolean

false

fields [2]

StructureField

name

String

“BoolStructureElement“

description

LocalizedText

Description of BoolStructureElement

dataType

NodeId

“i=1” [Boolean]

valueRank

Int32

-1 (Scalar)

isOptional

Boolean

false

It is strongly recommended for Ctrl servers to provide additionally the structured data as a set of sub variables (components of the variable) providing the structure as several separated values. This allows clients that do not support complex data to access the scalar values. The following Figure 24 shows an example (instances based on the above type descriptions).

image028.png

Figure 24 – Mapping of structure data types to Variable components

If a structure element is not an elementary data type, it has to be divided again into sub variables.

It is recommended that Ctrl servers do support complex data. If a server does not support complex data it provides only sub variables for structure variables. The structured variable would be a Folder object in this case.