Codesys Arithmetic Instructions

Published on May31, 2021 | Category: arithmetic
Share this article:

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.

codesys Arithmetic Addition ADD In

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.

img/add.webp

img/append.webp

codesys Arithmetic instruction Subtraction SUB

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.

img/sub.webp

codesys Arithmetic instruction Multiplication MUL

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.

img/mul.webp

codesys Arithmetic instruction Division DIV

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.

img/div.webp

codesys Arithmetic instruction example

img/exampleartm.webp

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.