DIV (Division)
Divides first input by second input, outputs the quotient.
The DIV function block divides the first input by the second input and outputs the quotient. For integer types, the result is truncated (no remainder). Division by zero must be protected against in PLC code to avoid faults. DIV is used for averaging, rate calculations, percentage computation, and analog de-scaling.
Parameters
Inputs
| Name | Type | Description |
|---|---|---|
| IN1 | ANY_NUM | Dividend (numerator) |
| IN2 | ANY_NUM | Divisor (denominator) - must not be zero |
Outputs
| Name | Type | Description |
|---|---|---|
| OUT | ANY_NUM | Quotient (IN1 / IN2) |
Ladder Logic Example
// Ladder Logic - DIV (Average Calculation) // // |----[DIV]----| // | IN1: Total_Sum | // | IN2: Sample_Count | // | OUT: Average_Value |
Structured Text Example
// Always protect against divide by zero!
IF Sample_Count > 0 THEN
Average_Value := Total_Sum / Sample_Count;
ELSE
Average_Value := 0.0;
END_IF;20 Production-Ready Ladder Logic Templates
Stop writing the same rungs from scratch. Get copy-paste-ready templates for motor control, PID loops, safety interlocks, conveyors, and more.
Platform-Specific Implementation
Siemens (TIA Portal)
Use DIV instruction in TIA Portal. Integer division truncates; use REAL for decimal results.
Allen-Bradley (Studio 5000)
Use DIV instruction. Division by zero generates a minor fault.
CODESYS
Use / operator in ST. Division by zero causes runtime error.
Common Applications
- Average calculation
- Rate computation
- Percentage calculation
- Analog de-scaling
- Flow rate from total/time
Common Mistakes to Avoid
- Not protecting against division by zero
- Integer division truncation losing precision
- Not converting to REAL before dividing integers
Frequently Asked Questions
What is DIV (Division) in PLC programming?
Divides first input by second input, outputs the quotient. The DIV function block divides the first input by the second input and outputs the quotient. For integer types, the result is truncated (no remainder).
What are common applications of DIV (Division)?
DIV (Division) is commonly used for: Average calculation, Rate computation, Percentage calculation, Analog de-scaling, Flow rate from total/time.
How do I use DIV (Division) in different PLC platforms?
Siemens: Use DIV instruction in TIA Portal. Integer division truncates; use REAL for decimal results. Allen-Bradley: Use DIV instruction. Division by zero generates a minor fault. CODESYS: Use / operator in ST. Division by zero causes runtime error.
Related Function Blocks
MUL (Multiplication)
Multiplies two numeric values and outputs the product.
View Reference →MOD (Modulo)
Returns the remainder after integer division of two values.
View Reference →ADD (Addition)
Adds two or more numeric values and outputs the sum.
View Reference →SUB (Subtraction)
Subtracts second input from first input, outputs the difference.
View Reference →ABS (Absolute Value)
Returns the absolute (non-negative) value of the input.
View Reference →Stop Writing Ladder Logic From Scratch
Get 20 production-ready ladder logic templates for $29 -- download instantly and use them on your next project today.
Instant download - 30-day money-back guarantee - Use on unlimited projects