Definition: Unit conversion

Unit conversions at »EASY UI Designer« are based on conversions of process variable values using linear equations. A typical example of this is the physical variable "temperature", which is specified country-specifically in Europe using the unit Celsius, but is represented in the US using Fahrenheit.

Conversion of physical quantities

The following formulae are used to convert "temperature" from Celsius to Fahrenheit and vice versa:

°C = (°F - 32)/1.8

°F = °C × 1.8 + 32

In »EASY UI Designer«, this linear equation is specified via two points of a linear curve. For this purpose, the values of two calculated points are specified in a unit definition. Based on the value °C, the calculation looks as follows as an example:

For 0 °C this results in: 0 × 1.8 + 32 = 32 (°F)

For 100 °C this results in: 100 × 1.8 + 32 = 212 (°F)

The values of the calculation output variable (°C) are then to be entered as X coordinates, here as 0 and 100. The respective calculated values are entered as Y coordinates (i.e. 32 and 212).

Two unit conversions are defined in the image above. For "German", the value is virtually unaffected as the X/Y value pairs are identical.

The progression of the linear equation over the two coordinates (0:0) and (1:1) results in a straight line that passes through the zero point with a gradient of 1, i.e. X and Y are identical for all points on the line.

In the conversion for "English", the values calculated above have been entered in the corresponding parameter fields.

However, this example only works if the process variables to be converted directly return the temperature value as °C. If this is not the case, the specific sensor resolution must be included in the calculation via a sensor adjustment.

Example: Sensor customisation

A distance of 0 ... 1000 mm recorded by the PLC is to be displayed in the application. Two different sensor types with the following output ranges are available:

Type

Measuring range

Output value range

A

0..2000 mm

0..32000

B

0..100 inch

0..32000

The conversion for [mm] in [inch] is:

1 in. = 25.4 mm

The expected value ranges for the distance 0..1000 mm are therefore for:

The two sensors have different value ranges. An adjustment in the visualisation can be implemented via a variable-dependent unit class. The conversion should take place between the communication component and the variable server so that a sensor-independent measured value is made available in the variable server.

The corresponding unit description looks like this in the development environment:

Again, virtually no conversion is specified for a state because the X and Y value pairs are the same. The second changeover contains the values calculated above.

In this way, sensor-specific value adjustments can be realised.

For the time being, it is only a matter of synchronising the PLC values for the different sensors in the variable server so that it does not matter which sensor is connected for further processing. A language-switched conversion has not yet been realised here. The country-specific switchover between mm and inch for the application can then be carried out via an additional conversion.

If you do not perform this separation, you cannot, for example, use the value independently of the sensor in systems that are connected directly to the variable server (e.g. recording as a trend).

Conversion of units

In »EASY UI Designer«, the configured unit conversions are summarised into so-called unit classes. A unit class contains several conversions and a switch that activates one of the contained conversions.

Functional linking

In »EASY UI Designer«, the process variable definitions are linked directly to unit classes. It is implicitly assumed here that the definition of a process variable already includes the characteristic of a physical unit. For example, if the process variable represents a temperature value, the physical quantity with unit text and country-specific conversion formula can be specified directly when defining the variable.

This has the advantage that the unit information is always included as part of the variable when displaying the process variables, whether as a value output, as a trend recording or as part of a report, without any further configuration effort.

The unit classes to be used are specified in the variable definition in the parameters Unit class (process) and Unit class (display).

Decimal point shift/decimal places

The following applies to integer variable types (VT_I2, VT_I4 etc.): The decimal point shift is a good solution to avoid rounding errors. Internally, the system treats an integer process variable value that is linked to a unit changeover as a floating point value. When the value is read, the value from the PLC is converted to a floating point variable in the variable server using linear conversion. When entering the value, this conversion must be performed in reverse. If the linear equation is used here, the value may have to be rounded. In the application, the user may then write a value to a control element and after sending the value in the control element jumps to the next higher/lower value. This phenomenon does not occur when using the decimal point shift alone.

The function of the comma shift parameter specified in the unit definition depends on the data type of the process variable used by the unit class:

Representation

All controls with a process variable connection contain the "RawValue" property in addition to the "Value" property.

Some control elements contain the "UseRawValue" property. If this property is set to "true", no conversion is performed in "Value". The values of "RawValue" and "Value" are then identical.

Further features of the unit conversion