Navigation:  Equipments (Devices) > SCA06 > Ladder > Math > Math Basic >

ADD

Previous pageReturn to chapter overviewNext page

Block that calculates the sum of the values of Value1 and Value2, storing the result in Result.

 

Ladder Representation

 

ADD_block

 

Block Structure

 

Variable Type

Name

Data Type

Description

VAR_INPUT

EN

BOOL

Block enabling

Value1

BYTE USINT SINT WORD UINT INT DWORD UDINT DINT REAL

First addend of the operation

Value2

BYTE USINT SINT WORD UINT INT DWORD UDINT DINT REAL

Second addend of the operation

VAR_OUTPUT

Done

BOOL

End of operation

Result

BYTE USINT SINT WORD UINT INT DWORD UDINT DINT REAL

Variable that stores the result of the operation

 

Operation

 

When this block has a TRUE value in EN, it sends to the Result output the sum of Value1 and Value2 variables. If no errors, the Done variable is set. If there is any error in the operation, Done is not set, staying in FALSE status, while Result remains with its value unchanged.

 

When EN has FALSE value, Result remains unchanged and Done remains in FALSE.

 

Block Flowchart

 

ADD_flowchart

 

Example in Ladder

 

ADD_example01

 

The above example calculates the sum of VALUE 1 and VALUE2 variables, storing the final result in RESULT.

 

ADD_example02

 

The above example calculates the sum of VALUE 1 and VALUE2 variables, storing the final result in RESULT. Notice that the block accepts arguments of both signs.

 

ADD_example03

 

The above example calculates the sum of VALUE1 and VALUE2 variables. The final result -170 cannot be stored in RESULT, because it is outside the limits of accepted values by SINT type. Therefore, RESULT remains unchanged and the output is disabled.

 

Example in ST

 

 The example below displays the instructions for applying the example above in the ST language.

 

 

VAR

   VALUE1 : SINT := 70;

   VALUE2 : SINT := -90;

   RESULT : SINT;

END_VAR

 

RESULT := FB_ADD(

   EN:=DI1,

   Value1:=VALUE1,

   Value2:=VALUE2,

   Done=>DO1);