Popular plc programmingladder logicPLC tutorial for beginnersIEC 61131-3industrial automationPLC timers
Lesson 6 of 12

Ladder logic basics: contacts, coils, AND, OR and NOT

In this lesson
  • The parts of a rung: rails, contacts and coils
  • How series, parallel and NC contacts give AND, OR and NOT
  • Why the program contact type is not the same as the field contact type
  • Good habits for readable rungs

Ladder logic is called that because the program looks like a ladder: two vertical rails on the left and right, and horizontal rungs between them. Think of the left rail as +24 V and the right rail as 0 V. If the PLC can find a path of closed contacts from left to right, “power” flows and the coil at the end of the rung turns on.

Of course no real current flows. The CPU is evaluating logic. But imagining power flow is exactly how you read a rung.

The three instructions you will use most

SymbolNameAllen-BradleyMitsubishi ILPasses power when
--| |--Normally open contactXIC (examine if closed)LD / AND / ORThe bit is 1 (true)
--|/|--Normally closed contactXIO (examine if open)LDI / ANI / ORIThe bit is 0 (false)
--( )--Output coilOTE (output energise)OUTSets its bit to 1 when the rung is true, 0 when false

AND: contacts in series

The motor may run only if the guard is closed and the run switch is on:

LD   X0      ; RUN switch
AND  X1      ; GUARD closed
OUT  Y0      ; MOTOR

Both contacts must pass power for the coil to turn on.

OR: contacts in parallel

The lamp turns on from either of two buttons:

LD   X0      ; Button A
OR   X1      ; Button B
OUT  Y0      ; LAMP

Either branch can carry power to the coil.

NOT: the normally closed contact

A normally closed contact passes power when its bit is off. “Run the fan while the over-temperature switch is NOT active”:

LDI  X2      ; NOT over-temperature
OUT  Y1      ; FAN

Truth table

X0X1X0 AND X1X0 OR X1NOT X0
00001
01011
10010
11110

The idea that clears up NO and NC

This catches out almost everyone. A program contact does not care how the field device is wired. It only asks: “is this bit 1 or 0 right now?”

Take a red stop button wired normally closed (as it should be, see lesson 4). When nobody is touching it, current flows and input X1 is 1. When someone presses it, the circuit opens and X1 becomes 0.

So to let the motor run while the stop button is not pressed, you use a normally open program contact on X1. It passes power while X1 is 1, which is while the button is released. Press the button, X1 drops to 0, the contact opens and the motor stops.

Ask “what is the bit?”, never “what is the button?” Look at the input LED: lit means 1. Then choose the program contact that passes power for the state you want. Field NC stop button → program NO contact. If you used an NC program contact on an NC-wired stop button, the motor could only run while someone held stop down.

In the Ladder Lab, STOP is simulated as a button that makes its input 1 while pressed (a normally open stop button), so the program uses an NC contact !X1. Same machine behaviour, opposite contact, because the wiring is the opposite. Try it:

Start / stop with seal-in RUN
Program listing (IL)
LD   X0
OR   Y0
ANI  X1
OUT  Y0

Combining logic

Real rungs mix series and parallel. “Run if (local start OR remote start) AND NOT fault”:

LD   X0      ; Local start
OR   X3      ; Remote start
ANI  M10     ; NOT fault
OUT  Y0      ; MOTOR

Habits that make programs readable

  • One output coil per bit, written once.
  • Keep rungs short. If a rung does three jobs, split it into three rungs with internal bits.
  • Put conditions that must always be true (stops, faults, permissives) in a consistent place, usually right before the coil.
  • Comment every rung with what it does on the machine, not what the symbols are.

Frequently asked questions

What is the difference between XIC and XIO?

XIC (examine if closed) passes power when its bit is 1. XIO (examine if open) passes power when its bit is 0. They are Allen-Bradley names for the normally open and normally closed program contacts.

Should a stop button use an NC contact in the program?

It depends on the wiring. A stop button wired normally closed (the usual, fail-safe way) makes the input 1 when released, so you use a normally open program contact. Always check the input LED state.

Knowledge check

Check your understanding

4 questions. Your best score is saved on this device.

1Two contacts in series give which logic function?
2A stop button is wired normally closed to input X1. Which program contact lets the motor run while stop is not pressed?
3In Mitsubishi instruction list, what does ANI mean?
4When does an output coil (OTE / OUT) turn its bit off?