Automation
Automation
Page 1 of 34
3.4: Complementation ............................................................................................................... 18
3.4.1. 1’s complement ........................................................................................................... 18
3.4.2: 2’s complement ........................................................................................................... 19
Chapter 4: Logic gates (Combinational logic) .............................................................................. 21
4.1: Introduction........................................................................................................................ 21
4.2: Truth table .......................................................................................................................... 21
4.3: OR gate .............................................................................................................................. 21
4.4: AND gate ........................................................................................................................... 22
4.5: NOT gate............................................................................................................................ 23
4.6: Exclusive OR gate (XOR) ................................................................................................. 24
4.7: Complementary logic gates ............................................................................................... 24
4.7.1: NAND (AND + NOT) gate ........................................................................................ 24
4.7.2: NOR (OR + NOT) gate............................................................................................... 25
4.7.3: Exclusive –NOR (XNOR) gate (XOR+NOT) gate .................................................... 26
4.8: Universal gates ................................................................................................................... 27
Chapter 5: Boolean algebra and simplification techniques........................................................... 28
5.1: Introduction........................................................................................................................ 28
5.2: Postulates of Boolean algebra ............................................................................................ 28
5.3: Theorems ........................................................................................................................... 28
5.4: Universality of NAND and NOR gates ............................................................................. 31
5.5: Simplification techniques .................................................................................................. 31
Page 2 of 34
Chapter 1: Number systems
1.1: introduction
The study of number systems is important from the view point of understanding how data are
represented before they can be processed by any digital system, including a digital computer,
PLC, etc. it is one of the most basic topics in digital electronics.
fractional part, these are r 1 , r 2 , r 3 , r 4 and so on, starting with the digit next to the radix point.
Here, r is the radix of the number system.
1.3: Binary number system
It is a base-2 number system with ‘0’ and ‘1’ as the two independent digits. All larger numbers
are represented in terms of ‘0’ and ‘1’. Each digit is called a bit.
Page 3 of 34
Note:
A nibble is a combination of 4 bits
Byte or bite is a combination of 8 digits.
Word is a combination of 16 digits or two bytes
1.4: Octal number system
The octal number system is a base-8 number system and has 8 distinct digits. All larger numbers
or higher order numbers are expressed as a combination of these digits. The independent digits
are: 0,1,2,3,4,5,6, and 7.
Solution
Integer part: 1001
Decimal equivalent: 1 20 0 21 0 22 1 23
1 0 0 8
9
Fractional part: 0101
Decimal equivalent: 0 21 1 22 0 2 3 1 2 4
0 0.25 0 0.0625
0.3125
Page 4 of 34
1001.01012 9.3125 10
Solution
Integer part: 137
Decimal equivalent: 7 80 3 81 1 82 7 24 64 95
Fractional part: 21
Decimal equivalent: 2 81 1 82 0.25 0.015625 0.265625
137.218 95.26562510
Solution
Integer part: 1E0
Decimal equivalent: 0 160 14 161 1 16 2 0 224 256 480
Fractional part: 2A
Decimal equivalent: 2 161 10 162 0.125 0.0390625 0.1640625
1E 0.2 A16 480.164062510
Page 5 of 34
equivalent bits has been obtained. This method of decimal-binary conversion is called the
double-dabble method.
Example
Convert 13.375 10 to a number in base 2
Solution
Integer part = 13
Divisor Dividend Remainder
2 13 -
2 6 1
2 3 0
2 1 1
- 0 1
2 0.375 -
2 0.75 0
2 0.5 1
- 0 1
Page 6 of 34
Convert 73.75 10 to a number in base 8
Solution
Integer part = 73
Divisor Dividend Remainder
8 73 -
8 9 1
8 1 1
- 0 1
8 0.75 -
- 0 6
73.7510 111.6 8
Page 7 of 34
1.7.3: Decimal to hexadecimal
The procedure is similar to decimal-to-binary conversion but the radix is 16.
Example
Convert 82.25 10 to a number in base 16
Solution
Integer part = 82
Divisor Dividend Remainder
16 82 -
16 5 2
- 0 5
16 0.25 -
- 0 4
Page 8 of 34
Solution
374.26 8 011111100.010110
3 7 4 2 6 2
011111100.010110 2
Example 2
Convert 1110100.01001112 to base 8
Solution
1110100.01001112 001110100.010
011100
1 6 4 2 3 4 2
164.234 8
Solution
17 E.F 6 16 000101111110.11110110
101111110.11110112
1 7 E F 6 2
Example 2
Convert 1011001110.011011101 2 to base 16
Solution
1011001110.0110111012 001011001110.011011101000
2CE.6 E 8 16
2 C E 6 E 8 2
1.8.3: Hexadecimal-octal and octal-hexadecimal conversions
For hexadecimal –octal conversions, the given hexadecimal number is firstly converted into its
binary equivalent which is further converted into its octal equivalent.
For octal –hexadecimal conversion, the octal number is first converted into an equivalent binary
number and then the binary number transformed into its hexadecimal equivalent.
Example
Convert 2 F .C 4 16 to a number in base 8.
Page 9 of 34
Solution
2 F .C 4 16 00101111.11000100 2
00101111.110
00100
5 7 6 1 2
2F .C 4 16 57.618
Example 2
Convert 762.0138 to a number in base 16.
762.0138 111110010.0000010112
000111110010.0000
01011000
1 F 2 0 5 8 2
Page 10 of 34
Chapter 2: Binary codes
2.1: Introduction
A code is a technique for representing information in a form (using letters, numbers or symbols)
suitable for storage or transmission or a mapping from a set of messages into binary strings. The
binary coding system, called the straight binary code, becomes very cumbersome to handle when
used to represent larger decimal numbers. To overcome this short coming, and also to perform
many other special functions, several binary codes have evolved over the years.
2.2: Binary coded decimal (BCD)
The binary coded decimal (BCD) is a type of binary code used to represent a given decimal
number. It uses the numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. They are three types of BCD: 8421
BCD code, 4221 BCD code and 5421 BCD code.
The numbers in the BCD code represent the weights (place values) of different bits in the four bit
groups, starting from the MSB and proceeding towards to the LSB. The 8421 code is the most
popular of all the BCD codes, and it is simply referred to as the BCD code.
2.2.1: BCD – to – decimal conversion
The equivalent of BCD code in decimal is obtained by splitting the integer part and the fractional
part into groups of 4-bits starting from the binary point.
Example
What is the decimal equivalent of 00100011.00010101 BCD
Solution
Integer part Fractional part
00100011
.00010101
2 3 1 5
Page 11 of 34
Solution
25.26 10 00100101.00100110 BCD
Solution
Converting BCD to decimal
00101001.01110101 BCD 00101001.01110101
29.75 10
2 9 7 5 BCD
Converting decimal to binary
Integer part = 29
2 29 -
2 14 1
2 7 0
2 3 1
2 1 1
- 0 1
Page 12 of 34
Fractional part = 0.75
Multiplier Factor Carry
2 0.75 -
2 0.5 1
- 0 1
29.7510 11101.112
00101001.01110101 BCD 11101.112
Solution
Convert 10101011.1012 to base 10
Integer part
101010112 1 20 1 21 0 22 1 23 0 24 1 25 0 26 1 27 1 2 8 32 128 17110
Fractional pat
0.101 2 1 21 0 22 1 23 0.5 0.125 0.625 10
Page 13 of 34
two decimal digits whose sum exceeds 9. The excess-3 code has no such limitation, and it
considerably simplifies arithmetic operations.
2.3.1: Decimal to excess-3 code conversion
The excess-3 code for a given decimal number is determined by adding ‘3’ to each decimal digit
in the given number and then replacing each digit of the newly found decimal number by its 4-bit
binary equivalent.
Example
Convert 597.25 10 into an excess-3 code.
Solution
Integer Fractional part
597
0.25
333
0.33
10 1010
8 1000
12 1100
5 0101
8 1000
Solution
1000 1100 1010. 0101 1000
1101 1101 1101 1101 1101
.
101011100110111
10010 10101
5 9 7 2 5
Page 14 of 34
encode data, is much less than the worst-case error encountered in the case of the straight binary
coding.
2.4.1: Binary-Gray code conversion
A given binary number can be converted into its gray code equivalent, by adding through the
following steps:
1. The MSB of the gray code is equivalent to the MSB of the binary code
2. The second MSB in the Gray code number, is obtained by adding the MSB and the
second MSB of the binary number and ignoring the carry if any
3. The third MSB in the Gray code number is obtained by adding the second MSB and the
third MSB of the binary number and ignoring the carry if any
4. The process continues until we obtain the LSB of the Gray code number.
Example
Convert 10112 into a Gray code number.
Solution
Binary = 10 1 1 10 1 1 10 1 1 10 1 1
Gray code = 1 11 111 11 1 0
Page 15 of 34
Example
What is the binary equivalent of 1110 Gray .
Solution
Gray code = 11 1 0 11 1 0 11 1 0 11 1 0
Binary = 1 10 101 10 1 1
Page 16 of 34
Page 17 of 34
Chapter 3: Digital arithmetic
3.1: Introduction
Having discussed different methods of data representation, the next obvious step is to study the
rules of data manipulation.
3.3 Number representation in binary
Different formats used for binary representation of both positive and negative decimal numbers
include: the sign-bit magnitude method, the 1’s complement method and the 2’s complement
method.
3.3.1: Sign-bit magnitude
In the sign-bit magnitude representation of positive and negative decimals, the MSB represent
the ‘sign’, with a ‘0’ denoting a plus sign and a ‘1’ denoting a minus sign. The remaining bits
represent the magnitude. In eight-bit representation for example, while the MSB represents the
sign, the remaining seven bits represent the magnitude.
An n-bit binary representation can be used to represent decimal numbers in the range of
2 n1 1 to 2 n1 1 . With 8-bit, the range is from -127 to +127.
Example
Using the sign-bit magnitude format to represent -9 in 8-bits.
Solution
+9 = 00001001, -9 = 10001001
3.4: Complementation
In order to avoid the problems related with binary subtraction especially when the subtrahend is
greater than the minuend, we make use of the complement and then carry out the process of
addition.
Example
4 1 4 1 ; 15 25 15 25
Page 18 of 34
3 00000011
3 11111100
11111111
From the basic laws of mathematics, when we add a number and its opposite (complement), the
result must be ‘0’.
From the example above, we see that the resultant is not zero but a negative number. It is only
when 1 is added to the LSB that we obtain a zero ‘0’ since we are working on 8-bits and ignoring
the carry.
i.e.
3 00000011
3 11111100
11111111
1
100000000
2 n1 1 .i.e from -127 to +127.
the range from 2 n1 1 to 2 n1 . For example using 8-bit it is from -128 to +127
The 2’s complement format is very popular as it is very easy to generate the 2’s complement of a
binary number and also because arithmetic operations are relatively easier to perform when the
numbers are represented in the 2’s complement format.
Example
The 8-bit 2’s complement representation of 2310 111010012 .
Page 19 of 34
Subtraction is similar to addition. Adding the 2’s complement of the subtrahend to the minuend
disregarding (rejecting) the carry (overflow), if any, achieves subtraction.
Example
24 10 14 10 00011000
11110010
100001010
Page 20 of 34
Chapter 4: Logic gates (Combinational logic)
4.1: Introduction
Logic gates are electronic circuits that can be used to implement the most elementary logic
expressions, also known as Boolean expressions. The logic gate is the most basic building block
of combinational logic.
In combinational logic system (circuits), the output depends only on the present value (state) of
the input. The logic gate is the most basic building block of any digital system, including
computers. The three basic gates are the OR gate, the AND gate and the NOT gate.
4.2: Truth table
A truth table lists all possible combinations of input binary variables and the corresponding
outputs of a logic system. The logic system output can be found from the logic expression, often
referred to as the Boolean expression that relates the output with the inputs of that very logic
system.
4.3: OR gate
It is a gate whose output is at logic level 1, whenever anyone, or more of its inputs is at logic
level 1.
Symbol
Electrical equivalent
Page 21 of 34
Truth table
A B F
0 0 0
0 1 1
1 0 1
1 1 1
Boolean expression for the output
F A B
4.4: AND gate
It is a gate whose output is at logic level 1, when all its inputs are at logic level 1.
Symbol
Electrical equivalent
Page 22 of 34
Truth table
A B F
0 0 0
0 1 0
1 0 0
1 1 1
Truth table
A F
0 1
1 0
Page 23 of 34
Boolean expression for the output
FA
Symbol
Electrical equivalent
Truth table
A B F
0 0 0
0 1 1
1 0 1
1 1 0
Page 24 of 34
Symbol
Electrical equivalent
Truth table
A B F
0 0 1
0 1 1
1 0 1
1 1 0
Symbol
Electrical equivalent
Page 25 of 34
Truth table
A B F
0 0 1
0 1 0
1 0 0
1 1 0
Symbol
Electrical equivalent
Truth table
A B F
0 0 1
Page 26 of 34
0 1 0
1 0 0
1 1 1
Page 27 of 34
Chapter 5: Boolean algebra and simplification techniques
5.1: Introduction
Boolean algebra is mathematics of logic. It is one of the most basic tools available that can be
effectively used for simplification of complex logic expressions, and it is simpler than ordinary
algebra. It is also composed of a set of symbols and rules to manipulate these symbols.
However, this is the only similarity between the two. Some major differences include:
1. In ordinary algebra, the letter symbols can take on any number of values including
infinity. In Boolean algebra, they can take on either of two values, i.e. 0 and 1.
2. The values assigned to a variable have a numerical significance in ordinary algebra,
whereas in Boolean algebra, they have a logical significance.
3. While ‘.’ and ‘+’ are respectively the signs of multiplication and addition in ordinary
algebra, in Boolean algebra, ‘.’ means an AND operation and ‘+’ means an ‘OR’
operation
5.2: Postulates of Boolean algebra
1. 11 1, 0 0 0
2. 10 01 0, 0 1 1 0 1
3. 00 0, 1 1 1
4. 1 0, and 0 1
5.3: Theorems
1. Operation with ‘0’ and ‘1’
a) 0 X 0
b) 1 X 1
c) 1 X X
d) 0 X X
2. Idempotent or Identity law
a) X X X X X X
b) X X X X X X
3. Complementation law
Page 28 of 34
a) X X 0
a) X X 1
4. Commutative laws
a) X Y Y X
b) X Y Y X
5. Associative laws
a ) X Y Z Y X Z Z X Y
b ) X Y Z Y X Z Z X Y
6. Distributive laws
a ) X Y Z X Y X Z
b) X YZ X Y X Z
Proof
X Y X Z XX XZ XY YZ
X XZ XY YZ
X 1 Z Y YZ
X YZ
Special case
a) X Y X Y X
b) X Y X Y X
X
b) X X Y X
Proof
X X Y XX XY
Page 29 of 34
X XY
X 1 Y
X
c) X Y Y X Y
Proof
X Y Y X Y X Y X Y X Y
X Y X Y X Y X Y
Y X X X Y Y
X Y
8. Demorgan’s Theorem
a ) X 1 X 2 X 3 X n X 1 X 2 X 3 X n
b) X 1 X 2 X 3 X n X 1 X 2 X 3 X n
9. Involution law
XX
Example 1
Simplify using Boolean algebra
Y ABC ABC ABC ABC
Y ABC ABC ABC ABC ABC ABC
Y BC A A BC A A AC B B
Y BC BC AC
Y C
Example 2
Simplify using Boolean algebra
Y ABC ABC ABC ABC ABC
Y ABC ABC ABC ABC ABC ABC
Y BC A A BC A A AC B B
Y BC BC AC
Page 30 of 34
5.4: Universality of NAND and NOR gates
5.5: Simplification techniques
The primary objective of all simplification procedures is to obtain an expression that has the
minimum number of terms. The techniques commonly used are:
1. The theorems of Boolean algebra
2. The Karnaugh map method
Sum-of-products Boolean expression
It is customary when starting a logic design problems, to first construct a truth table. The table
details the exact operation of the digital circuit. From the table, derive the sum of product of
Boolean expressions that describe the circuit behavior. This expression is also known as a
minterm expression.
It is also possible to write the Boolean expression in the form of product-of-sum also referred to
maxterm expression.
The Nomenclature
We will represent this function using notation. The first step is to write the expanded sum-of-
products given by:
f A, B, C , D A.B.C. D D A.B.C.D A.B.C.D A.B.C.D
Differrent terms are then arranged in ascending order of the binary numbers represented by
various terms, with true variables representing a '1' and a complemented variable representing a
'0'. The expression becomes
Page 31 of 34
The different terms represent 0001, 0101, 1000, 1001 and 1111. The decimal equivalent of these
terms enclosed in the then gives the notation for the Boolean function. That is,
f A, B, C , D 1,5,8,9,15
f A, B, C , D 0, 2,3, 4, 6, 7,10,11,12,13,14
Page 32 of 34
There are various forms of K-maps for the same Boolean expression. But for convenience, we
will use the following configurations.
1. 2-variable K-map
A A
B AB AB
B AB AB
2. 3-variable K-map
AB AB AB AB
C ABC ABC ABC ABC
C ABC ABC ABC ABC
3. 4-variable K-map
AB AB AB AB
CD ABCD ABCD ABCD ABCD
Page 33 of 34
Figure Some of unusual loop variations
Karnaugh maps with don’t care conditions
In some digital systems, certain input conditions never occur during normal operation; therefore,
the corresponding output never appears. Since the output never appears, it is indicated by an X in
the truth table. The X is called a don’t-care condition. Whenever you see an X in a truth table,
you can let it equal either 0 or 1, whichever produces a simpler logic circuit.
Note
Given the truth table, draw a K-map with 0s, 1s and don’t-cares (Xs)
Encircle the actual 1s on the K-map in the largest groups you can find by treating the
don’t-cares as 1s.
After the actual 1s have been included in groups, disregard the remaining don’t-cares by
visualizing them as 0s.
Page 34 of 34