This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Simatic S7 SCL reference: Conversion operations ====== Back to reference overview: [[de:s7:scl_reference|Simatic S7 SCL reference with examples]] ===== ROUND: Round numerical value ===== {{anchor:round}} Round numerical value. See: [[de:s7:scl_reference#conversions|conversions]] <color white/yellow>[[de:s7:tia_knowhow#fc|_FC_]]</color> <color green>Result</color> := **ROUND** (<color blue>Value</color>); <color blue>Value</color>: function input ([[de:s7:tia_datatypes#fpn|floating-point numbers]])\\ <color green>Result</color>: the return value of the function ([[de:s7:tia_datatypes#integers|integers]], [[de:s7:tia_datatypes#fpn|floating-point numbers]])\\ {{:de:s7:round_example.png|ROUND}} A yellow underline in the code indicates that the result of the function is not completely accurate for [[de:s7:tia_datatypes#int|INT]] types. For [[de:s7:tia_datatypes#real|REAL]], [[de:s7:tia_datatypes#lreal|LREAL]] type, precision is complete. ==== ROUND_x ==== On the TIA portal, you can specify the type of variable used for the function by entering ROUND_:[[de:s7:tia_datatypes#int|INT]], [[de:s7:tia_datatypes#dint|DINT]], [[de:s7:tia_datatypes#sint|SINT]], [[de:s7:tia_datatypes#lint|LINT]], [[de:s7:tia_datatypes#real|REAL]], [[de:s7:tia_datatypes#lreal|LREAL]]. ===== CEIL: Generate next higher integer from floating-point number ===== {{anchor:ceil}} Generate next higher integer from floating-point number. See: [[de:s7:scl_reference#conversions|conversions]] <color white/yellow>[[de:s7:tia_knowhow#fc|_FC_]]</color> <color green>Result</color> := **CEIL** (<color blue>Value</color>); <color blue>Value</color>: function input ([[de:s7:tia_datatypes#fpn|floating-point numbers]])\\ <color green>Result</color>: the return value of the function ([[de:s7:tia_datatypes#integers|integers]], [[de:s7:tia_datatypes#fpn|floating-point numbers]])\\ {{:de:s7:ceil_example.png|CEIL}} A yellow underline in the code indicates that the result of the function is not completely accurate for [[de:s7:tia_datatypes#int|INT]] types. For [[de:s7:tia_datatypes#real|REAL]], [[de:s7:tia_datatypes#lreal|LREAL]] type, precision is complete. ==== CEIL_x ==== On the TIA portal, you can specify the type of variable used for the function by entering CEIL_:[[de:s7:tia_datatypes#int|INT]], [[de:s7:tia_datatypes#dint|DINT]], [[de:s7:tia_datatypes#sint|SINT]], [[de:s7:tia_datatypes#lint|LINT]], [[de:s7:tia_datatypes#real|REAL]], [[de:s7:tia_datatypes#lreal|LREAL]]. ===== FLOOR: Generate next lower integer from floating-point number ===== {{anchor:floor}} Generate next lower integer from floating-point number. See: [[de:s7:scl_reference#conversions|conversions]] <color white/yellow>[[de:s7:tia_knowhow#fc|_FC_]]</color> <color green>Result</color> := **FLOOR** (<color blue>Value</color>); <color blue>Value</color>: function input ([[de:s7:tia_datatypes#fpn|floating-point numbers]])\\ <color green>Result</color>: the return value of the function ([[de:s7:tia_datatypes#integers|integers]], [[de:s7:tia_datatypes#fpn|floating-point numbers]])\\ {{:de:s7:floor_example.png|FLOOR}} A yellow underline in the code indicates that the result of the function is not completely accurate for [[de:s7:tia_datatypes#int|INT]] types. For [[de:s7:tia_datatypes#real|REAL]], [[de:s7:tia_datatypes#lreal|LREAL]] type, precision is complete. ==== FLOOR_x ==== On the TIA portal, you can specify the type of variable used for the function by entering FLOOR_:[[de:s7:tia_datatypes#int|INT]], [[de:s7:tia_datatypes#dint|DINT]], [[de:s7:tia_datatypes#sint|SINT]], [[de:s7:tia_datatypes#lint|LINT]], [[de:s7:tia_datatypes#real|REAL]], [[de:s7:tia_datatypes#lreal|LREAL]]. ===== TRUNC: Truncate numerical value ===== {{anchor:trunc}} Truncate numerical value. See: [[de:s7:scl_reference#conversions|conversions]] <color white/yellow>[[de:s7:tia_knowhow#fc|_FC_]]</color> <color green>Result</color> := **TRUNC** (<color blue>Value</color>); <color blue>Value</color>: function input ([[de:s7:tia_datatypes#fpn|floating-point numbers]])\\ <color green>Result</color>: the return value of the function ([[de:s7:tia_datatypes#integers|integers]], [[de:s7:tia_datatypes#fpn|floating-point numbers]]), Default: [[de:s7:tia_datatypes#dint|DINT]]\\ {{:de:s7:trunc_example.png|TRUNC}} A yellow underline in the code indicates that the result of the function is not completely accurate for [[de:s7:tia_datatypes#int|INT]] types. For [[de:s7:tia_datatypes#real|REAL]], [[de:s7:tia_datatypes#lreal|LREAL]] type, precision is complete. ==== TRUNC_x ==== On the TIA portal, you can specify the type of variable used for the function by entering TRUNC_:[[de:s7:tia_datatypes#int|INT]], [[de:s7:tia_datatypes#dint|DINT]], [[de:s7:tia_datatypes#sint|SINT]], [[de:s7:tia_datatypes#lint|LINT]], [[de:s7:tia_datatypes#real|REAL]], [[de:s7:tia_datatypes#lreal|LREAL]]. ===== 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. See: [[de:s7:scl_reference#conversions|conversions]] <color white/yellow>[[de:s7:tia_knowhow#fc|_FC_]]</color> <color green>Result</color> := **SCALE_X** (<color blue>MIN :=</color> minimum value, <color blue>VALUE:=</color> act. value, <color blue>MAX :=</color> maximal value); <color blue>MIN</color>: function input, low limit of range ([[de:s7:tia_datatypes#integers|integers]],[[de:s7:tia_datatypes#fpn|floating-point numbers]]) \\ <color blue>MAX</color>: function input, high limit of range ([[de:s7:tia_datatypes#integers|integers]],[[de:s7:tia_datatypes#fpn|floating-point numbers]]) \\ <color blue>VALUE</color>: function input, value to scale ([[de:s7:tia_datatypes#fpn|floating-point numbers]]) \\ <color green>Result</color>: the return value of the function ([[de:s7:tia_datatypes#integers|integers]], [[de:s7:tia_datatypes#fpn|floating-point numbers]]), Default: [[de:s7:tia_datatypes#int|INT]]\\ {{:de:s7:scale_example.png|SCALE_X}} ==== SCALE_X_x ==== On the TIA portal, you can specify the type of variable used for the function by entering SCALE_X_:[[de:s7:tia_datatypes#int|INT]], [[de:s7:tia_datatypes#dint|DINT]], [[de:s7:tia_datatypes#sint|SINT]], [[de:s7:tia_datatypes#lint|LINT]], [[de:s7:tia_datatypes#real|REAL]], [[de:s7:tia_datatypes#lreal|LREAL]]. ===== 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. See: [[de:s7:scl_reference#conversions|conversions]] <color white/yellow>[[de:s7:tia_knowhow#fc|_FC_]]</color> <color green>Result</color> := **NORM_X** (<color blue>MIN :=</color> minimum range value, <color blue>VALUE:=</color> value to be normalized, <color blue>MAX :=</color> maximal range value); <color blue>MIN</color>: function input, low limit of range ([[de:s7:tia_datatypes#integers|integers]],[[de:s7:tia_datatypes#fpn|floating-point numbers]]) \\ <color blue>MAX</color>: function input, high limit of range ([[de:s7:tia_datatypes#integers|integers]],[[de:s7:tia_datatypes#fpn|floating-point numbers]]) \\ <color blue>VALUE</color>: function input, value to be normalized ([[de:s7:tia_datatypes#fpn|floating-point numbers]]) \\ <color green>Result</color>: the return value of the function ([[de:s7:tia_datatypes#integers|integers]], [[de:s7:tia_datatypes#fpn|floating-point numbers]]), Default: [[de:s7:tia_datatypes#real|REAL]]\\ {{:de:s7:norm_example.png|NORM_X}} ==== NORM_X_x ==== On the TIA portal, you can specify the type of variable used for the function by entering NORM_X_:[[de:s7:tia_datatypes#int|INT]], [[de:s7:tia_datatypes#dint|DINT]], [[de:s7:tia_datatypes#sint|SINT]], [[de:s7:tia_datatypes#lint|LINT]], [[de:s7:tia_datatypes#real|REAL]], [[de:s7:tia_datatypes#lreal|LREAL]]. ===== 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: {{:de:s7:scale_bipolar.png|SCALE / BIPOLAR}} See: [[de:s7:scl_reference#conversions|conversions]] <color white/yellow>[[de:s7:tia_knowhow#fc|_FC_]]</color> <color green>RET_VAL</color> := **SCALE** (<color blue>IN :=</color> value to be scaled, <color blue>HI_LIM:=</color> maximal range value, <color blue>LO_LIM :=</color> minimal range value, <color blue>BIPOLAR :=</color> bipolar/unipolar, <color blue>OUT =></color> result); <color blue>IN</color>: function input, value to be scaled ([[de:s7:tia_datatypes#int|INT]]) \\ <color blue>HI_LIM</color>: function input, high limit of range ([[de:s7:tia_datatypes#real|REAL]]) \\ <color blue>LO_LIM</color>: function input, low limit of range ([[de:s7:tia_datatypes#real|REAL]]) \\ <color blue>BIPOLAR</color>: create bipolar/unipolar field ([[de:s7:tia_datatypes#bool|BOOL]]) \\ <color blue>OUT</color>: function output, result ([[de:s7:tia_datatypes#real|REAL]]) \\ <color green>RET_VAL</color>: functionstate (error / ok) 0: no error ([[de:s7:tia_datatypes#word|WORD]]\\ {{:de:s7:scale2_example.png|SCALE}} de/s7/scl_reference_conversions.txt 2022/04/21 15:01()