Professional Documents
Culture Documents
Industrial Engineering
Introduction To Mechatronics
(MEng3212)
Chapter Five
Digital Logics
Every logic circuit requires at least one input, before it can produce
any kind of output.
Digital logic inputs and outputs are usually binary. In other words
they can only be one of two possible values.
3
Introduction to Mechatronics
Introduction
Digital devices convert digital inputs into one or more digital outputs.
In binary (or, two-state) logic a variable can take one of two discrete
states: true (T) or false (F).
decimal number system, each digit can assume one of the ten values
denoted by 0, 1, 2,…, 9.
Similarly in the binary number system, each digit can assume one of
only two values: 0 or 1.
6
Introduction to Mechatronics
Introduction
7
Introduction to Mechatronics
Introduction
9
Introduction to Mechatronics
Digital Representations
For the decimal system R=10; for the binary system R=2; for the
octal system R=8; and for the hexadecimal system R=16.
10
Introduction to Mechatronics
Digital Representations
Binary Representation
11
Introduction to Mechatronics
Digital Representations
Binary Representation
A binary number consists of binary digits (bits). Each bit can take the
value 0 or 1.
Binary Representation
13
Introduction to Mechatronics
Digital Representations
Binary Representation
Each digit in a decimal number is a placeholder for different powers
of 10 according to
Where n is the number of digits and each digit di is one of the ten
symbols. Note that the highest power of 10 is ( n - 1), 1 less than the
number of digits.
Example, the decimal number 123 can be expanded as
Binary Representation
The reason for this is that the operation of digital devices is based on
transistors that switch between two states: the ON or saturated state
and the OFF or cutoff state.
These states are designated by the symbols 1 (ON) and 0 (OFF) in the
base 2 system.
Binary Representation
16
Introduction to Mechatronics
Digital Representations
Binary Representation
A bit (binary digit) is the smallest unit of data that a computer can
process and store.
17
Introduction to Mechatronics
Digital Representations
Binary Representation
The first, or left most, bit is known as the most significant bit
(MSB) because it represents the largest power of 2.
The last, or right most, bit is known as the least significant bit
(LSB) because it represents the smallest power of 2.
Binary Representation
19
Introduction to Mechatronics
Digital Representations
Binary Representation
where b is the base and n is the number of digits and also used to
convert from an arbitrary base to base 10.
Binary Representation
Binary Representation
22
Introduction to Mechatronics
Digital Representations
Binary Representation
Binary Representation
• In addition to numbers, alphanumeric characters can also be
represented in digital (binary) form with ASCII codes.
• ASCII is short for the American Standard Code for Information
Interchange.
• ASCII codes are 7-bit codes used to denote all of the alphanumeric
characters. The 7-bit codes are usually stored in an 8-bit byte. There
is a unique code for each alphanumeric character.
Some example codes are;
24
Introduction to Mechatronics
Digital Representations
Binary Representation
Binary coded decimal (BCD) is another type of digital
representation some times used for input and output of numerical
data.
With BCD, 4 bits are used to represent a single, base 10 digit.
BCD is a convenient mechanism for representing decimal numbers
in a binary number format, but it is inefficient for storing or
transmitting multiple-digit numbers because only 10 of the 16
(2^4) possible states of the 4-bit number are used.
To convert a decimal number to BCD, assemble the 4-bit codes for
each decimal digit. For example,
Note that this is different from the binary representation:
25
Introduction to Mechatronics
Digital Representations
Number Systems and Binary Arithmetic
• Most number systems are order dependent
• Decimal
123410 = (1 103) + (2 102) + (3 101) + (4 100)
• Binary
11012 = (1 23) + (1 22) + (0 21) + (1 20)
• Octal
1238 = (1 83) + (2 82) + (3 81)
• Hexadecimal
12316 = (1 163) + (2 162) + (3 161)
here we need 16 characters – 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
26
Introduction to Mechatronics
Digital Representations
Number Systems and Binary Arithmetic
• Number conversion
• conversion to decimal
• add up decimal equivalent of individual digits
Example 1
binary (110102 )to decimal
110102 = (1 24) + (1 23) + (0 22) + (1 21) + (0 20)
= 16 + 8 + 0 + 2 + 0
= 26
27
Introduction to Mechatronics
Digital Representations
Number Systems and Binary Arithmetic
• Number conversion
• conversion from decimal
• repeatedly divide by the base and remember the remainder
Example 2
Decimal to binary
Number Remainder
Starting point 26
2 13 0
2 6 1
2 3 0
2 1 1
2 0 1
read number from this end
28
=11010
Introduction to Mechatronics
Digital Representations
Example 3
Decimal to octal
29
Introduction to Mechatronics
Digital Representations
Example 4
Decimal to binary(knowing significant bit)
30
Introduction to Mechatronics Binary
Decimal
Digital Representations
0 0
Numeric and Alphabetic Codes 1 1
Binary code 2 10
By far the most common way of representing 3 11
4 100
numeric information has advantages of easy 101
5
conversion to/from decimal simplicity and 6 110
111
efficiency of storage formed by converting each 7
8 1000
digit of a decimal number individually into 1001
9
binary requires more digits than conventional 10 1010
1011
binary used where input and output are in 11 1100
12
decimal form. etc. etc. 31
Introduction to Mechatronics
ASCII(America Standard Code for Information Exchange)Code
32
Introduction to Mechatronics
ASCII(America Standard Code for Information Exchange)Code
Furthermore, numbers that appear in a text file (e.g., in a letter or
report) take a different meaning internally within a computer, from
numerical data that will be processed (e.g., multiply, subtract) by the
computer.
Similarly, information transmitted from a computer to an output
device (e.g., display) also can take these different forms.
Usually, information enters and leaves a keyboard as a sequence of
pulses (in bit serial manner) and the information is handled by a
computer in a bit parallel manner (as bytes or words).
33
Introduction to Mechatronics
Combinational Logic and Logic Classes
Combinational logic devices are digital devices that convert binary
inputs into binary outputs based on the rules of mathematical logic.
The basic operations, schematic symbols, and algebraic expressions
for combinational logic devices.
These devices are also called gates, because they control the flow of
signals from the inputs to the single output.
A small circle at the input or output of a digital device denotes signal
inversion; that is, a 0 becomes a 1 or a 1 becomes a 0.
The truth table for each device is shown on the right.
Truth table: is a compact means of displaying all combinations of
inputs and their corresponding outputs.
34
Introduction to Mechatronics
Logic Gates
logic gate is a device that acts as a building block for digital circuits.
They perform basic logical functions that are fundamental to digital
circuits.
All digital systems can be constructed by only three basic logic gates.
These basic gates are AND gate, OR gate, and NOT gate.
Some textbooks also include the NAND gate, the NOR gate and the
EOR gate as the members of the family of basic logic gates.
Each gate has its own logic symbol which allows complex functions
to be represented by a logic diagram.
The function of each gate can be represented by a truth table or
using Boolean notation
35
Introduction to Mechatronics
Logic Gates
The standard AND, NAND, OR, NOR, and XOR gates have only
two inputs, but other forms are available with more than two inputs.
The algebraic symbols used to represent the logic functions are: plus
(+) for logic OR, dot (·) for the logic AND, and an overbar ( xˉ ) for
logic NOT, denoting inversion.
36
Introduction to Mechatronics
Logic Gates
In the case of a multiple input AND gate, the output is 1 if and
only if all inputs are 1; otherwise, the output is 0.
In the case of the NAND gate, the output is 0 if and only if all
inputs are 1; otherwise, it is 1.
In case of NOR gate, produces a high output (1) only if all its inputs
are false, and otherwise low output (0).
In the case of the XOR gate, the output is 0 if all of the inputs are 0 or if
all of the inputs are 1; otherwise, it is 1. 38
Introduction to Mechatronics
Logic gates
There are two families of digital integrated circuits, called TTL for
transistor-transistor logic and CMOS for complementary metal-
oxide semiconductors.
Voltage levels define logic low (0) and logic high (1) at the inputs
and outputs. The ranges for the logic levels vary depending on the
device family.
40
Introduction to Mechatronics
AND Gate
It gives a high output only when both input A and input B are high;
for all other conditions it gives a low output
Only when switch A and switch B are closed is there a current.
Different sets of standard circuit symbols for logic gates have been
used, with the main form being that originated in the United States.
we can express the relationship between the inputs and the outputs of
a gate in the form of an equation, termed a Boolean equation.
An example of an AND gate is an interlock control system for a
machine tool such that if the safety guard is in place and gives a 1
signal and the power is on, giving a 1 signal, then there can be an
output, a 1 signal, and the machine operate
41
Introduction to Mechatronics
AND Gate
The relationships between inputs to a logic gate and the outputs can
be tabulated in a form known as a truth table.
Thus for an AND gate with inputs A and B and a single output C, we
will have a 1 output when, and only when, A = 1 and B = 1.
Switch diagram 43
Introduction to Mechatronics
NOT Gate (or inverter)
A NOT gate has just one input and one output, giving a 1 output
when the input is 0 and a 0 output when the input is 1.
The NOT gate gives an output which is the inversion of the input and
is called an inverter.
The 1 representing NOT actually symbolizes logic identity, i.e. no
operation, and the inversion is depicted by the circle on the output.
Thus if we have a digital input which varies with time, the out
variation with time is the inverse
46
Introduction to Mechatronics
Exclusive OR Gate (XOR)
47
Introduction to Mechatronics
Combinational Logic
48
Introduction to Mechatronics
Combinational Logic
49
Introduction to Mechatronics
Example
X A BC
answer
50
Introduction to Mechatronics
Next Lecture:
Chapter Six: Microcontrollers and
Microprocessors
51