codesys Arithmetic instruction such as Addition, Subtraction,Multiplication, Division, in these instruction generally have two input variable and one output, in addition block you can append input more than two.
this block is used for adding variables input, when EN input set to true, this block add input variables and store the result into output variable. output coil set to true when operation is complete.
This block is used for subtracting one variables to another variable. when En is set to true Value1 is subtracted by value2 and store the result in output variable. output true if block subtraction done. Note: negative TIME values are undefined.
This block is used for Multiplication of one variables to another variable. when En is set to true Value1 is Multiplied by value2 and store the result in output variable. output true if block Multiplication done.You can extend the MUL operator to additional function block inputs by append input . The number of additional function block inputs is limited.
This block is used for Division of one variables to another variable. when En is set to true Value1 is divided by value2 and store the result in output variable. output true if block Division done. to avoid a division by 0 define functions in your project with the names CheckDivByte, CheckDivWord, CheckDivDWord and CheckDivReal, you can use them to check the value of the divisor if you use the operator DIV.
this example show if divisor is equal to 0 than divison (DIV) block EN input set to false and no divisonal operation done. otherwise division block perform divide value1 to value2 and store result to output.