0% found this document useful (0 votes)
5 views

IAT LESSON 06 Logic Gates Boolean Logic in PLCs

This document provides a comprehensive overview of logic gates and Boolean logic as applied to Programmable Logic Controllers (PLCs), detailing their functionality, applications, and implementation in PLC programming. It covers fundamental logic gates, their truth tables, and examples of Ladder Logic, along with the importance of Boolean algebra for simplifying complex logic expressions. The module emphasizes the role of these concepts in designing efficient and reliable control systems in industrial automation.

Uploaded by

3 dots . . .
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

IAT LESSON 06 Logic Gates Boolean Logic in PLCs

This document provides a comprehensive overview of logic gates and Boolean logic as applied to Programmable Logic Controllers (PLCs), detailing their functionality, applications, and implementation in PLC programming. It covers fundamental logic gates, their truth tables, and examples of Ladder Logic, along with the importance of Boolean algebra for simplifying complex logic expressions. The module emphasizes the role of these concepts in designing efficient and reliable control systems in industrial automation.

Uploaded by

3 dots . . .
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

IAT LESSON 06 Logic Gates & Boolean Logic in PLCs|1

University of Makati
College of Technology Management

IAT : Automation with PLC


Logic Gates & Boolean
Lesson 6 :
Logic in PLCs

IAT : Industrial Automation Technology


IAT LESSON 06 Logic Gates & Boolean Logic in PLCs|2

IAT LESSON 06 Logic Gates & Boolean


Logic in PLCs

Objectives:

At the end of the lesson, you are expected to:

1. To understand the functionality and application of fundamental

logic gates in PLC programming.

2. To analyze and apply Boolean algebra for simplifying complex

logic expressions.

3. To implement logic gate functions using Ladder Logic for effective

PLC-based control systems.

Introduction

This module provides an in-depth exploration of logic gates and

Boolean logic as applied to Programmable Logic Controllers (PLCs).

Understanding these fundamental concepts is essential for designing

efficient control systems in automation and industrial processes. The

module covers the basic logic gates, Boolean algebra, and their direct

implementation in Ladder Logic programming.

IAT : Industrial Automation Technology


IAT LESSON 06 Logic Gates & Boolean Logic in PLCs|3

Programmable Logic Controllers (PLCs) are widely used in industrial

automation to control machinery and processes. One of the

fundamental principles behind PLC programming is digital logic, which

is built upon logic gates and Boolean algebra. This module explores the

basic logic gates, their role in PLC programming, and how Boolean

algebra simplifies logic circuits.

BASIC LOGIC GATES IN PLCs

Logic gates are the fundamental components of digital circuits,

controlling how input signals determine output results. In PLC

(Programmable Logic Controller) programming, these gates are used

to create logical operations in ladder logic, function block diagrams

(FBD), and structured text.

1. AND Gate

Function:

The AND gate outputs HIGH (1) only when all inputs are HIGH

(1). Otherwise, it outputs LOW (0).

Truth Table:

Input A Input B Output (Y)


0 0 0
0 1 0
1 0 0
1 1 1
PLC Example (Ladder Logic):

IAT : Industrial Automation Technology


IAT LESSON 06 Logic Gates & Boolean Logic in PLCs|4

 Two normally open (NO) contacts in series.

 Both conditions (A and B) must be TRUE (closed) for the coil

(output) to activate.

Application:

 Used in safety circuits where multiple conditions must be met

before activation.

 Example: A conveyor belt should run only if both the "Start"

button is pressed and the "Safety Sensor" is clear.

2. OR Gate

Function:

The OR gate outputs HIGH (1) if at least one input is HIGH (1).

Truth Table:

Input A Input B Output (Y)


0 0 0
0 1 1
1 0 1
1 1 1

PLC Example (Ladder Logic):

 Two normally open (NO) contacts in parallel.

 If either input (A or B) is active, the coil (output) energizes.

IAT : Industrial Automation Technology


IAT LESSON 06 Logic Gates & Boolean Logic in PLCs|5

Application:

 Used in control systems where multiple triggering options are

available.

 Example: A motor starts if either of two push buttons is pressed.

3. NOT Gate (Inverter)

Function:

The NOT gate inverts the input—if the input is HIGH (1), the

output is LOW (0), and vice versa.

Truth Table:

Input A Output (Y)


0 1
1 0

PLC Example (Ladder Logic):

 A normally closed (NC) contact is used.

 When the NC contact is activated (open), the output deactivates.

Application:

 Used to create fail-safe conditions.

 Example: A fan should turn off when a temperature sensor

detects overheating.

IAT : Industrial Automation Technology


IAT LESSON 06 Logic Gates & Boolean Logic in PLCs|6

4. NAND Gate (NOT AND)

Function:

The NAND gate is the opposite of the AND gate. It outputs LOW (0)

only when all inputs are HIGH (1); otherwise, it outputs HIGH

(1).

Truth Table:

Input A Input B Output (Y)


0 0 1
0 1 1
1 0 1
1 1 0

PLC Example (Ladder Logic):

 A series circuit with a NOT gate (NC contact) at the end.

 The output remains HIGH unless both inputs are HIGH.

Application:

 Used in fail-safe circuits.

 Example: An emergency stop system ensures that if both

emergency stop buttons are pressed, the machine shuts down.

5. NOR Gate (NOT OR)

IAT : Industrial Automation Technology


IAT LESSON 06 Logic Gates & Boolean Logic in PLCs|7

Function:

The NOR gate is the opposite of the OR gate. It outputs HIGH (1)

only when all inputs are LOW (0).

Truth Table:

Input A Input B Output (Y)


0 0 1
0 1 0
1 0 0
1 1 0

PLC Example (Ladder Logic):

 A parallel circuit with NC contacts.

 The output remains HIGH only when neither input is active.

Application:

 Used for automatic shutdown systems.

 Example: A machine should remain off unless both start buttons

are not pressed.

6. XOR Gate (Exclusive OR)

Function:

The XOR gate outputs HIGH (1) when inputs are different (one is

HIGH, the other is LOW). If both inputs are the same, it outputs

LOW.

Truth Table:

IAT : Industrial Automation Technology


IAT LESSON 06 Logic Gates & Boolean Logic in PLCs|8

Input A Input B Output (Y)


0 0 0
0 1 1
1 0 1
1 1 0

PLC Example (Ladder Logic):

 Uses a combination of AND, OR, and NOT gates.

 Two branches with mixed NO/NC contacts.

Application:

 Used for toggle switch functions.

 Example: A light should turn on when one switch is flipped, but

turn off when both switches are in the same position.

7. XNOR Gate (Exclusive NOR)

Function:

The XNOR gate is the opposite of the XOR gate. It outputs HIGH (1)

when both inputs are the same (both HIGH or both LOW). If

inputs are different, it outputs LOW.

Truth Table:

IAT : Industrial Automation Technology


IAT LESSON 06 Logic Gates & Boolean Logic in PLCs|9

Input A Input B Output (Y)


0 0 1
0 1 0
1 0 0
1 1 1

PLC Example (Ladder Logic):

 Similar to XOR but with an additional NOT gate.

Application:

 Used in error detection systems.

 Example: A security system that triggers an alarm if two

sensors disagree.

Summary Table

Functi
Gate Output Condition
on
AND A*B 1 if all inputs are 1
OR A+B 1 if at least one input is 1
NOT A' Inverts input
NAND (A * B)' 0 if all inputs are 1

A⊕B
NOR (A + B)' 1 if all inputs are 0

(A ⊕ B)'
XOR 1 if inputs are different
XNOR 1 if inputs are the same

Conclusion

Logic gates are fundamental to PLC programming, enabling decision-

making and control in automation systems. By combining these gates,

IAT : Industrial Automation Technology


I A T L E S S O N 0 6 L o g i c G a t e s & B o o l e a n L o g i c i n P L C s | 10

complex logical operations can be implemented, ensuring efficiency,

safety, and reliability in industrial processes.

BOOLEAN ALGEBRA IN PLC PROGRAMMING

1. Introduction to Boolean Algebra in PLC

What is Boolean Algebra?

Boolean algebra is a branch of mathematics used in digital logic

design and PLC programming. It simplifies complex logic

expressions, reducing the number of required logic gates and

optimizing control circuits.

This results in:

 Faster execution in PLCs

 Reduced memory usage

 Improved troubleshooting efficiency

 Cost-effective hardware implementation

Why is Boolean Algebra Important in PLCs?

IAT : Industrial Automation Technology


I A T L E S S O N 0 6 L o g i c G a t e s & B o o l e a n L o g i c i n P L C s | 11

In PLC programming, logic expressions are implemented using

Ladder Logic, Function Block Diagrams (FBD), or Structured

Text (ST).

Simplifying these expressions reduces:

 The number of relay contacts or logic elements

 PLC scan time, improving real-time performance

 Troubleshooting complexity

2. Boolean Laws and Theorems

Understanding Boolean laws helps optimize ladder logic diagrams

and digital circuits.

A. Basic Boolean Laws

a) Commutative Law

 Addition (OR): A+B=B+A

 Multiplication (AND): A⋅B=B⋅A

 Order of operands does not matter.

PLC Application: The sequence of rungs in a ladder diagram

can be rearranged without affecting logic.

b) Associative Law

 Addition (OR): (A+B)+C=A+(B+C)

 Multiplication (AND): (A⋅B)⋅C=A⋅(B⋅C)

IAT : Industrial Automation Technology


I A T L E S S O N 0 6 L o g i c G a t e s & B o o l e a n L o g i c i n P L C s | 12

 Grouping does not affect the result.

PLC Application: Parallel rungs in Ladder Logic can be

restructured.

c) Distributive Law

 A⋅(B+C)=(A⋅B)+(A⋅C)

 AND distributes over OR.

PLC Application: Helps minimize relay contacts in Ladder

Logic.

d) Identity Law

 A+0=A

 A⋅1=A

 Adding zero or multiplying by one does not change

the result.

PLC Application: Eliminates redundant logic in relay circuits.

e) Complement Law

 A+A′=1

 A⋅A′=0

 A variable ORed with its complement is always 1,

and ANDed with its complement is always 0.

PLC Application: Detects signal changes in control systems.

IAT : Industrial Automation Technology


I A T L E S S O N 0 6 L o g i c G a t e s & B o o l e a n L o g i c i n P L C s | 13

B. Additional Boolean Theorems

a) Idempotent Law

 A+A=A

 A⋅A=A

 Repeating a variable does not change the value.

b) Absorption Law

 A+AB=A

 A(A+B)=A

 Eliminates unnecessary logic operations.

PLC Application: Removes redundant rungs in Ladder Logic.

c) De Morgan’s Theorem

 (A⋅B)′=A′+B′

 (A+B)′=A′⋅B′

 Used to simplify complex NOT operations.

PLC Application: Converts NAND/NOR logic into simpler

AND/OR logic.

IAT : Industrial Automation Technology


I A T L E S S O N 0 6 L o g i c G a t e s & B o o l e a n L o g i c i n P L C s | 14

3. Application in PLC Programming

Boolean Algebra in Ladder Logic

Consider a PLC controlling a conveyor belt system. The belt should

operate if:

1. Sensor A is active AND Motor is running

2. OR if Sensor B is active and Emergency Override is ON

Boolean Expression:

Y=(A⋅M)+(B⋅E)

Step-by-Step Ladder Logic Implementation:

1. Use two AND gates:

o One for A⋅

o One for B⋅E

2. Use one OR gate to combine outputs.

Simplification Example

Given Boolean expression:

Y=A+AB

Using Absorption Law:

Y=A

This means B is irrelevant, reducing the number of relays in

the PLC program.

IAT : Industrial Automation Technology


I A T L E S S O N 0 6 L o g i c G a t e s & B o o l e a n L o g i c i n P L C s | 15

4. More Examples with Simplification

Example 1: Reducing Logic Complexity

Given:

Y=AB+A(B+C)

Step-by-step simplification:

1. Apply Distributive Law: Y=AB+AB+AC

2. Apply Idempotent Law: (AB+AB=AB)

Y=AB+AC

Final optimized logic uses only two AND gates and one OR

gate instead of three AND gates.

Example 2: Optimizing PLC Scan Time

Given:

Y=A+A⋅B

Apply Absorption Law:

Y=A

B is unnecessary, so the PLC will run faster and use fewer

resources.

5. Exercises for Practice

IAT : Industrial Automation Technology


I A T L E S S O N 0 6 L o g i c G a t e s & B o o l e a n L o g i c i n P L C s | 16

Exercise 1: Simplify the Expression

Question:

Simplify the Boolean expression:

Y=A⋅(B+C)+A′B

Hint: Use the Distributive Law and Absorption Law.

Solution:

1. Apply the Distributive Law: Y=AB+AC+A′B

2. Use the Absorption Law: AB+A′B=B

3. Final simplified expression: Y=B+AC

Exercise 2: Implement Boolean Expression in Ladder Logic

Question:

Given the Boolean expression:

Y=AB+A′B+B′CY = AB + A'B + B'C

 Draw a ladder diagram for this logic.

 Identify ways to optimize it.

Solution:

1. Convert the Boolean terms into relay contacts:

o AB: A and B in series

IAT : Industrial Automation Technology


I A T L E S S O N 0 6 L o g i c G a t e s & B o o l e a n L o g i c i n P L C s | 17

o A'B: Normally closed A in series with B

o B'C: Normally closed B in series with C

2. Connect these branches in parallel in the ladder diagram.

Optimization:

 Simplify using Boolean algebra: Y=AB+A′B+B′C

=B(A+A′)+B′C

=B+B′C

=B+C

The optimized ladder diagram should have parallel contacts for B

and C, reducing complexity.

Exercise 3: Find Redundant Logic

Question:

Find and remove redundant logic in the Boolean expression:

Y=A+AB+A′B

Hint: Use the Absorption Law to simplify.

Solution:

1. Apply the Absorption Law: A+AB=A

So, Y=A+A′B

2. Use Absorption Law again: A+A′B=A+B

3. Final simplified expression: Y=A+B

IAT : Industrial Automation Technology


I A T L E S S O N 0 6 L o g i c G a t e s & B o o l e a n L o g i c i n P L C s | 18

6. Conclusion

Mastering Boolean algebra is essential for efficient PLC programming.

By applying these simplifications, PLC programmers can:

 Reduce execution time

 Minimize logic elements

 Improve troubleshooting efficiency

 Optimize industrial automation systems

APPLICATION OF LOGIC GATES IN LADDER LOGIC

PROGRAMMING

Ladder Logic is an essential programming language used in PLCs

(Programmable Logic Controllers). It represents electrical control

circuits using symbols that mimic relay logic. Logic gates play a crucial

role in implementing decision-making in PLC-based automation.

Basic Logic Gate Implementations in Ladder Logic

1. AND Gate Implementation

IAT : Industrial Automation Technology


I A T L E S S O N 0 6 L o g i c G a t e s & B o o l e a n L o g i c i n P L C s | 19

The AND gate requires both inputs to be HIGH (1) for the output to

be HIGH. In Ladder Logic, this is represented using two normally

open contacts in series.

Example Ladder Logic Representation:

--[ ]--[ ]--( )--

 If both input conditions are TRUE (closed contacts), the output

coil is activated.

Application Example:

 Start Button & Safety Sensor: A motor should start only if

both the start button is pressed (Input A) and the safety sensor

confirms the area is clear (Input B).

2. OR Gate Implementation

The OR gate requires at least one input to be HIGH for the output to

be HIGH. In Ladder Logic, this is represented using two normally

open contacts in parallel.

Example Ladder Logic Representation:

--[ ]--( )--

--[ ]--( )--

 If either of the input conditions is TRUE, the output coil is

activated.

IAT : Industrial Automation Technology


I A T L E S S O N 0 6 L o g i c G a t e s & B o o l e a n L o g i c i n P L C s | 20

Application Example:

 Dual Start System: A machine can be turned on using either a

manual button (Input A) or an automatic sensor (Input B).

3. NOT Gate Implementation

The NOT gate inverts the input signal. It is implemented in Ladder

Logic using a normally closed contact.

Example Ladder Logic Representation:

--[/]--( )--

 If the input is HIGH, the normally closed contact opens,

deactivating the output.

Application Example:

 Emergency Stop Circuit: If the emergency stop button is

pressed (Input A), the circuit should cut off power to the motor.

4. XOR (Exclusive OR) Gate Implementation

The XOR gate is HIGH only if one input is HIGH and the other is

LOW. This is achieved using two rungs in Ladder Logic.

Example Ladder Logic Representation:

--[ ]--[/]--( )--

--[/]--[ ]--( )--

 Ensures an output is activated only if one input is TRUE and the

other is FALSE.

Application Example:

IAT : Industrial Automation Technology


I A T L E S S O N 0 6 L o g i c G a t e s & B o o l e a n L o g i c i n P L C s | 21

 Toggle Switch Control: A machine alternates between ON and

OFF when two buttons are pressed alternately.

Advanced PLC Applications Using Logic Gates

1. Conveyor Belt System

A PLC-controlled conveyor belt system uses logic gates to ensure

packages move correctly:

 If Sensor A detects a package and Sensor B detects an

obstruction, the motor should stop.

 If Sensor A detects a package and there’s no obstruction, the

motor should run.

Ladder Logic Representation:

--[Sensor A]--[/Sensor B]--(Motor)—

2. Automated Pump Control System

A pump should start when either Tank A or Tank B is empty but

should stop when both are full. This is an OR Gate application.

Ladder Logic Representation:

--[/Tank_A_Full]--(Pump)--

--[/Tank_B_Full]--(Pump)--

IAT : Industrial Automation Technology


I A T L E S S O N 0 6 L o g i c G a t e s & B o o l e a n L o g i c i n P L C s | 22

Exercise 1: Simple AND & OR Gate Implementation

Objective:

 Create a Ladder Logic program where a light turns ON only when

both Switch A and Switch B are pressed simultaneously (AND

logic).

 Modify the program so that the light turns ON if either Switch A

or Switch B is pressed (OR logic).

Solution 1: AND Gate Implementation

--[ Switch A ]--[ Switch B ]--( Light )--

 Both switches must be ON (closed contacts) for the light to turn

ON.

Solution 2: OR Gate Implementation

--[ Switch A ]--( Light )--

--[ Switch B ]--( Light )--

 If either switch is ON, the light activates.

Exercise 2: Traffic Light Control System

Objective:

Design a simple traffic control system where:

IAT : Industrial Automation Technology


I A T L E S S O N 0 6 L o g i c G a t e s & B o o l e a n L o g i c i n P L C s | 23

 The green light should turn ON only if the pedestrian button is

NOT pressed (NOT gate) and there are no vehicles detected on

the crossroad (AND gate).

 The red light should turn ON if either the pedestrian button is

pressed OR a crossroad vehicle is detected (OR gate).

Solution 1: Green Light Control (AND + NOT Gate)

--[/ Pedestrian_Button ]--[/ Crossroad_Vehicle ]--( Green_Light )--

 If both conditions are met (pedestrian button not pressed, no

crossroad vehicle), the green light turns ON.

Solution 2: Red Light Control (OR Gate)

--[ Pedestrian_Button ]--( Red_Light )--

--[ Crossroad_Vehicle ]--( Red_Light )--

 If either condition is TRUE, the red light turns ON.

Exercise 3: Industrial Machine Safety Lock

Objective:

A machine should start only if:

1. The start button is pressed (normally open contact).

IAT : Industrial Automation Technology


I A T L E S S O N 0 6 L o g i c G a t e s & B o o l e a n L o g i c i n P L C s | 24

2. The safety door is closed (normally open contact).

3. The emergency stop is NOT activated (normally closed contact).

Solution: Machine Safety Lock Implementation

--[ Start_Button ]--[ Safety_Door_Closed ]--[/ Emergency_Stop ]--

( Machine_Start )--

 Explanation:

o The start button and safety door must be ON.

o The emergency stop must be OFF (hence, NC contact).

o When all conditions are met, the machine starts.

Conclusion

Logic gates in Ladder Logic allow for complex decision-making in

industrial automation. Understanding how to apply AND, OR, NOT, and

XOR gates ensures efficient and safe PLC programming. Through real-

world applications and exercises, engineers and technicians can

develop robust control systems for various industries.

MODULE SUMMARY

This module explored the fundamental concepts of logic gates,

Boolean algebra, and their application in Programmable Logic

Controllers (PLCs). Understanding these concepts is essential for

designing efficient and reliable automation control systems. The

module covered the seven basic logic gates (AND, OR, NOT, NAND,

IAT : Industrial Automation Technology


I A T L E S S O N 0 6 L o g i c G a t e s & B o o l e a n L o g i c i n P L C s | 25

NOR, XOR, XNOR), their truth tables, Ladder Logic implementations,

and real-world applications. Additionally, Boolean algebra principles

and simplification techniques were discussed to optimize PLC

programming and improve system performance.

KEY TAKEAWAYS

1. Logic Gates in PLCs: Logic gates form the backbone of digital

logic and PLC programming, facilitating decision-making processes

in industrial automation.

2. Boolean Algebra: The application of Boolean laws and theorems

simplifies complex logic expressions, reducing memory usage,

execution time, and troubleshooting complexity in PLC-based

control systems.

3. Ladder Logic Implementation: Each logic gate can be

implemented in Ladder Logic using normally open (NO) and

normally closed (NC) contacts, which help in designing real-world

automation applications.

4. Optimization through Boolean Algebra: Simplifying Boolean

expressions minimizes the number of relays and logic elements in

PLC programs, leading to enhanced efficiency and cost-

effectiveness.

IAT : Industrial Automation Technology


I A T L E S S O N 0 6 L o g i c G a t e s & B o o l e a n L o g i c i n P L C s | 26

5. Real-world Applications: Logic gates and Boolean algebra are

used in various industrial automation scenarios, including conveyor

belt control, traffic light systems, and machine safety mechanisms.

MODULE CONCLUSION

Mastering logic gates and Boolean algebra is essential for efficient PLC

programming in industrial automation. Understanding the role of AND,

OR, NOT, XOR, and other logic functions allows engineers to create

optimized, reliable, and cost-effective control systems. Boolean algebra

further enhances programming efficiency by simplifying complex

expressions, reducing system resources, and improving

troubleshooting. Practical applications, such as conveyor belts, traffic

lights, and safety systems, demonstrate the real-world significance of

these concepts in modern automation. As PLC technology continues to

evolve, a strong foundation in logic gates and Boolean algebra remains

crucial for industrial automation professionals.

REFERENCES

Bolton, W. (2022). Programmable Logic Controllers (7th ed.).

Butterworth-Heinemann. Groover, M. P. (2020). Automation,

Production Systems, and Computer-Integrated Manufacturing (5th ed.).

Pearson Education. Petruzella, F. D. (2016). Programmable Logic

Controllers (5th ed.). McGraw-Hill Education. Rockwell Automation.

(2021). Introduction to Ladder Logic Programming. Retrieved from

IAT : Industrial Automation Technology


I A T L E S S O N 0 6 L o g i c G a t e s & B o o l e a n L o g i c i n P L C s | 27

https://www.rockwellautomation.com Siemens. (2020). PLC

Programming with Siemens S7-1200 and TIA Portal. Siemens AG.

IAT : Industrial Automation Technology

You might also like