Documentation
Math

Math Functions in Ladder Diagram

Basic math functions like ADD, SUB, MUL, and DIV are used for fundamental arithmetic operations. ADD performs addition, SUB handles subtraction, MUL carries out multiplication, and DIV conducts division. These functions take in operands as inputs and deliver the calculated results as outputs, serving as building blocks for more complex control logic in industrial automation.

Symbol

ADD
EN
ENO
IN1
<???>
IN2
<???>
OUT
<???>

Configuration

Two input parameters, IN1 and IN2, along with one output parameter, OUT, are required for each basic math function in Ladder Logic. The function block is controlled by two additional parameters: EN for enabling and ENO for indicating that the block is enabled. Specifically, EN activates the function block, while ENO confirms its active status. The operands for the calculation are fed into IN1 and IN2, and the computed result is stored in OUT.

It's important to note that only Number or Time variable types are permitted for these input and output parameters.

ADD
EN
ENO
IN1
InputNumber1
IN2
<???>
OUT
<???>

Runtime Behavior

When EN is set to true, the math function gets executed. The result is stored in OUT, and ENO also becomes true to indicate the function is active. If EN is set to false, the function is disabled, and ENO is set to false to confirm it's turned off. If EN remains true, the function will run in every cycle scan. To run the function only a single time, you can use Positive or Negative Transition-Sensing Contacts.

SUB
EN
ENO
IN1
10InputNumber1
IN2
2InputNumber2
OUT
8OutputNumber

Addition

Result = Input1 + Input2

ADD
EN
ENO
IN1
10Input1
IN2
2Input2
OUT
12Result

Subtraction

Result = Input1 - Input2

SUB
EN
ENO
IN1
10Input1
IN2
2Input2
OUT
8Result

Multiplication

Result = Input1 \* Input2

MUL
EN
ENO
IN1
10Input1
IN2
2Input2
OUT
20Result

Division

Result = Input1 / Input2

DIV
EN
ENO
IN1
10Input1
IN2
2Input2
OUT
5Result

Examples


© CodingPLC 2023