Counters and Shift Reg
Counters and Shift Reg
7-1
Introduction
Chap. 7 How FFs and logic gates can be combined to produce different types of counters and registers
Divided into 2 parts Part I : principles of counter operation, various counter circuit arrangement, and representative IC counters Part II : counter application, types of IC register, and troubleshooting
Digital Systems
7-2
Exam. 7-1) Some time later the clock pulses are removed, and the counter FFs read 0011. How many clock pulses have occurred? 3 + 16 = 19 + 16 = 35 + 16 = 51 .. Mod Number = 2N ( N : number of FF ) Number of different states
Fig. 7-1 : MOD-16 ripple counter ( 0000 1111)
Exam. 7-2) The counter must be able to count as many as one thousand items. How many FFs are required ? 10 FFs : 0 1023 ( 1001 1023 ) Frequency Division For any counter, the output from the last FF(the MSB) divides the input clock frequency by the MOD number of the counter MOD-16 Counter = Divide-by-16 Counter : Fig. 7-2 Exam. 7-3) How many FFs are required for the MOD-60 counter? There is no integer power of 2 that will equal 60 : 26 = 64 In the next section we will see how to modify the basic counter so that any MOD number can be obtained.
Digital Systems
7-3
State Transition Diagram : Fig. 7-5 Dotted line : Temporary state(=110) 111 state : never reached, not even temporarily
Exam. 7-4) a) LED status of 5, b) LED clocked by 1 kHz, c) LED will be visible for 110 in Fig.7-5
Exam. 7-5) Determine the MOD number and the frequency at the D output of the counter in Fig.7-6(a) D C B A = 1 1 1 0 = 14 NAND output = 0 (Clear Input) : MOD 14 30 kHz/14 = 2.14 kHz
Korea Univ. of Tech. & Edu. Dept. of Info. & Comm.
Digital Systems
7-4
General Procedure (to construct MOD X Counter) 1) Find the smallest number of FFs such that 2N X, connect them as a counter. If 2N = X, do not do steps 2 and 3 2) Connect a NAND output to the CLEAR inputs of all the FFs 3) Determine which FFs will be in the HIGH state at a count = X; then connect the outputs of these FFs to the NAND inputs. Exam. 7-6) Construct a MOD-10 (count from 0000 ~ 1001) counter : Fig. 7-6(b) Find the smallest number of FFs : 4 ( 24 = 16 ) D C B A = 1 0 1 0 = 10 : D and B must be connected as the NAND gate input
Decade Counters/BCD counters : Fig. 7-6(b) or IC MOD-10 Counter = Decade Counter = BCD Counter
Count in sequence from 0000(0) to 1001(9)
Exam. 7-7) Construct a MOD-60 Counter : Fig. 7-7 Find the smallest number of FFs :64 ( 26 = 64 ) Q5 Q4 Q3 Q2 Q1 Q0 = 1 1 1 1 0 0 = 60 (32 + 16 + 8 + 4)
Digital Systems
7-5
MR1 MR2
Clear ( C0 )
Exam. 7-10) How to wire the 74LS293 as a MOD-14 Counter : Fig. 7-11 Q3 Q2 Q1 Q0 = 1 1 1 0 = 14 (8 + 4 + 2) Exam. 7-11) Construct a MOD-60 Counter with 74LS293 : Fig. 7-12 MOD-10 counter X MOD-6 counter = MOD-60 counter
MOD-10 counter : Exam. 7-9 MOD-6 counter : Q0 3 (Q3 Q2 Q1)
Digital Systems
7-6
CMOS Asynchronous Counters 74HC4024 : MOD-128 ripple counter = CTR DIV128 ( Fig. 7-14 ) 74HC4040 : MOD-4096 ripple counter
Digital Systems
7-7
Each FF should have its J and K inputs connected such that they are HIGH only when the outputs of all lower-order FFs are in the HIGH state
C A AB =( J = K) B
Total delay is the same no matter how many FFs are in the counter
Actual ICs 74LS160/162, 74HC160/162 : Synchronous Decade(MOD-10) Counters 74LS161/163, 74HC161/163 : Synchronous MOD-16 Counters Exam. 7-12) (a) Determine fmax for the counter of Fig. 7-17(a) and Compare this value with MOD-16 ripple counter( FF tpd = 50 ns, AND gate tpd = 20 ns) Parallel Counter : fmax = 1 / ( 50 ns + 20 ns ) = 14.3 MHz Ripple Counter : fmax = 1 / (4 x 50 ns ) = 5 MHz
Korea Univ. of Tech. & Edu. Dept. of Info. & Comm.
Digital Systems
7-8
5 FF(25 = 32) , J and K input are fed by the output of a four input AND gate whose inputs are A, B, C, and D
FF 14.3 MHz
Exam. 7-13) What problems might be caused if the Up/Down signal changes levels on the NGT of the clock ? Possible Problems : Unpredictable results of FF
the J and K inputs change at about the same time that a NGT occurs at their CLK input.
Digital Systems
7-9
Synchronous Presetting The counter is preset on the active transition of the same clock signal Synchronous Presetting IC Counters
TTL : 74LS160, 161, 162, 163 CMOS : 74HC160, 161, 162, 163
Digital Systems
7-10
Exam. 7-14) Determine the counter output waveforms in Fig. 7-22(a) Up Counter : Fig. 7-22(b) Exam. 7-15) Determine the counter output waveforms in Fig. 7-23(a) Down Counter : Fig. 7-23(b) Variable MOD Number Using the 74LS193 5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, ... TCD = PL : Preset to 0101(5) - Fig. 7-24 Q2 = 5 Clock cycle : Divide the frequency by 5
MOD-6 MOD-5
We can vary the frequency division by changing the logic levels applied to the parallel data inputs
A variable frequency-divider can be easily implemented by connecting switches to the parallel data inputs in Fig. 7-24
Digital Systems
7-11
Multistage Arrangement : Fig. 7-25 8 bits Up/Down Counter using two 74LS193s
Active-HIGH Decoding : Fig. 7-27 At any one time only one AND gate output is HIGH Exam. 7-16) How many AND gates are required to decode all of the states of a MOD-32 counter? What are the inputs to the gate that decodes for 21 MOD-32 counter has 32 possible states : 32 AND gate 1 0 1 0 1(21) : E, D, C, B, A Active-LOW Decoding NAND gates are used in place of AND gates
Exam. 7-17) Generate a control waveform which could be used to control devices such as a motor, solenoid valve, or heater. Control Signal Generation(On/Off control) : Fig. 7-28 The X output is HIGH between the counts of 8 and 14 for each cycle of counter
Digital Systems
7-12
Digital Systems
7-13
2) Draw the state transition diagram : Fig. 7-33 3) Tabulate present/next state table : Tab. 7-4
Use the state transition diagram to setup a present/next state table
K X X 1 0
J 0 0 1 1
K 0 1 0 1
Digital Systems
7-14
5) Design logic circuits to generate the levels required at each J and K input
J A C , KA 1 FF A : Fig. 7-34 FF B : Fig. 7-35(b) J B AC , K B A B FF C : Fig. 7-35(a) J C AB, KC 1
Stepper Motor Control Step Motor Drive Circuit(with Direction Control) : Fig. 7-37(a) State Transition Diagram : Fig. 7-37(b) Circuit Excitation Table : Tab. 7-6 K-map Simplification : Fig. 7-38 Implementation : Fig. 7-39
7-15
4 distinct states
Starting a Ring Counter A ring counter must start off with only one FF in the 1 state and all the others in the 0 state Ring Counter Starter : Fig. 7-41
1) On power-up, the capacitor will charge up relatively slowly toward Vcc, Inverter 1 input = 0 2) Inverter 1 output = 1, Inverter 2 output = 0 until Inverter 1 input = 1
Johnson Counter/Twisted Ring Counter The inverted output of the last FF is connected to the input of the first FF 3 bits Johnson counter : Fig. 7-42
MOD-6(six distinct states) : 000, 100, 110, 111, 011, and 001 50 percent duty cycle square wave at one-sixth the frequency of the clock MOD-N counter(N= even number) by connecting N/2 FFs
Digital Systems
7-16
Decoding a Johnson Counter For a given MOD number, a Johnson counter requires only half the number of FFs that a ring counter requires
MOD-8 Ring Counter : 8 FFs MOD-8 Johnson Counter : 4 FFs
Digital Systems
7-17
Exam. 7-18) The unknown frequency is 3792 pulses per second(pps). Determine the counter reading after a sampling interval of (a) 1 s, (b) 0.1 s, and (c)10ms (a) 1 s : 3792 (b) 0.1 s : 379.2, 379 or 380 (c) 0.01 s : 37.92, 37 or 38 A method for obtaining accurate sampling interval : Fig. 7-45 Crystal Oscillator : generate a very accurate 100-kHz waveform Decade Counter : divide 100-kHz frequency by 10 Rotary Switch : select one of the decade-counter output Flip-Flop : 2
In position 1 : 1 Hz / 2 = 0.5 Hz
Digital Systems
7-18
Exam. 7-19) The unknown input frequency is between 1, 000 pps and 9,990 pps, what is the best setting for the switch position in Fig. 7-45 with 3 BCD counter and display. With three BCD counter : total capacity = 000 - 999
0.1 s sampling interval : 100 - 999
Digital Systems
7-19
Q3 = 1, = 9 = 1 ( 09
10).
7-18 IC Registers
1) Parallel in/Parallel out : 74174, 74178
Digital Systems
7-20
Exam. 7-20A) How to connect 74ALS174 so that D5 D4 D3 D2 D1 D0 ( = data input at D5 and data output at Q0 ). Fig. 7-50 Exam. 7-20B) How to connect two 74ALS174 to operate as a 12 bit shift register. Connect the Q0 of the first IC to the D5 of the second IC.
Digital Systems
7-21
Exam. 7-21) Delay circuit using 4731B chip : Fig. 7-52 Q63 goes HIGH approximately 64 clock cycles after Ds input
Contents
Response
0 1 1
X 0 1
Exam. 7-22) Determine (a)the conditions necessary to load the register with parallel data, (b) the conditions necessary for the shifting operation (a) SH/LD = 0 : only Q7 will be externally available (b) SH/LD = 1, CP INH = 0, and PGT Clock Pulse at CP
Exam. 7-23) What signal will appear at Q7(Q7=Ds, CP=200kHz, CP INH=0) 8-bit Johnson counter divided by 16 = 12.5 kHz
Digital Systems
7-22
74374/LS374/HC374 : 8 bit parallel in/parallel out register 8 edge-triggered D Flip-Flops with tri-state outputs
Pin 11 : Clock Pulse(CP) Edge trigger(PGT) 373
Digital Systems
Korea Univ. of Tech. & Edu. Dept. of Info. & Comm.
7-23
Exam. 7-25) Determine the possible faults of MOD-10 counter in Fig. 7-57(a) ( The displayed waveforms of the Q output with an oscilloscope are shown in Fig. 7-57(b) ) : Q1, Q2, and Q3(except Q0) are stuck in the LOW state :
1) 2) 3) 4) Q1 : internally or externally shorted to ground MR1 : internally shorted to ground (Q1=0) Q0 CP1 Open : Q1 Clock Input IC internal fault
Exam. 7-26) 4 , Fig. 7-58 Q1 glitch . ? MR2 Open : MR2 = HIGH in TTL
Q1 glitch 0 reset , MOD-2 ( 0, 1 )
Exam. 7-27) The displayed frequency is exactly twice in Fig. 7-46, What is the probable cause for the malfunction ? 3 input AND gate Open : SAMPLE pulse = HIGH:
t3 t4 sampling , t2 t4 sampling .
Exam. 7-28) The HOURS section displays in the manner shown in Tab. 7-7 . ? ( p. 382, Fig. 7-48 ) 74LS192 Q3 Q2 74LS112 CLK
9
Digital Systems
0 X = 1 , 7
8 X = 1 .
Korea Univ. of Tech. & Edu. Dept. of Info. & Comm.
7-24
Digital Systems