10. Fundamentals of Logic: AND, OR, NOT in Ladder Logic10.


0
Categories : PLC Foundations

Before learning advanced PLC programming, every automation technician must understand the basic logic operations used in ladder logic.

The three most important logic functions are:

AND
OR
NOT

These are the foundation of almost every PLC program.

In simple words:

AND = All conditions must be true
OR  = At least one condition must be true
NOT = The condition must be false

In industrial control systems, these logic functions are used to control motors, valves, lights, alarms, conveyors, pumps, permissives, interlocks, and machine sequences.


Why Logic Matters in PLC Programming

A PLC program is based on decisions.

Examples:

Should the motor start?
Should the valve open?
Should the alarm turn ON?
Should the conveyor stop?
Should the machine allow automatic mode?

The PLC makes these decisions by checking input conditions and internal memory bits.

Example:

If Start button is pressed
AND Stop circuit is healthy
AND Overload is OK
THEN run the motor.

That is basic PLC logic.


Ladder Logic Is Based on Electrical Logic

Ladder logic was designed to look similar to electrical relay control circuits.

That is why ladder logic uses symbols that look like relay contacts and coils.

Common ladder logic symbols:

XIC = Examine If Closed
XIO = Examine If Open
OTE = Output Energize

In simple terms:

XIC checks if a bit is ON.
XIO checks if a bit is OFF.
OTE turns a bit or output ON when the rung is true.

1. AND Logic

What Is AND Logic?

AND logic means all conditions must be true before the output turns ON.

Simple rule:

Condition A AND Condition B must both be true.

Industrial example:

Start_PB must be ON
AND Stop_PB_OK must be ON
AND Overload_OK must be ON
THEN Motor_Run turns ON.

AND Logic in Ladder

In ladder logic, AND logic is created by placing contacts in series.

Example:

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

This rung means:

If DI_Start_PB is ON
AND DI_Stop_PB_OK is ON
AND DI_Overload_OK is ON
THEN Motor_Run_Command is ON.

If any one condition is false, the rung becomes false and the output turns OFF.


AND Logic Truth Table
Start PBStop OKOverload OKMotor Run
0000
1010
1100
1111

The motor only runs when all required conditions are true.


Practical AND Example: Motor Permissive

A motor should only be allowed to start when all permissives are healthy.

E-Stop circuit OK
AND Motor overload OK
AND Guard door closed
AND Air pressure OK

Ladder concept:

DI_Estop_OK     DI_OL_OK     DI_GuardClosed     DI_AirPressure_OK     Motor_Permissive
----] [------------] [-------------] [----------------] [--------------------( )----

This is a common structure in real industrial machines.


2. OR Logic

What Is OR Logic?

OR logic means at least one condition must be true before the output turns ON.

Simple rule:

Condition A OR Condition B can turn ON the output.

Industrial example:

Motor can be started from the local pushbutton
OR from the HMI start button.

If either command is active, the start request becomes true.


OR Logic in Ladder

In ladder logic, OR logic is created using parallel branches.

Example:

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

This means:

If DI_Local_Start_PB is ON
OR HMI_Start_PB is ON
THEN Start_Request is ON.

The output turns ON if at least one branch is true.


OR Logic Truth Table
Local StartHMI StartStart Request
000
101
011
111

The output is ON when any valid path is true.


Practical OR Example: Multiple Start Sources

A conveyor may be started from different locations:

Local Start Pushbutton
OR HMI Start Button
OR Auto Sequence Start

Ladder concept:

DI_Local_Start_PB
----] [------------------------+----------------( Start_Request )
                               |
HMI_Start_Command              |
----] [------------------------+
                               |
Auto_Start_Command             |
----] [------------------------+

This is useful when the same action can be requested from multiple sources.


3. NOT Logic

What Is NOT Logic?

NOT logic means the PLC is looking for a condition to be false.

Simple rule:

NOT = true when the bit is OFF.

In ladder logic, NOT logic is commonly represented by an XIO instruction.

XIO = Examine If Open

An XIO instruction is true when the addressed bit is 0.


NOT Logic in Ladder

Example:

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

This means:

If Fault_Active is NOT ON
THEN Motor_Enable is ON.

Or more clearly:

If there is no active fault,
allow the motor enable.

NOT Logic Truth Table
Fault ActiveXIO Fault ActiveMotor Enable
011
100

When the fault is active, the XIO instruction goes false.


XIC vs XIO Explained Simply

This is one of the most important beginner concepts.

XIC — Examine If Closed
----] [----

XIC is true when the bit is ON.

Example:

DI_Start_PB
----] [----

Meaning:

Is DI_Start_PB ON?

XIO — Examine If Open
----]/[----

XIO is true when the bit is OFF.

Example:

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

Meaning:

Is Fault_Active OFF?

Very Important: XIC/XIO Is Not the Same as NO/NC Wiring

This is where many beginners get confused.

A physical device can be:

Normally Open
Normally Closed

But in the PLC program, you use:

XIC
XIO

These are not exactly the same thing.

The PLC instruction does not know the physical contact type. It only checks the status of the PLC bit.


Example: Normally Closed Stop Button

A Stop pushbutton is usually wired normally closed for safety and reliability.

When the Stop button is healthy and not pressed:

PLC input = ON

When the Stop button is pressed:

PLC input = OFF

So in the PLC program, it is common to use an XIC instruction:

DI_Stop_PB_OK
----] [----

Why?

Because the tag means:

Stop pushbutton circuit is OK.

The instruction is checking for the healthy condition.


Better Tag Naming Reduces Confusion

Instead of naming the input:

DI_Stop_PB

A better name may be:

DI_Stop_PB_OK

or:

DI_Stop_Circuit_OK

This makes the logic easier to read.

Example:

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

This reads naturally:

Start is pressed
AND stop circuit is OK
THEN motor run command.

Combining AND, OR, and NOT

Most real ladder logic combines AND, OR, and NOT together.

Example requirement:

Run the conveyor when:
Start request is active
AND stop circuit is OK
AND overload is OK
AND no fault is active
AND either Auto Mode or Manual Mode is active.

Ladder concept:

Start_Request   DI_Stop_OK   DI_OL_OK   Fault_Active
----] [------------] [----------] [----------]/[-------------+----( Conveyor_Run )
                                                        |
Auto_Mode                                               |
----] [-------------------------------------------------+
                                                        |
Manual_Mode                                             |
----] [-------------------------------------------------+

A cleaner way to think about it:

Conveyor_Run =
Start_Request
AND Stop_OK
AND Overload_OK
AND NOT Fault_Active
AND (Auto_Mode OR Manual_Mode)

This is how PLC logic builds real machine decisions.


Series Contacts = AND

When contacts are in series, all of them must be true.

A        B        C        Output
--] [----] [------] [--------( )--

Meaning:

A AND B AND C = Output

If one contact is false, the output is false.


Parallel Branches = OR

When contacts are in parallel branches, any branch can make the output true.

A
--] [----------------+----( Output )
                     |
B                    |
--] [----------------+

Meaning:

A OR B = Output

If A or B is true, the output turns ON.


XIO Contact = NOT

An XIO instruction checks for a false bit.

A
--]/[----( Output )

Meaning:

NOT A = Output

If A is OFF, the XIO is true.

If A is ON, the XIO is false.


Practical Example: Alarm Horn Logic

Requirement

Turn ON the alarm horn when a fault is active and the alarm is not acknowledged.

Fault_Active AND NOT Alarm_Ack = Horn_ON

Ladder concept:

Fault_Active      Alarm_Ack        Horn_Output
----] [--------------]/[----------------( )----

Meaning:

If a fault is active
AND the alarm has not been acknowledged
THEN turn on the horn.

Once the operator acknowledges the alarm, Alarm_Ack becomes ON, the XIO becomes false, and the horn turns OFF.


Practical Example: Door Open Command

Requirement

Open the door when:

Open pushbutton is pressed
AND door is not already fully open
AND no fault is active
AND close command is not active

Ladder concept:

DI_Open_PB    DI_Door_Fully_Open    Fault_Active    Close_Command      Open_Command
----] [------------]/[----------------]/[---------------]/[----------------( )----

This means:

Open button is pressed
AND door is NOT fully open
AND fault is NOT active
AND close command is NOT active
THEN Open_Command is ON.

This is a simple example of AND plus NOT logic.


Practical Example: Pump Start Logic

Requirement

Start the pump when:

Start request is active
AND tank low level is not active
AND discharge valve is open
AND motor overload is OK

Ladder concept:

Start_Request   DI_Tank_LowLevel   DI_DischargeValve_Open   DI_OL_OK     Pump_Run
----] [--------------]/[--------------------] [----------------] [-----------( )----

This means:

Start request is ON
AND tank low level is NOT active
AND discharge valve is open
AND overload is OK
THEN pump run command.

Truth Tables

Truth tables help explain how logic works.

AND Truth Table
ABA AND B
000
010
100
111

OR Truth Table
ABA OR B
000
011
101
111

NOT Truth Table
ANOT A
01
10

Common Beginner Mistakes

Mistake 1 — Confusing XIO with Normally Closed Wiring

XIO does not mean the physical device is normally closed.

XIO means:

Check if the PLC bit is OFF.

Always think about the tag value, not only the physical device type.


Mistake 2 — Bad Tag Names

Bad tag name:

Stop_PB

Better tag name:

Stop_PB_OK

Why?

Because in real machines, stop circuits are often ON when healthy.

Clear names make the logic easier to read.


Mistake 3 — Too Much Logic in One Rung

A very long rung with many branches can be difficult to troubleshoot.

Better approach:

Create intermediate bits.

Example:

Motor_Permissive_OK
Motor_Interlock_OK
Motor_Fault_Clear
Motor_Start_Request
Motor_Run_Command

This makes the program easier to understand.


Mistake 4 — Duplicating Output Coils

Do not control the same output coil in multiple rungs unless you fully understand the consequences.

Bad structure:

Rung 5 controls DO_Motor_Starter
Rung 20 also controls DO_Motor_Starter

Better structure:

Use one internal command bit.
Map it once to the physical output.

Example:

Motor_Run_Command → DO_Motor_Starter

Professional Logic Structure

For industrial programs, it is better to build logic in layers.

Example:

1. Input Mapping
2. Mode Logic
3. Requests
4. Permissives
5. Interlocks
6. Faults
7. Commands
8. Output Mapping

Motor example:

Start PB / HMI Start
        ↓
Start_Request
        ↓
Motor_Permissive_OK
        ↓
Motor_Interlock_OK
        ↓
Motor_Run_Command
        ↓
DO_Motor_Starter

This makes troubleshooting more logical.


Automation Technician Notes

When reading a ladder rung, ask:

Are the contacts in series or parallel?
Which contacts must be true?
Which branches are optional paths?
Which XIO instructions are checking for OFF conditions?
Is the tag name describing the healthy condition?
Is this a command, feedback, permissive, interlock, or fault?
Is the output written somewhere else?

A good technician does not just look at whether a rung is green.

A good technician understands why the rung is true or false.


Troubleshooting Example

Problem

The motor does not start.

Rung Logic
DI_Start_PB     DI_Stop_OK     DI_OL_OK     Fault_Active     Motor_Run_Command
----] [------------] [------------] [------------]/[----------------( )----
Online Values
DI_Start_PB = 1
DI_Stop_OK = 1
DI_OL_OK = 1
Fault_Active = 1
Result

The motor does not run because:

Fault_Active = 1

The XIO instruction on Fault_Active is false.

So the rung is false.

The problem is not the Start button, Stop button, or Overload input. The problem is that a fault is active.


Another Troubleshooting Example

Problem

The alarm horn does not turn ON.

Rung Logic
Fault_Active     Alarm_Ack      Horn_Output
----] [-------------]/[------------( )----
Online Values
Fault_Active = 1
Alarm_Ack = 1
Result

The horn stays OFF because the alarm has already been acknowledged.

The XIO instruction on Alarm_Ack is false.

That is correct operation.


Key Terms
TermMeaning
AND LogicAll conditions must be true
OR LogicAt least one condition must be true
NOT LogicCondition must be false
XICExamine If Closed, true when bit is ON
XIOExamine If Open, true when bit is OFF
OTEOutput Energize
Series ContactsLadder contacts used for AND logic
Parallel BranchesLadder branches used for OR logic
Truth TableTable showing logic results
PermissiveRequired condition to allow an action
InterlockCondition that blocks unsafe or unwanted action
CommandPLC request to activate something
FeedbackProof that the field device actually responded

Final Thoughts

AND, OR, and NOT logic are the foundation of PLC programming.

In ladder logic:

Series contacts create AND logic.
Parallel branches create OR logic.
XIO contacts create NOT logic.

Once you understand these three concepts, ladder logic becomes much easier to read and troubleshoot.

For an Automation Technician, this knowledge is critical. Most machine problems can be understood by following the logic and asking:

Which condition is missing?
Which interlock is active?
Which fault is blocking the command?
Which branch is allowing the output?

Mastering basic logic is the first major step toward reading real industrial PLC programs with confidence.

Leave a Reply

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