Skip to content
Tutorials Center
My learning

Topics

Lesson 9 of 37 ยท Ladder Logic

Ladder Logic Basics

Learn ladder logic from scratch: power rails, rungs, normally open and normally closed contacts, coils, power flow and how a rung is solved, with a runnable C ladder simulator.

Ladder logic (LD, Ladder Diagram) is the most widely used PLC language. It looks like an electrical relay schematic turned on its side: two vertical power rails, with horizontal rungs between them. Electricians and technicians can read it without learning a programming language, which is why it dominates discrete machine control.

In this lesson you will learn the symbols, how a rung is evaluated using the idea of power flow, and how to read simple rungs. The real ladder editor is not available on this site, so the runnable examples are C programs that solve rungs the same way a PLC does.

Rails, rungs and power flow

TEXT
|                                          |
|--[ Start ]------[ Guard ]------( Motor )--|
|                                          |

The left rail is "power". Imagine current flowing left to right along the rung. If the contacts along the path are all true, the power reaches the coil on the right and the coil turns on. If any contact on the path is false, power is blocked and the coil is off.

Nothing really flows. The PLC evaluates each rung with logic: Motor = Start AND Guard. The picture is only a way of thinking.

Ladder building blocks

Contact A condition: is a bit on?
Coil An action: set a bit
Rung Contacts then a coil

Solved left to right, top to bottom

1 / 2

Contacts

A contact asks a question about a bit.

Symbol Name Passes power when the bit is...
--[ ]-- Examine-if-on, normally open (NO) 1 (true)
--[/]-- Examine-if-off, normally closed (NC) 0 (false)

An NO contact in the program is not the same as an NO button. The contact examines a bit: if the bit is 1, the contact is closed. A normally-closed stop button gives a 1 at rest, so in the program you use an NO contact (--[ ]--) for it, and the rung drops out when the button is pressed. Beginners often reverse this; see the wiring lesson.

Coils

A coil writes the result of the rung to a bit.

Symbol Name Action
--( )-- Output coil Bit = rung power (set when true, cleared when false)
--(/)-- Negated coil Bit = NOT rung power
--(S)-- Set (latch) Sets the bit to 1 and keeps it
--(R)-- Reset (unlatch) Clears the bit to 0

A plain output coil follows the rung every scan, which is the easiest to reason about. Set and reset are covered in latching and seal-in.

Solving a rung

The PLC solves a rung left to right. Each contact ANDs its state into the "power" value; the coil receives the result.

C Stand-in: solve one rung like a PLC (C)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

Only one row turns the motor on: Start pressed and no fault.

Reading a ladder program

A program is a list of rungs, run in order each scan (see the scan cycle). Each rung is usually one idea. Rung comments explain it:

TEXT
Rung 1: Run permissive.
|--[ Guard_Closed ]--[ E_Stop_Ok ]--[/ Overload ]----------( Ready )--|

Rung 2: Motor runs when ready and the start command is on.
|--[ Ready ]--[ Start_Cmd ]---------------------------------( Motor )--|

Rung 1 builds a permissive (all conditions required to run), and rung 2 uses it. Splitting logic like this keeps rungs short and troubleshooting easy: you can see at once which condition is missing.

C Stand-in: two rungs, run in order each scan (C)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

Branches: OR in ladder

When two paths to the same coil exist, the rung has a branch:

TEXT
|--+--[ Start_Local ]--+--[ Guard ]--( Motor )--|
|  |                   |
|  +--[ Start_Remote ]-+

Power reaches the coil if either start path is true AND the guard is closed. Branches are the topic of AND, OR and NOT in ladder.

Good ladder style

  • One output coil per bit; no double coils.
  • Put contacts that must be true on the left, the coil on the far right.
  • Use descriptive tags (see tags and naming).
  • Keep rungs simple; add a comment to each.

When a machine does not run, go online, find the rung of the output that should be on, and look for the first contact that is not highlighted. That is your answer more often than you would expect.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. In ladder logic, when does a coil turn on?

    A coil is driven by the power flow, i.e. the logical result of the rung.
  2. 2. What state of its bit makes a normally-closed contact (--[/]--) pass power?

    An examine-if-off contact passes when the bit is 0.
  3. 3. In what order does the PLC solve a rung?

    Contacts are evaluated from the left rail toward the coil.
  4. 4. Why split a large condition into a 'permissive' rung and a use rung?

    Short, well-named rungs are much easier to read and troubleshoot.

Summary

  • Ladder has two rails and rungs; contacts test bits, coils write bits.
  • A rung is solved left to right; power flow is just a logic picture.
  • NO and NC contacts examine bits, not physical wiring.
  • Write short, commented rungs with one coil per output.

Next: AND, OR and NOT in Ladder