S7-1200 and S7-1500 mathematical functions

CALCULATE: calculation

You can use the "Calculate" command to define and execute expressions, and calculate mathematical operations or complex logic operations based on the selected data type.

The data type of the instruction can be selected from the "???" drop-down list in the instruction box. Depending on the selected data type, functions of certain instructions can be combined to perform complex calculations. The expression to be calculated will be specified in a dialog box. Click the "calculator" icon above the command box to open the dialog box. The expression can include the name of the input parameter and the syntax of the command. The operand name and operand address cannot be specified.

In the initial state, the command box contains at least two inputs (IN1 and IN2). The number of inputs can be expanded. Number the inserted input in the function box in ascending order.

Use the entered value to execute the specified expression. Not all defined inputs will be used in the expression. The result of this instruction will be transferred to output OUT.

If one of the mathematical operations in the expression fails, no result is sent to the output OUT, and the output ENO is enabled to return the signal state "1".

If inputs that are not available in the function box are used in the expression, these inputs will be inserted automatically. This requires that the newly defined input numbers in the expression are continuous. For example, if input IN3 is not defined in the expression, input IN4 cannot be used.

If one of the following conditions is met, the signal state of the enable output ENO is "0":

  • The signal state of the enable input EN is "0".
  • The result of the "calculate" instruction exceeds the allowable range of the data type specified by the output OUT.
  • The value of the floating point number is invalid.
  • An error occurred during the execution of an instruction in the expression.

If the signal state of the input "Tag_Input" is "1", the "Calculate" instruction will be executed. Add the value of operand "Tag_Value_1" to the value of operand "Tag_Value_2". The calculated sum is multiplied by the value of the operand "Tag_Value_3". The obtained product is divided by the value of the operand "Tag_Value_4". The obtained quotient is transferred to the operand "Tag_Result" as the final result and copied to the output OUT of the instruction. If the instruction is successfully executed, the ENO enable output and the signal state of the "Tag_Output" operand are set to "1".

ADD: add 

Use the "add" command to add the value of input IN1 to the value of input IN2, and query the total at output OUT.

In the initial state, the command box contains at least two inputs (IN1 and IN2). The number of inputs can be expanded. Number the inserted input in the function box in ascending order. When this instruction is executed, the values ​​of all available input parameters are added. The calculated sum is stored in the output OUT.

If one of the following conditions is met, the signal state of the enable output ENO is "0":

  • The signal state of the enable input EN is "0".
  • The instruction result exceeds the allowable range of the data type specified by the output OUT.
  • The value of the floating point number is invalid.

If the signal state of the operand "TagIn" is "1", the "add" instruction will be executed. If the instruction is executed successfully, the signal state of the enable output ENO is "1" and the output "TagOut" is set.

Other math function instructions:

  1. SUB,MUL,DIV,MOD,MIN,MAX,
  2. ABS, SQR (calculation square), SQRT, SIN (the IN input is specified in radians), COS, TAN, FRAC: return decimals,
  3. LN: Calculate the natural logarithm, EXP: calculate the exponent value with e as the base, EXPT: exponentiate (calculate the result based on the value of the input IN1 as the base and the value of the input IN2 as the power)

Guess you like

Origin blog.csdn.net/Airfrozen/article/details/107214890