Ladder logic basics
Ladder logic is the most widely used PLC programming language. It looks like an electrical relay diagram: power flows from the left rail, through contacts, to a coil on the right. If you can read a relay circuit, you can read ladder.
Rails and rungs
A ladder program has two vertical rails and horizontal rungs between them. Each rung is one line of logic: conditions (contacts) on the left, an action (coil or instruction) on the right. The PLC solves rungs from top to bottom on every scan.
Contacts
| Symbol | Name | Passes power when |
|---|---|---|
-| |- | Normally open (NO, XIC, LD) | the bit is 1 (button pressed, sensor on) |
-|/|- | Normally closed (NC, XIO, LDI) | the bit is 0 |
-|P|- / -|↑|- | Rising edge | for one scan when the bit goes 0 → 1 |
-|N|- / -|↓|- | Falling edge | for one scan when the bit goes 1 → 0 |
Important: the contact symbol describes the program, not the field device. A normally closed stop button that is not pressed sends a 1 to the PLC, so in the program you use a normally open contact for it. This confuses almost every beginner.
AND and OR
Contacts in series are AND: all must be closed. Contacts in parallel (a branch) are OR: any one closes the path.
|--[ Guard_closed ]--[ Start ]--------( Motor )--| AND |--[ PB_1 ]--+-------------------------( Lamp )--| OR |--[ PB_2 ]--+
The start/stop seal-in circuit
A momentary start button must keep a motor running after it is released. The output's own contact is placed in parallel with the start button, sealing the rung in:
|--+--[ Start ]--+--[ Stop ]--[ Overload ]--( Motor )--| | +--[ Motor ]--+
Press Start: Motor turns on, and its contact holds the rung on. Press Stop (the NC button opens, the input goes 0): the rung breaks and Motor drops out. Because Stop is in series before the coil, stop always wins.
Set and reset (latch / unlatch)
SET (OTL, S) turns a bit on and leaves it on; RESET (OTU, R) turns it off. They are handy for sequences and alarms, but every SET needs a matching RESET somewhere, and you should not mix OUT and SET/RESET on the same address.
Rules that avoid bugs
- One coil per address. A double coil means only the last rung wins.
- Every rung ends in an output instruction.
- Don't connect a coil straight to the left rail; use an always-ON system bit if you need it.
- Comment every address and rung.
Timers and counters
For delays and counting, see PLC timers and counters.
The PLC Sim Lab Playground has a grid ladder editor (with F-key shortcuts like real software) where you can build and run every circuit on this page.
Watch it in the video tutorial
Starts at 7:10: writing a start/stop ladder rung with a seal-in, step by step. Open on YouTube →
Try it yourself. Wire sensors, contactors and a PLC, write ladder logic and press RUN in the free PLC Sim Lab Playground. Nothing to install.
Open the Playground →Guided lessons →