Learn PLCs free
Math OperationsBeginnerIEC 61131-3

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

NameTypeDescription
IN1ANY_NUMDividend (numerator)
IN2ANY_NUMDivisor (denominator) - must not be zero

Outputs

NameTypeDescription
OUTANY_NUMQuotient (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

S

Siemens (TIA Portal)

Use DIV instruction in TIA Portal. Integer division truncates; use REAL for decimal results.

AB

Allen-Bradley (Studio 5000)

Use DIV instruction. Division by zero generates a minor fault.

C

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.

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.

20
Ready-Made Templates
LD + ST
Both Languages Included
$29
One-Time Purchase
Get Instant Access -- $29

Instant download - 30-day money-back guarantee - Use on unlimited projects

Free PLC simulator

Wire this block up and run it

Drop the instruction into a rung, hit Run, and watch it execute in your browser. 12 guided lessons across 8 PLC dialects — free account, no credit card.

Practice PLCs free →