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

DIV

Previous pageReturn to chapter overviewNext page

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

 

Ladder Representation

 

DIV_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

Dividend of the operation

Value2

BYTE USINT SINT WORD UINT INT DWORD UDINT DINT REAL

Divisor 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 division of Value1 and Value2 variables. The value stored will be the exact division if Result is REAL, or, in other cases, only the quotient. 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

 

DIV_flowchart

 

Example in Ladder

 

DIV_example01

 

The above example calculates the division of VALUE 1 and VALUE2 variables, storing the final result in RESULT. Since RESULT is SINT type, only the quotient is stored in it.

 

DIV_example02

 

The above example calculates the division of VALUE 1 and VALUE2 variables, storing the final result in RESULT. Since RESULT is of REAL type, the exact value of the division is stored in it.

 

DIV_example03

 

The above example calculates the division of VALUE 1 and VALUE2 variables, storing the final result in RESULT. Since RESULT is SINT type, only the quotient is stored in it. Notice that the block accepts arguments of both signs.

 

DIV_example04

 

The above example calculates the division of VALUE 1 and VALUE2 variables, storing the final result in RESULT. Since VALUE2 is zero, the block generates a runtime error, 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 := -8;

   RESULT : SINT;

END_VAR

 

RESULT := FB_DIV(

   EN:=DI1,

   Value1:=VALUE1,

   Value2:=VALUE2,

   Done=>DO1);