ME 515 Mechatronics 10/5/2006
1
ME 515 Mechatronics
Digital ElectronicsAsanga Ratnaweera
Department of Mechanical EngineeringFaculty of Engineering
University of PeradeniyaTel: 081239 (3627)
Email: [email protected]
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
2
Introduction to Digital ElectronicsDigital circuits are evolved from transistor circuits being able to output at one of the two voltage levels depending on the levels at its inputs.The two levels, usually 0 or 5 V are the low and high signals and represented by 0 and 1. Therefore, binary number system is widely used with digital circuitry.
ME 515 Mechatronics 10/5/2006
2
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
3
Boolean Expressions, Logic Gates & Truth Tables
NOTZ = AA Z
0 1
1 0
ANDZ = A.BA B Z0 0 00 1 01 0 01 1 1
ORZ = A+BA B Z0 0 00 1 11 0 11 1 1
ZABBAZ ⊕= XOR
Z
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
4
Boolean Expressions, Logic Gates & Truth Tables
NORZ = A+B A B Z0 0 10 1 01 0 01 1 0
FAF =F
BUF
ABF = NAND
ME 515 Mechatronics 10/5/2006
3
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
5
Commercial Logic ICs
21 3 4 5 6 7
1 4 1 3 1 2 11 1 0 9 8
+ V c c
G n d(0 V )
7408
21 3 4 5 6 7
1 4 1 3 1 2 1 1 1 0 9 8
+ V c c
G n d( 0 V )
7432
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
6
Logic Families
0.1 mW8 mWActive power Cons.
10 MHz33 MHzMax. Op. frequency
-0.20.0001-0.40.02Current / mA
4.953.5 V2.72.0Voltage / V1 state
0.5-0.00018-0.4Current / mA
0.051.50.50.8Voltage / V0 state
OutputInputOutputInput
-0.02 mA-100 mAMax. supply current
5-15 V4.75-5.25 VSupply voltage
40XX or 74HCXX74XX, 74LSXXCode
CMOSTTLDescription
ME 515 Mechatronics 10/5/2006
4
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
7
Classification of Digital circuitsDigital electronics is classified as:
Combinational logic circuits Combination logic output depends only on the inputs levels.
Sequential logic circuits.The output of sequential logic depends on both stored levels and the input levels. Therefore, sequential logic is capable of “remembering” a particular state.
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
8
Z = A.B.C
Z = A.B.C
Combinational logic circuits
1111
0011
1101
000101100010
01000000ZCBA
Therefore;
Z = A.B.C or A.B.C
Z = A.B.C + A.B.CTruth Table
ME 515 Mechatronics 10/5/2006
5
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
9
Combinational logic circuitsProducing Boolean expressions from truth table:
Find the 1s in the Z columnWrite the Boolean expression for each 1( logic high output)Write the expressions out in words, e.g. Z = ( A AND NOT B AND C) OR (A AND B AND C)Write out the inputs, e.g. A , B CDraw in any NOT gatesDraw in the AND gatesFinally draw in the OR gates if required
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
10
Combinational logic circuits
1111
0011
1101
000101100010
01000000
ZCBA
A
B
C Z
Z = A.B.C + A.B.C
ME 515 Mechatronics 10/5/2006
6
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
11
Combinational logic circuits
Pin-out Diagrams & Drawing CircuitsYou must be able to select suitable logic ICs (chips) and draw in the connections for a given logic system. An example is given below. Don’t forget to draw in the connections for +Vcc ( the positive supply voltage) and 0v.Remember you don’t need to use all the logic gates in a chip – if you only need one, you only use one!
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
12
Combinational logic circuits
21 3 4 5 6 7
14 13 12 11 10 9 8+Vcc
Gnd(0V)
21 3 4 5 6 7
14 13 12 11 10 9 8+Vcc
Gnd(0V)
OUTPUT
7408 7432
+Vcc
0v
Input AInput B
ME 515 Mechatronics 10/5/2006
7
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
13
Combinational logic circuitsBoolean simplification
De Morgan’s theorem
Karnaugh MapA grid of 2N squares where N is the number of input variables in the Boolean expressions. K-maps are usually used for minimization expressions with six or fewer variables
yxyx +=•
yxyx •=+
yxyx +=•
yxyx •=+
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
14
Combinational logic circuitsEx: For three variables
Each square represents one mintermOnly one variable changes between adjacent squares The maps are constructed to “wrap” around so that top and bottom corresponding squares are adjacent
ME 515 Mechatronics 10/5/2006
8
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
15
Combinational logic circuits
For two variablesFor four variables
24 = 16
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
16
Combinational logic circuitsFilling out K-Map
1
1 11
00
0
0
The adjacent squares that have “1”s are combined in groups of 2, 4 or 8.When squares can be chosen as several groups, the largest grouphas to be selected and each square should be used only once
ME 515 Mechatronics 10/5/2006
9
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
17
Combinational logic circuitsIdentify the variables which do not change within the cluster and write them down as a Boolean expression
1
1 11
00
0
0
X = BC +AC + AB
BC
ABAC
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
18
Combinational logic circuitsMore examples
11111 0
01001 1
01000 1
11010 0
1 01 10 10 0CD
AB
ME 515 Mechatronics 10/5/2006
10
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
19
Design of Combination Logic circuits
Ex:Three push buttons are provided to turn on a machine in an automobile assembly plant. For safety purposes, the machine is to be turned on, only if at least two of the buttons are pushed. Obtain a suitable Logic Circuit.
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
20
Applications of Combinational circuitsAdders / substructures
Half adder
Full adder
ME 515 Mechatronics 10/5/2006
11
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
21
Applications of Combinational circuitsEncoders
A binary encoder generates a binary code corresponding to the input value presented at its inputs
Ex: 8 bit encoderIf 5 is pressed, binary number 0000 0101 should be generated at the output of the encoder
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
22
Applications of Combinational circuitsEncoders
ME 515 Mechatronics 10/5/2006
12
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
23
Applications of Combinational circuitsDecoders
A binary decoder converts binary information to discrete outputs.
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
24
Applications of Combinational circuitsDecoders
ME 515 Mechatronics 10/5/2006
13
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
25
Applications of Combinational circuitsMultiplexers
A multiplexer selects binary information from one of many input lines and directs it to a single output line.
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
26
Applications of Combinational circuitsMultiplexers
ME 515 Mechatronics 10/5/2006
14
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
27
Applications of Combinational circuits
De-multiplexersA de-multiplexer receives binary information on a single input line and passes this information to one of its many output lines.
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
28
Sequential logic circuitsThe output of a sequential logic device depends on its present internal state and the present inputs.
Sequential logic device has some kind of memory of at least part of its ``history'' (i.e., its previous inputs).
The memory elements in a sequential circuit are called flip-flops.
ME 515 Mechatronics 10/5/2006
15
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
29
Flop-FlopsA flip-flop circuit can be constructed from two NAND gates or two NOR gates.
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
30
Flop-FlopsClocked SR Flip-Flop
Information from the S and R inputs passes through to the basic flip-flop only when the clock pulse goes to 1. With both S=1 and R=1, the occurrence of a clock pulse causes both outputs to momentarily go to 0.
ME 515 Mechatronics 10/5/2006
16
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
31
Flop-FlopsD Flip-Flop
The D input goes directly into the S input and the complement of the D input goes to the R input. The D input is sampled during the occurrence of a clock pulse. If it is 1, the flip-flop is switched to the set state (unless it was already set). If it is 0, the flip-flop switches to the clear state.
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
32
Flop-FlopsJK Flip-Flop
A JK flip-flop is a refinement of the SR flip-flop in that the indeterminate state of the SR type is defined in the JK type.
ME 515 Mechatronics 10/5/2006
17
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
33
Flop-FlopsT Flip-FlopThe T flip-flop is a single input version of the JK flip-flop. The output of the T flip-flop "toggles" with each clock pulse.
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
34
Flop-FlopsTriggering of Flip-flops
The clock pulse goes through two signal transitions: from 0 to 1 and the return from 1 to 0. The positive transition is defined as the positive edge and the negative transition as the negative edge. These flip-flops are termed edge-triggered flip-flops
ME 515 Mechatronics 10/5/2006
18
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
35
Triggering of Flip-flopsEdge-triggered flip-flops
Ex: Positive edge triggered SR flip-flop
Truth table Timing diagram
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
36
Triggering of Flip-flopsLevel-triggered flip-flops
Level-triggered flip-flops respond to their inputs while the clock signal is at a high level and retain their output values after the level change
Timing diagram Truth table
ME 515 Mechatronics 10/5/2006
19
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
37
Clock pulse generation555 timer
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
38
Clock pulse generation
ME 515 Mechatronics 10/5/2006
20
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
39
Clock pulse generation555 timer
T = 0.7 × (R1 + 2R2) × C1f = 1.4
(R1 + 2R2) × C1T = time period in seconds (s) f = frequency in hertz (Hz) R1 = resistance in ohms ( ) R2 = resistance in ohms ( ) C1 = capacitance in farads (F)The time period can be split into two parts:
T = Tm + TsMark time (output high): Tm = 0.7 × (R1 + R2) × C1Space time (output low): Ts = 0.7 × R2 × C1
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
40
Clock pulse generation555 timer
ME 515 Mechatronics 10/5/2006
21
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
41
Flop-Flop ICsFlip-flops are commercially available as IC packages
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
42
State MachineA state machine is a device that stores the status of something at a given time and can operate on input to change the status and/or cause an action or output to take place for any given change.
Ex: computer.
ME 515 Mechatronics 10/5/2006
22
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
43
State MachineEx: Design of a modulo-4 up-down counter
State transition diagram
00 01
11 10
1
0
10
1
0
1 0
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
44
Design of an up-down counter
Ex: Design of a modulo-4 up-down counterState Table
01101001
Next state / Q1
01111011010110010110101001001000
Next state / Q2
Current state / q2
Current state / q1
Inputx
ME 515 Mechatronics 10/5/2006
23
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
45
Design of an up-down counter
Ex: Design of a modulo-4 up-down counterState Transition Table with SR flip flops
01010101
Q2
0d10d001
S1
100d01d0
R1
01010101
S2
10101010
R2
01101001
Q1
111011101001110010100000
q2q1x
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
46
Design of an up-down counterUse K-maps for simplification
ME 515 Mechatronics 10/5/2006
24
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
47
Design of an up-down counterLogic circuit
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
48
Applications of Digital ElectronicsBinary counters
ME 515 Mechatronics 10/5/2006
25
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
49
Applications of Digital ElectronicsDecade counters
Use to perform binary countingA negative edge-triggered counter and the output is binary coded decimal (BCD) consists of four bits. Ex: LS 7490 IC
Output sequence
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
50
Applications of Digital ElectronicsDecade counters
Timing diagram
Remember: this is a negative edge-triggered counter
ME 515 Mechatronics 10/5/2006
26
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
51
Applications of Digital Electronics
Decade countersBCD counters can be cascaded in order to count in powers of 10. Output D can be used as the clock input for the second decade counter (7490)Cascading two together in order to raise the range for counting from 0 to 99.
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
52
Applications of Digital ElectronicsDecade counters
Note:IC 7447 negative logic seven segment LED code(LED Switches ON when output is low)
ME 515 Mechatronics 10/5/2006
27
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
53
Applications of Digital ElectronicsData registers
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
54
Applications of Digital ElectronicsSerial & Parallel Interfaces
ME 515 Mechatronics 10/5/2006
28
5 October 2006 Asanga Ratnaweera, Department of Mechanical Engineering
55
Applications of Digital ElectronicsSerial & Parallel Interfaces