Logical Gates (And, Or, Not, Nand, NOR, EX-OR and EX-NOR) and PLC Ladder Logic For Logical Gates

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 19

LOGICAL GATES ( AND, OR, NOT, NAND,

NOR, EX-OR and EX-NOR) and PLC Ladder


logic for Logical gates
Electric Logic
Logical values can easily be expressed by electrical circuits.
True or 1 can be defined as voltage on a wire while False or 0 can be defined as no voltage. We
will use positive logic.
Analog values can be anything while digital only has discrete values, 0 or 1 Electrical devices called
gates can implement the logical

Logic Gates & Symbols

Note that gates can have more than 2 inputs

Truth table of all gates:


AND gate

The AND gate is an electronic circuit that gives a true output (1) only if all its inputs gives a true output (1)
only if all its inputs are true. A dot () is used to show the AND operation i.e. AB. Note that the dot is
sometimes omitted i.e. AB
Inputs and Outputs
The inputs can be considered as logical (true or false) values.
You can also think of the inputs as voltage (true) or ground (false).
The output of the gate will also be voltage (true) or ground (false).

Ladder logic in PLC for AND gate is shown below.It gives similar result as AND logic gate.
OR gate

The OR gate is an electronic circuit that gives a true output (1) if one or more of its gives a true output (1)
if one or more of its inputs are true. A plus (+) is used to show the OR operation.

Ladder logic in PLC for OR gate is shown below.It gives similar result as OR logic gate.

NOT gate
The NOT gate is an electronic circuit that produces an inverted version of that produces an inverted
version of the input at its output.
It is also known as an inverter.
If the input variable is A, the inverted output is known as NOT A.
This is also shown as A', or ,with a bar over the top A

Ladder logic in PLC for NOT gate is shown below.It gives similar result as NOT logic gate.
NAND gate

This is a NOT-AND gate which is equal to an AND gate followed by a NOT gate.
The outputs of all NAND gates are true if any of the inputs are false.
The symbol is an AND gate with a small circle on the output. The small circle represents inversion.

Ladder logic in PLC for NAND gate is shown below.It gives similar result as NAND logic gate.

NOR gate
This is a NOT-OR gate which is equal to an OR gate followed by a NOT gate.
The outputs of all NOR gates are false if any of the inputs are true.
The symbol is an OR gate with a small circle on the output. The small circle represents inversion
represents inversion.

Ladder logic in PLC for NOR gate is shown below.It gives similar result as NOR logic gate.

EX-OR gate
The 'Exclusive-OR' gate is a circuit which will give a true output if either, but not both, of its two inputs are
true.
An encircled plus sign ( ) is used to show the EX-OR operation.

Ladder logic in PLC for EX-OR gate is shown below.It gives similar result as EX-OR logic gate.

EX-NOR gate
The 'Exclusive-NOR' gate circuit does the opposite to the EX-NOR gate.
It will give a false output if either, but not both, of its two inputs are true.
The symbol is an EX-NOR gate with a small circle on the output small circle on the output.
The small circle represents inversion.
Logic gates representation using the Truth table.

Ladder logic in PLC for EX-NOR gate is shown below.It gives similar result as EX-NOR logic gate.

Logical Equivalence

Circuits are logically equivalent if they produce the same truth table output. Similarly we can make many
Logic using Logical gates as shown below.
Three Input one output AND gate is shown below:
Four input AND gate is shown below:

Two input,Three input and Four input OR gates are shown below:
The Decision Makers: AND, OR and NOT
Life is full of decisions. What is true for us is also true of PLCs. We gather information
(input) and based on that we make choices that determine our output. All though I've
always found computers to be quite a bit more logical then human beings.

For an example of how we use logic in everyday life consider these statements:

If Tommy OR Bob want to play basketball then I'll play too.

It's 6 o'clock AND I'm NOT hungry therefore I'm going to keep playing.
If Mom comes out AND orders me inside OR it get's dark then I'll stop playing.

Now these are pretty simple decisions especially if you're a ten year old boy. You'll notice
that they all involve three types of comparisions: AND, OR and NOT. Now we could get
more complex but all that we'd be doing is using these simple building blocks.

In the world of automation these types of TRUE or FALSE conditions come down to a device
being ON or OFF, CLOSED or OPEN, PRESENT or ABSENT, 24 VOLTS or 0 VOLTS. In the PLC
it all boils down to our now familiar binary system of a 1 or a 0. Typically having a bit ON
represents a TRUE condition while OFF is FALSE. This is abitrary though as it may make
more sense to use what is called failsafe logic and have an ON bit as a FALSE condition.

Let's turn again to some simple statements but this time using automation examples.

When the button is pressed AND the door is closed then turn on the motor.

If the process is done OR the emergency stop button signal is NOT on then turn off
the motor. (This is an example of a failsafe operation as the emergency stop button
could be pressed or the wire has been disconnected. In either case we want to check
this for safety reasons. Relying on a signal to turn on when a wire has fallen off long
ago may cause an awkward moment when we truly have to stop the machine in an
emergency.)

If the tank is full OR the button is pressed AND there are no alarms then start the
process.

It would be nice to program like this but computers like to be a little bit more structured. A
series of graphical objects have been used for years to represent these logic elements and
they can be easily converted to a common ladder logic equivalent. These functions are also
called gates as they act like gate keepers for different logic.

The NOT function

The simplest of all logic functions is the NOT gate.


It's sole function in life is to invert of flip the logic state. So an input of 1 will come out as a
0 and visa versa. Shown below is a truth table (it doesn't lie) showing all possible inputs
and the resulting logical output.

Input A Output

0 1

1 0

The ladder logic equivalent for a NOT function looks like a normal contact but with a slash
through it.

The AND function

The AND gate is associated with the following symbol that can have any number of inputs
but only one output.

The truth table below shows that the output is only turned on when all the inputs are true
(1). An easy way to remember this is AND works like multiplication.

Input A Input B Output

0 0 0
1 0 0

0 1 0

1 1 1

The ladder logic equivalent for an AND function looks like two normal contacts side by side.

The OR function

Last but not least the OR gate is associated with the following symbol that also can have
any number of inputs but only one output.

The truth table below shows that the output is turned on (1) when any of the inputs are true
(1). An easy way to remember this is OR works like addition.

Input A Input B Output

0 0 0

1 0 1

0 1 1

1 1 1
The ladder logic equivalent for an OR function looks like two normal contacts on top of each
other.

Combining AND or OR with NOT

The NOT gate might not look like much help if you haven't programmed much but you'll find
yourself actually using it frequently. It's very common to use it in combination with AND
and OR. So the engineering gods decided to make some symbols for these combinations.

Putting the NOT and AND gates together forms the NAND gate. The truth table below
shows that it is simply an inverted output of the AND gate.

Input A Input B Output

0 0 1

1 0 1

0 1 1

1 1 0

A little circle (or if you like, a bubble) at the end of a AND gate is used to signify the NAND
function. It's symbol and corresponding ladder logic are shown below. Now pay close
attention to the ladder logic because the contacts are in parallel and not in series like the
AND function.
Putting the NOT and OR gates together forms... you got it... the NOR gate. The truth table
below shows that it is simply an inverted output of the OR gate.

Input A Input B Output

0 0 1

1 0 0

0 1 0

1 1 0

Again a little circle is placed at the end of an OR gate to signify the NOR function. It's
symbol and corresponding ladder logic are shown below. The ladder logic is very different
from the regular OR gate.

But wait! Don't order yet... the XOR gate.

So far with our logic gates we've covered almost all possible combinations except for one
shown by the truth table below.
Input A Input B Output

0 0 0

1 0 1

0 1 1

1 1 0

The logic to produce this output is called an Exclusive OR gate otherwise known as the XOR
gate. It's a specialized form of the OR gate. So if either one of the inputs are on then the
output is true, otherwise you're out of luck. The symbol for the XOR gate is shown by
added a curved line to the OR gate symbol.

The ladder logic to implement an XOR gate is a little more complex then the others.

How useful is the XOR logic? You probably use the XOR gate everyday without thinking
about it if you have a room with a light that works off two switches. If both switches are in
the same position then the light will be off. Therefore just flipping one switch will turn the
light on. In the PLC program this can be extremely useful for programming alternating
actions or gray codes.
Ok, there is one more logic gate but I promise it is the last one. It makes sense that there
is a XNOR gate which is the combination of the NOT and XOR logic. It simply inverts the
output of the XOR function.

Input A Input B Output

0 0 1

1 0 0

0 1 0

1 1 1

The symbol for the XNOR gate is shown below along with it's ladder logic equivalent.

Hope for the Future

While these terms and symbols may seem a bit esoteric for the PLC beginner they are
important in the long run. A good grasp of these essentials will make PLC programming
easier, simplier and save memory. The next lesson will make this clearer when we
consider Boolean algebra.

You might also like