Ladder Logic in Practice

Contacts and coils, seal-in and interlock circuits, one-shots and latches, with the same rung shown on several platforms.

How to read a rung

Ladder logic is drawn like a relay panel. Two vertical rails run down the sides, power conceptually flows from the left rail to the right, and each horizontal rung is a circuit. Contacts on the left are conditions (an input, a flag, a timer’s done bit). The coil at the right is the result: an output or an internal bit. If a path of true contacts connects the left rail to the coil, the coil turns on.

SymbolNameTrue whenExamples
──┤ ├──Normally open (NO) contactits bit is 1Allen-Bradley XIC, Siemens normally open, Mitsubishi LD
──┤/├──Normally closed (NC) contactits bit is 0XIO, normally closed, LDI
──( )──Output coilsets its bit to the rung’s result (true or false)OTE, coil, OUT
──(L)──, ──(U)──Latch (set) and unlatch (reset) coilsa true rung sets or clears the bit and it staysOTL and OTU, SET and RST
──┤P├──Rising-edge contacttrue for one scan when its bit goes 0 to 1ONS or OSR, P_TRIG, PLS, DIFU
BoxesTimers, counters, compare, mathdepends on the instructionTON, CTU, GEQ, ADD

The contact is a test of a bit, not a physical contact. An NC contact on a start button tag does not mean the button is wired normally closed; it means “true while the tag is 0”. When a field device is wired normally closed (a stop button, an overload), its input is on when healthy, so the program usually uses a normally open contact for it. This catches many beginners.

Boolean logic in ladder

LogicLadder formResult is true when
ANDTwo contacts in seriesA and B are both true
ORTwo contacts in parallelA or B (or both) is true
NOTOne NC contactA is false
NANDTwo NC contacts in parallelA or B is false
NORTwo NC contacts in seriesA and B are both false
XORA with NOT B in one branch, NOT A with B in a parallel branchA and B differ

Start/stop with a seal-in

The most important rung in industrial control. Pressing Start turns the motor output on. The motor’s own contact in parallel with Start then holds the rung true (“seals in”) after the button is released. Stop, an overload trip or an emergency-stop status breaks the series path and drops the rung out.

Rung 1: start/stop with seal-in (stop and overload are wired normally closed, so they are true when healthy)Start_PBI0.0Motor_RunQ0.0Stop_OKI0.1Overload_OKI0.2EStop_OKI0.3Motor_RunQ0.0Rung 2: run lamp follows the motor outputMotor_RunQ0.0Run_LampQ0.1
A seal-in rung with stop, overload and emergency-stop status contacts, and a second rung that lights a run lamp.
  • Stop dominates. Because Stop is in series, pressing both Start and Stop leaves the motor off. If you must let Start win (rare), place the seal-in in a different position and think hard about it.
  • Wire stops and overloads normally closed in the field. A broken wire or a pressed button then reads as “stop”. In the program they appear as normally open contacts (true while healthy), as in the figure.
  • Seal with the output, not the input. Using the real output bit (or a feedback contact from the contactor) proves that the motor actually started. A seal-in on an internal bit would stay on even if the contactor did not pull in.
  • Restart after a power loss. A seal-in on a non-retentive output drops out at power loss, so the motor does not restart unexpectedly when power returns. If an output is on a retentive bit, the machine can start without warning.
  • Emergency stops are not PLC logic. The e-stop must cut power to the motor by itself, in hardware; the PLC input only reports its state. See PLC Troubleshooting, Safety and Documentation.

Worked example: tracing the rung, step by step

  • Idle: Start_PB off, Motor_Run off. Stop_OK, Overload_OK and EStop_OK are all on (healthy). The branch is false, so the rung is false and Motor_Run is off.
  • Press Start: Start_PB turns on. The branch becomes true and the series contacts are all true, so Motor_Run turns on in that scan.
  • Release Start: Start_PB turns off, but Motor_Run is now on, so the parallel contact keeps the branch true. The motor continues to run.
  • Press Stop: the Stop input turns off (its NC button opens), the Stop_OK contact goes false, the rung is false and Motor_Run turns off. Releasing Stop does not restart it, because the seal-in branch is no longer true.
  • Overload trips: Overload_OK goes false and the motor stops, exactly like Stop.

Interlocks: forward and reverse

An interlock stops two outputs that must never be on together (forward and reverse contactors, which would short the supply; a valve opening against a closed pump). The standard method is to put a normally closed contact of each output in the other’s rung.

Forward: runs only if reverse is off, with its own seal-inFwd_PBI0.0FwdQ0.0Stop_OKI0.2RevQ0.1FwdQ0.0Reverse: runs only if forward is offRev_PBI0.1RevQ0.1Stop_OKI0.2FwdQ0.0RevQ0.1
Forward and reverse with software interlocks: each rung contains a normally closed contact of the opposite output.
  • Software interlocks are not enough for power circuits. Add a hardwired mechanical interlock between the two contactors, or an electrical interlock with their auxiliary contacts, so that a failed output or a welded contactor cannot short the supply.
  • Reversing delay. Allow time for the motor to stop before reversing, with an off-delay or a state machine; reversing a spinning motor stresses the drive and the mechanics.
  • Priority. The first rung to turn on wins and blocks the other; to change direction, press Stop first (as in the figure).

Latch, unlatch and one-shots

Latch the alarm (set), clear it with Acknowledge only when the fault is goneOvertempI0.4LAlarmM0.0Ack_PBI0.5OvertempI0.4UAlarmM0.0One button on/off (toggle): the first press with the light off sets it…PToggle_PBI0.6LightQ0.2Set_LightM0.1…and the first press with the light on clears itPToggle_PBI0.6LightQ0.2Clr_LightM0.2Set_LightM0.1LightQ0.2Clr_LightM0.2LightQ0.2
A latched alarm with set and reset coils, and a one-button on/off toggle built from one-shot contacts.
ApproachHow it worksUse it forBeware
Seal-in rungThe output holds itself with its own contactMotors, pumps, states that should drop out on power lossNone special: the usual choice
Latch/unlatch (OTL/OTU, SET/RST)A pulse sets the bit; another pulse clears itAlarms that need acknowledgment, remembered faults, mode flagsThe bit holds through a power cycle if it is retentive; the last instruction in the scan wins
One-shot contact (P)True for one scan on a 0 to 1 changeCounting, logging, toggling, starting a sequence onceDo not use a one-shot on a bit written only later in the scan
  • Clear a latched alarm only when the cause is gone. The reset rung in the figure requires both Ack and the fault input to be off.
  • Latch and unlatch the same bit from one place (or one routine); spread over the program, it becomes impossible to know what will happen.
  • Retentive alarms and modes after a power cut need a deliberate decision: clear them at start-up, or keep them.

One button on and off

To turn a light or a mode on with the first press and off with the second, you need an edge. Without it, the bit would toggle every scan while the button is held. The pattern in the figure uses a one-shot contact on the button together with the state of the output: the first press with the light off sets Set_Light for one scan; the first press with the light on sets Clr_Light for one scan; a seal-in rung then sets or clears the light.

  • In structured text it is shorter: IF Toggle_Edge THEN Light := NOT Light; END_IF; where Toggle_Edge is the one-shot of the button.
  • On hardware, debounce the button (a 20–50 ms on-delay timer, or the input filter) so that contact bounce does not toggle it twice.
  • Some platforms have a toggle or flip-flop instruction (for example the Mitsubishi ALT instruction).

Several start and stop stations

Machines with more than one operator position follow a simple rule: Starts go in parallel (OR), stops go in series (AND). Any start button can start the machine; any stop (wired normally closed) stops it.

  • Parallel starts: (Start_A OR Start_B OR Motor_Run).
  • Series stops: Stop_A_OK AND Stop_B_OK AND EStop_OK.
  • In structured text: Motor_Run := (Start_A OR Start_B OR Motor_Run) AND Stop_A_OK AND Stop_B_OK AND EStop_OK;
  • Jog (run only while a button is held): put the jog button in a separate rung that drives the output, ORed with the seal-in rung, and be sure it cannot defeat an interlock.
  • Permissives. Conditions that must be true before starting (guard closed, oil pressure OK, upstream machine running) go in series with the Start branch but not necessarily with the seal-in, depending on whether they should stop a running machine.

Worked example: a pump with a low-level permissive and a running trip

  • Permissive to start: the tank level must be above LS_Low. Start only works if LS_Low is true.
  • Trip while running: if the level falls to LS_LowLow, the pump stops and a fault is latched.
  • Logic: Pump := ((Start AND LS_Low) OR Pump) AND LS_LowLow_OK AND Stop_OK; (LS_Low is true above the low mark; it can drop while running without stopping the pump, but LS_LowLow_OK falling stops it).
  • Fault latch: a set coil on NOT LS_LowLow_OK, a reset on Ack when the level is back.

Instruction names by platform

FunctionAllen-Bradley LogixSiemens S7-1200Mitsubishi FX/iQ-FOmron CP1IDEC FC6A
NO contactXIC——| |——LD, AND, ORLD, AND, ORLOD, AND, OR
NC contactXIO——|/|——LDI, ANI, ORILD NOT, AND NOTLODN, ANDN, ORN
Output coilOTE——( )OUTOUTOUT
Latch / unlatchOTL / OTUS / R (SET_BF, RESET_BF)SET / RSTSET / RSETSET / RST
Rising edgeONS, OSRP contact, P_TRIGLDP, PLSDIFUSOTU
Falling edgeOSFN contact, N_TRIGLDF, PLFDIFDSOTD
On-delay timerTONTONOUT T (K value)TIMTIM
Up counterCTUCTUOUT C (K value)CNTCNT

Names, edge instructions and timer units vary between models and software versions. Confirm in your manual; the ideas stay the same.

How the scan changes what you see

  • One coil per output. If two rungs write the same coil, the last rung in the scan wins and the other is silently ignored. Many programming tools warn about a double coil; heed it.
  • Rung order matters. A rung placed after the one that sets a bit sees the new value in the same scan; a rung placed before sees it one scan late.
  • The input image is frozen for the scan. A button pressed during a scan does not change the program’s view until the next scan.
  • Edges are per scan. A one-shot is true for exactly one scan, so any logic that depends on it must be in the same scan, or the pulse must be stored.
  • Outputs update at the end of the scan. Turning an output on and off in the same scan produces nothing at the terminal.
  • Latch bits and seal-ins are evaluated in order; a reset placed after a set cancels it in the same scan.

Good ladder style

  • Name every tag clearly and comment the rung with what it does and why.
  • One idea per rung. A rung that does many things is hard to follow and to fix.
  • Put the conditions on the left and the result on the right, and keep rungs short enough to read on a laptop without scrolling.
  • Group by function: inputs and conditioning, interlocks, sequences, outputs, alarms.
  • Avoid unlatched states that depend on rung order. Prefer a seal-in for state that should drop out, and a state machine for sequences (see Sequences and State Machines).
  • Use the cross-reference. Before changing an output, check every rung that writes it.
  • Test off-line in a simulator, then on the machine with the load disconnected.

Related

FAQ

Why does my motor not stop when I press Stop?

The Stop input may not be wired normally closed, so the program test is the wrong way round, or the output is also written by another rung, or the seal-in uses a different tag. Go online and watch the rung while pressing the button.

What is a seal-in?

A contact of the output in parallel with the Start button, so that the rung stays true after Start is released. It is the software version of a relay holding itself on through its own contact.

Should I use latch and unlatch or a seal-in?

Use a seal-in for things that should stop at power loss or on a fault. Use latch and unlatch for alarms and modes that must be remembered until someone resets them.

Why is my one-shot not firing?

The one-shot stores the previous scan’s state; if the input bit is written after the one-shot in the scan, or if the rung is skipped (a jump or a disabled routine), the one-shot may miss the edge. Put the one-shot after the input conditioning and keep it in a routine that runs every scan.

Can I write ladder on any PLC?

Almost every PLC supports ladder diagram, though the symbols and instruction sets differ. Concepts such as contacts, coils, timers and counters carry over directly.

References

  • IEC 61131-3, Programmable controllers, Part 3: Programming languages (ladder diagram).
  • Rockwell Automation, Logix 5000 Controllers General Instructions Reference Manual (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF).
  • Siemens, S7-1200 System Manual (bit logic operations, edge detection).
  • Mitsubishi Electric, MELSEC iQ-F FX5 Programming Manual (Instructions); Omron, CP1 Instructions Reference Manual; IDEC, FC6A Series User’s Manual.
  • Petruzella, F., Programmable Logic Controllers, McGraw-Hill.

Last reviewed: October 2026. Instruction names, addresses and data sizes differ by manufacturer: confirm against your controller’s manual, and keep safety functions independent of standard PLC logic.