DIV

Divide

DIV divides the value of the first input variable by the value of the second.

Parameters

Input

Unnamed input (INT, DINT, UINT, UDINT, REAL, LREAL)

1st input: dividend

Unnamed input (INT, DINT, UINT, UDINT, REAL, LREAL)

2nd input: divisor

Output

Unnamed output (INT, DINT, UINT, UDINT, REAL, LREAL)

Output as input: result

Remarks

Input and output variables must be of one of the noted data types. All operands must be of the same data type.

Example

POU header

All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.

	VAR
		enable: BOOL:=FALSE;
		dividend: INT:=0;
		divisor: INT:=0;
		result: INT:=0;
	END_VAR

In this example the input variables dividend, divisor and enable have been declared. Instead, you may enter constants directly into the function (enable input e.g. for tests).

LD body

If enable is set (TRUE), dividend is divided by divisor. The result is written into result.

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 5 ;
        NETWORK_BODY
B(B_VARIN,,dividend,8,2,10,4,);
B(B_CONTACT,,enable,4,1,6,3,);
B(B_F,E_DIV!,,10,0,16,5,,?DEN?D?D?AENO?C);
B(B_VARIN,,divisor,8,3,10,5,);
B(B_VAROUT,,result,16,2,18,4,);
L(6,2,10,2);
L(1,2,4,2);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

IL body

LD

enable

E_DIV

dividend, divisor, result

Modified on: 2022-08-23Feedback on this pagePanasonic hotline