PLC

# Logic Gates in PLC Programming: A Guide with Truth Tables and Ladder Logic Diagrams

• Programmable Logic Controllers (PLCs) are crucial in industrial automation, controlling machinery and processes by executing programmed logic sequences.
• At the core of PLC programming are logic gates, which perform fundamental logical operations on one or more binary inputs to produce a single binary output.

This guide will provide an in-depth look at the primary logic gates used in PLC programming, including their truth tables and representation in ladder logic diagrams.

An AND gate outputs true (1) only if all its inputs are true (1). This gate is used in scenarios where multiple conditions must be satisfied simultaneously.

• When both Input A and Input B are 1, the output is 1.
• For all other combinations of inputs, the output is 0.

In the ladder logic diagram, the series connection of two contacts (A and B) represents the AND gate. Both contacts must be closed (true) for the output coil to be energized.

An OR gate outputs true (1) if at least one of its inputs is true (1). This gate is used when any one of multiple conditions can trigger an action.

• When either Input A or Input B is 1, the output is 1.
• If both inputs are 0, the output is 0.

In this diagram, the parallel connection of two contacts (A and B) represents the OR gate. If either contact is closed (true), the output coil is energized.

A NOT gate outputs the inverse of its input. This gate is used when the output should be true if the input is false, and vice versa.

• When the input is 0, the output is 1.
• When the input is 1, the output is 0.

In ladder logic, a normally closed contact (A) represents the NOT gate. When A is open (false), the output coil is energized.

A NAND gate outputs true (1) if at least one of its inputs is false (0). It is the inverse of the AND gate and is useful in circuits where the output should be true unless all inputs are true.

• When both Input A and Input B are 1, the output is 0.
• For all other combinations of inputs, the output is 1.

The parallel  connection of two contacts (A and B) followed by a normally closed contact represents the NAND gate. The output is false only when both A and B are true.

A NOR gate outputs true (1) if all its inputs are false (0). It is the inverse of the OR gate and is used where the output should be true only when all inputs are false.

• When both inputs are 0, the output is 1.
• If either input is 1, the output is 0.

In this diagram, the series  connection of two normally closed contacts (A and B) represents the NOR gate. The output is true only when both contacts are open (false).

An XOR (exclusive OR) gate outputs true (1) if exactly one of its inputs is true (1). It is used when the output should be true only if one of the inputs is true, but not both.

• The output is true if only one of the inputs is true.
• If both inputs are the same, the output is false.

In ladder logic, the XOR gate is represented by a combination of series and parallel connections of normally open and normally closed contacts. This ensures the output is true only when the inputs are different.

An XNOR (exclusive NOR) gate outputs true (1) if both inputs are the same. It is the inverse of the XOR gate and is used when the output should be true if both inputs are either true or false.

• The output is true if both inputs are the same.
• If the inputs are different, the output is false.

The XNOR gate is represented by a combination of series and parallel connections, similar to the XOR gate but arranged to produce the inverse result. This ensures the output is true only when the inputs are identical.

Understanding and implementing logic gates in PLC programming is fundamental for developing complex and efficient control systems. Each logic gate performs a specific logical function, which can be represented and combined in ladder logic diagrams to achieve desired automation outcomes. By mastering these basic elements, engineers can create sophisticated control programs that enhance the performance and reliability of industrial automation systems.

### Sundareswaran Iyalunaidu

With over 24 years of dedicated experience, I am a seasoned professional specializing in the commissioning, maintenance, and installation of Electrical, Instrumentation and Control systems. My expertise extends across a spectrum of industries, including Power stations, Oil and Gas, Aluminium, Utilities, Steel and Continuous process industries. Tweet me @sundareshinfohe