~~NOCACHE~~
====== LamaPLC: Simatic S7 SCL commands: Conversions ======
==== ROUND: Round numerical value ====
{{anchor:round}}
Round numerical value.
[[:simatic:tia_knowhow#fc|_FC_]] Result := **ROUND** (Value);
Value: function input ([[:simatic:typedef#fpn|floating-point numbers]])\\
Result: the return value of the function ([[:simatic:typedef#integers|integers]], [[:simatic:typedef#fpn|floating-point numbers]])\\
{{:simatic:round_example.png|ROUND}}
A yellow underline in the code indicates that the result of the function is not completely accurate for [[:simatic:typedef#int|INT]] types. For [[:simatic:typedef#real|REAL]], [[:simatic:typedef#lreal|LREAL]] type, precision is complete.
[[simatic:scl_commands|>> Back to LamaPLC main menu (SCL commands)]]
=== ROUND_x ===
On the TIA portal, you can specify the type of variable used for the function by entering ROUND_:[[:simatic:typedef#int|INT]],
[[:simatic:typedef#dint|DINT]],
[[:simatic:typedef#sint|SINT]],
[[:simatic:typedef#lint|LINT]],
[[:simatic:typedef#real|REAL]],
[[:simatic:typedef#lreal|LREAL]].
[[simatic:scl_commands|>> Back to LamaPLC main menu (SCL commands)]]
==== CEIL: Generate next higher integer from floating-point number ====
{{anchor:ceil}}
Generate next higher integer from floating-point number.
[[:simatic:tia_knowhow#fc|_FC_]] Result := **CEIL** (Value);
Value: function input ([[:simatic:typedef#fpn|floating-point numbers]])\\
Result: the return value of the function ([[:simatic:typedef#integers|integers]], [[:simatic:typedef#fpn|floating-point numbers]])\\
{{:simatic:ceil_example.png|CEIL}}
A yellow underline in the code indicates that the result of the function is not completely accurate for [[:simatic:typedef#int|INT]] types. For [[:simatic:typedef#real|REAL]], [[:simatic:typedef#lreal|LREAL]] type, precision is complete.
[[simatic:scl_commands|>> Back to LamaPLC main menu (SCL commands)]]
=== CEIL_x ===
On the TIA portal, you can specify the type of variable used for the function by entering CEIL_:[[:simatic:typedef#int|INT]],
[[:simatic:typedef#dint|DINT]],
[[:simatic:typedef#sint|SINT]],
[[:simatic:typedef#lint|LINT]],
[[:simatic:typedef#real|REAL]],
[[:simatic:typedef#lreal|LREAL]].
[[simatic:scl_commands|>> Back to LamaPLC main menu (SCL commands)]]
==== FLOOR: Generate next lower integer from floating-point number ====
{{anchor:floor}}
Generate next lower integer from floating-point number.
[[:simatic:tia_knowhow#fc|_FC_]] Result := **FLOOR** (Value);
Value: function input ([[:simatic:typedef#fpn|floating-point numbers]])\\
Result: the return value of the function ([[:simatic:typedef#integers|integers]], [[:simatic:typedef#fpn|floating-point numbers]])\\
{{:simatic:floor_example.png|FLOOR}}
A yellow underline in the code indicates that the result of the function is not completely accurate for [[:simatic:typedef#int|INT]] types. For [[:simatic:typedef#real|REAL]], [[:simatic:typedef#lreal|LREAL]] type, precision is complete.
[[simatic:scl_commands|>> Back to LamaPLC main menu (SCL commands)]]
=== FLOOR_x ===
On the TIA portal, you can specify the type of variable used for the function by entering FLOOR_:[[:simatic:typedef#int|INT]],
[[:simatic:typedef#dint|DINT]],
[[:simatic:typedef#sint|SINT]],
[[:simatic:typedef#lint|LINT]],
[[:simatic:typedef#real|REAL]],
[[:simatic:typedef#lreal|LREAL]].
[[simatic:scl_commands|>> Back to LamaPLC main menu (SCL commands)]]
==== TRUNC: Truncate numerical value ====
{{anchor:trunc}}
Truncate numerical value.
[[:simatic:tia_knowhow#fc|_FC_]] Result := **TRUNC** (Value);
Value: function input ([[:simatic:typedef#fpn|floating-point numbers]])\\
Result: the return value of the function ([[:simatic:typedef#integers|integers]], [[:simatic:typedef#fpn|floating-point numbers]]), Default: [[:simatic:typedef#dint|DINT]]\\
{{:simatic:trunc_example.png|TRUNC}}
A yellow underline in the code indicates that the result of the function is not completely accurate for [[:simatic:typedef#int|INT]] types. For [[:simatic:typedef#real|REAL]], [[:simatic:typedef#lreal|LREAL]] type, precision is complete.
[[simatic:scl_commands|>> Back to LamaPLC main menu (SCL commands)]]
=== TRUNC_x ===
On the TIA portal, you can specify the type of variable used for the function by entering TRUNC_:[[:simatic:typedef#int|INT]],
[[:simatic:typedef#dint|DINT]],
[[:simatic:typedef#sint|SINT]],
[[:simatic:typedef#lint|LINT]],
[[:simatic:typedef#real|REAL]],
[[:simatic:typedef#lreal|LREAL]].
[[simatic:scl_commands|>> Back to LamaPLC main menu (SCL commands)]]
==== SCALE_X: Scale ====
{{anchor:scale_x}}
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|NORM_X]]) function.
[[:simatic:tia_knowhow#fc|_FC_]] Result := **SCALE_X** (MIN := minimum value, VALUE:= act. value, MAX := maximal value);
MIN: function input, low limit of range ([[:simatic:typedef#integers|integers]],[[:simatic:typedef#fpn|floating-point numbers]]) \\
MAX: function input, high limit of range ([[:simatic:typedef#integers|integers]],[[:simatic:typedef#fpn|floating-point numbers]]) \\
VALUE: function input, value to scale ([[:simatic:typedef#fpn|floating-point numbers]]) \\
Result: the return value of the function ([[:simatic:typedef#integers|integers]], [[:simatic:typedef#fpn|floating-point numbers]]), Default: [[:simatic:typedef#int|INT]]\\
{{:simatic:scale_example.png|SCALE_X}}
[[simatic:scl_commands|>> Back to LamaPLC main menu (SCL commands)]]
=== SCALE_X_x ===
On the TIA portal, you can specify the type of variable used for the function by entering SCALE_X_:[[:simatic:typedef#int|INT]],
[[:simatic:typedef#dint|DINT]],
[[:simatic:typedef#sint|SINT]],
[[:simatic:typedef#lint|LINT]],
[[:simatic:typedef#real|REAL]],
[[:simatic:typedef#lreal|LREAL]].
[[simatic:scl_commands|>> Back to LamaPLC main menu (SCL commands)]]
==== NORM_X: Normalize ====
{{anchor:norm_x}}
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|SCALE_X]]) function.
[[:simatic:tia_knowhow#fc|_FC_]] Result := **NORM_X** (MIN := minimum range value, VALUE:= value to be normalized, MAX := maximal range value);
MIN: function input, low limit of range ([[:simatic:typedef#integers|integers]],[[:simatic:typedef#fpn|floating-point numbers]]) \\
MAX: function input, high limit of range ([[:simatic:typedef#integers|integers]],[[:simatic:typedef#fpn|floating-point numbers]]) \\
VALUE: function input, value to be normalized ([[:simatic:typedef#fpn|floating-point numbers]]) \\
Result: the return value of the function ([[:simatic:typedef#integers|integers]], [[:simatic:typedef#fpn|floating-point numbers]]), Default: [[:simatic:typedef#real|REAL]]\\
{{:simatic:norm_example.png|NORM_X}}
[[simatic:scl_commands|>> Back to LamaPLC main menu (SCL commands)]]
=== NORM_X_x ===
On the TIA portal, you can specify the type of variable used for the function by entering NORM_X_:[[:simatic:typedef#int|INT]],
[[:simatic:typedef#dint|DINT]],
[[:simatic:typedef#sint|SINT]],
[[:simatic:typedef#lint|LINT]],
[[:simatic:typedef#real|REAL]],
[[:simatic:typedef#lreal|LREAL]].
[[simatic:scl_commands|>> Back to LamaPLC main menu (SCL commands)]]
==== SCALE: Scale ====
{{anchor:scale}}
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:
{{:simatic:scale_bipolar.png|SCALE / BIPOLAR}}
[[:simatic:tia_knowhow#fc|_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 ([[:simatic:typedef#int|INT]]) \\
HI_LIM: function input, high limit of range ([[:simatic:typedef#real|REAL]]) \\
LO_LIM: function input, low limit of range ([[:simatic:typedef#real|REAL]]) \\
BIPOLAR: create bipolar/unipolar field ([[:simatic:typedef#bool|BOOL]]) \\
OUT: function output, result ([[:simatic:typedef#real|REAL]]) \\
RET_VAL: functionstate (error / ok) 0: no error ([[:simatic:typedef#word|WORD]]\\
{{:simatic:scale2_example.png|SCALE}}
[[simatic:scl_commands|>> Back to LamaPLC main menu (SCL commands)]]
\\
\\
{{tag>Simatic SCL TIA ROUND CEIL FLOOR TRUNC SCALE_X NORM_X SCALE conversion}}
\\
This page has been accessed for: Today: {{counter|today}}, Until now: {{counter|total}}