Field fix / guideManual / ReferenceVendor-agnosticIEC 61131-3industrial-automation

Ladder Logic (LD) Programming — Engineering Guide

Shared by TSIMEREZIVO Team · 4 Oct 2026 · 50 views

# Ladder Logic (LD) Programming Ladder Diagram is the most widely used IEC 61131-3 language in industrial automation — derived from electromechanical relay panel wiring diagrams. This tutorial builds a complete pump motor starter from scratch inside LogicForge. 25 min *[Interactive diagram — view in the TSIMEREZIVO docs]* 4-rung ladder diagram — motor starter with interlock, timer, fault latch and reset. IEC 61131-3 compliant. ## Core Concepts | symbol | desc | |---|---| | Rung | A horizontal line of logic. Like a row on a relay panel. Power flows left to right. If conditions allow current to flow the coil on the right energises. | | XIC | Examine If Closed — Normally Open contact. TRUE when the tag bit is 1. Blocks current when 0. Like a N/O relay contact. | | XIO | Examine If Open — Normally Closed contact. TRUE when the tag bit is 0. Blocks current when 1. Like a N/C relay contact (closed at rest, opens on alarm). | | OTE | Output Energise — Coil. Sets the tag to 1 when rung is TRUE, 0 when FALSE. Non-retentive. The most common output instruction. | | OTL / OTU | Output Latch / Unlatch — Retentive coil pair. OTL sets a bit; OTU clears it. Used for alarm latching and permissive interlocks. | | TON | Timer On Delay. Accumulates time while rung is TRUE. .DN (done) bit goes TRUE after preset time. Essential for anti-bounce, startup delays. | ## Tutorial — Pump Motor Starter Build a standard motor starter that energises pump PP-101 when: the start button is pressed, no fault is active, no E-Stop is active, and the motor starter contactor confirms run via a feedback contact. ### Step 1 — Create the tags | name | addr | type | desc | |---|---|---|---| | PP101_START_PB | I:0/0 | BOOL | Start push-button, Panel A, NO contact | | PP101_STOP_PB | I:0/1 | BOOL | Stop push-button, Panel A, NC wired as NO | | PP101_ESTOP | I:0/2 | BOOL | E-Stop mushroom head, Panel A, NC wired | | PP101_FAULT | I:0/3 | BOOL | Motor starter overload trip relay | | PP101_FEEDBACK | I:0/4 | BOOL | Auxiliary contact — motor starter running | | PP101_OUT | O:0/0 | BOOL | Motor starter coil output relay | | PP101_RUNNING | B3:0/0 | BOOL | Internal run seal-in bit | | PP101_FAULT_LAT | B3:0/1 | BOOL | Latched fault output bit | | PP101_START_TMR | T4:0 | TIMER | | ### Step 1 — Rung 0001 — Start Logic with Anti-Bounce Timer This rung starts the anti-bounce timer when the start button is pressed AND no fault is active. ```text (* Rung 0001 — Start request / anti-bounce timer *) IF PP101_START_PB AND NOT PP101_FAULT_LAT AND NOT PP101_ESTOP THEN PP101_START_TMR.IN := TRUE; ELSE PP101_START_TMR.IN := FALSE; END_IF; (* TON coil: PP101_START_TMR PT := T#2000ms *) ``` In LogicForge LD view: place XIC(PP101_START_PB) → XIO(PP101_FAULT_LAT) → XIO(PP101_ESTOP) → TON(PP101_START_TMR, PT:=2000). ### Step 2 — Rung 0002 — Seal-In / Run Output ```text (* Rung 0002 — Motor run output *) (* Start timer done OR self-sealing via RUNNING bit *) IF (PP101_START_TMR.DN OR PP101_RUNNING) AND NOT PP101_STOP_PB AND NOT PP101_ESTOP AND NOT PP101_FAULT_LAT THEN PP101_OUT := TRUE; PP101_RUNNING := TRUE; ELSE PP101_OUT := FALSE; PP101_RUNNING := FALSE; END_IF; ``` The seal-in contact (XIC on PP101_RUNNING in parallel with the timer .DN contact) holds the motor running after the start button is released — exactly like a relay self-hold circuit. ### Step 3 — Rung 0003 — Feedback / Confirmation Watchdog ```text (* Rung 0003 — Start feedback watchdog *) (* If motor commanded ON but feedback not received within 5s → FAULT *) IF PP101_OUT AND NOT PP101_FEEDBACK THEN PP101_WDOG_TMR.IN := TRUE; (* TON, PT := T#5000ms *) ELSE PP101_WDOG_TMR.IN := FALSE; END_IF; (* Rung 0004 — Watchdog trip or overload → Fault Latch *) IF PP101_WDOG_TMR.DN OR PP101_FAULT THEN PP101_FAULT_LAT := TRUE; (* OTL latch *) END_IF; (* Rung 0005 — Fault Reset *) IF PP101_FAULT_RESET_PB AND NOT PP101_FAULT THEN PP101_FAULT_LAT := FALSE; (* OTU unlatch *) END_IF; ``` > **IEC 61131-3 Scan Cycle** — The PLC executes your ladder program top-to-bottom every scan. Each scan reads all inputs, executes all rungs in order, then writes all outputs. Typical scan time: 1–20 ms depending on program size and PLC speed. LogicForge shows estimated scan time in the status bar. ## Ladder Logic Best Practices | rule | desc | |---|---| | One OTE per bit | Never drive the same output coil from two rungs. Creates ambiguous write order. Use OTL/OTU pairs for multi-source control. | | NC contacts as XIO | Wire N/C safety contacts (E-Stop, overload) as XIO (Examine If Open). If the wire breaks or the device faults, the XIO goes TRUE, allowing the rung — you must have a separate interlock rung. | | Comment every rung | Add a rung comment explaining what the rung does, not what the code says. "Starts motor after 2s anti-bounce" not "Timer done enables output". | | Group by function | Keep all motor control rungs together. Group PID loops together. Use program sections or separate programs per ISA-88 unit module. | | No floating contacts | Every XIC/XIO must drive toward a coil or FB. Never leave a contact chain ending without an output — it is dead code that wastes scan time and confuses readers. | | Test in simulator first | Use LogicForge Simulator to step through all rungs, force inputs, and verify transitions before downloading to a live PLC. Never test live without a safe bypass procedure. | ### Next Steps | href | label | desc | |---|---|---| | /dashboard/docs/structured-text | Structured Text | Write algorithms in ST — PID, recipes, arrays | | /dashboard/docs/pid-control | PID Loop Setup | Configure auto-tuned regulatory control loops | | /dashboard/docs/simulator-intro | Simulate & Test | Test your LD logic without connecting a PLC |

More like this

Rate, comment, and get full access

Members can download files, rate contributions, and discuss fixes with the engineers who posted them — free.

Join the library