Vous êtes sur la page 1sur 24

Switching Logic

Logic gates
Logic gates are very useful in dealing with and processing a combination of different
inputs. This switching logic can be applied to electrical switches and sensors,
pneumatic valves or hydraulic systems. Switching logic uses logic gates to perform
decisions. In previous work you have already seen NOT, AND and OR logic gates.

NOT

A
B

AND

A
B

OR

It is worth remembering that logic gates are part of digital systems and, as such,
respond to either logic 1 or logic 0 signals only.
Integrated circuits
Although logic gates have electronic symbols, they are not discrete components: they
are contained in integrated circuits. A typical example is the TTL7400 IC shown
below. (The LS part gives more information about the chip for users.)

NAND logic gates are a combination of


NOT and AND logic gates see the
following page.

Standard Grade Technological Studies: Logic Revision Notes

The NAND logic gate


The NAND gate is effectively an inverted AND gate. In other words, the results
obtained from the output are the opposite to those of the AND gate. This gate is often
referred to as NOT AND.
When drawing up the truth table for the NAND gate it can be difficult to picture or
imagine the results. The best way to do this is to pretend that it is an AND gate and
then invert (reverse) the results, thus giving you the outputs for the NAND gate.
A

Symbol for NAND Gate


The NOR logic gate
The NOR gate is effectively an inverted OR gate. In other words, the results obtained
from the output are the opposite to that of the OR gate. This gate is often referred to as
NOT OR.
As with the NAND gate, when drawing up the truth table for the NOR gate it can be
difficult to picture or imagine the results. The best way to do this is to pretend that it
is an OR gate and then invert (reverse) the results, thus giving you the outputs for the
NOR gate.
A

B
Symbol for NOR gate

The XOR logic gate


The XOR gate is a strange one off gate. It behaves like the OR gate, except that it
gives a 0 when both outputs are on.

A
B

Symbol for XOR gate

Standard Grade Technological Studies: Logic Revision Notes

NAND gate technology


NAND gate technology can be used to build other logic gates using NAND gates only.
(The same thing can be achieved using NOR gates, but NAND gate chips are more
common.)

NOT

AND

OR

NOR

XOR

Many manufacturers use only one type of gate (normally NAND) in the manufacture
of their products. This has several advantages.

You only have to stock one type of chip instead of a large range.
People only have to be familiar with the characteristics of this one chip.
Very often significant simplification of complex circuits is possible, thus reducing
the number of chips required.

Standard Grade Technological Studies: Logic Revision Notes

Binary numbers
The number system that we use is the decimal system; that is, we use a scale of ten.
This decimal system uses 10 different digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. You should
have noticed that truth tables use only two digits, 0 and 1. This is called a binary
system and it uses combinations of the digits 0 and 1 to form binary numbers.
The decimal system
The table below shows the decimal system of counting. The values of the columns (of
the left-hand table) working from right to left are 1, 10, 100 and 1000. These can be
written as powers of ten: 100, 101, 102, and 103. As indicated above, this type of
counting is called decimal and uses a base of 10.

Decimal
3

Binary

10

10

10

1000

100

10

1
1
1
1
1
1
1

10

22

21

20

1
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6

16

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

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

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

1
1
1
1
1
1
1
1
0

The binary system


As stated above, the binary system uses only two digits, 1 and 0. This system is suited
to digital systems in electronics, where 1 represents ON or HIGH and 0 represents
OFF or LOW.
The right-hand table shows the binary equivalents of the decimal numbers in the table
on the left. The values of the columns working from right to left are 1, 2, 4, 8, and 16.
These can be written in powers of 2: 20, 21, 22, 23 and 24.

Standard Grade Technological Studies: Logic Revision Notes

Combinational logic
The simple block diagram of the electronic system below, you will notice it has an
AND gate, an OR gate and an inverter (NOT gate) in it.

L ig h t
S e n so r

In v e r te r

Po w e r
C o n n e c t io n

P u sh
S w it c h

O R
G a te

P re s s u re
Pa d

AND
G a te

Tr a n s d u c e r
D riv e r

B u lb
U n it

We can draw a logic diagram of this system, as shown below. There is more than one
logic gate in this diagram and so it is known as a combinational logic diagram.
L IG H T
SENSO R
PRESSURE
PAD
S W IT C H

Standard Grade Technological Studies: Logic Revision Notes

BUZZER

Truth tables for combinational logic systems


Drawing up a truth table for a system with more than one logic gate is not too
difficult. As long as you know how each of the basic gates work, you can treat each
gate on its own and then work your way through the system.
Before going ahead to look at the outputs in the truth tables, it is worth reminding
ourselves of the number of combinations of inputs possible per number of actual
inputs.
One input
If there is only one input (A), then there are only two combinations (logic 0 or logic
1). So the incomplete truth table would be drawn up as below (ignoring the results in
the output column, Z).
A Z
0
1
Two inputs
If there are two inputs (A and B) they can be arranged in four different combinations:
A and B both off
A off and B on
A on and B off
A and B both on.
You cannot create any other combinations. The truth table would therefore be drawn
up as below (ignoring the results in the output column, Z).
A
0
0
1
1

B
0
1
0
1

Z
0
1
1
1

You should notice that the input columns are arranged in binary number order.
Three inputs
If there are three inputs (A, B and C) they can be arranged in eight different
combinations. The truth table for a 3-input system is shown below.
A
0
0
0
0
1
1
1
1
6

B
0
0
1
1
0
0
1
1

C
0
1
0
1
0
1
0
1

Standard Grade Technological Studies: Logic Revision Notes

Summary
The pattern in the truth tables above is clear. Starting with one input giving two
combinations, you simply double the number of combinations each time an input is
added.
1 input: 2 combinations
2 inputs: 4 combinations
3 inputs: 8 combinations
4 inputs: 16 combinations
and so on.
You will never be asked to work with a system that has more than three inputs.
Worked example
The example below shows a logic diagram that has two logic gates. There are three
inputs, so this gives eight combinations in the truth table.

B
Z

Stage 1
Draw up the results for point D.(This is the output from the AND gate, being fed by
inputs A and B only.)
A
0
0
0
0
1
1
1
1

B
0
0
1
1
0
0
1
1

C
0
1
0
1
0
1
0
1

D
0
0
0
0
0
0
1
1

Standard Grade Technological Studies: Logic Revision Notes

Stage 2
Draw up the results for point Z. (This is the output from the OR gate, being fed by
output D and input C only.)
A
0
0
0
0
1
1
1
1

B
0
0
1
1
0
0
1
1

C
0
1
0
1
0
1
0
1

D
0
0
0
0
0
0
1
1

Z
0
1
0
1
0
1
1
1

By following this technique, logic system problems can be solved easily.


You could use a circuit simulation program to check your results.

Standard Grade Technological Studies: Logic Revision Notes

Boolean expressions
Each logic gate has a corresponding Boolean mathematical formula or expression.
The use of these expressions saves us having to draw symbol diagrams over and over
again.
The name Boolean is taken from an English mathematician, George Boole, who
founded symbolic logic in the nineteenth century.

Z=A

NOT

Z = A.B

AND

Z = A+B

OR

Z = A.B

NAND

Z = A+B

NOR

Standard Grade Technological Studies: Logic Revision Notes

Creating logic diagrams from truth tables


When designing systems, it is normal to design a logic diagram from a prepared truth
table. This may seem difficult to start with, but if you concentrate on the
combinations which give a logic 1 condition in the output column, solutions can be
found easily.
The truth table below shows two inputs, A and B, and one output, Z.
A
0
0
1
1

B
0
1
0
1

Z
0
0
1
0

Z = A. B

The output Z is at logic 1 in the third row down, and we can see that for this to happen
A must be at logic 1 and B must be at logic 0. In other words
Z = A AND NOT B

This means that we need a two-input AND gate, with B being fed through a NOT
gate. We can write the statement in shorthand Boolean as

Z = A. B
This means that the logic diagram is as shown below.

10

A.B

Standard Grade Technological Studies: Logic Revision Notes

Worked example
In this problem we have three inputs, A, B and C, with one output, Z. From the truth
table we can see that there are two occasions when the output goes to logic 1.
A
0
0
0
0
1
1
1
1

B
0
0
1
1
0
0
1
1

C
0
1
0
1
0
1
0
1

Z
0
0
0
1
0
0
1
0

Z =A. B . C

Z =A. B . C

In other words, Z = 1 if (A is at logic 1 AND B is at logic 1 AND C is at logic 1) OR


if (A is at logic 1 AND B is at logic 1 AND C is at logic 0).
This means we need a two-input OR gate being fed from two three-input AND gates
as shown below.

A
A.B.C

B
(A . B . C) + (A . B . C)
C
A.B.C
C
The shorthand Boolean equation for this truth table is

Z = ( A . B . C) + ( A . B . C)

Standard Grade Technological Studies: Logic Revision Notes

11

Creating logic systems from written specifications


Perhaps the most common application of switching logic is creating a logic system to
meet a given specification. Normally, by reading the specification carefully, the
system designer can almost see the required logic system.
Worked example
A burglar alarm system is to sound if a master switch is on and either a light beam is
broken or a pressure pad is stood on.
Draw a logic diagram and a truth table for this system.
Read the specification carefully. You should notice that it has three inputs. These are:
a master switch (M)
a light sensor (L), and
a pressure pad (P).
It has one output, an alarm bell (B).
The bell should go to logic 1 if the master switch is at 1 and either the light beam goes
to logic 0 or the pressure pad goes to logic 1. This can be written in Boolean as:
B = M . (L + P )
Note: The alarm has to be triggered when the light beam is broken and so a NOT gate
is needed.
In other words, you need a two-input AND gate that is fed directly from M and also
from a two-input OR gate that is fed from L (through an inverter) and P. The logic
diagram is shown below.
M

L
L

The truth table for this system is shown below. Again, all you have to do is read the
specification carefully and then read across each row, one at a time, and decide
whether the bell should be ringing or not. There are some short cuts. For example, in
the first four rows the master switch is off; therefore the bell must be at logic 0 even
if there is a burglar in the house.
M L P B
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 0

12

Standard Grade Technological Studies: Logic Revision Notes

1
Logic gate integrated circuits (ICs)

Integrated circuits consist of plastic cases filled with electronic circuitry. There are
many resistors, transistors and other components packed into the chips. There are
literally thousands of ICs on the market, all designed to do different jobs logic gates,
amplifiers, timers, etc.
In this work we will be using the TTL (transistortransistor logic) range of chips.

TTL chips require a stable 5V supply to work properly. (Great difficulties will be met
if any other voltage is used.) Any unconnected pins automatically go to logic 1. In
other words, if a wire connected to a pin is connected to the 0-volt rail (logic 0), it will
go to logic 0. If the wire is disconnected from the 0-volt rail it will go to logic 1.
However, it is good practice to connect pins to high or low as needed.
All TTL chips have a four-digit code number, which always starts with 74. For
example, a 7400 is a quad two-input NAND chip.
Although the chip contains complex circuitry, the internal wiring can be shown as
simple logic circuits with the inputs and outputs of each logic gate shown. This is
called a pin-out diagram.
+Vcc
14

13

12

11

10

Pin-out diagram for


7408 quad
two-input AND gate

7
Gnd
(0V)

Pin 14 is connected to the 5-volt stable supply and pin 7 to 0 volts.

Standard Grade Technological Studies: Logic Revision Notes

13

Pin-out diagrams
ICs are impossible to use without the manufacturers data sheets to show what
facilities are available on the chip and how the pins are to be connected. These data
sheets contain pin-out diagrams. A pin-out diagram is a graphical layout of the chip
and its contents.
Note: all chips have either a notch or a small dot (or both) above pin number 1 so that
the user can identify all the pins without them being numbered. The dot is always at
pin 1.
Pin-out diagrams for common TTL logic ICs
The description of each pin-out diagram gives details of the chip. For example, a dual
four-input NOR means the chip has two (dual) NOR gates on it, each having four
inputs. A quad two-input AND means the chip has four AND gates, each gate having
two inputs.
+Vcc

+Vcc

14

13

12

11

10

1
1

13

12

11

10

Gnd
(0V)

7400
+Vcc

13
13

14

14

Gnd
(0V)

7404
+Vcc
+Vcc 14

12
12

2
2

11
10

11

3
3

10

4
4

7421

9
9

5
5

14

13

12

11

10

6
6

7
7 Gnd

Gnd(0V)
(0V)

Gnd
(0V)

7420
+Vcc
14

13

12

11

10

7432

Gnd
(0V)

N
14

Standard Grade Technological Studies: Logic Revision Notes

Pin-out and wiring diagrams example


The following logic circuit could be constructed using ICs.
INPUT A
OUTPUT
INPUT B

Since the gates within an IC are identical, any one of them can be used. An example
of possible connections is shown in the IC circuit diagram below.
+Vcc
14

+Vcc
13

12

11

10

14

13

12

INPUT A

10

743
2

740
8
1

11

Gnd
(0V)

OUTPUT

Gnd
(0V)

INPUT B

Standard Grade Technological Studies: Logic Revision Notes

15

16

Standard Grade Technological Studies: Logic Revision Notes

Standard Grade Technological Studies: Logic Revision Notes

17

18

Standard Grade Technological Studies: Logic Revision Notes

Standard Grade Technological Studies: Logic Revision Notes

19

20

Standard Grade Technological Studies: Logic Revision Notes

Standard Grade Technological Studies: Logic Revision Notes

21

22

Standard Grade Technological Studies: Logic Revision Notes

Standard Grade Technological Studies: Logic Revision Notes

23

24

Standard Grade Technological Studies: Logic Revision Notes

Vous aimerez peut-être aussi