OpcUa - Conversion of CommonCode and UnitId

An OpcUa unit is defined by various properties.
For example by

  • The CommonCode
  • The UnitID
  • The symbol
  • The description

When using the unit in the B&R system, the unit is identified either by means of the unique CommonCode or the unique UnitID.

These two properties are directly dependent on each other, so that it is possible to generate the UnitID from the CommonCode and vice versa.

The conversion works in such a way that the individual characters of the CommonCodes, as ASCII-Code characters in a row result in the CommonCode.

CommonCode -> [HEX]Ascii-Letters -> [HEX]UnitID

Here is an example:

The unit “Degree Celisius” has the common code “CEL”.

image
Siehe auch available units in der AS-Hilfe.

These 3 letters must now be converted into ASCII-Codes.

C -> [HEX]43
E -> [HEX]45
L -> [HEX]4C

This results in a unitID [Hex]43454C or [Dec]4408652

1 Like

Thanks for sharing @FIH-RSB

Hello,

nice information, but there are also libraries in place which can also do this and even more.
ArUnitConv

ArUnitText

BR
Fabian

1 Like