The common Attributes of OPC UA Address Space Nodes and their mapping from IEC 61131-3 are defined in Table 26.
Table 26 – Common Node Attributes
Attribute |
Use |
DataType |
Description |
NodeId |
Mandatory |
NodeId |
The NodeId is a unique identifier for a Node in an OPC UA Address Space. The identifier is server specific and its format is not defined in this specification. |
NodeClass |
Mandatory |
NodeClass |
The NodeClass is Variable for all Ctrl Variables. |
BrowseName |
Mandatory |
QualifiedName |
The BrowseName is a QualifiedName composed of a name string and a namespace index. It is used to create paths that can be passed to the TranslateBrowsePathsToNodeIds Service to get the NodeId of a Variable Node. This is typically used to get the NodeId of Variable in an Object instance based on the path known from the Object type. The BrowseName is not used to display the name of the Node. The name part is generated from the Ctrl Variable name. The namespace part depends of the scope where the Variable is defined. Chapter 12.5 describes the handling of namespaces. |
DisplayName |
Mandatory |
LocalizedText |
The DisplayName is a LocalizedText used by clients to display the name of a Node. It is composed of a localized text part and a LocaleId identifying the language of the text. The DisplayName is server specific if the server supports localization of Variable names. The DisplayName is composed of the Ctrl Variable name and an empty LocaleId string if the server does not support localization. |
Description |
Optional |
LocalizedText |
The optional Description shall describe the meaning of the Node using a localized text. The Description may correspond to the element Documentation of the element Variable in PLCopen XML. |
WriteMask |
Optional |
UInt32 |
The WriteMask provides the optional information which attributes of the Node can be written by a client. This excludes the Value Attribute where the access is described by the AccessLevel Attribute. The value of this Attribute is server specific. Servers only supporting the use cases Observation and Operation are typically setting this Attribute to 0 or are not providing this optional Attribute. Servers supporting also the use cases Engineering and Service may allow clients to change Node Attributes. |
UserWriteMask |
Optional |
UInt32 |
The user specific settings for the WriteMask. |
The mapping of IEC 61131-3 elementary data types to OPC UA data types is formally defined in Table 27. The OPC UA built in data types are used for the wire representation of the data type. Additional PLCopen specific OPC UA data type definitions are used to provide the special semantic if necessary.
Table 27 – Mapping IEC 61131-3 elementary data types to OPC UA built in data types
No. |
IEC 61131-3 elementary data types (Keyword / Description) |
DataTypeNodeID |
OPC UA built in data types |
PLCopen specific OPC UA simple data type definitions |
Comment |
1 |
BOOL / Boolean |
--- |
Boolean (UA:1) |
- |
A one bit value (true or false). |
2 |
SINT / Short integer |
--- |
SByte (UA:2) |
- |
An 8 bit signed integer value. |
3 |
INT / Integer |
--- |
Int16 (UA:4) |
- |
A 16 bit signed integer value. |
4 |
DINT |
--- |
Int32 (UA:6) |
- |
A 32 bit signed integer value. |
5 |
LINT / Long integer |
--- |
Int64 (UA:8) |
- |
A 64 bit signed integer value. |
6 |
USINT / Unsigned short integer |
--- |
Byte (UA:3) |
- |
An 8 bit unsigned integer value. |
7 |
UINT / Unsinged integer |
--- |
UInt16 (UA:5) |
- |
A 16 bit unsigned integer value. |
8 |
UDINT / Unsigned double integer |
--- |
UInt32 (UA:7) |
- |
A 32 bit unsigned integer value. |
9 |
ULINT / Unsigned long integer |
--- |
UInt64 (UA:9) |
- |
A 64 bit unsigned integer value. |
10 |
REAL / Real numbers |
--- |
Float (UA:10) |
- |
OPC UA definition: An IEEE-754 single precision (32 bit) floating point value. IEC 61131-3 definition: Real (32 bit) with a range of values as defined in IEC 60559 for the basic single width floating-point format. Both standards are identical. |
11 |
LREAL / Long reals |
--- |
Double (UA:11) |
- |
OPC UA definition: An IEEE-754 double precision (64 bit) floating point value. IEC 61131-3 definition: Long real (64 bit) with a range of values as defined in IEC 60559 for the basic double width floating-point format. Both standards are identical. |
12a |
TIME / Duration |
x:3005 |
Int64 (UA:8) |
TIME |
The OPC UA simple data type TIME/Duration is derived from the built-in data type Int64. It describes that the type is used as interval of time in milliseconds. The range of valid values is vendor specific. |
12b |
LTIME / Duration |
x:3006 |
Int64 (UA:8) |
LTIME |
The PLCopen simple data type LTIME is derived from the build in data type Int64. It describes that the type is used as interval of time in nanoseconds. The valid range is LT#-106751d23h47m16s854ms775us808ns to LT#+106751d23h47m16s854ms775us807ns. The representation contains information for days (d), hours (h), minutes (m), seconds (s) milliseconds (ms), microseconds (us) and nanoseconds (ns). |
13a |
DATE / Date (only) |
x:3007 |
DateTime (UA:13) |
DATE |
The PLC open specific OPC UA simple data type DATE is derived from the built-in data type DateTime. It describes that the type is used as a date only. |
13b |
LDATE / Long date (only) |
X:3014 |
Int64 (UA:8) |
LDATE |
The PLCopen specific OPC UA simple data type LDATE is derived from the built-in data type Int64. It describes that the type is used as date only. The interval is nanoseconds since 1970-01-01. |
14a |
TOD Time of day (only) |
x:3008 |
UInt32 (UA:7) |
TOD |
TOD (TIME_OF_DAY) stores number of milliseconds since the beginning of the day: TOD#00:00:00.000 to TOD#23:59:59.999. |
14b |
LTOD (Time of day) |
x:3009 |
Int64 (UA:8) |
LTOD |
LTOD (LTIME_OF_DAY) stores the number of nanoseconds since the beginning of the day: LTOD#00:00:00.000000000 to LTOD#23:59:59.999999999. |
15a |
DT Date and time of day |
x:3010 |
DateTime (UA:13) |
DT |
The range and resolution of this type is vendor specific. |
15b |
LDT Date and time of day |
x:3015 |
Int64 (UA:8) |
LDT |
The PLCopen specific OPC UA Simple datatype LDT is derived from the build in data type Int64. It describes the number of nanoseconds elapsed since 1970-01-01-00:00:00 |
16a |
STRINGvariable-length single-byte character string |
x:3013 |
String (UA:12) |
STRING |
The PLC open specific OPC UA simple data type STRING is derived from the built-in data type String. It describes that the type is used as a variable-length single-byte character string. |
16b |
WSTRINGvariable-length double-byte character string |
--- |
String (UA:12) |
- |
OPC UA definition: A sequence of UTF8 characters. IEC 61131-3 definition: Variable-length double-byte character string |
17a |
CHARsingle-byte character |
x:3011 |
Byte (UA:3) |
CHAR |
The PLC open specific OPC UA simple data type CHAR is derived from the built-in data type Byte. It describes that the type is used as single-byte character |
17b |
WCHARdouble-byte character |
x:3012 |
UInt16 |
WCHAR |
The PLC open specific OPC UA simple data type WCHAR is derived from the built-in data type UInt16. It describes that the type is used as double-byte character. |
18 |
BYTEBit string of length 8 |
x:3001 |
Byte |
BYTE |
The PLC open specific OPC UA simple data type BYTE is derived from the built-in data type Byte. It describes that the type is used as bit string of length 8. |
19 |
WORDBit string of length 16 |
x:3002 |
UInt16 |
WORD |
The PLC open specific OPC UA simple data type WORD is derived from the built-in data type UInt16. It describes that the type is used as bit string of length 16 |
20 |
DWORDBit string of length 32 |
x:3003
|
UInt32 |
DWORD |
The PLC open specific OPC UA simple data type DWORD is derived from the built-in data type UInt32. It describes that the type is used as bit string of length 32 |
21 |
LWORDBit string of length 64 |
x:3004 |
UInt64 |
LWORD |
The PLC open specific OPC UA simple data type LWORD is derived from the built-in data type UInt64. It describes that the type is used as bit string of length 64 |
The mapping of IEC 61131-3 generic data types to OPC UA data types is formally defined in Table 28. Since the generic data type should not be used in user-declared Ctrl Program Organization Units, this mapping definition is defined for completeness but is normally not used in an OPC UA AddressSpace.
Table 28 – Mapping IEC 61131-3 generic data types to OPC UA data types
IEC 61131-3 generic data types |
OPC UA data types |
Description |
ANY |
BaseDataType |
This abstract OPC UA DataType defines a value that can have any valid OPC UA DataType. |
ANY_DERIVED |
BaseDataType |
|
ANY_ELEMENTARY |
BaseDataType |
|
ANY_MAGNITUDE |
BaseDataType |
|
ANY_NUM |
Number |
This abstract OPC UA DataType defines a number value that can have any of the OPC UA Number subtypes. |
ANY_REAL |
Number |
|
ANY_INT |
Number |
|
ANY_BIT |
Number |
|
ANY_STRING |
String |
This OPC UA Built-in DataType defines a Unicode character string that should exclude control characters that are not whitespaces (0x00 - 0x08, 0x0E-0x1F or 0x7F). |
ANY_DATE |
DateTime |
This OPC UA Built-in DataType defines a Gregorian calendar date. It is a 64-bit signed integer which represents the number of 100 nanosecond intervals since January 1, 1601. |
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.
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).
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).
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.
The Variable specific Attributes of OPC UA Address Space Nodes and their mapping from IEC 61131-3 are defined in Table 33.
Table 33 – Variable Node Attributes
Attribute |
Use |
DataType |
Description |
Value |
Mandatory |
Defined by DataType |
The most recent value of the Variable that the server has. Its data type is defined by the DataType, ValueRank and ArrayDimension Attribute. |
DataType |
Mandatory |
NodeId |
The DataType of the Variable Value. It defines the type specific content of the Value together with the ValueRank and the ArrayDimension Attributes, The mapping is defined in 9.2. |
ValueRank |
Mandatory |
Int32 |
This Attribute indicates whether the Value of the Variable is an array and how many dimensions the array has. Ctrl Variables declared as scalar type have the ValueRank -1. Ctrl Variables declared with the key word ARRAY…OF have a ValueRank that indicates the number of dimension of the array declared for the Ctrl Variable. |
ArrayDimensions |
Optional |
UInt32[] |
This Attribute specifies the length of each dimension for an array value. The Attribute is intended to describe the capability of the Variable, not the current size. The dimension entries have the length defined with the key word ARRAY…OF. |
AccessLevel |
Mandatory |
Byte |
The AccessLevel Attribute is used to indicate how the Value of a Variable can be accessed (read/write) and if it contains current and/or historic data. The handling of access to historic data is server specific and is not part of this specification. The mapping of the read and write access part of the AccessLevel is defined in 9.3.2 |
UserAccessLevel |
Mandatory |
Byte |
The user specific settings for the AccessLevel. |
MinimumSamplingInterval |
Optional |
Duration |
The MinimumSamplingInterval Attribute indicates how “current” the Value of the Variable will be kept. It specifies (in milliseconds) how fast the server can reasonably sample the value for changes. A MinimumSamplingInterval of 0 indicates that the server is to monitor the item continuously. A MinimumSamplingInterval of -1 means indeterminate. The value of this Attribute is server specific. |
Historizing |
Mandatory |
Boolean |
Indicates if the server is currently collecting history for the Variable Value. The support of value history is server specific. |
If the IEC attribute CONSTANT is set, the Access Level shall be read only.
The IEC standard does not define a key word to set the Access Level for a Ctrl Variable. The configuration in a programming system is vendor specific but it is recommended to provide a configuration option for the OPC UA Access Level.
When using the PLCopen XML format the AccessLevel shall be provided in PLCopen XML Additional Data in the XML element addData using the XML element UaAccessLevel as part of the XML element representing the variable. The value is a bit mask where the first bit indicates the read access and the second bit indicates the write access.
The IEC 61131-3 key word mapping to OPC UA Properties is formally defined in Table 34.
Table 34 – IEC 61131-3 Variable Key Word Property Definition
References |
NodeClass |
BrowseName |
DataType |
TypeDefinition |
ModellingRule |
Instance of any Variable Type. |
|||||
HasProperty |
Variable |
RETAIN |
Boolean |
PropertyType |
Optional |
HasProperty |
Variable |
NON_RETAIN |
Boolean |
PropertyType |
Optional |
HasProperty |
Variable |
CONSTANT |
Boolean |
PropertyType |
Optional |
HasProperty |
Variable |
AT |
String |
PropertyType |
Optional |
The Property RETAIN indicates if the RETAIN key word is set for the Ctrl Variable. It provides an explicit declaration of “warm start” behaviour of the Ctrl Variable (and Ctrl Function Blocks and Ctrl Programs).
The Property NON_RETAIN indicates if the NON_RETAIN key word is set for the Ctrl Variable. It provides an explicit declaration of “warm start” behaviour of the Ctrl Variable (and Ctrl Function Blocks and Ctrl Programs).
The Property CONSTANT indicates if the CONSTANT key word is set for the Ctrl Variable. It provides a declaration of a fixed value for the Ctrl Variable. The Ctrl Variable cannot be modified.
The Property AT contains the location assignment to the Ctrl Variable as string if the AT key word is set for the Ctrl Variable.
The IEC standard does not define key words to configure information like the value range or the engineering unit for a Ctrl Variable. The configuration in a programming system is vendor specific but this specification defines the export format in the PLCopen XML Additional Data in the XML element addData.
The InstrumentRange Property defined in OPC 10000-8 shall be provided in the XML element UaInstrumentRange as part of the XML element representing the Ctrl Variable. The attributes of the XML element are formally defined in Table 35.
Table 35 – Range XML attributes
Name |
Type |
Use |
Default |
|
Low |
double |
required |
|
|
High |
double |
required |
|
The EURange Property defined in OPC 10000-8 shall be provided in the XML element UaEURange as part of the XML element representing the Ctrl Variable. The attributes of the XML element are formally defined in Table 35.
The EngineeringUnits Property defined in OPC 10000-8 shall be provided in the XML element UaEngineeringUnits as part of the XML element representing the Ctrl Variable.