Skip to content
Tutorials Center
My learning

Topics

Lesson 10 of 37 ยท Ladder Logic

AND, OR and NOT Logic in Ladder

Build AND, OR, NOT, NAND, NOR and XOR in ladder logic using series and parallel contacts, check them with truth tables and turn them into practical interlocks.

Almost all control logic is built from three ideas: AND (all conditions required), OR (any condition is enough) and NOT (invert). Ladder logic expresses them with how you arrange contacts: in series, in parallel, or normally closed. Once you can see these shapes, you can read or write almost any rung.

This lesson shows each gate in ladder form, proves them with truth tables you can run, and combines them into realistic conditions.

AND: contacts in series

Contacts in series all must be true.

TEXT
|--[ A ]--[ B ]--( Out )--|        Out = A AND B
A B Out
0 0 0
0 1 0
1 0 0
1 1 1

OR: contacts in parallel

A branch means either path can supply power.

TEXT
|--+--[ A ]--+--( Out )--|          Out = A OR B
|  |         |
|  +--[ B ]--+
A B Out
0 0 0
0 1 1
1 0 1
1 1 1

NOT: normally-closed contact

TEXT
|--[/ A ]--( Out )--|              Out = NOT A

Gates as shapes

Series = AND All must be true
Parallel = OR Any is enough
NC contact = NOT True when bit is 0

Combine them freely

1 / 2
C Stand-in: truth tables for AND, OR, NOT (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.

NAND, NOR and XOR

  • NAND = NOT (A AND B): off only when both are on.
  • NOR = NOT (A OR B): on only when both are off.
  • XOR (exclusive OR): on when exactly one input is on. In ladder you build it with two branches: A AND NOT B in one, NOT A AND B in the other.
TEXT
|--+--[ A ]--[/ B ]--+--( Out )--|     Out = A XOR B
|  |                 |
|  +--[/ A ]--[ B ]--+

XOR is useful for two-position checks, such as "exactly one of the two limit switches is active".

Combining: AND of ORs

Real conditions mix shapes. Example: the pump may run if the level is not low, and either the Auto mode is on with the schedule active, or the Manual switch is on.

TEXT
|--[/ Low_Level ]--+--[ Auto ]--[ Schedule ]--+--( Pump )--|
|                  |                           |
|                  +--[ Manual ]---------------+

Pump = NOT Low_Level AND ((Auto AND Schedule) OR Manual)

C Stand-in: a pump permissive, all combinations (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.

Notice how Low_Level blocks every case, even Manual. That is what a series NC contact in front of a branch does.

De Morgan's laws

Two identities help you simplify and check logic:

  • NOT (A AND B) = (NOT A) OR (NOT B)
  • NOT (A OR B) = (NOT A) AND (NOT B)

A rung that says "stop if either guard is open" can be written as Run = NOT (G1_open OR G2_open) or Run = G1_closed AND G2_closed. Both are the same; the second is usually easier to read.

C Stand-in: proving De Morgan by checking every case (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.

Practical advice

  • Prefer positive logic: name bits for the good condition (Guard_Closed) and use series contacts for permissives.
  • Avoid deeply nested branches; split into several rungs with named intermediate bits.
  • A branch with a contact that appears in both paths can often be simplified.

Next you will learn how a rung can remember its state: latching and seal-in.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which ladder shape implements OR?

    Either parallel path can supply power, so the result is A OR B.
  2. 2. When is an XOR output on?

    XOR is true when the inputs differ.
  3. 3. What does NOT (A OR B) equal?

    De Morgan: the negation of an OR is the AND of the negations.
  4. 4. A series NC contact (Low_Level) in front of a branch means:

    A series contact must be true for any power to reach the branch.

Summary

  • Series contacts are AND, parallel branches are OR, NC contacts are NOT.
  • NAND, NOR and XOR are built from these shapes.
  • Truth tables and De Morgan's laws help you check and simplify rungs.
  • Use named intermediate bits to keep rungs readable.

Next: Latching and Seal-In Circuits