DIV

The IEC operator is used for division of variables.

Permitted data types: BYTE, WORD, DWORD, LWORD, SINT, USINT, INT, UINT, DINT, UDINT, LINT, ULINT, REAL, LREAL, TIME

DIV 1:

In TwinCAT, division by zero always leads to an exception and the corresponding task is stopped.

Examples:

ST:

nVar := 8/2;

FBD:

1. Series of DIV function blocks, 2. Individual DIV function block, 3. DIV function block with EN/ENO parameters

DIV 2:
DIV 3:

Note the possibility to monitor for division by 0 during runtime using the implicit monitoring functions CheckDivInt, CheckDivLint, CheckDivLReal and CheckDivLReal.

See also: