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;Free · no signup to try
Run this block in your browser
Try the instruction on a live rung before you copy it into a project — nothing to install.
Try it in your browser — no signupOpens plcsimulationsoftware.com — same team
Prefer ready-made code? Ladder Logic Pack — $29 on Gumroad
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 →Free · no signup to try
Wire this block up and run it
Drop the instruction into a rung, press Run and watch it execute in your browser — then adapt it to your vendor tool.
Try it in your browser — no signupOpens plcsimulationsoftware.com — same team
Prefer ready-made code? Ladder Logic Pack — $29 on Gumroad