de:s7:scl_reference_conversions

Simatic S7 SCL reference: Conversion operations

Back to reference overview: Simatic S7 SCL reference with examples

Round numerical value.

See: conversions

_FC_ Result := ROUND (Value);

Value: function input (floating-point numbers)
Result: the return value of the function (integers, floating-point numbers)

ROUND

A yellow underline in the code indicates that the result of the function is not completely accurate for INT types. For REAL, LREAL type, precision is complete.

On the TIA portal, you can specify the type of variable used for the function by entering ROUND_:INT, DINT, SINT, LINT, REAL, LREAL.

Generate next higher integer from floating-point number.

See: conversions

_FC_ Result := CEIL (Value);

Value: function input (floating-point numbers)
Result: the return value of the function (integers, floating-point numbers)

CEIL

A yellow underline in the code indicates that the result of the function is not completely accurate for INT types. For REAL, LREAL type, precision is complete.

On the TIA portal, you can specify the type of variable used for the function by entering CEIL_:INT, DINT, SINT, LINT, REAL, LREAL.

Generate next lower integer from floating-point number.

See: conversions

_FC_ Result := FLOOR (Value);

Value: function input (floating-point numbers)
Result: the return value of the function (integers, floating-point numbers)

FLOOR

A yellow underline in the code indicates that the result of the function is not completely accurate for INT types. For REAL, LREAL type, precision is complete.

On the TIA portal, you can specify the type of variable used for the function by entering FLOOR_:INT, DINT, SINT, LINT, REAL, LREAL.

Truncate numerical value.

See: conversions

_FC_ Result := TRUNC (Value);

Value: function input (floating-point numbers)
Result: the return value of the function (integers, floating-point numbers), Default: DINT

TRUNC

A yellow underline in the code indicates that the result of the function is not completely accurate for INT types. For REAL, LREAL type, precision is complete.

On the TIA portal, you can specify the type of variable used for the function by entering TRUNC_:INT, DINT, SINT, LINT, REAL, LREAL.

Use the Scale instruction to scale a floating-point number by mapping it to a specific value range. You specify the value range with the MIN and MAX parameters. The result of the scaling is an integer. The inverse of the scale function is the norm (NORM_X) function.

See: conversions

_FC_ Result := SCALE_X (MIN := minimum value, VALUE:= act. value, MAX := maximal value);

MIN: function input, low limit of range (integers,floating-point numbers)
MAX: function input, high limit of range (integers,floating-point numbers)
VALUE: function input, value to scale (floating-point numbers)
Result: the return value of the function (integers, floating-point numbers), Default: INT

SCALE_X

On the TIA portal, you can specify the type of variable used for the function by entering SCALE_X_:INT, DINT, SINT, LINT, REAL, LREAL.

You can use the instruction Normalize to normalize the value of the tag at the VALUE input by mapping it to a linear scale. You can use the MIN and MAX parameters to define the limits of a value range that is applied to the scale. The result at the OUT output is calculated and stored as a floating-point number depending on the location of the value to be normalized within this value range. If the value to be normalized equals the value at input MIN, the instruction returns the result 0.0. If the value to be normalized equals the value at input MAX, the instruction returns the result 1.0. The inverse of the scale function is the scale (SCALE_X) function.

See: conversions

_FC_ Result := NORM_X (MIN := minimum range value, VALUE:= value to be normalized, MAX := maximal range value);

MIN: function input, low limit of range (integers,floating-point numbers)
MAX: function input, high limit of range (integers,floating-point numbers)
VALUE: function input, value to be normalized (floating-point numbers)
Result: the return value of the function (integers, floating-point numbers), Default: REAL

NORM_X

On the TIA portal, you can specify the type of variable used for the function by entering NORM_X_:INT, DINT, SINT, LINT, REAL, LREAL.

Use the Scale instruction to convert the integer at the IN parameter into a floating-point number that can be scaled in physical units between a low limit value and a high limit value. You can use the LO_LIM and HI_LIM parameters to specify the low limit and high limit of the value range to which the input value is scaled. The result of the instruction is output at the OUT parameter.

The Scale instruction works with the following logic:

SCALE / BIPOLAR

See: conversions

_FC_ RET_VAL := SCALE (IN := value to be scaled, HI_LIM:= maximal range value, LO_LIM := minimal range value, BIPOLAR := bipolar/unipolar, OUT ⇒ result);

IN: function input, value to be scaled (INT)
HI_LIM: function input, high limit of range (REAL)
LO_LIM: function input, low limit of range (REAL)
BIPOLAR: create bipolar/unipolar field (BOOL)
OUT: function output, result (REAL)
RET_VAL: functionstate (error / ok) 0: no error (WORD

SCALE

  • de/s7/scl_reference_conversions.txt
  • 2022/04/21 15:01
  • ()