What Is Ladder Logic?
Ladder logic is a PLC programming language that represents electrical relay circuits as horizontal rungs on a ladder. Each rung has inputs on the left (conditions) and outputs on the right (actions). When all input conditions are true, the output energizes. That's the entire mental model — everything else is variations on this. In our testing with hundreds of real programs, this simple concept covers 90% of what you'll encounter in production.
The name comes from the visual similarity to an actual electrical ladder diagram. Two vertical lines (power rails) run left and right, with horizontal rungs connecting them. Current flows down the left rail, through the logic on the rung, and if allowed, to the output coil on the right. Understanding this power-flow metaphor is the key to reading ladder logic fluently.
Before You Start: What You Need to Know
Electrical concepts help, but they're not required. Ladder logic uses relay logic as a teaching analogy, but you can learn it as pure logic — if this, then that. Here's what you should understand before we continue:
- Basic If/Then Logic — If condition A is true, then action B happens. That's ladder logic.
- Boolean Algebra (AND / OR) — AND means all conditions must be true. OR means any condition can be true. Ladder logic uses these constantly.
- Reading Electrical Diagrams — Helpful but not required. We'll explain every concept as we go.
- How to Research When Stuck — PLC programs are often cryptic. Learn to read documentation, cross-reference tags, and ask for help from experienced technicians. That skill matters more than any single instruction.
Lesson 1: The Rung
A rung is one logical statement. Think of it like a sentence in English. The left side contains input conditions (contacts), the right side contains the output (coil), and the power rails on far left and right complete the circuit. Here's how to read a rung:
- Start at the left side of the rung.
- Read all input conditions from left to right.
- If all conditions allow power to flow, the output on the right energizes.
- The coil on the right is the action that happens.
As an if/then statement: If [all input conditions are true], then [output energizes]. The PLC checks every rung during each scan cycle. If the conditions are true on scan 1, the output is on during scan 1 — then the PLC moves to the next rung.
Lesson 2: Contacts and Coils
Contacts and coils are the fundamental building blocks. Understanding these four instructions unlocks 80% of what you'll encounter. After parsing thousands of files, we've found these patterns repeat across every plant:
- XIC (Examine If Closed) — Also called a normally open contact. The rung condition is true (allows power to flow) when the tag bit is 1. Think of it as a switch that must be pressed to allow power through. Used when you want to execute an action only when a condition is ON.
- XIO (Examine If Open) — Also called a normally closed contact. The rung condition is true when the tag bit is 0. It's the opposite of XIC: power flows when the condition is OFF. Used for safety interlocks and to prevent actions under certain conditions.
- OTE (Output Energize) — Sets a bit to 1 when the rung conditions are true. When the rung becomes false, the bit is cleared to 0. It's the most common output instruction. Every output energize coil on the right side of a rung is an OTE.
- OTL / OTU (Latch / Unlatch) — OTL sets a bit to 1 and keeps it there (latches) even if the rung condition becomes false. OTU clears the bit back to 0. Used together to create "toggle" behavior or to hold a state across scan cycles. Critical for emergency stop and safety logic.
Lesson 3: Series and Parallel Logic
This is where ladder logic gets powerful. Contacts can be arranged in series or in parallel, and this determines whether the logic behaves as AND or OR.
Series Contacts = AND Logic
When contacts are arranged left to right in a line, they form AND logic. ALL of them must be true for power to flow. Example: to run a machine, BOTH the start button AND the safety guard must be closed. Series arrangement.
Parallel Contacts = OR Logic
When contacts are arranged top and bottom (branching), they form OR logic. ANY of them can be true for power to flow. Example: the machine stops if EITHER the e-stop button is pressed OR the overtemperature sensor triggers. Parallel arrangement.
You can nest series and parallel logic. A series block can be in parallel with another series block. This creates complex conditions. But 90% of real programs use simple series/parallel combinations — start with recognizing these patterns and you'll understand most code you encounter.
Lesson 4: Timers
Timers are specialized instructions that measure elapsed time. They count up (or down) at a fixed rate and trigger outputs when specific time thresholds are crossed. There are three main timer types in Allen-Bradley ladder logic.
- TON (Timer On Delay) — Starts counting when the rung goes true. After the preset time has elapsed, the DN (done) bit sets to 1. When the rung goes false, the timer resets to zero. Use this for "wait 5 seconds then turn on the alarm" scenarios. DN bit is your signal that the delay has finished.
- TOF (Timer Off Delay) — Starts counting when the rung goes false. Delays the turn-off of an output. While the rung is true, DN stays at 1. When the rung becomes false, the timer counts down, and after the preset time, DN goes to 0. Use this for "keep the cooling fan running for 2 minutes after the machine shuts down."
- RTO (Retentive Timer On) — Like TON but the accumulated time persists even if the rung condition becomes false. The accumulated value doesn't reset until a separate RES (reset) instruction fires. Use this to count total runtime across multiple on/off cycles.
All timers have three key parameters: Preset (the target time), Accumulated (how much time has elapsed), and DN (done bit that fires when accumulated equals preset). Understand these three values and you understand timers.
Lesson 5: Counters
Counters work the same way as timers, but they count events instead of time. Every time the rung becomes true, a counter increments. When the count reaches the preset, the DN bit fires.
- CTU (Count Up) — Increments by 1 each time the rung transitions from false to true. When accumulated equals preset, DN sets to 1. Use this to count parts on a conveyor, bottles filled, or items removed from a stack.
- CTD (Count Down) — Decrements by 1 each time the rung transitions from false to true. Start at the preset value, count down. When accumulated reaches 0, DN sets to 1. Use this to count down remaining items from a batch.
- RES (Reset) — Clears a counter or timer back to zero. Accumulated goes to 0, DN goes to 0. Use this to reset a counter after a batch is complete or after an alarm is acknowledged.
Like timers: Preset (target count), Accumulated (how many counted so far), DN (done bit). The two instructions — CTU (up) and CTD (down) — are simpler than timers because they don't care about elapsed time, just transitions.
Lesson 6: How to Read a Real Production Program
Textbook examples are clean and simple. Real production programs are often cryptic, poorly documented, and written by engineers who are long gone. Here's how to approach an unfamiliar program:
- Pick a single output coil you want to understand.
- Find all rungs that reference that coil as an OTE or OTL.
- For each rung, identify all input tags and trace them backward.
- Use the cross-reference tool to see where each input tag originates.
- Build a map: Input → Logic → Output. Repeat until you understand the complete signal path.
Don't try to read the entire program sequentially. Programs aren't linear — they loop, jump, and reference each other. Focus on a single signal path, understand it completely, then move to the next. After parsing thousands of files, we've found this approach works for every program, no matter how cryptic.
Next Steps: Practice with Real Programs
Everything above is the foundation. The real learning happens when you read production code. Theory alone doesn't stick — you need to see patterns repeated in actual programs. Upload an ACD or L5X file from your plant to plc.company. Pick a simple subroutine and trace through it. Don't rush — take time to understand every rung. When you're stuck, use the AI explanations to get unstuck, but try to solve it first.
After reading 50 rungs from real code, you'll start seeing patterns. After 500 rungs, you'll be fast. After 5,000 rungs, you'll be reading unfamiliar programs with confidence. This is how every expert learned — by reading production code, not by studying tutorials. This tutorial is just the map; you build the skill by walking the territory.
Read Real Ladder Logic in Your Browser
Upload your ACD or L5X file and practice reading actual production ladder logic. Trace signals, understand rungs, and master the patterns used by real engineers in real plants.