11. Basics of Ladder Logic Programming


0
Categories : PLC Foundations

Ladder Logic is one of the most common PLC programming languages used in industrial automation.

It was designed to look similar to electrical relay control circuits, which makes it easier for electricians, technicians, and controls personnel to understand machine logic.

In simple words:

Ladder Logic is a graphical PLC programming language that uses contacts, coils, rungs, and instructions to control machines.

A ladder program looks like an electrical ladder because it has:

Left rail
Right rail
Horizontal rungs
Contacts
Coils
Instructions

The PLC reads the ladder logic and uses it to decide when outputs, internal bits, timers, counters, faults, alarms, and machine commands should turn ON or OFF.

Ladder Diagram, also known as Ladder Logic or Relay Ladder Logic, is described as a graphical language that shows logical relationships between inputs and outputs using symbols similar to contacts and coils in relay circuits.


Why Ladder Logic Is Used

Ladder Logic is popular because it is visual and practical.

It allows a technician to see how an output is being controlled.

For example:

Start button is ON
Stop circuit is OK
Overload is OK
No fault is active
Motor run command turns ON

This can be represented clearly in ladder format.

Ladder Logic is also useful for troubleshooting because many PLC software packages allow the technician to go online and see which instructions are true or false in real time.


Basic Ladder Logic Structure

A simple ladder rung has:

Left rail → Logic conditions → Output instruction → Right rail

Example:

DI_Start_PB        Motor_Run_Command
----] [--------------------( )----

This means:

If DI_Start_PB is ON,
then Motor_Run_Command turns ON.

In a real machine, the logic is usually more complete:

DI_Start_PB     DI_Stop_OK     DI_Overload_OK     Motor_Run_Command
----] [------------] [-------------] [--------------------( )----

This means:

Start button must be pressed
AND Stop circuit must be OK
AND Overload must be OK
THEN motor run command turns ON.

What Is a Rung?

A rung is one horizontal line of ladder logic.

Each rung usually performs one control decision.

Examples:

Rung 1: Create Start Request
Rung 2: Build Motor Permissive
Rung 3: Command Motor Run
Rung 4: Turn ON Run Light
Rung 5: Generate Fault

A good rung should be easy to read.

Bad practice:

One huge rung controls everything.

Better practice:

Use multiple clear rungs with descriptive comments.

This makes troubleshooting much easier.


What Are Rails?

The vertical lines on the left and right side of a ladder diagram are called rails.

In traditional relay logic, these rails represented power supply lines.

In PLC ladder logic, they represent a virtual path of logic power.

The PLC does not literally send voltage through the ladder diagram. The software evaluates whether the rung is logically true or false.

The source material explains that ladder diagrams can be thought of as virtual circuits where virtual “power” passes through virtual contacts to energize virtual coils; the contacts and coils in the program act on PLC memory bits rather than being physical contacts and coils.


Main Ladder Logic Instructions

The most basic instructions are:

XIC
XIO
OTE

These are common Allen-Bradley / Studio 5000 instructions.


1. XIC — Examine If Closed

Symbol:

----] [----

Meaning:

The instruction is true when the tag/bit is ON.

Example:

DI_Start_PB
----] [----

This checks:

Is DI_Start_PB ON?

If the Start pushbutton input is ON, the XIC instruction is true.


2. XIO — Examine If Open

Symbol:

----]/[----

Meaning:

The instruction is true when the tag/bit is OFF.

Example:

Fault_Active
----]/[----

This checks:

Is Fault_Active OFF?

This is commonly used for fault permissives, stop conditions, interlocks, and “not active” conditions.

Example:

Fault_Active        Motor_Enable
----]/[------------------( )----

Meaning:

If no fault is active,
allow motor enable.

3. OTE — Output Energize

Symbol:

----( )----

Meaning:

The output/tag turns ON when the rung is true.
The output/tag turns OFF when the rung is false.

Example:

DI_Start_PB        Motor_Run_Command
----] [--------------------( )----

When the rung is true:

Motor_Run_Command = 1

When the rung is false:

Motor_Run_Command = 0

Contacts and Coils Are Read/Write Instructions

This is very important.

A contact does not always mean a physical input.

A coil does not always mean a physical output.

In PLC logic:

Contacts read bits.
Coils write bits.

Example:

DI_Start_PB        Motor_Run_Command
----] [--------------------( )----

The contact reads DI_Start_PB.

The coil writes to Motor_Run_Command.

A common beginner mistake is thinking:

Contacts = always inputs
Coils = always outputs

That is not always true.

A contact can read an input, output, internal bit, timer done bit, counter done bit, fault bit, or HMI command.

A coil can write to an internal command bit, output bit, status bit, alarm bit, or latch logic bit.

The reference material specifically warns that it is a misconception to always associate contacts with PLC inputs and coils with PLC outputs; in reality, contacts and coils are read and write operations on memory bits.


Simple Ladder Logic Example

Requirement

Turn ON a pilot light when a pushbutton is pressed.

Tags
TagTypeDescription
DI_PushbuttonBOOLPushbutton input
DO_PilotLightBOOLPilot light output
Ladder Concept
DI_Pushbutton        DO_PilotLight
----] [--------------------( )----
Plain English
If the pushbutton is pressed,
turn ON the pilot light.

This is the simplest ladder logic concept.


Motor Start Logic Example

A more industrial example is motor start logic.

Requirement

The motor can run only when:

Start pushbutton is pressed
Stop circuit is OK
Overload is OK
No fault is active
Tags
TagDescription
DI_Start_PBStart pushbutton input
DI_Stop_PB_OKStop circuit healthy
DI_Motor_OL_OKMotor overload healthy
Fault_ActiveFault active bit
Motor_Run_CommandInternal motor run command
Ladder Concept
DI_Start_PB    DI_Stop_PB_OK    DI_Motor_OL_OK    Fault_Active      Motor_Run_Command
----] [------------] [---------------] [--------------]/[--------------------( )----
Plain English
If Start is pressed
AND Stop circuit is OK
AND Overload is OK
AND Fault is NOT active
THEN Motor_Run_Command turns ON.

This is basic but very common industrial ladder logic.


Ladder Logic Scan Behavior

The PLC scans ladder logic from:

Top to bottom
Left to right

This means rung order matters.

Example:

Rung 1: Calculate Motor_Permissive_OK
Rung 2: Use Motor_Permissive_OK to command Motor_Run

This is good.

But if you reverse the order:

Rung 1: Use Motor_Permissive_OK
Rung 2: Calculate Motor_Permissive_OK

The motor command may use the previous scan’s value.

That can create confusing behavior during troubleshooting.

PLC ladder programs scan the program repeatedly and update the internal I/O table many times per second, which is why rung order and scan behavior matter.


Ladder Logic Should Be Built in Layers

A professional PLC program is not just random rungs.

A good structure separates the logic into sections.

Recommended structure:

1. Input Mapping
2. Debounce / Signal Conditioning
3. Mode Logic
4. Requests
5. Permissives
6. Interlocks
7. Faults and Alarms
8. Commands
9. Output Mapping
10. HMI Status

This structure makes the program easier to read and troubleshoot.


1. Input Mapping

Input mapping copies raw hardware inputs into meaningful internal tags.

Example:

Local:1:I.Data.0 → DI_Start_PB
Local:1:I.Data.1 → DI_Stop_PB_OK
Local:1:I.Data.2 → DI_Motor_OL_OK

Ladder concept:

Local:1:I.Data.0        DI_Start_PB
----] [--------------------( )----

Why do this?

Cleaner tag names
Easier troubleshooting
Allows debounce
Allows signal inversion
Allows simulation
Reduces raw hardware usage everywhere

2. Request Logic

Request logic captures what the operator or machine wants to do.

Examples:

Start_Request
Stop_Request
Open_Request
Close_Request
Reset_Request
Auto_Start_Request

Example:

DI_Start_PB        Start_Request
----] [----------------( )----

Or with multiple sources:

DI_Start_PB
----] [----------------+--------( Start_Request )
                       |
HMI_Start_PB           |
----] [----------------+

This means:

Local Start OR HMI Start creates Start_Request.

3. Permissive Logic

Permissives are conditions that must be healthy before the machine is allowed to run.

Examples:

E-Stop OK
Guard closed
Air pressure OK
Overload OK
VFD ready
No safety fault

Example:

DI_Estop_OK    DI_GuardClosed    DI_AirPressure_OK    DI_Motor_OL_OK      Motor_Permissive_OK
----] [-------------] [----------------] [----------------] [--------------------( )----

If one permissive is missing, the motor should not run.


4. Interlock Logic

Interlocks prevent conflicting or unsafe commands.

Examples:

Do not open and close a valve at the same time.
Do not run forward and reverse at the same time.
Do not lower a door if the photoeye is blocked.
Do not start a pump if tank level is too low.

Example:

Close_Command        Open_Allowed
----]/[------------------( )----

Meaning:

Open is allowed only when Close_Command is not active.

5. Command Logic

Command logic decides what the PLC wants to energize.

Example:

Start_Request    Motor_Permissive_OK    Motor_Interlock_OK    Fault_Active      Motor_Run_Command
----] [---------------] [-------------------] [---------------]/[--------------------( )----

This creates the internal motor command.

Notice this is not necessarily the physical output yet.


6. Output Mapping

Output mapping connects internal commands to real physical outputs.

Example:

Motor_Run_Command        DO_Motor_Starter
----] [-----------------------( )----

This makes it clear:

Motor_Run_Command = internal decision
DO_Motor_Starter = physical output

This is a very good industrial habit.


Why Separate Commands from Outputs?

This is one of the best professional habits.

Instead of doing this everywhere:

Start_PB        Local:2:O.Data.0
----] [----------------( )----

Use this:

Start logic → Motor_Run_Command
Motor_Run_Command → DO_Motor_Starter

Benefits:

Easier troubleshooting
Avoids duplicate outputs
Cleaner output mapping
Easier HMI status
Easier simulation
Easier future modifications

Basic Seal-In Circuit

A seal-in circuit is used to keep a motor running after the operator releases the Start pushbutton.

Requirement
Press Start → Motor turns ON
Release Start → Motor stays ON
Press Stop → Motor turns OFF
Ladder Concept
DI_Start_PB
----] [----------------+----] [----] [----]/[----( Motor_Run_Command )
                       |    DI_Stop_OK  DI_OL_OK  Fault_Active
Motor_Run_Command      |
----] [----------------+

Simplified view:

Start_PB OR Motor_Run_Command
AND Stop_OK
AND Overload_OK
AND NOT Fault_Active
THEN Motor_Run_Command

This is one of the most important ladder logic patterns.


Important: Seal-In Using Output Feedback vs Real Feedback

A basic seal-in circuit may use the motor command bit to hold itself ON.

But in real industrial equipment, it is often better to prove the device actually responded.

Example:

Motor_Run_Command = PLC asks motor to run.
Motor_Running_Feedback = auxiliary contact or VFD running status proves it is running.

Better industrial logic may include:

Start_Request → Motor_Run_Command
Motor_Run_Command → Starter Output
Starter Aux Feedback → Motor_Running_Status
If command ON but feedback OFF after timer → Fault

The source material shows that using real contactor auxiliary feedback allows the PLC to know whether the contactor actually energized, which is safer than assuming the output command always means the real device operated.


Basic Ladder Logic Symbols

SymbolAllen-Bradley NameMeaning
----] [----XICTrue when bit is ON
----]/[----XIOTrue when bit is OFF
----( )----OTEEnergizes bit when rung is true
----(L)----OTLLatch bit ON
----(U)----OTUUnlatch bit OFF
TONTimer On DelayStarts timing when rung is true
CTUCount UpCounts false-to-true transitions
ONSOne ShotTrue for one scan

OTE vs OTL/OTU

OTE

An OTE is non-retentive.

Rung true  → bit ON
Rung false → bit OFF

Use OTE for normal command logic.

Example:

Motor_Run_Command

OTL / OTU

OTL and OTU are retentive latch instructions.

OTL = latch ON
OTU = unlatch OFF

Use them carefully for things that should stay active until reset.

Examples:

Fault_Latched
Alarm_Latched
Cycle_Started

Do not overuse latch/unlatch.

For beginners, OTE logic is often easier to troubleshoot.


Common Beginner Mistakes

Mistake 1 — Using Raw Inputs Everywhere

Bad:

Local:1:I.Data.0 used in 30 different rungs

Better:

Local:1:I.Data.0 → DI_Start_PB
Use DI_Start_PB everywhere else

Mistake 2 — Duplicate Output Coils

Bad:

Rung 5 writes DO_Motor_Starter
Rung 20 also writes DO_Motor_Starter

This can cause confusing behavior because the last rung scanned may control the final value.

Better:

Use Motor_Run_Command internally.
Map it once to DO_Motor_Starter.

Mistake 3 — Confusing NO/NC with XIC/XIO

A normally closed Stop pushbutton is often ON when healthy.

So the program may use:

DI_Stop_PB_OK
----] [----

This does not mean the field device is normally open.

It means:

The PLC bit is ON when the stop circuit is healthy.

Mistake 4 — No Rung Comments

Bad programs are hard to troubleshoot because they have no documentation.

Better:

Rung Comment:
"Motor run command is allowed when start request is active, all permissives are OK, and no fault is active."

Good comments explain the intent of the rung.


Example: Professional Motor Logic Structure

Input Mapping
Local:1:I.Data.0        DI_Start_PB
----] [--------------------( )----

Local:1:I.Data.1        DI_Stop_PB_OK
----] [--------------------( )----

Local:1:I.Data.2        DI_Motor_OL_OK
----] [--------------------( )----

Start Request
DI_Start_PB        Start_Request
----] [----------------( )----

Motor Permissive
DI_Stop_PB_OK    DI_Motor_OL_OK    Fault_Active      Motor_Permissive_OK
----] [-------------] [--------------]/[--------------------( )----

Motor Command
Start_Request    Motor_Permissive_OK      Motor_Run_Command
----] [---------------] [----------------------( )----

Output Mapping
Motor_Run_Command        DO_Motor_Starter
----] [-----------------------( )----

This structure is simple, readable, and easier to troubleshoot.


Automation Technician Notes

When reading ladder logic, ask:

What is this rung trying to do?
Is this an input, internal bit, or physical output?
Is the instruction checking for ON or OFF?
Is the rung true or false?
What condition is missing?
Is a fault or interlock blocking the command?
Is the output mapped only once?
Does the tag name clearly describe the signal?
Is this command proven by feedback?

A strong technician does not just look for green rungs.

A strong technician follows the logic from:

Input → Request → Permissive → Interlock → Command → Output → Feedback

That is the real troubleshooting path.


Practical Troubleshooting Example

Problem

The conveyor does not start.

Online Logic
DI_Start_PB = 1
DI_Stop_PB_OK = 1
DI_Motor_OL_OK = 1
Fault_Active = 1
Motor_Run_Command = 0
Interpretation

The Start button is working.

The Stop circuit is OK.

The Overload is OK.

But the fault is active.

Because the logic uses:

Fault_Active
----]/[----

the rung is false when Fault_Active = 1.

The motor is blocked by the fault logic.

The technician should now troubleshoot the fault, not the Start button.


Practical Troubleshooting Example 2

Problem

The PLC output is ON, but the motor does not run.

Possible Causes
No control voltage
Blown fuse
Bad interposing relay
Bad starter coil
Overload tripped
VFD fault
Loose wire
Disconnect OFF
Mechanical jam
No motor feedback

This is why command and feedback should be separated.

Command ON does not always mean the machine moved.
Feedback proves the real device responded.

Best Practices for Basic Ladder Logic

Use these habits:

Use meaningful tag names.
Use rung comments.
Map inputs in one place.
Map outputs in one place.
Separate commands from feedback.
Use internal bits for requests, permissives, interlocks, and commands.
Avoid duplicate physical output coils.
Keep rungs short and readable.
Use XIC/XIO based on tag meaning, not just physical NO/NC wiring.
Test logic online carefully.

Key Terms

TermMeaning
Ladder LogicGraphical PLC programming language based on relay logic
RungHorizontal line of ladder logic
RailVertical line at the side of a ladder diagram
XICExamine If Closed; true when bit is ON
XIOExamine If Open; true when bit is OFF
OTEOutput Energize; writes ON/OFF based on rung state
OTLOutput Latch; latches a bit ON
OTUOutput Unlatch; unlatches a bit OFF
ContactLadder instruction that reads a bit
CoilLadder instruction that writes a bit
Seal-In CircuitLogic that holds a command ON after a momentary start
CommandPLC request to activate something
FeedbackProof that the field device actually responded
PermissiveRequired condition to allow an action
InterlockCondition that blocks an unsafe or unwanted action

Final Thoughts

Ladder Logic is the foundation of PLC programming for many industrial machines.

It uses contacts, coils, rungs, and instructions to represent machine logic in a visual way. Contacts read PLC bits. Coils write PLC bits. Rungs organize the logic into clear control decisions.

For an Automation Technician, the most important skill is learning how to follow the logic from input to output:

Input → Logic → Command → Output → Feedback

Once you understand how basic ladder rungs work, you can troubleshoot motors, sensors, valves, alarms, faults, permissives, interlocks, and machine sequences with much more confidence.

Leave a Reply

Your email address will not be published. Required fields are marked *