Ladder Logic Explained: How PLC Ladder Diagrams Execute, Contacts, Coils, Timers, Counters and Patterns Every Controls Engineer Uses

Ladder Logic Explained: How PLC Ladder Diagrams Execute, Contacts, Coils, Timers, Counters and Patterns Every Controls Engineer Uses

Ladder Logic Explained: How PLC Ladder Diagrams Execute, Contacts, Coils, Timers, Counters and Patterns Every Controls Engineer Uses

A ladder diagram looks like a relay schematic, and that resemblance is the most common source of bugs in it. Relays operate in parallel and settle physically. Ladder logic does neither. It is a sequential program that a PLC evaluates one rung at a time, against a snapshot of the inputs, and then writes the results out in one block. Engineers who read a rung as wiring get double-coil faults, one-scan races and alarms that clear before anyone sees them. This matters now because the fourth edition of IEC 61131-3 was published in May 2025, legacy relay-era code is being migrated to new controllers, and more teams generate PLC code with tools that do not understand scan semantics. You will leave with an execution model you can reason about, precise semantics for contacts, coils, latches, edges, timers and counters, and six production patterns shown both as ladder and as Structured Text.

What this covers: IEC 61131-3 Ladder Diagram semantics, the scan cycle, the instruction set across Rockwell, Siemens and CODESYS, six reusable patterns, common bugs, safety limits and when to switch languages.

Context and Background

Ladder Diagram (LD) is one of the programming languages defined in IEC 61131-3, the international standard for PLC programming languages. The standard was first published in 1993. The third edition arrived in 2013, and the fourth edition, IEC 61131-3:2025, was published on 22 May 2025 at 518 pages. The IEC abstract names its languages as Structured Text (ST), Ladder Diagram, Function Block Diagram (FBD) and Sequential Function Chart (SFC). Instruction List (IL), the assembler-like language, was deprecated in 2013 and, according to the standard’s public summaries, removed in the 2025 edition. The IEC lists the inclusion of UTF-8 strings as a key technical change and points to an Annex B that tracks every added, removed or deprecated feature. You can check the abstract on the IEC webstore page for IEC 61131-3:2025.

None of that changes how a rung executes. LD semantics have been stable for decades, which is why ladder written in the 1990s still runs, in translated form, on modern controllers. The incumbents that matter in practice are three tool families. Rockwell Automation’s Studio 5000 Logix Designer uses mnemonic instructions such as XIC, XIO and OTE. Siemens TIA Portal uses LAD with IEC-style blocks; Siemens announced TIA Portal V21 on 13 November 2025. CODESYS, an IEC 61131-3 runtime licensed to many hardware vendors, stays closest to the standard’s own names.

Ladder logic survives for a social reason as well as a technical one. Electricians and maintenance technicians can follow power flow on a laptop at 3 a.m. with a machine stopped. The online view highlights energised contacts in colour, which makes LD the fastest language for troubleshooting a discrete machine. That benefit fades for arithmetic, string handling and data structures, which is why most real projects mix languages.

Ladder also sits inside a larger timing model. Every rung runs inside a task, and every task runs inside the controller’s scan. We covered that layer in depth in our article on PLC scan cycle determinism, jitter and task scheduling. This post sits one level lower. It explains what each ladder element does inside a single scan, and how the classic patterns depend on that behaviour.

The thesis is simple. Ladder logic is not a wiring diagram. It is a sequence of boolean assignments evaluated against a frozen input image, and every famous ladder bug is a violation of that one fact.

How Ladder Logic Executes: The Reference Model

Ladder logic is a graphical PLC language in which each rung computes a boolean result, called power flow, from contacts on the left and assigns it to coils or function blocks on the right. The PLC evaluates rungs in order, top to bottom, once per scan, using a snapshot of inputs, then writes outputs together.

Ladder logic execution inside the PLC scan cycle, from input image through rung evaluation to output image

Figure 1: Where ladder rungs sit inside the PLC scan: input snapshot, ordered rung evaluation, output write, housekeeping, all supervised by a watchdog.

Figure 1 shows the classic image-table model. The controller reads physical inputs into an input image. It then solves rung 1, rung 2 and so on, each rung seeing the results that earlier rungs wrote. When the last rung finishes, the output image is copied to the physical outputs, and the controller handles communications and diagnostics before starting again. A watchdog timer faults the controller if the logic solve takes longer than its configured limit, which protects against infinite loops and runaway scans.

Power rails, power flow and why a rung is an assignment

An LD network sits between a left power rail and a right power rail. The left rail is always TRUE. Power flows left to right through contacts. Series contacts form a logical AND, parallel branches form a logical OR, and the boolean result at the right end of the contact network drives whatever coils or blocks sit there.

The useful mental shift is to read each rung as a line of code. A rung with contacts A and B in series, a parallel branch C, and a coil Y is exactly Y := (A AND B) OR C;. The coil is not a relay that pulls in when current flows. It is an assignment that happens when the PLC reaches that rung, and only then.

That framing explains a lot. A coil written on rung 10 is still holding last scan’s value when rung 5 reads it. Two coils with the same address on rungs 10 and 40 are two assignments to one variable, so the second one wins. And a rung that is skipped by a jump does not execute its assignments at all, so its coils freeze at whatever value they last held.

Rung evaluation order and the frozen input image

IEC 61131-3 specifies that LD networks are evaluated top to bottom unless a jump or return changes control flow. Within a rung, evaluation proceeds so that every element sees the power flow to its left. Most vendors evaluate branches in a defined order, and a few allow an output coil in the middle of a rung, which then participates in later evaluation on the same rung.

The input image is the other half of the model. On a classic image-table PLC, a pushbutton that changes state halfway through the logic solve is not seen until the next scan. Every rung in a scan therefore sees a consistent set of inputs. Consistency is the property that makes ladder reasoning tractable, and it is why Siemens S7 controllers still expose a process image and require explicit syntax, such as the :P suffix in TIA Portal, to read a peripheral input directly.

Not every platform keeps that guarantee. Rockwell’s ControlLogix user manual states plainly that “ControlLogix controllers update data asynchronously with the execution of logic.” Input tags on those controllers are refreshed at the module’s requested packet interval (RPI), not at the start of the scan. A sensor tag can therefore change between rung 3 and rung 30 in the same scan. Experienced Logix programmers buffer inputs by copying them to internal tags at the top of the routine, which restores the snapshot semantics the rest of the code assumes.

Scan time arithmetic and what it means for signals

The scan model sets a hard limit on what ladder can observe. A signal must be stable for at least one full scan, plus input filter delay, to be reliably seen. Take an illustrative machine with a 10 ms scan and a 3 ms input filter. A product-present pulse lasting 8 ms may be missed entirely if it rises just after the input read and falls before the next one.

The worst-case reaction time is roughly input filter plus two scans plus output delay. One scan can pass before the change is captured, and another passes before the result reaches the output image. With the illustrative numbers above, that is 3 + 10 + 10 ms plus the output module’s switching time. Relay-based outputs can add several milliseconds on their own; check the module datasheet rather than assuming.

These numbers matter for the patterns later in this article. Debounce timers, edge detectors and counters all assume that inputs are slower than the scan. When they are not, the correct fix is hardware: a high-speed counter module, an interrupt-driven input, or a faster periodic task. Adding more ladder will not help.

The Instruction Set: Contacts, Coils, Edges, Timers and Counters

Before the patterns, here is what each ladder logic element actually does, using IEC names with the Rockwell and Siemens equivalents.

Contacts examine bits; they do not sense devices

A normally open (NO) contact passes power when its bit is TRUE. A normally closed (NC) contact passes power when its bit is FALSE. Rockwell calls these Examine If Closed (XIC) and Examine If Open (XIO). Its documentation says XIO “examines the data bit to set or clear the rung condition”, which is the key word: the instruction examines a bit, not a field device.

This distinction trips up engineers new to PLC ladder logic. A stop pushbutton is normally wired with a physically normally closed contact, so the input bit is TRUE when the button is not pressed and the wire is intact. In the program you then use an NO contact (XIC) on that input. The ladder symbol describes the test on the bit, while the hardware choice describes fail-safe wiring. A broken wire then looks like a pressed stop button, which is the safe direction.

Coils assign, latch, unlatch or pulse

The plain coil, --( )--, writes the rung result to its bit every scan: TRUE when the rung is TRUE, FALSE when it is FALSE. Rockwell’s Output Energize (OTE) documentation is explicit that when the rung is false, “the data bit is cleared to false”, and that the bit is also cleared during prescan, the pass Logix makes over the program at mode change. A negated coil, --(/)--, writes the inverse.

The set coil, --(S)--, writes TRUE when its rung is TRUE and does nothing when the rung is FALSE. The reset coil, --(R)--, writes FALSE when its rung is TRUE. Rockwell names these Output Latch (OTL) and Output Unlatch (OTU). Its OTL page says the instruction “does not change the status of the data bit” when the rung goes false, and that the bit “remains true until it is cleared, typically by an OTU instruction”. OTL takes no action on prescan, so a latched bit survives a mode change. That is exactly what you want for a fault memory and exactly what you do not want for a motor run command.

IEC 61131-3 also defines bistable function blocks. SR is set-dominant: if both inputs are TRUE, the output is TRUE. RS is reset-dominant: if both are TRUE, the output is FALSE. Choosing between them is a safety decision, not a style choice. A motor enable should almost always be reset-dominant, so that a stop request beats a simultaneous start.

Edge detection turns levels into events

A level is a state that persists; an edge is the scan in which it changes. IEC 61131-3 provides R_TRIG for a rising edge and F_TRIG for a falling edge. Each keeps an internal memory of last scan’s input and outputs TRUE for exactly one scan when the input changes in the relevant direction. LD also offers edge contacts, drawn --|P|-- and --|N|--.

Rockwell’s equivalents are ONS, which “enable[s] outputs for one scan each time a rung goes true”, plus OSR and OSF, which set a bit for one scan on the rung’s rising or falling transition. Siemens TIA Portal lists separate instructions: P and N to scan an operand, P_TRIG and N_TRIG to scan the rung’s result of logic operation (RLO), and R_TRIG and F_TRIG as instance-based blocks. Siemens notes that R_TRIG keeps “the state of the previous query (edge memory bit)” in its instance.

The edge memory is the whole mechanism. Every edge instruction needs its own private storage bit. If two edge instructions share one storage bit, each overwrites the other’s memory, and one of them never fires. That shared-memory fault is common in copied code.

Timers: TON, TOF and TP

IEC 61131-3 defines three standard timers, all with inputs IN and PT (preset time) and outputs Q and ET (elapsed time).

Ladder logic TON on-delay timer state machine showing idle, timing and done states

Figure 2: The TON on-delay timer as a three-state machine. Any drop of IN returns it to Idle and resets elapsed time.

Figure 2 shows TON, the on-delay timer and the one you will use most. While IN is FALSE, Q is FALSE and ET is zero. When IN becomes TRUE, ET starts counting. If IN drops before ET reaches PT, the timer resets to idle, with no partial credit. When ET reaches PT, Q becomes TRUE and stays TRUE until IN drops. That reset-on-drop behaviour is what makes TON a natural debounce and confirmation filter.

TOF, the off-delay timer, is the mirror image. Q becomes TRUE immediately when IN goes TRUE. When IN falls, ET starts counting, and Q stays TRUE until ET reaches PT. A cooling fan that runs for two minutes after a motor stops is a TOF. TP, the pulse timer, produces a fixed-width pulse. On a rising edge of IN, Q goes TRUE for exactly PT, regardless of what IN does next, and a new edge during the pulse does not retrigger it.

Vendors add variants. Rockwell provides TON, TOF and RTO, the retentive timer that holds its accumulated value when the rung goes false and needs a RES instruction to clear. Its timer structure exposes .EN, .TT (timing) and .DN (done) bits, with preset and accumulator in milliseconds. Siemens offers TON, TOF, TP and TONR, a retentive on-delay. An RTO or TONR is the right tool for accumulating run hours toward a maintenance interval. It is the wrong tool for anything that should restart cleanly after an interruption.

Timers in ladder logic are not interrupts. A timer instance only updates when its rung executes. Place a TON inside a subroutine that is called every fifth scan and it will still read the system clock correctly on most modern platforms, but its Q output can only change on scans where it runs. Timer resolution is therefore bounded by the scan of the task that owns it.

Counters: CTU, CTD and CTUD

The IEC up counter CTU increments its current value CV on each rising edge of CU, and its output Q is TRUE when CV is greater than or equal to the preset PV. Input R resets CV to zero. CTD decrements CV on each rising edge of CD, loads PV when LD is TRUE, and sets Q when CV is less than or equal to zero. CTUD combines both with outputs QU and QD.

Rockwell’s CTU and CTD count false-to-true transitions of the rung and set .DN when the accumulator reaches the preset; a separate RES clears it. Two properties matter more than the names. First, counters are edge-triggered internally, so you should not add an extra one-shot in front of them. Second, counters can only see edges that last at least one scan. A 2 kHz encoder is far beyond any ladder counter, and a high-speed counter module exists for that reason.

Walk-through: Six Ladder Logic Examples Every Controls Engineer Uses

The six ladder logic examples below appear in nearly every machine. Each is shown as rung text, then as equivalent Structured Text. Tag names are illustrative. The ladder uses a plain-text notation where ] [ is an NO contact, ]/[ is an NC contact and ( ) is a coil.

Pattern 1: Start/stop seal-in

The seal-in circuit, also called a holding or latching circuit, is the “hello world” of PLC programming basics. A momentary start button energises the motor, and a contact from the motor’s own run bit holds the rung TRUE after the button is released. The stop button breaks the rung.

Rung 1:
|--+--] [ Start_PB --+--] [ Stop_PB_OK --] [ OL_OK --] [ Perm_OK --( Motor_Run )--|
|  |                 |
|  +--] [ Motor_Run -+
Motor_Run := (Start_PB OR Motor_Run) AND Stop_PB_OK AND OL_OK AND Perm_OK;

Why a seal-in rather than a set/reset pair? The seal-in is reset-dominant by construction: if stop and start are both active, the series stop contact wins. It also drops out automatically on prescan, power loss or a controller mode change, because Motor_Run is an OTE-style coil. A latch with OTL would restart the motor after a power cycle if the latched bit is retentive. On many machines that behaviour is a hazard.

Notice Stop_PB_OK and OL_OK. The stop button and the overload relay are wired normally closed in the field, so a broken wire produces a stop. The program then examines them with NO contacts. Naming the tags for their healthy state removes the double negatives that make stop logic hard to audit.

Pattern 2: Interlocks and permissives

An interlock prevents one action while a conflicting state exists. The classic case is a reversing motor, where forward and reverse contactors must never close together. A permissive is the positive form: a set of conditions that must all be TRUE before an action is allowed.

Rung 2:
|--+--] [ Fwd_PB --+--] [ Stop_OK --]/[ Rev_Run --]/[ Rev_Cmd --( Fwd_Run )--|
|  +--] [ Fwd_Run -+
Rung 3:
|--+--] [ Rev_PB --+--] [ Stop_OK --]/[ Fwd_Run --]/[ Fwd_Cmd --( Rev_Run )--|
|  +--] [ Rev_Run -+
Fwd_Run := (Fwd_PB OR Fwd_Run) AND Stop_OK AND NOT Rev_Run AND NOT Rev_Cmd;
Rev_Run := (Rev_PB OR Rev_Run) AND Stop_OK AND NOT Fwd_Run AND NOT Fwd_Cmd;

The software interlock is necessary but not sufficient. Rung 2 executes before rung 3, so in one scan forward can be evaluated with the old value of reverse. That asymmetry is harmless here because both rungs check each other. However, the contactors themselves take tens of milliseconds to open, and a welded contact does not care what the PLC believes. A real reversing starter also has a mechanical interlock and auxiliary contacts wired in hardware. The ladder interlock is the second line, not the first.

Good permissive design groups conditions into one named bit, such as Pump1_Permissive, built on its own rung. The HMI can then display which condition is missing, and maintenance can see the single reason a pump will not start. That one habit saves hours of troubleshooting.

Pattern 3: Input debounce and confirmation

Debounce is one of the most practical ladder logic examples. Mechanical contacts bounce for a few milliseconds when they change state. Level switches chatter as liquid sloshes. A debounce filter requires an input to be stable for a minimum time before the program trusts it.

Rung 4:
|--] [ LS_Raw ----------[TON Deb_On  IN  PT=T#200ms]--|
Rung 5:
|--]/[ LS_Raw ----------[TON Deb_Off IN  PT=T#200ms]--|
Rung 6:
|--+--] [ Deb_On.Q --+--]/[ Deb_Off.Q --( LS_Stable )--|
|  +--] [ LS_Stable -+
Deb_On(IN := LS_Raw, PT := T#200MS);
Deb_Off(IN := NOT LS_Raw, PT := T#200MS);
IF Deb_On.Q THEN
    LS_Stable := TRUE;
ELSIF Deb_Off.Q THEN
    LS_Stable := FALSE;
END_IF;

Two timers give symmetric filtering: the stable bit only changes after the raw input has held its new state for the full preset. A single TON filters only the rising direction, which is fine for a “confirmed running” feedback but wrong for a level switch that must also confirm the falling edge. The preset is a process choice. A 200 ms value is illustrative; a pushbutton may need 20 to 50 ms, while a level switch on a turbulent tank may need seconds.

The debounce pattern adds latency by design. If a safety-relevant decision depends on this input, document the added delay and include it in the reaction-time budget.

Pattern 4: Alarm latch with acknowledge

An alarm that clears itself the moment its condition clears is an unlatched alarm. If a pressure spike lasts 400 ms, the operator never sees it. The correct pattern latches the alarm until it has been both acknowledged and cleared, matching the state model used in alarm management standards.

Ladder logic alarm latch with acknowledge state machine from normal to active unacknowledged, acknowledged and cleared

Figure 3: The four alarm states that a latch-with-acknowledge pattern must represent. An alarm returns to Normal only after it is both acknowledged and cleared.

Figure 3 follows the state model described in ISA-18.2. A new alarm is Active and Unacknowledged. The operator can acknowledge it while it is still active, or the condition can clear first, leaving a Cleared but Unacknowledged alarm that still demands attention. Only when both acknowledgment and clearance have happened does it return to Normal. Our article on ISA-18.2 alarm management and alarm floods covers why this matters at plant scale.

Rung 7:  alarm detection with on-delay to suppress chatter
|--] [ PT101_HiHi --------------------[TON HH_Dly IN PT=T#2s]--|
Rung 8:  latch on rising edge of the delayed condition
|--] [ HH_Dly.Q --[ONS HH_Ons]--+--(S) HH_Alarm  --|
|                                +--(S) HH_Unack  --|
Rung 9:  acknowledge clears the unacknowledged flag
|--] [ HMI_Ack --------------------------------(R) HH_Unack  --|
Rung 10: reset only when acknowledged and cleared
|--]/[ HH_Unack --]/[ HH_Dly.Q -----------------(R) HH_Alarm  --|
HH_Dly(IN := PT101_HiHi, PT := T#2S);
HH_Trig(CLK := HH_Dly.Q);
IF HH_Trig.Q THEN
    HH_Alarm := TRUE;
    HH_Unack := TRUE;
END_IF;
IF HMI_Ack THEN
    HH_Unack := FALSE;
END_IF;
IF NOT HH_Unack AND NOT HH_Dly.Q THEN
    HH_Alarm := FALSE;
END_IF;

Three details deserve attention. The two-second on-delay is an alarm delay, not a debounce; it suppresses nuisance alarms from brief excursions and should come from rationalisation, not guesswork. The rising-edge trigger means a still-active alarm does not re-assert Unack after acknowledgment, which avoids a stuck unacknowledged state. And the acknowledge comes from the HMI as a momentary bit, which the HMI or the PLC must clear after one scan, or every future alarm will be acknowledged the instant it appears.

That last bug is real and common. An HMI pushbutton configured as “set” rather than “momentary” leaves HMI_Ack TRUE forever. Every alarm then self-acknowledges, and the alarm banner looks quiet while the plant is not.

Pattern 5: Sequencer as a state machine

Machines run in steps: clamp, drill, retract, unclamp. Writing sequences as scattered seal-ins produces logic that nobody can follow. The robust ladder pattern uses an integer step register and one rung per transition, which is a state machine written in LD.

Rung 11: Step 0 Idle  ->  Step 10 Clamp
|--[EQU Step 0]--] [ Cycle_Start --] [ Part_Present ------[MOV 10 Step]--|
Rung 12: Step 10 Clamp  ->  Step 20 Drill
|--[EQU Step 10]--] [ Clamp_Closed_Stable ---------------[MOV 20 Step]--|
Rung 13: Step 20 Drill  ->  Step 30 Retract
|--[EQU Step 20]--] [ Drill_Depth_Reached ---------------[MOV 30 Step]--|
Rung 14: Step 30 Retract  ->  Step 0 Idle
|--[EQU Step 30]--] [ Drill_Home --]/[ Clamp_Closed ------[MOV 0  Step]--|
Rung 15: outputs decoded from step
|--[EQU Step 10]--+------------------------------------( Clamp_Sol )--|
|--[EQU Step 20]--+
|--[EQU Step 20]--------------------------------------( Drill_Fwd )--|
Rung 16: step watchdog, simplified, resets only at Idle
|--[NEQ Step 0]--[TON Step_Tmr IN PT=T#15s]--] [ Step_Tmr.Q --(S) Seq_Fault --|
CASE Step OF
    0:  IF Cycle_Start AND Part_Present THEN Step := 10; END_IF;
    10: IF Clamp_Closed_Stable THEN Step := 20; END_IF;
    20: IF Drill_Depth_Reached THEN Step := 30; END_IF;
    30: IF Drill_Home AND NOT Clamp_Closed THEN Step := 0; END_IF;
END_CASE;
Clamp_Sol := (Step = 10) OR (Step = 20);
Drill_Fwd := (Step = 20);
Step_Tmr(IN := (Step <> 0) AND (Step = Prev_Step), PT := T#15S);
IF Step_Tmr.Q THEN Seq_Fault := TRUE; END_IF;
Prev_Step := Step;

The ladder watchdog on rung 16 is simplified; the ST version restarts the timer on every step change, which is what you want in production. Several design choices make this pattern hold up. Step numbers are spaced by ten so that a new step can be inserted without renumbering. Outputs are decoded from the step in one place, never set inside transitions, so each output has a single writer. And a step watchdog faults the sequence if any step takes longer than expected, which turns a stuck sensor into a clear diagnostic instead of a silent stall.

Ordering is the subtle part. Because rungs run top to bottom, a transition on rung 11 can move to step 10, and rung 12 can then immediately test step 10’s exit condition in the same scan. If Clamp_Closed_Stable happens to be TRUE already, the sequence skips through step 10 without ever energising the clamp. Some engineers accept this. Others add a “step changed this scan” flag to allow only one transition per scan in the ladder logic. Pick one rule and apply it consistently. The ST CASE version, by contrast, evaluates only one branch per scan, so it allows at most one transition per scan by construction. That difference is a good reason to prefer CASE or SFC for sequences.

Pattern 6: First-scan initialisation

Some things must happen exactly once at startup: clear a sequence step, reset a non-retentive mode, load default setpoints, or force a homing routine. Every platform provides a first-scan indicator. Rockwell exposes S:FS, the first-scan status bit. Siemens provides start-up organisation blocks such as OB100 for warm restart, which run before the cyclic program. CODESYS projects typically use an initialisation flag or a dedicated init task, and some runtimes expose a system first-cycle flag.

Rung 17:
|--] [ S:FS ----+--[MOV 0 Step]------------|
|               +--(R) Seq_Fault ----------|
|               +--(S) Homing_Required ----|
IF First_Scan THEN
    Step := 0;
    Seq_Fault := FALSE;
    Homing_Required := TRUE;
    First_Scan := FALSE;
END_IF;

In the ST version, First_Scan is declared BOOL := TRUE and is not retentive, so it is TRUE only on the first execution after a cold or warm start. The pattern looks trivial, but the design question behind it is not. Which variables should survive a power cycle, and which must restart from a known state? Write that list down. A retentive step register that resumes a drilling cycle mid-stroke after a power loss is a mechanical crash waiting to happen.

Vendor Differences: Rockwell vs Siemens vs CODESYS

The core ladder logic semantics match across vendors, but names, memory models and edge-case behaviour differ. The matrix below covers what changes when you move code between platforms.

Concept IEC 61131-3 / CODESYS Rockwell Studio 5000 Siemens TIA Portal LAD
NO / NC contact --| |-- / --|/|-- XIC / XIO Normally open / normally closed contact
Plain coil --( )-- OTE, cleared on prescan Assignment coil
Set / reset coil --(S)-- / --(R)-- OTL / OTU, no prescan action Set output / reset output
Bistable block SR set-dominant, RS reset-dominant Usually built from OTL/OTU or seal-in SR and RS flip-flops
Rising edge R_TRIG, --|P|-- ONS, OSR; OSRI in FBD P, P_TRIG, R_TRIG, P=
On-delay timer TON with IN, PT, Q, ET TON with .EN, .TT, .DN, PRE, ACC in ms TON, plus TONR retentive
Retentive timer Vendor extension RTO plus RES TONR
Up counter CTU with CU, R, PV, Q, CV CTU with .DN, PRE, ACC, RES CTU
I/O update model Runtime-dependent, usually process image per task Asynchronous at RPI on ControlLogix Process image, :P for direct access
Start-up logic Init flag or init task S:FS first-scan bit Start-up OBs such as OB100

Three practical consequences follow. First, porting a Rockwell program to an image-table platform can change behaviour, because code written for asynchronous inputs often buffers them already while code written for a process image never needed to. Second, Siemens’ edge instructions need explicit memory operands that must be unique, while Rockwell ONS and OSR also need a unique storage bit; copy-paste errors in either case break edge detection silently. Third, the CODESYS ecosystem, used under many hardware brands, keeps IEC names, so code written there ports most cleanly to other IEC-conformant tools.

Version context matters too. The Rockwell instruction descriptions quoted here come from the Studio 5000 Logix Designer v38 documentation, and Siemens’ quotes come from the TIA Portal V20 online help. Instruction semantics at this level rarely change between versions, but always confirm against the help for the version you deploy. For the language-level comparison with the event-driven standard, see our IEC 61499 vs IEC 61131-3 comparison.

Trade-offs, Gotchas, and What Goes Wrong

Double-coil syndrome

Writing the same output from two OTE coils is the classic ladder logic bug. Rung 10 sets Valve_Open TRUE, and rung 40 sets it FALSE because its own condition is false. The physical valve follows rung 40, and the online view shows rung 10 energised, which sends troubleshooters in circles. Many tools can cross-reference duplicate destructive writes; enable that check and treat a hit as an error. The rule is simple: one plain coil per bit, or a single set/reset pair with documented priority.

Scan-order races

In ladder logic, rungs that read bits written later in the same scan see last scan’s value. Usually that is harmless. It becomes a bug when two rungs form a handshake, when a one-shot is consumed before it is produced, or when a sequence transition chains through several steps in one scan. Draw the data dependencies for any rung group that feeds itself, and order rungs so producers come before consumers.

Asynchronous I/O and mid-scan changes

On ControlLogix-class platforms, an input can change between two rungs of the same scan. A rung that tests the same input twice can see two different values. Buffer inputs at the top of each program, or use the vendor’s synchronous copy instruction for structured data that must stay consistent.

Retentive memory surprises

Latched bits, retentive timers and retentive step registers survive power cycles by design. Combined with a seal-in-free run command, they can restart equipment without a human request. Audit every OTL, set coil and retentive tag against a defined restart policy, and initialise the rest with a first-scan routine.

Unlatched and self-acknowledging alarms

An alarm coil driven directly by a process condition disappears with the condition. A stuck acknowledge bit acknowledges everything. Both failures look like a quiet alarm system, which is the worst possible failure mode for operator awareness.

Never rely on standard PLC ladder for safety functions

A standard PLC is not developed, certified or diagnosed to the integrity required for safety functions. Emergency stops, guard interlocks, light curtains and burner management belong in hardwired safety relays or a certified safety PLC with a safety task, designed under IEC 61508, IEC 62061 or ISO 13849. Our guides to IEC 61508 SIL, PFD and safety PLC architecture and to ISO 13849 performance levels explain why. A standard PLC can monitor a safety circuit and report its status; it should not be the safety circuit.

When ladder is the wrong language

Ladder logic language selection decision flow across Ladder Diagram, SFC, Structured Text, FBD and safety PLC

Figure 4: A practical decision flow for choosing ladder logic versus other IEC 61131-3 languages, with safety functions routed out of the standard PLC entirely.

Figure 4 encodes a rule of thumb that many integrators follow. Safety functions leave the standard program first. Boolean interlocks and discrete device control stay in LD, because that is where its online view shines. Sequences with explicit steps belong in SFC, which makes active steps and transitions visible and prevents the multi-step-per-scan problem from Pattern 5. Arithmetic, loops, arrays, string handling and protocol parsing belong in ST. FBD suits continuous signal flow such as PID loops. Mixing is normal: an SFC step often calls ladder logic or ST for its actions.

Practical Recommendations

Treat ladder logic as code that happens to be drawn, because the controller does. That means the same disciplines as any other software: naming conventions, single writers per variable, reviews and version control. Siemens’ announcement that TIA Portal V21 supports a new export format for Git-based workflows reflects how far that expectation has moved in mainstream tools.

Start every project with an explicit execution model. Document the task structure, scan targets, I/O update behaviour and restart policy before writing the first rung. Then build a small ladder logic library of the six patterns above as tested, reusable blocks rather than re-drawing them by hand on every machine. Reusable function blocks make the patterns consistent, and consistent patterns make code reviews fast.

If you use code generation tools, apply extra scrutiny to scan semantics, edge memory and coil duplication, because generated code is often syntactically valid and behaviourally wrong. Our analysis of LLM-generated IEC 61131-3 PLC code and its verification covers how to test it. For network-side context on the controllers themselves, see our article on applying the Purdue model and OT segmentation.

A short checklist for every ladder review:

  1. Every output bit has exactly one plain coil, or one documented set/reset pair.
  2. Every edge instruction has its own unique memory bit.
  3. Stop and overload inputs are wired fail-safe and named for their healthy state.
  4. Inputs are buffered on platforms with asynchronous I/O.
  5. Every alarm latches until acknowledged and cleared, and the acknowledge bit is momentary.
  6. Every sequence step has a watchdog timer and a single place where outputs are decoded.
  7. A written restart policy lists which tags are retentive and which are initialised on first scan.
  8. No safety function depends on the standard PLC program.

Frequently Asked Questions

What is ladder logic in a PLC?

Ladder logic is a graphical programming language for programmable logic controllers, standardised as Ladder Diagram in IEC 61131-3. A program consists of rungs drawn between two vertical power rails. Contacts on the left of each rung test boolean variables, and coils or function blocks on the right receive the result. Although it looks like a relay schematic, the PLC executes it as sequential code, evaluating rungs top to bottom once per scan against a snapshot of inputs, then writing all outputs together. That sequential execution model is what you must reason about when debugging.

How does a PLC execute ladder logic rungs?

In the classic model, the PLC copies physical inputs into an input image, evaluates every rung in order from top to bottom, writes the results into an output image, and then updates the physical outputs. Within a rung, power flow moves left to right through series and parallel contacts. A rung later in the program sees values written by earlier rungs in the same scan. Some platforms, including ControlLogix, update I/O asynchronously instead, so inputs can change mid-scan unless you buffer them. Housekeeping and communications run between scans, and a watchdog limits total scan time.

What is the difference between OTE and OTL in Rockwell ladder logic?

OTE, Output Energize, writes the rung result to its bit every scan, so the bit is TRUE only while the rung is TRUE. Rockwell also clears OTE bits during prescan. OTL, Output Latch, sets the bit when the rung is TRUE and leaves it unchanged when the rung goes FALSE; the bit stays TRUE until an OTU, Output Unlatch, clears it. OTL takes no action during prescan, so latched bits survive a mode change. Use OTE seal-ins for run commands and OTL/OTU for fault memories and states that must persist deliberately.

How do TON, TOF and TP timers differ?

All three IEC 61131-3 timers take an input IN and a preset PT and produce output Q and elapsed time ET. TON delays turning on: Q becomes TRUE only after IN has been continuously TRUE for PT, and any drop resets it. TOF delays turning off: Q goes TRUE with IN, then stays TRUE for PT after IN falls. TP generates a fixed-width pulse of length PT on a rising edge of IN and ignores further edges until the pulse ends. Vendors also offer retentive variants, such as Rockwell RTO and Siemens TONR, that keep accumulated time.

What is double-coil syndrome in PLC ladder logic?

Double-coil syndrome happens when two plain output coils write the same bit on different rungs. Because the PLC executes rungs sequentially, the last rung to execute determines the final value written to the output image. The online view can show the first rung energised while the physical output stays off, which misleads troubleshooting. The fix is to give each bit a single writer: combine the conditions into one rung, or use a documented set/reset pair. Many programming tools can flag duplicate destructive writes in their verification or cross-reference views.

Is ladder logic still used in 2026, or should I learn Structured Text?

Ladder Diagram remains part of IEC 61131-3:2025 and is still widely used for discrete machine control, interlocks and anything maintenance technicians must troubleshoot online. Structured Text is better for arithmetic, loops, arrays, strings and complex algorithms, and SFC is better for step-based sequences. Most modern projects mix languages within one controller. Learn ladder for reading existing plants and for boolean device logic, and learn ST for everything that looks like conventional programming. The execution model, scan behaviour and data semantics are shared, so the skills transfer directly.

Further Reading

By Riju — about

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *