Boolean Logic in PLC Programming: Understanding FBD Logic Gates

Boolean logic is the foundation of every PLC program. From simple machine controls to complex industrial automation systems, logic gates determine how controllers respond to changing inputs and ope...

Every PLC program relies on a simple concept: making decisions based on true or false conditions. Whether a conveyor starts, a motor stops, or an alarm activates, the controller evaluates a set of logical rules before taking action. These rules are based on Boolean logic, the same principles used in digital electronics and computer systems.

Function Block Diagram (FBD) programming provides a visual way to implement Boolean logic inside a PLC. Instead of relying on electrical symbols, FBD uses interconnected blocks that represent logical operations. This approach makes it easier to visualize signal flow and understand how inputs affect outputs.

Understanding Function Block Diagrams

Engineers often compare Function Block Diagrams to electronic circuits. Each block performs a specific operation, while the connecting lines carry signals between functions. Inputs enter one side of the block, the logic is evaluated, and the resulting output is sent to the next function.

Compact PLC training setup used for learning function block programming

Figure 1. Compact PLC training setup used for learning function block programming.

Figure 1 shows a simple PLC training setup. While the hardware is small, the same programming concepts apply to large industrial automation systems used in manufacturing, process control, and material handling applications.

Before exploring logic gates, it is helpful to understand the most basic FBD program: directly connecting an input to an output.

Basic function block diagram connecting PLC inputs directly to outputs

Figure 2. Basic function block diagram connecting PLC inputs directly to outputs.

In this example, the PLC simply transfers the status of an input device to an output. This type of program is commonly used during commissioning and troubleshooting to verify that field wiring and I/O modules are functioning correctly.

AND Logic: Requiring Multiple Conditions

The AND gate is one of the most frequently used logic functions in industrial automation. An AND function requires all inputs to be active before the output can energize. If any input becomes inactive, the output immediately turns off.

AND logic represented in ladder logic, structured text, and function block diagrams

Figure 3. AND logic represented in ladder logic, structured text, and function block diagrams.

AND logic is commonly used for machine interlocks. A conveyor motor might require a start command, a healthy safety circuit, and confirmation that downstream equipment is available. All three conditions must be true before the PLC allows the motor to run.

This logic helps prevent equipment damage and ensures machines operate only when safe conditions exist.

OR Logic: Accepting Alternative Inputs

Unlike an AND gate, an OR gate only requires one input to be active for the output to energize. Additional active inputs do not change the result because the output is already true.

OR logic displayed using ladder logic and function block diagrams

Figure 4. OR logic displayed using ladder logic and function block diagrams.

OR logic appears frequently in alarm systems. A machine alarm may activate when a safety fault occurs, a motor overload trips, or a communication error is detected. Since any of these events requires operator attention, OR logic provides an efficient way to combine multiple fault conditions.

Another common application is machine startup. Operators may be able to start equipment from a local pushbutton or an HMI screen. Either command is acceptable, making OR logic the ideal choice.

NOT Logic: Inverting a Signal

The NOT gate performs a simple but important function. It reverses the state of a signal. If the input is true, the output becomes false. If the input is false, the output becomes true.

NOT logic example showing signal inversion within a PLC program

Figure 5. Example showing OR logic for one output and NOT logic for another output.

NOT logic is widely used in safety and fault-monitoring applications. Engineers often monitor signals that should remain active during normal operation. If the signal disappears unexpectedly, the controller interprets the change as a fault condition.

For example, a healthy safety relay may continuously provide a status signal. By using NOT logic, the PLC can immediately identify when that signal is lost and stop the machine if necessary.

NAND Logic: Inverting an AND Function

NAND logic is created by placing an inverter on the output of an AND gate. Instead of requiring all inputs to turn the output on, NAND logic requires all inputs to turn the output off.

NAND logic implementation using ladder logic and function block programming

Figure 6. NAND logic implementation using ladder logic and function block programming.

NAND logic can be difficult for new programmers to visualize because the inversion occurs at the output rather than the inputs. Understanding this difference helps avoid common design mistakes when translating logic between ladder diagrams and function block diagrams.

In practice, NAND logic is useful whenever equipment should remain active until a specific combination of conditions occurs.

NOR Logic and Safety Circuits

NOR logic combines an OR function with an inverted output. The output remains active only when every input remains inactive.

NOR logic commonly used in emergency stop and safety circuits

Figure 7. NOR logic commonly used in emergency stop and safety circuits.

Emergency stop systems provide a practical example. Under normal conditions, all emergency stop buttons remain reset and the safety circuit stays energized. Pressing any emergency stop button immediately breaks the safety chain and removes power from hazardous equipment.

This fail-safe design philosophy is a cornerstone of modern machine safety systems.

XOR Logic: When Inputs Must Be Different

The Exclusive OR, or XOR gate, behaves differently from standard OR logic. The output only energizes when one input is active and the other is inactive.

XOR logic showing exclusive input conditions in a PLC application

Figure 8. XOR logic showing exclusive input conditions in a PLC application.

If both inputs are off, the output remains off. If both inputs are on, the output also remains off. The output only activates when the two inputs differ.

XOR logic is commonly used with selector switches, mode selection circuits, and redundant sensors. For example, a machine may be designed to operate in either automatic mode or manual mode, but never both simultaneously. XOR logic can verify that only one operating mode has been selected.

Why Boolean Logic Matters in PLC Programming

Although modern automation systems have become increasingly sophisticated, Boolean logic remains at the heart of every PLC application. Logic gates allow controllers to evaluate operating conditions, enforce safety requirements, process sensor inputs, and control outputs in a predictable manner.

Function Block Diagram programming provides a clear visual representation of these logical relationships. By understanding how AND, OR, NOT, NAND, NOR, and XOR functions operate, engineers can create more reliable control systems and troubleshoot existing programs more effectively.

Whether you are working on a small standalone machine or a large industrial automation project, mastering Boolean logic is one of the most valuable skills in PLC programming.

About the Author

Michael Harrington | Industrial Control Systems Analyst

Michael Harrington has over 12 years of experience covering industrial automation, PLC programming, machinery protection systems, and digital manufacturing technologies. His background includes automation projects involving Siemens SIMATIC platforms, Allen-Bradley ControlLogix systems, ABB AC800M controllers, and Honeywell process automation solutions. He regularly reports on control engineering trends, industrial cybersecurity, machine safety, and advanced manufacturing technologies used across global process and discrete industries.

Leave a comment

Please note, comments need to be approved before they are published.