Logic Gates in PLC Ladder Logic: Truth Table & Diagram

Share:
PLC
Logic Gates in PLC Ladder Logic: How to Build AND, OR, NOT, NAND, NOR, XOR and XNOR Rungs

Every ladder rung is a Boolean expression, so each gate maps to a simple pattern of contacts in series or parallel. Below you will find all seven patterns with truth tables, field examples and a quick checker for rung outputs.

AND OR NOT NAND NOR XOR XNOR XIC vs XIO Truth Tables

See how each Boolean gate becomes a ladder rung made of normally open and normally closed contacts. You also get truth tables, a worked XOR example, a gate output checker and a troubleshooting flowchart.

Hello everyone, today we are going to learn logic gates in PLC ladder logic, rung by rung, with truth tables and real plant examples.
logic gates in PLC ladder logic
Quick Answer

What are logic gates in PLC ladder logic and how are they drawn?

Logic gates in PLC ladder logic are Boolean functions built from contacts on a rung. Contacts in series make AND, contacts in parallel make OR, and an XIO (normally closed) contact makes NOT. For example, A = 1 and B = 0 gives AND = 0, OR = 1 and XOR = 1. NAND, NOR, XOR and XNOR are combinations of these three basic patterns.

What Are Logic Gates in PLC Ladder Logic?

The term logic gates in PLC ladder logic means drawing Boolean functions such as AND, OR and NOT with contacts and coils instead of chip symbols. The PLC solves each rung like a relay circuit, and the coil turns on only when a continuous path of true contacts connects the left rail to the right rail.

Key Facts
  • Series contacts give AND, parallel branches give OR.
  • An XIO (examine if open) contact gives NOT.
  • NAND, NOR, XOR and XNOR are built from those three patterns.
  • A two input truth table has 4 rows; three inputs give 8 rows.
  • The rung output is held in the output image until the next scan writes it again.

If you already know the chip version from digital logic gates, the ladder version is the same truth table drawn as switches. The table below maps each gate to its rung pattern and to the Boolean algebra expression the PLC is really solving.

GateLadder patternBoolean
ANDXIC A in series with XIC BQ = A AND B
ORXIC A in parallel with XIC BQ = A OR B
NOTSingle XIO AQ = NOT A
NANDXIO A in parallel with XIO BQ = NOT (A AND B)
NORXIO A in series with XIO BQ = NOT (A OR B)
XORTwo branches: A NOT B, NOT A BQ = A XOR B
XNORTwo branches: A B, NOT A NOT BQ = NOT (A XOR B)
Do You Know?

Ladder diagrams copied the relay control drawings that electricians already used in the 1960s, which is why the first PLCs were sold as relay panel replacements. The rails still represent the control supply, even though the PLC only solves the logic in memory.

Advertisement

What Is the Difference Between XIC and XIO?

XIC (examine if closed) is true when its bit is 1, and XIO (examine if open) is true when its bit is 0. They test the bit in memory, not the field switch.

Rockwell names them XIC and XIO, while Siemens and the IEC 61131 3 standard call them normally open and normally closed contacts. You will find the same symbols in every vendor listed under IEC 61131 3 programming languages.

XIC contact (normally open symbol)
  • True when the input or memory bit is 1
  • Used for AND and OR building blocks
  • Used with an NC stop button so a broken wire stops the machine
  • Drawn as two plain vertical bars
XIO contact (normally closed symbol)
  • True when the bit is 0
  • Used to make NOT, NAND and NOR
  • Easy to confuse with a physical NC field contact
  • Drawn with a slash across the bars
Quick Tip

Before you choose XIC or XIO, look at the input LED with the switch in its normal state. If the LED is on when nothing is happening, the bit is 1 at rest and the logic must be written for that.

How Do You Write an AND Gate in Ladder Logic?

You write an AND gate by placing two XIC contacts in series on one rung so both must be true before the coil turns on. OR uses the same contacts on parallel branches, and NOT uses a single XIO contact in front of the coil.

logic gates in PLC ladder logic diagram with AND OR NOT XOR rungs
Diagram by Instrumentation Blog showing AND, OR, NOT and XOR gates drawn as ladder rungs with XIC and XIO contacts and output coils Q1 to Q4.

These are the first rungs in most ladder logic for beginners lessons. Most of the PLC ladder logic examples you see in plant software are long AND chains with a few OR branches for alternatives.

How to Make an XOR Gate in Ladder Logic

You make an XOR gate with two parallel branches: XIC A with XIO B on the first, and XIO A with XIC B on the second. NAND, NOR and XNOR are built the same way, by mixing XIO contacts with series and parallel paths.

NAND

Two XIO contacts in parallel. The coil is on unless both inputs are 1.

Best for: Permissive lost alarm
Derived
NOR

Two XIO contacts in series. The coil is on only when both inputs are 0.

Best for: Machine ready lamp
Derived
XOR

Branch 1 is XIC A and XIO B, branch 2 is XIO A and XIC B. The coil is on when the inputs differ.

Best for: Two way light switch
Two branch
XNOR

Branch 1 is XIC A and XIC B, branch 2 is XIO A and XIO B. The coil is on when the inputs match.

Best for: Discrepancy check
Two branch
Solved example with A = 1 and B = 0
XOR = (A AND NOT B) OR (NOT A AND B)
= (1 AND 1) OR (0 AND 0)
= 1 OR 0 = 1
NAND = NOT (1 AND 0) = NOT 0 = 1
NOR = NOT (1 OR 0) = NOT 1 = 0

De Morgan rules are why a NAND rung uses parallel XIO contacts and a NOR rung uses series XIO contacts. Many controllers also offer a word level XOR instruction, and Rockwell documents a bitwise XOR for comparing whole DINT tags in its general instructions manual.

Advertisement

Truth Tables for Every Ladder Gate

A truth table lists every input combination and the coil state for each one, which makes it the quickest way to prove a rung works. Two inputs give 4 rows, and each extra input doubles the rows because the count is 2 to the power n.

two input truth table for AND OR NAND NOR XOR XNOR ladder gates
Diagram by Instrumentation Blog showing the two input truth table for AND, OR, NAND, NOR, XOR and XNOR with the worked example A equals 1 and B equals 0 highlighted.
Ladder Gate Output Checker
Coil states for these inputs
AND 0, OR 1, NAND 1, NOR 0, XOR 1, XNOR 0, NOT A 0
Do You Know?

During each scan the PLC solves rungs from top to bottom and left to right. That order is explained in how the PLC scan cycle works and it decides which rung wins when two rungs write the same coil.

Field Examples of Each Gate

In plants the gates rarely appear alone, but each has a clear job. These examples come from pump skids, conveyors and valve stations.

AND: pump permissive
Pump runs only when suction valve open, tank level not low and motor overload healthy.
OR: multiple start points
Motor starts from the MCC panel, the field push button or the DCS command.
NOT: heater cut off
Heater output is on while the high temperature switch is not made.
XOR: valve position
A healthy on off valve shows exactly one limit switch made, open or closed.
XNOR: travel fault
Both limits made or both limits clear after the travel time means a valve fault.
Field Tip
For the valve check, add a delay with a TON timer so the XNOR fault does not trip during normal travel. Set the delay a little longer than the measured stroke time.

The XNOR valve fault above needs a delay, so pair the rung with PLC timer instructions such as TON. When an alarm list grows, the NAND pattern combines nicely with a first out alarm rung that records which permissive dropped first.

Why Is a Stop Button Wired NC but Programmed XIC?

A stop button is wired normally closed so the input is 1 when everything is healthy, and the program uses XIC so the rung stays true until someone presses stop. If the wire breaks, the input drops to 0 and the motor stops, which is the safe direction.

HealthyNC stop closed, input bit = 1, XIC true
Start pressedXIC Start OR seal in contact energises Motor
Seal inMotor contact holds the rung after Start is released
Stop or broken wireInput bit = 0, XIC false, Motor drops out

This start stop rung is an OR (start or seal in) in series with an AND (stop healthy), so it is really a small gate circuit. Emergency stops must still follow emergency stop push button rules from ISO 13850, which call for direct opening contacts and a stop that does not depend only on standard PLC logic.

Advertisement

Troubleshooting Gate Rungs That Do Not Work

When a gate rung fails, the program is usually asking about the wrong bit state and the Boolean logic itself is fine. Work through the flowchart from the field device back to the coil.

flowchart to troubleshoot a PLC ladder rung coil that stays off
Diagram by Instrumentation Blog showing a troubleshooting flowchart for a ladder rung output that stays off, checking input LED, tag value, contact type and double coils.
SymptomLikely causeFix
Coil on when it should be offXIO used where XIC was neededCheck input LED at rest and swap the contact
Coil flickers or ignores a rungSame coil written on two rungsKeep one OTE per coil, combine conditions with OR
Input LED on, tag stays 0Wrong address or module not configuredCompare the I/O tree with the wiring list
No input LED at allSinking and sourcing mismatch or no 24 VMeasure at the terminal and check the common

A missing input LED is often a common wiring issue, so recheck sinking and sourcing before you blame the program. For the output side, compare the load with the PLC output module types to confirm the card can switch it.

Myth: A normally closed field switch must use an XIO contact.
Fact: The contact choice depends on the bit state you want to test; an NC stop wired to an input is usually programmed with XIC.
Myth: Writing the same coil on two rungs makes an OR gate.
Fact: The last rung scanned decides the coil, so the earlier rung is overwritten; build the OR with parallel branches on one rung.
Myth: XOR needs a special instruction in ladder.
Fact: XOR is only two parallel branches of XIC and XIO contacts; a bitwise XOR instruction is just a shortcut for whole words.
Quick Tip

When a rung must react to a button press only once, add a one shot instead of making the gate more complex. It keeps the Boolean logic easy to read during night shift faultfinding.

Ladder Gate Review Checklist

Run through this checklist before you download a new rung. Each item matches a fault we see on site.

  • Each input checked at rest with the LED and the online tag value
  • XIC or XIO chosen for the bit state, not for the switch symbol
  • Only one output coil instruction per tag
  • Truth table tested row by row with forces or a simulator
  • Stop and trip inputs wired NC and programmed XIC
  • Timers added where a gate checks moving equipment
  • Rung comment states the Boolean expression in words
PDF
Logix 5000 Controllers General Instructions Reference Manual
Rockwell Automation PDF covering XIC, XIO, OTE and bitwise XOR instructions

Once your gate rungs are clear, move to one shot instructions and compare instructions which feed bits into the same patterns. You can practise all of it for free with free PLC programming software.

Logic Gates in PLC Ladder Logic FAQ

What is the difference between XIC and XIO in PLC ladder logic?

XIC is true when its bit is 1 and XIO is true when its bit is 0. Neither instruction describes the field switch; they only test the bit stored in memory.

So an NC stop button that reads 1 when healthy is normally programmed with XIC, and the machine stops when the bit drops to 0.

How do you make an XOR gate in ladder logic with example?

Draw two parallel branches: XIC A with XIO B on top and XIO A with XIC B below. The coil turns on when the inputs differ.

With A = 1 and B = 0 the top branch is true, so XOR = 1. With both inputs at 1 neither branch is true and the coil is off.

How do you build a NAND gate using ladder logic contacts?

Place two XIO contacts in parallel before the coil. By De Morgan, NOT (A AND B) equals NOT A OR NOT B, so the coil is on unless both inputs are 1.

A common use is an alarm that lights as soon as any one of two permissives is lost. Add more parallel XIO branches for more inputs.

How many rows does a truth table need for a three input rung?

A three input rung needs 8 rows because the count is 2 to the power n. Two inputs give 4 rows and four inputs give 16 rows.

Test each row online with forces or a simulator and write down the coil state. Any row that does not match the expected result points to a wrong contact type.

Why does my ladder coil stay on even when the input is off?

The most common cause is an XIO contact where an XIC was needed, so the rung is true while the input is 0. A second cause is the same coil written on another rung.

Check the input LED at rest, then search the program for every place that tag is used as an output coil.

Which is better for logic gates in PLC ladder logic or structured text?

Ladder is better for simple bit gates because maintenance staff can watch power flow online. Structured text suits long expressions and word level operations such as bitwise XOR.

Many plants use ladder for interlocks and permissives, then structured text for calculations. Pick what your site team can troubleshoot at night.

Advertisement

Related Articles

External References

What We Learn Today

  • We learned how logic gates in PLC ladder logic map to contacts: series rungs for AND, parallel branches for OR, XIO contacts for NOT.
  • We built NAND, NOR, XOR and XNOR from those three patterns using De Morgan rules and a worked example with A = 1 and B = 0.
  • We saw why a stop button is wired NC but programmed XIC, and how to troubleshoot a coil that stays off using a simple flowchart.
Advertisement
I hope you like above blog. There is no cost associated in sharing the article in your social media. Thanks for reading!! Happy Learning!!
Sunayana Gadepatil, author at Instrumentation Blog
Author · instrumentationblog.in
Ms. Sunayana Gadepatil is an instrumentation professional, technical writer, and the author behind Instrumentation Blog. With a strong interest in industrial instrumentation, process measurement, and automation, she specializes in simplifying complex technical concepts into clear, practical, and easy to understand insights. Through her articles, Ms. Sunayana shares valuable knowledge on flow, pressure, level, temperature, control systems, and industrial automation for engineers, students, technicians, and industry professionals.
Technically reviewed on

Leave a Reply

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

Support free learning

Help keep every guide, calculator and tool 100% free

Hosting, software and hours of research go into every article. Even a small contribution helps us publish more in-depth guides for students, technicians and engineers.

  • No paywalls
  • No sign up
  • Free for everyone