Configuration of units with the aid of PLC attributes

In addition to the input option via the Unit Wizard, units can also be configured with the aid of the attributes of a symbol or a data type in the PLC code. This is useful, for example, if a certain variable is recorded more frequently using the TC3 Scope. The unit then only needs to be provided once as an attribute and not reconfigured every time.

PLC attributes are specified directly via the declaration of a variable or the data type in curly brackets, as can be seen in the illustration below.

Configuration of units with the aid of PLC attributes 1:

Three different unit elements can be specified with the aid of the PLC attributes: Base units (BaseUnit), transformations (UnitTransformation) and user units (UserUnit).

The syntax for their input is as follows:

Base units

{attribute 'BaseUnit' := '< BaseUnit, ScaleFactor, Offset, Prefix >'}

e.g.: {attribute 'BaseUnit' := '< AngularVelocity, 0.5, 0, kilo>'}

→ The unit is then krad/s (AngularVelocity) with a ScaleFactor of 0.5.

Transformations

{attribute 'UnitTransformation' := '<SourceUnit, TargetUnit, ScaleFactor, Name>'}

e.g.: {attribute 'UnitTransformation' := '<Current, Temperature, 10, Current-Temperature Converter>'}

→ The resulting unit is the temperature in °C.

User units

{attribute 'UserUnit' := '<BaseUnit, UserUnit, Symbol, ScaleFactor, Offset, Prefix >'}

e.g.: {attribute 'UserUnit' := '<Temperature, Fahrenheit, °F, 1.8, 32, 0>'}

→ The resulting unit is the temperature in °F.

For the base units and prefixes the Enum values can be entered as numbers in addition to the names. This enables any base units and prefixes to be selected even if they are not predefined.

The three different elements can be specified individually or in combination. Note, however, that not all combinations make sense. A transformation and a user unit, for example, should be specified with an appropriate base unit. If no appropriate base unit is specified it will automatically be set to the base unit of the transformation or user unit.

In the case of input errors in the attribute syntax, the default value, i.e. a "Unit of One" is set automatically with a scale factor of "1", an offset of "0" and the prefix "none".