Learn ladder logic
Free lessons that take you from your first contact and coil to timers, counters and complete machine programs. Each one explains how the instruction behaves on a real PLC, and you can try every example in the Playground, right in your browser.
New to PLCs? Read the Getting started lessons in order. They cover what ladder logic is, how a PLC scans a program, and how to build AND, OR and NOT conditions. The Instructions section is a reference you can come back to whenever you meet an instruction you don't know. The Tutorials put it all together: each one builds a working program for a simulated machine, one rung at a time.
Getting started
- What is ladder logic?A beginner's introduction to ladder logic: rails, rungs, contacts and coils, and why PLC programmers still draw programs like relay wiring diagrams.
- How a PLC scan cycle worksRead inputs, solve the rungs top to bottom, write outputs, repeat. How the PLC scan works and why rung order matters in ladder logic.
- Tags and data types (BOOL, DINT, REAL, TIMER, COUNTER)What PLC tags are, the five data types you can use (BOOL, DINT, REAL, TIMER and COUNTER), and how to read timer and counter bits like T1.DN.
- AND, OR and NOT in ladder logicHow series contacts make AND logic, parallel branches make OR logic, and XIO makes NOT, with truth tables and ladder examples.
Instructions
- XIC and XIO: Examine If Closed and Examine If OpenHow the XIC (normally open) and XIO (normally closed) contact instructions work, the classic stop-button confusion explained, and examples.
- OTE: Output EnergizeHow the OTE coil instruction works, why you should only write each OTE tag once, and how outputs are seen by later rungs in the same scan.
- OTL and OTU: Latch and UnlatchHow the OTL (latch) and OTU (unlatch) instructions work as set/reset logic, when to use them instead of a seal-in, and the pitfalls to avoid.
- TON: Timer On DelayHow the TON timer works: preset, accumulator and the EN, TT and DN bits, with timing examples for delays, debouncing and sequences.
- TOF: Timer Off DelayHow the TOF off-delay timer keeps its DN bit on for a set time after the rung goes false, with run-on fan and cooldown examples.
- RTO: Retentive Timer OnHow the RTO retentive timer keeps its accumulated time when the rung goes false, how to reset it with RES, and run-hour examples.
- CTU and CTD: Count Up and Count DownHow the CTU and CTD counter instructions count rising edges, how DN, CU and CD work, and how to track parts in and out with one counter.
- RES: Reset timers and countersHow the RES instruction clears a timer or counter's accumulator and done bit, and common ways to wire a reset.
- ONS, OSR and OSF: One-shot instructionsHow one-shot instructions turn a held button or sensor into a single-scan pulse, and the difference between ONS, OSR and OSF.
- Compare instructions: EQ, NE, LT, GT, LE, GE, LIMIT and CMPHow ladder logic compare instructions test numbers, including the LIMIT band test and CMP expressions, with practical examples.
- Math and move instructions: ADD, SUB, MUL, DIV, CPT and MOVHow math and move instructions calculate and copy values in ladder logic, integer versus REAL results, and the CPT expression instruction.
Tutorials
- Tutorial: the start/stop seal-in circuitBuild the most important circuit in ladder logic, the three-wire start/stop motor control with a seal-in contact, step by step.
- Tutorial: count boxes on a conveyor with a photo eyeUse a photo eye, a CTU counter and a RES to count boxes on a conveyor and stop the line when a batch is complete.
- Tutorial: program a traffic light sequence with timersProgram a two-way traffic intersection with TON timers: green, yellow and all-red phases, and why the all-red gap matters.
The best way to learn ladder logic is to write some. Open the Playground, add a rung and press Run.
Open the Playground