AnalogItemType
Requirements This functionality is only available for Data Access devices based on TwinCAT 3 and the import of TMC symbol files. |
AnalogItemTypes are part of the OPC UA specification and allow meta information such as units to be attached to a variable. You can define these items of meta information in the form of PLC attributes in the TwinCAT 3 PLC.
The following parameters can be set:
- EngineeringUnits: Units defined by the OPC UA specification
- EURange: Maximum value range of the variables
- InstrumentRange: Maximum value range of the variables
- WriteBehavior: Behavior if the value range is exceeded during a write operation.
The following sample shows how the fillLevel variable is configured as an AnalogItemType. The following parameters are set:
- Unit: 20529 ("Percent", defined in the OPC UA specification)
- Max. value range: 0 to 100
- Normal value range: 10 to 90
- Write behavior: 1 (Clamping)
{attribute 'OPC.UA.DA' := '1'}
{attribute 'OPC.UA.DA.AnalogItemType' := '1'}
{attribute 'OPC.UA.DA.AnalogItemType.EngineeringUnits' := '20529'}
{attribute 'OPC.UA.DA.AnalogItemType.EURange' := '0:100'}
{attribute 'OPC.UA.DA.AnalogItemType.InstrumentRange' := '10:90'}
{attribute 'OPC.UA.DA.AnalogItemType.WriteBehavior' := '1'}
fillLevel : UINT;
EngineeringUnits can be configured using the IDs specified in OPC UA (Part 8 of the OPC UA specification). The IDs are based on the widely used and accepted "Codes for Units of Measurement (Recommendation N.20)" published by the "United Nations Center for Trade Facilitation and Electronic Business". CommonCode, which specifies the three-digit alphanumeric ID, is converted by OPC UA according to specification into an Int32 value and referenced (extract from OPC UA specification v1.02, pseudo-code):
Int32 unitId = 0;
Int32 c;
for (i=0; i<=3;i++)
{
c = CommonCode[i];
if (c == 0)
break; // end of Common Code
unitId = unitId << 8; // shift left
unitId = unitId | c; // OR operation
}
Write behavior
When writing an AnalogItemType variable, you can define how the OPC UA Server should handle the new value in relation to the value range. The following options are available:
- 0: All values are allowed and are accepted during a write operation.
- 1: The value to be written is truncated according to the value range.
- 2: The value to be written is rejected if it exceeds the value range.