Try a PLC free — no signup
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;

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 signup

Opens plcsimulationsoftware.com — same team

Prefer ready-made code? Ladder Logic Pack — $29 on Gumroad

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.

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 signup

Opens plcsimulationsoftware.com — same team

Prefer ready-made code? Ladder Logic Pack — $29 on Gumroad