Overview and mapping of OPC UA and CODESYS data types
In order to map exported IEC variables from CODESYS in the OPC UA Server, the compatibility of the different, available data types must be ensured. The following two tables list standard OPC UA data types and standard CODESYS data types. A third table shows the mapping between OPC UA and CODESYS data types.
Standard OPC UA data types
Data type | Description | Comment |
---|---|---|
Logic types | ||
Boolean | Truth value | TRUE, FALSE |
Integral types | ||
SByte | Signed 8 bit integer | [ -128, 127 ] |
Byte | Unsigned 8 bit integer | [ 0, 255 ] |
Int16 | Signed 16 bit integer | [ -2^15, 2^15 - 1 ] |
UInt16 | Unsigned 16 bit integer | [ 0, 2^16 - 1 ] |
Int32 | Signed 32 bit integer | [ -2^31, 2^31 - 1 ] |
UInt32 | Unsigned 32 bit integer | [ 0, 2^32 - 1 ] |
Int64 | Signed 64 bit integer | [ -2^63, 2^63 - 1 ] |
UInt64 | Unsigned 64 bit integer | [ 0, 2^64 - 1 ] |
Floating point types | ||
Float | IEEE 754-1985 single precision floating point value | |
Double | IEEE 754-1985 double precision data type | |
String data types | ||
String | Unicode string | |
ByteString | A sequence of byte values | |
Time and date types | ||
DateTime | A date in the Gregorian calendar with time | |
UtcTime | Time indication in coordinated universal time (UTC) | All time information between OPC UA servers and clients is in UTC. Clients should offer conversion to local time. |
Duration | Specification of a time duration as a floating point value | Double value, that specifies a time interval in milliseconds. Sub-millisecond values can be represented by fractions. |
TimeString | Represents a point in time as a string conforming to ISO 8601-2000 | Uses 24 hour clock Simple format: [hh][mm][ss] |
DurationString | Represents a time duration as a string conforming to ISO 8601-2000 | Format: P[n]Y[n]M[n]DT[n]H[n]M[n]S Example: |
User defined types | ||
Enumeration | Enumeration list | |
Structure | Structure, composition of fields |
Standard CODESYS data types
Data type | Description | Comment |
---|---|---|
Logic types | ||
BOOL | Truth value | TRUE, FALSE |
BIT | 1 bit logic value | 1, 0 |
BYTE | 8 bit logic value | [ 16#00, 16#FF ] |
WORD | 16 bit logic value | [ 16#0000, 16#FFFF ] |
DWORD | 32 bit logic value | [ 16#00000000, 16#FFFFFFFF ] |
LWORD | 64 bit logic value | [ 16#0000000000000000, 16#FFFFFFFFFFFFFFFF ] |
Integral types | ||
SINT | Signed 8 bit integer | [ -128, 127 ] |
USINT | Unsigned 8 bit integer | [ 0, 255 ] |
INT | Signed 16 bit integer | [ -2^15, 2^15 - 1 ] |
UINT | Unsigned 16 bit integer | [ 0, 2^16 - 1 ] |
DINT | Signed 32 bit integer | [ -2^31, 2^31 - 1 ] |
UDINT | Unsigned 32 bit integer | [ 0, 2^32 - 1 ] |
LINT | Signed 64 bit integer | [ -2^63, 2^63 - 1 ] |
ULINT | Unsigned 64 bit integer | [ 0, 2^64 - 1 ] |
Floating point data types | ||
REAL | floating point value, 32 bit | IEC 60559 resp. IEEE 754-2008 |
LREAL | floating point value, 64 bit | IEC 60559 resp. IEEE 754-2008 |
String types | ||
STRING | Single byte character string | |
WSTRING | Double byte character string | |
Zeit- und Datumstypen | ||
DATE | Date | Prefix: DATE# or D# Example: DATE#1984-06-25 oder D#1984-06-25 |
TIME | Duration | Prefix: TIME# or T# Example: TIME#14ms T#14.7m T#5d_14h_12m_18s_3.5ms |
LTIME | Long duration | |
TIME_OF_DAY / TOD | Time of day | Prefix: TIME_OF_DAY# or TOD# Example: TIME_OF_DAY#15:36:30.123 oder TOD#15:36:30.123 |
DATE_AND_TIME / DT | Date and time | Prefix: DATE_AND_TIME# or DT# Example: DATE_AND_TIME#1996-05-06-15:36:30 or DT#1996-05-06-15: 36:30 |
Features
- A direct derivation of elementary types can be made..
- Example:
TYPE RU_REAL : REAL ; END_TYPE
- Subsets of types (Subranges) can be used.
- Example:
TYPE ANALOG_DATA : INT (-4095..4095) ; END_TYPE
Program Organization Units conforming to IEC 61131-3
- Functions
- Function blocks
- Programs
Mapping between OPC UA and CODESYS Data types
The following table shows the mapping between the data types used for CODESYS and OPC UA.
CODESYS data type | OPC UA data type |
---|---|
BOOL | Boolean |
BIT | Boolean |
BYTE | Byte |
WORD | UInt16 |
DWORD | UInt32 |
LWORD | UInt64 |
SINT | SByte |
USINT | Byte |
INT | Int16 |
UINT | UInt16 |
DINT | Int32 |
UDINT | UInt32 |
LINT | Int64 |
ULINT | UInt64 |
REAL | Float |
LREAL | Double |
STRING | String |
WSTRING | String |
DATE | DateTime |
TIME | Int64 |
LTIME | Int64 |
TIME_OF_DAY / TOD | DateTime |
DATE_AND_TIME / DT | DateTime |
ENUM | Enumeration |
STRUCT | Structure |