Ladder logic is the most widely used programming language for PLCs (Programmable Logic Controllers). If you work in industrial automation — or plan to — understanding ladder logic is the single most important skill you can develop. This guide explains what it is, where it came from, and how to start writing it.
What is Ladder Logic?
Ladder logic (LD) is a graphical programming language defined in the IEC 61131-3 standard. It represents program logic as a series of horizontal "rungs" on a vertical pair of power rails — visually resembling a ladder, hence the name.
Each rung defines a logical relationship between inputs (contacts) on the left and outputs (coils) on the right. When the conditions on a rung evaluate to TRUE, the output energizes. When they evaluate to FALSE, it de-energizes. The PLC scans all rungs from top to bottom, left to right, in a continuous cycle — typically every 1–20 milliseconds.
Where Did Ladder Logic Come From?
Before PLCs existed, industrial control systems were built entirely from physical relays, timers, and hardwired contacts. Electricians would design "relay ladder diagrams" — schematics that showed how power flowed from one rail through a series of relay contacts to energize a coil on the other rail.
When Dick Morley and his team at Bedford Associates built the first PLC (the Modicon 084) in 1968, they faced a practical problem: electricians and maintenance technicians already understood relay logic. Teaching them a text-based programming language would have been a non-starter. So they designed a programming interface that looked exactly like the relay diagrams these engineers already knew — ladder logic.
This heritage is why ladder logic remains dominant in discrete manufacturing, packaging, material handling, and any application where maintenance electricians need to troubleshoot logic on the plant floor. It maps directly to how they already think about control circuits.
How Rungs Work
A ladder logic program consists of rungs strung between two vertical power rails. The left rail represents the power source (L1), and the right rail represents the return (L2/neutral). Power "flows" from left to right through each rung.
Left Rail Right Rail
| |
|---[ START ]---[/ STOP ]---( MOTOR )---|
| |
|---[ SENSOR_A ]---[ SENSOR_B ]---( Y )---|
| |In the diagram above, the first rung reads: "IF START is closed AND STOP is not pressed, THEN energize MOTOR." The second rung reads: "IF SENSOR_A is active AND SENSOR_B is active, THEN energize output Y."
Contacts in series form AND logic — all must be true. Contacts in parallel (branched paths) form OR logic — any one path being true energizes the output. This maps directly to how physical relay circuits work: series wiring requires all switches closed, parallel wiring requires any one closed.
Basic Elements
Every ladder logic program is built from a small set of fundamental elements:
Normally Open (NO) Contact — [ ]
Passes power when its associated variable is TRUE (1). Think of it as a pushbutton that connects the circuit when pressed. In a relay diagram, this represents a contact that is open at rest and closes when its coil is energized.
Normally Closed (NC) Contact — [/]
Passes power when its associated variable is FALSE (0). This is the opposite: it conducts by default and breaks the circuit when its coil energizes. Emergency stops and safety interlocks commonly use NC contacts — if a wire breaks, the circuit opens and the system shuts down safely.
Coil — ( )
The output element. When power reaches a coil, its associated variable becomes TRUE. When power flow is interrupted, the variable becomes FALSE. A coil can drive a physical output (motor contactor, solenoid valve) or an internal memory bit used in other rungs.
Timer (TON / TOF / TP)
TON (Timer On-Delay) starts counting when its input goes TRUE and energizes its output after the preset time elapses. TOF (Timer Off-Delay) keeps the output energized for a set time after the input drops. TP (Pulse Timer) produces a fixed-duration pulse regardless of how long the input remains active. Timers are essential for debouncing, sequencing, and motor startup delays.
Counter (CTU / CTD / CTUD)
CTU (Count Up) increments on each rising edge of its input and sets a done bit when the count reaches its preset value. CTD (Count Down) decrements. CTUD counts both directions. Counters handle batch counting, event tracking, and part-per-cycle monitoring.
Example: Motor Start/Stop Circuit
The most fundamental ladder logic pattern is the seal-in (or latch) circuit for motor control. This replicates the behavior of a physical 3-wire start/stop station:
| | |---[ START_PB ]---[/ STOP_PB ]---( MOTOR )---| | | | |---[ MOTOR ]------| | | |
How it works: Pressing START_PB completes the rung and energizes MOTOR. The parallel branch below (the "seal-in" contact) uses the MOTOR bit itself as a NO contact — once MOTOR turns on, it keeps itself energized even after you release the start button. Pressing STOP_PB opens the NC contact, breaking the circuit and de-energizing MOTOR. The seal-in contact then opens too, and the motor stays off until START is pressed again.
This pattern is so universal that experienced PLC programmers can draw it from memory. It directly mirrors how a physical motor starter with a holding contact works.
Example: Conveyor Control with Sensor
Here is a slightly more complex example — a conveyor that runs when enabled, stops when a part is detected at the end, and counts parts:
| | |---[ ENABLE ]---[/ PART_AT_END ]---( CONV_RUN )----| | | |---[ PART_AT_END ]---[CTU PART_CNT, PV=100]--------| | | |---[ PART_CNT.DN ]---( BATCH_DONE )----------------| | |
Rung 1: The conveyor runs when ENABLE is true and no part is at the end sensor. Rung 2: Each time a part arrives at the sensor, the counter increments. Rung 3: When the count reaches 100, the BATCH_DONE bit energizes, which could trigger an alarm, signal an HMI, or stop the line.
When to Use Ladder Logic vs. Other Languages
IEC 61131-3 defines five PLC programming languages. Ladder logic excels in some contexts but not all:
- Use Ladder Logic (LD) when programming discrete (on/off) control, motor circuits, interlocks, and safety logic. It is ideal when maintenance electricians need to troubleshoot the code, and for applications that map naturally to relay circuits.
- Use Structured Text (ST) for math-heavy operations, PID loops, data manipulation, string processing, and complex algorithms. ST is far more readable than trying to do arithmetic in ladder.
- Use Function Block Diagram (FBD) for analog signal processing, continuous control, and reusable logic blocks. FBD excels at showing data flow between processing stages.
- Use Sequential Function Chart (SFC) for multi-step sequences with defined states and transitions — batch processes, machine startup routines, CIP (clean-in-place) cycles.
- Use Instruction List (IL) — actually, don't. IL is deprecated in the 3rd edition of IEC 61131-3 and has no advantages over the other languages.
In practice, most real PLC programs use a mix. Motor control and I/O mapping in ladder, PID and calculations in structured text, and high-level sequencing in SFC. The best engineers pick the right language for each task rather than forcing everything into one paradigm.
Getting Started with Plaxio's LD Editor
Traditional ladder logic editors are locked behind expensive vendor software — Rockwell's Studio 5000 costs thousands per seat, and even free options like OpenPLC lack modern developer ergonomics. Plaxio changes that.
Plaxio's ladder diagram editor is built into a full IDE with version control, AI-assisted development, and multi-language support. You can:
- Draw ladder rungs with a visual editor — drag contacts and coils, wire them together
- Simulate logic in real-time without hardware
- Export to IEC 61131-3 compliant formats for deployment to real PLCs
- Use AI to generate ladder logic from natural language descriptions
- Track changes with Git — see who modified which rung and when
Whether you are a controls engineer moving away from expensive vendor tools or a software developer entering the automation space, Plaxio gives you a modern environment to write, test, and deploy ladder logic.
Start writing ladder logic today
Download Plaxio and build your first ladder diagram in minutes — no license fees, no vendor lock-in.
Download Plaxio Free