Divide (DIV)
When enabled, the DIV instruction and the operator '/' divides Source A by Source B.
Available Languages
Ladder Diagram

Function Block Diagram
Function Block Diagram supports these elements:
FBD Block

FBD Function

Structured Text
This instruction is not available in structured text.
TIP:
Use the operator '/' in an expression to compute the same result. Refer to
Structured Text Syntax
for more information on the syntax of expressions and
assignments within structured text.Operands
IMPORTANT:
Unexpected operation may occur if:
- Output tag operands are overwritten.
- Members of a structure operand are overwritten.
- Except when specified, structure operands are shared by multiple instructions.
There are data conversion rules for mixing numeric data types within an instruction. See
Data Conversions
.Ladder Diagram
Operand | Data Type | Format | Description |
|---|---|---|---|
SourceA | SINT INT DINT LINT USINT UINT UDINT ULINT REAL LREAL | immediate tag | Value of the dividend |
SourceB | SINT INT DINT LINT USINT UINT UDINT ULINT REAL LREAL | immediate tag | Value of the divisor |
Dest | SINT INT DINT LINT USINT UINT UDINT ULINT REAL LREAL | tag | Tag to store the result of the instruction. |
Function Block Diagram
FBD Block
Operand | Data Type | Format | Description |
|---|---|---|---|
DIV | FBD_MATH | tag | DIV structure |
FBD_MATH Structure
Input Members | Data Type | Description |
|---|---|---|
EnableIn | BOOL | Enable input. If false, the instruction does not execute and outputs are not updated.
Default is true. |
Source A | REAL | Value of the dividend. |
Source B | REAL | Value of the divisor. |
Output Members | Data Type | Description |
|---|---|---|
EnableOut | BOOL | Indicates if the instruction executed without fault when it was enabled. |
Dest | REAL | Result of the instruction. |
FBD Function
Input Operands (Left Pins) | Data Type | Description |
|---|---|---|
SourceA (top) | SINT USINT INT UINT DINT UDINT LINT ULINT REAL LREAL | Value of the dividend. |
SourceB (bottom) | SINT USINT INT UINT DINT UDINT LINT ULINT REAL LREAL | Value of the divisor |
Output Operands (Right Pin) | Data Type | Description |
|---|---|---|
Dest | DINT UDINT LINT ULINT REAL LREAL | Result of the function |
See
FBD Functions
.Affects Math Status Flags
Conditional
See Math Status Flags.
Major/Minor Faults
A minor fault will occur if: | Fault Type | Fault Code |
|---|---|---|
Source_B = 0 | 4 | 4 |
See Index Through Arrays for array-indexing faults.
Execution
Ladder Diagram
Condition/State | Action Taken |
|---|---|
Prescan | N/A |
Rung-condition-in is false | Set Rung-condition-out to Rung-condition-in |
Rung-condition-in is true | Set Rung-condition-out to Rung-condition-in Dest = Source A / Source B 1,2 |
Postscan | N/A |
Function Block Diagram
Condition/State | Action Taken |
|---|---|
Prescan | N/A |
EnableIn is false | Set EnableOut to EnableIn |
EnableIn is true | Dest = SourceA / SourceB 1,2 If overflow occurs Clear EnableOut to false else Set EnableOut to true |
Instruction first run | N/A |
Instruction first scan | N/A |
Postscan | N/A |
FBD Function
Condition/State | Action Taken |
|---|---|
Prescan | N/A |
Normal Scan | Dest = SourceA / SourceB 1,2 |
Instruction first run | N/A |
Instruction first scan | N/A |
Postscan | N/A |
1
If SourceB is zero the result will be SourceA for integer divides and 1.$ for floating point divides. This condition can also cause minor overflow faults. 2
For integer destination and source operands the result is truncated.Examples
Ladder Diagram

Function Block Diagram
FBD Block

FBD Function

Structured Text
DINT_dst := DINT_srcA / DINT_srcB;
Provide Feedback