What is Ladder Logic?
Ladder Logic is a graphical programming language for PLCs in which control logic is drawn as a ladder diagram of contacts and coils between two vertical rails, modelled on classic relay schematics. In the IEC 61131-3 standard the language is officially called Ladder Diagram, abbreviated LD; in practice the terms ladder diagram, ladder logic and LD are used interchangeably. The language is popular in machine building and industrial automation because electricians and maintenance technicians can read the program much like an electrical drawing.
🧠 How does a ladder diagram work?
A ladder diagram consists of two vertical rails with horizontal lines between them, called rungs. The left rail represents the supply, the right rail the return. Each rung holds the conditions (contacts) on the left and the result (a coil or function block) on the right. When the contacts form an unbroken path from left to right, this is called power flow and the coil is energised.
No current actually flows: the PLC works with Boolean values. A contact reads a bit and a coil writes a bit. The PLC runs the program cyclically in a scan cycle:
- Read inputs - the state of all physical inputs is copied into a process image
- Execute logic - rungs are evaluated from top to bottom, and each rung from left to right
- Write outputs - the results are sent to the physical outputs
- Communication and diagnostics - then the next cycle starts
Because the order is fixed, the behaviour is predictable. That deterministic behaviour is a major reason why ladder programs have been trusted for machine control for decades. One consequence of the fixed order is that a bit written lower down in the program only becomes visible to rungs above it in the next scan.
| Element | Function | Equivalent in a relay schematic |
|---|---|---|
| Left rail | Start of every rung, logical “voltage” | Phase or positive of the control supply |
| Right rail | End of every rung | Neutral or negative |
| Rung | One logical line | One circuit |
| Contact | Condition that reads a bit | Auxiliary relay contact or push button |
| Coil | Result that writes a bit | Relay coil, lamp or solenoid valve |
| Function block | Timer, counter, comparator or custom block | Time-delay relay, counter |
🔧 Which symbols and instructions does Ladder Logic use?
IEC 61131-3 defines the basic symbols. Vendors also use their own names: Rockwell Automation refers to instructions such as XIC and OTE in Studio 5000, while Siemens calls the language LAD in TIA Portal (KOP, Kontaktplan, in German).
| Symbol (IEC) | Meaning | Rockwell | Behaviour |
|---|---|---|---|
-[ ]- |
Normally open contact | XIC | Passes power when the bit is 1 |
-[/]- |
Normally closed contact | XIO | Passes power when the bit is 0 |
-[P]- and -[N]- |
Edge detection | ONS and variants | Passes power for one scan on a rising or falling edge |
-( )- |
Coil | OTE | Writes the rung result to the bit |
-(/)- |
Negated coil | no direct equivalent | Writes the inverted result |
-(S)- and -(R)- |
Set and reset coil | OTL and OTU | Latches the bit to 1 or clears it to 0 |
Contacts in series form an AND function, contacts in parallel an OR function, and a normally closed contact a NOT function. Any Boolean expression can be drawn this way. The best-known pattern is the seal-in (self-holding) circuit for a motor:
|----[ Start ]----+----[/ Stop ]----[/ Fault ]----( Motor )----|
| | |
|----[ Motor ]----+ |
Pressing Start energises the Motor coil. The parallel Motor contact then “seals in” the rung, even after the button is released. Stop or Fault breaks the rung and the motor drops out. After a power failure the motor does not restart on its own, which can happen with a set (latch) coil on a retentive bit. That is why the seal-in circuit is the usual choice for motor starters and interlocks.
⏱️ How do you use timers and counters in a ladder diagram?
Besides contacts and coils, LD has function blocks that sit on a rung. The standard blocks from IEC 61131-3 are everyday tools for every ladder programmer:
| Block | Name | Typical use |
|---|---|---|
| TON | On-delay timer | Start a pump only after 5 s of stable pressure, debounce a chattering sensor |
| TOF | Off-delay timer | Keep a fan running for a while after stopping |
| TP | Pulse timer | Fixed-length pulse to a solenoid valve |
| CTU, CTD, CTUD | Up, down and up/down counter | Count products, batch size, maintenance interval |
| Comparators | GT, LT, EQ and related | Alarm when a temperature exceeds its limit |
A TON replaces the time-delay relay in the relay panel: the output only becomes 1 once the input has been 1 continuously for the preset time. Larger programs also use custom function blocks, called Add-On Instructions at Rockwell, so the same logic for ten pumps is not drawn ten times.
Counter values and batch numbers often need to survive a power failure. For this the PLC offers retentive variables, declared in IEC 61131-3 with the RETAIN keyword, which keep their value after a restart. Use this deliberately: it is what you want for a production counter, but not for a start command. The PLC also shares the status of timers, counters and motors via Modbus TCP, IP, PROFINET or OPC UA with HMI, SCADA, the historian and MES, so operators see the same bits as the ladder logic.
🕰️ Where does Ladder Logic come from?
Ladder Logic is a direct legacy of the relay panel. When General Motors asked in 1968 for a reprogrammable replacement for hard-wired relay panels, the new controller had to be understandable for the electricians who maintained the old panels. The language therefore mimicked their relay schematics.
| Year | Event |
|---|---|
| 1968 | General Motors specifies a programmable replacement for relay panels |
| 1969 | The Modicon 084 is delivered and is regarded as the first commercial PLC |
| 1993 | The first edition of IEC 61131-3 standardises LD alongside FBD, ST, IL and SFC |
| 2013 | The third edition adds object-oriented extensions and deprecates IL |
| 2025 | The fourth edition removes IL; LD remains one of the graphical languages |
🔄 How does Ladder Logic differ from other PLC languages?
Besides LD, IEC 61131-3 defines FBD, ST, SFC and, until 2025, IL. Modern environments such as TIA Portal, Studio 5000 and CODESYS let you combine them in one project.
| Language | Form | Strong in | Less suited to |
|---|---|---|---|
| LD (ladder diagram) | Graphical | Discrete switching logic, interlocks, readable for technicians | Calculations, arrays, string and data handling |
| FBD | Graphical | Continuous control, signal processing | Long sequences |
| ST | Text | Algorithms, maths, loops | Quick visual fault-finding by technicians |
| SFC | Graphical | Step sequences and batch processes | Loose Boolean logic |
| IL | Text | Compact code on old systems | New projects (removed) |
A common split is SFC for the order of steps, LD for interlocks and I/O handling, and ST for calculations. Ladder has traditionally been strongest in North America; in Europe FBD and textual code are used widely alongside LD.
🏭 How do you write a maintainable and safe ladder program?
A ladder program is often maintained for twenty years or more, by people other than the original author. These practical rules prevent most problems:
- One coil per output - write a bit in one place only. If the same coil appears in two rungs, the last one wins and the first seems “not to work”
- Wire fail-safe - a stop button is wired as a normally closed contact so that a broken wire causes a stop. In the program that input is 1 at rest and you examine it with a normally open contact. This regularly confuses beginners
- Prefer seal-in over set/reset - use set/reset only for deliberate memory functions, such as holding a fault until the operator acknowledges it
-
Clear tags and comments -
Pump_P101_Startsays more thanB3:0/4; add a line of explanation to every rung - Structure in routines - split per machine section and use function blocks for repeated objects
- Watch the scan time - scan times are usually between a few and a few tens of milliseconds; an overly long scan can miss short pulses
- No emergency stop in standard logic - IEC 60204-1 treats an emergency stop as a safety function that must meet ISO 13849 or IEC 62061; in practice it runs on a safety relay or a certified safety PLC. Standard ladder logic may report the stop, but must not be the only thing that switches off. The same principle applies in the process industry, where safety functions under IEC 61511 run on a separate SIS
| Symptom when fault-finding | Likely cause |
|---|---|
| Output flickers or does not respond | Duplicate coil on the same bit |
| Output chatters on and off rapidly | Bouncing or unstable input; filter it with a TON |
| Machine restarts by itself after a power failure | Latch coil on a retentive bit instead of a seal-in |
| Short sensor pulse is missed | Scan time longer than the pulse; fast input or interrupt needed |
| Stop does not work when a wire comes loose | Stop button wired as a normally open contact |
Fault-finding is where LD shines: in the online view, energised contacts and coils are highlighted, so a technician sees immediately which condition is missing.
🔐 How do you secure ladder programs?
Whoever can change the PLC logic controls what the machine does. Stuxnet showed in 2010 how this goes wrong: the worm injected code into organisation blocks OB1 and OB35 of Siemens S7-315 and S7-417 PLCs and hid those changes by replacing a DLL of the engineering software, so the engineer could not see the manipulated code. The attack therefore ran through the engineering station.
| Measure | Purpose |
|---|---|
| Network Segmentation | Only authorised engineering stations can reach the PLC |
| Version Control | Record and compare every version of the program |
| Online/offline comparison | Detect unplanned changes in the PLC |
| CPU protection and key switch | Block downloads without a password or in RUN mode |
| Change Management | Test and approve changes before they go live |
| Patch Management | Close known vulnerabilities in engineering software and PLC firmware |
| Backup and Logging | Restore quickly and trace afterwards who changed what |
Also use MFA and Application Whitelisting on engineering stations, because that is where the project files live and the software that writes to the PLC runs.
❓ Frequently asked questions
Is Ladder Logic the same as a ladder diagram?
Yes, Ladder Logic and ladder diagram are two names for the same graphical PLC language. IEC 61131-3 uses the name Ladder Diagram with the abbreviation LD. Siemens calls the same language LAD (KOP in German).
Why is it called a ladder diagram?
A ladder diagram is so called because the two vertical rails with horizontal rungs between them look like a ladder. Each rung of that ladder is one logical line with conditions on the left and a result on the right. The form comes straight from the electrical schematics of relay control systems.
Is Ladder Logic still used?
Ladder Logic is still widely used, especially for discrete machine control, interlocks and motor control. The fourth edition of IEC 61131-3 from 2025 keeps LD as a graphical language, while IL has been removed. In modern projects LD is usually combined with ST and SFC.
What is the difference between a normally open and a normally closed contact in LD?
A normally open contact (XIC at Rockwell) passes power in LD when the linked bit is 1. A normally closed contact (XIO) passes power only when the bit is 0. This refers to the bit in the PLC, not to how the physical push button is wired.
Can I program an emergency stop in Ladder Logic?
An emergency stop should not rely solely on standard Ladder Logic, because an ordinary PLC is not certified for safety functions. Use a safety relay or a safety PLC in line with standards such as IEC 60204-1 and ISO 13849; standard ladder logic may still report the emergency stop state. Safety PLCs often support a ladder diagram as well, but within a certified environment.
Is Ladder Logic hard to learn?
Ladder Logic is relatively easy to learn for people with an electrical background, because a ladder diagram resembles a relay schematic. The basics of contacts, coils, timers and counters can be understood in a few days. The hard part is structuring a large program so that it stays clear, maintainable and secure.
📌 In summary
Ladder Logic, officially Ladder Diagram (LD), translates the relay schematic into software: contacts read bits, coils write bits and the PLC executes the rungs in a fixed scan cycle. That makes the language predictable and easy for technicians to read. For calculations and sequences, combining it with ST and SFC is sensible, and emergency stops belong on safety-certified hardware.
Ladder Logic remains the most readable language for switching logic on the shop floor, provided you structure the program well and protect the PLC against unauthorised changes.
