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
| Symbol | Name | Allen-Bradley | Mitsubishi IL | Passes power when |
|---|---|---|---|---|
--| |-- | Normally open contact | XIC (examine if closed) | LD / AND / OR | The bit is 1 (true) |
--|/|-- | Normally closed contact | XIO (examine if open) | LDI / ANI / ORI | The bit is 0 (false) |
--( )-- | Output coil | OTE (output energise) | OUT | Sets 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
| X0 | X1 | X0 AND X1 | X0 OR X1 | NOT X0 |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 |
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:
Program listing (IL)
LD X0
OR Y0
ANI X1
OUT Y0Combining 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.
