You are on page 1of 51

School of Mechanical and

Industrial Engineering
Introduction To Mechatronics
(MEng3212)
Chapter Five
Digital Logics

አዘጋጅ፡ ሙሉጌታ በላይ ኅዳር 2015 ዓ.ም


1
Introduction to Mechatronics
Introduction

 A digital logic circuit uses digital inputs to make logical decisions


and produce digital outputs.

 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.

 A digital circuit is a circuit where the signal must be one of two


discrete levels.
2
Introduction to Mechatronics
Introduction

 Each level is interpreted as one of two different states (for example,


on/off, 0/1, true/false).

 Digital circuits use transistors to create logic gates in order to perform


Boolean logic.

3
Introduction to Mechatronics
Introduction

 Digital devices, digital computers in particular, use digits (according


to some code) to represent information and some form of logic to
process such information.

 Since mechatronic systems use digital devices for information


formation acquisition, information formation communication,
information processing, and device control, the field of digital
hardware and logic are important in Mechatronics.

 Digital devices are categorized according to their function as


combinational logic or sequential logic devices. 4
Introduction to Mechatronics
Introduction

 Digital devices convert digital inputs into one or more digital outputs.

 The difference between the two categories is based on signal timing.

 For sequential logic devices, the timing, or sequencing history, of the


input signals plays a role in determining the output.

 In binary (or, two-state) logic a variable can take one of two discrete
states: true (T) or false (F).

 Numerical digit can assume several values depending on the particular


number system used.
5
Introduction to Mechatronics
Introduction

 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

 Analog and digital signals are the types of signals carrying


information.

 A digital system uses discontinuous-time signals, for carrying


information.

 Analog system uses continuous-time signals for carrying information.

7
Introduction to Mechatronics
Introduction

 A digital device has to process logical quantities as well as numerical


data.

 It is convenient to use the binary number system in digital devices,


not only because two-state logical variables and numerical variables
can be processed in the same manner, but because components that
can assume one of two states can be used as the building blocks for a
digital circuit.
 The particular number system itself does not introduce any error in
representing and processing information, provided that sufficient
memory is available to store the data. 8
Introduction to Mechatronics
Introduction

 A code is needed represent such a quantity in a digital form. The


result is a coded piece of information.

 Logic is called the Calculus of computer science.

 Calculus-Physical Science and Engineering Disciplines.

9
Introduction to Mechatronics
Digital Representations

 The base or the radix (denoted by R) of a number system is the


maximum number of discrete values each digit of a number can
assume.

 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.

 decimal system-human has ten fingers.

10
Introduction to Mechatronics
Digital Representations

Binary Representation

Since digital devices internally make use of high/low voltage levels,


the presence/absence of voltage pulses, and the on/off state of bistable
elements (micro-switches) for data representation and processing, it is
the binary representation that is natural for their internal operations.

 Instructions, stored data, and addresses of memory locations in a


computer are all present in the form of binary numbers, even though
all such types of information are not numerical.

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.

 Information is arranged in 8-bit groups called bytes, internally in a


digital computer.

 A digital computer operates on one data word at a time, however, and


the word size can be several bytes (e.g., 16 and 32 bits in
microcomputers).
12
Introduction to Mechatronics
Digital Representations

Binary Representation

 If a string of bits represents a binary number, then it can be converted


into a decimal number in a straightforward manner. This simply
amounts to a conversion from the base-2 (or radix-2) representation
into the base-10 representation.

 The base of the number system indicates the number of different


symbols that can be used to represent a digit. In base 10, the symbols
are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.

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

 In order to represent and manipulate numbers with digital devices


such as computers, we use a base 2 number system called the binary
number system.
14
Introduction to Mechatronics
Digital Representations

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.

 The digits in a binary number, as with the base 10 system, correspond


to different powers of the base.
15
Introduction to Mechatronics
Digital Representations

Binary Representation

 A binary number can be expanded as

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.

 A bit is always in one of two physical states, similar to an on/off light


switch. The state is represented by a single binary value, usually a 0
or 1.

 The first and last bits have special names.

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.

 A group of 8 bits is called a byte.

 In general, the value of a number represented in any base can be


expanded and computed.
18
Introduction to Mechatronics
Digital Representations

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.

 To convert a number from base 10 to some other base, the procedure


is to successively divide the decimal number by the base and record
the remainders after each division. The remainders, when written in
reverse order from left to right, form the digits of the number
represented in the new base as shown next example in next slide
20
Introduction to Mechatronics
Digital Representations

Binary Representation

 In decimal to binary, we divide the number by 2,

 in decimal to hexadecimal we divide the number by 16.

 In decimal to octal, we divide the number by 8 and write the


remainders in the reverse order to get the equivalent octal number.

 Decimal to Octal: Convert 0.52 into an octal number. Solution: The


fraction part of the decimal number has to be multiplied by 8. So,
for the fractional octal number, we read the generated carry from up
21
to Down. So, 4121 is the octal number.
Introduction to Mechatronics
Digital Representations

Binary Representation

 Binary arithmetic is carried out in


the same way as the more familiar
base 10 arithmetic.
 To convert a binary number to
hexadecimal, divide the number Decimal to binary conversion
into groups of four digits
beginning with the least
significant bit and replace each
group with its hexadecimal
equivalent. For example,

22
Introduction to Mechatronics
Digital Representations

Binary Representation

Another base useful in representing binary numbers in


concise form is octal (base 8). To convert a binary number to
octal, divide the number into groups of three digits
beginning with the least significant bit and replace each
group with its octal equivalent. For example,
23
Introduction to Mechatronics
Digital Representations

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

Used for the information transfer between a computer and a keyboard

Logical and numerical operations are directly useful in all types of


mechatronic systems. An understanding of the concepts of binary logic
is important in the analysis and design of digital logic circuits.

 Information received by a digital computer from a peripheral device


such as keyboard (an input device) may include non-numeric data
(e.g., letters in the alphabet and special characters and control
commands) as well as numeric data

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 the case of the OR gate, the output is 0 if and 37


only if all inputs are 0; otherwise, it is 1.
Introduction to Mechatronics
Logic Gates

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

 Buffer(controls the flow of current):used to increase the current


supplied at the output while retaining the digital state.

 This is important if you wish to drive multiple digital inputs from a


single output.

 A normal digital gate has a limited fan-out, which defines the


maximum number of similar digital inputs that can be driven by the
gate’s output.

 All the gates are manufactured as integrated circuits where


transistors, resistors, and diodes exist on a single chip of silicon.
39
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

 Another example is a burglar alarm in which it gives an output, the


alarm sounding, when the alarm is switched on and when a door is
opened to activate a sensor.

 The relationships between inputs to a logic gate and the outputs can
be tabulated in a form known as a truth table.

 This specifies the relationships between the inputs and outputs

 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.

 All other combinations of A and B will generate a 0 output 42


Introduction to Mechatronics
OR Gate

 An OR gate with inputs A and B gives an output of a 1 when A or B


is 1.

 We can visualize such a gate as an electric circuit involving two


switches in parallel.

 When switch A or B is closed, then there is a current.

 OR gates can also have more than two inputs

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

 A bar over a symbol is used to indicate that the inverse, or


complement, is being taken; thus the bar over the A indicates that the
output B is the inverse value of A.
44
Introduction to Mechatronics
NAND Gate
 The NAND gate can be considered as a combination of an AND gate
followed by a NOT gate.
 Thus when input A is 1 and input B is 1, there is an output of 0, all
other inputs giving an output of 1.
 The NAND gate is just the AND gate truth table with the outputs
inverted.
 An alternative way of considering the gate is as an AND gate with a
NOT gate applied to invert both the inputs before they reach the AND
gate
 AND symbol followed by the circle to indicate inversion.
 The output that occurs for a NAND gate when its two inputs are
digital signals which vary with time. There is only a low output when
both the inputs are high.
45
Introduction to Mechatronics
NOR Gate

 The NOR gate can be considered as a combination of an OR gate


followed by a NOT gate.

 Thus when input A or input B is 1 there is an output of 0.

 It is just the OR gate with the outputs inverted.

 An alternative way of considering the gate is as an OR gate with a


NOT gate applied to invert both the inputs before they reach the OR
gate.

46
Introduction to Mechatronics
Exclusive OR Gate (XOR)

 The EXCLUSIVE-OR gate (XOR) can be considered to be an OR


gate with a NOT gate applied to one of the inputs to invert it before
the inputs reach the OR gat.
 The output is true if only one input is true otherwise false.

 This implies when the input is same the output is true.

47
Introduction to Mechatronics
Combinational Logic

 Digital systems may be divided into two broad categories:

 Combinational logic: the outputs are determined solely by the


current states of the inputs.

 Sequential logic: the outputs are determined not only by the


current inputs but also by the sequence of inputs that led to the
current state.

48
Introduction to Mechatronics
Combinational Logic

A designer must be careful when mixing different types of digital


integrated circuits because different digital devices have specified
current source and sink capabilities that affect how much fan-out is
allowed and how they may be mixed with each other.

49
Introduction to Mechatronics
Example

X  A  BC
answer

50
Introduction to Mechatronics

End of Chapter Five

Next Lecture:
Chapter Six: Microcontrollers and
Microprocessors
51

You might also like