Scilab Textbook Companion for Analog And Digital Electronics by U. A. Bakshi And A. P. Godse1 Created by Priyank Bangar B.Tech Electronics Engineering NMIMS College Teacher No Teacher Cross-Checked by
May 23, 2016
1 Funded
by a grant from the National Mission on Education through ICT, http://spoken-tutorial.org/NMEICT-Intro. This Textbook Companion and Scilab codes written in it can be downloaded from the ”Textbook Companion Project” section at the website http://scilab.in
Book Description Title: Analog And Digital Electronics Author: U. A. Bakshi And A. P. Godse Publisher: Technical Publications, Pune Edition: 1 Year: 2009 ISBN: 9788184316902
1
Scilab numbering policy used in this document and the relation to the above book. Exa Example (Solved example) Eqn Equation (Particular equation of the above book) AP Appendix to Example(Scilab Code that is an Appednix to a particular Example of the above book) For example, Exa 3.51 means solved example 3.51 of this book. Sec 2.3 means a scilab code whose theory is explained in Section 2.3 of the book.
2
Contents List of Scilab Codes
4
1 Special Diodes
6
2 Frequency Response
8
3 Feedback Amplifiers
14
4 Oscillators
37
5 Combinational Logic Circuits
56
6 Sequential Logic Circuits
80
7 Shift Registers
82
8 Counters
83
9 Op amp Applications
115
10 Voltage Regulators
134
3
List of Scilab Codes Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa
1.1 1.2 2.1 2.2 2.3 2.4 2.5 2.6 2.7 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15 3.16 3.17 3.18 3.19
current through LED . . . . . . . . . . . . . . . transition capacitance and constant K . . . . . . maximum voltage gain . . . . . . . . . . . . . . . gain of the amplifier . . . . . . . . . . . . . . . . gain of an amplifier . . . . . . . . . . . . . . . . low frequency response of the amplifier . . . . . . low frequency response of the FET amplifier . . . high frequency response of the amplifier . . . . . high frequency response of the amplifier . . . . . gain fL and fH . . . . . . . . . . . . . . . . . . . Vo and second harmonic distortion with feedback beta and Af . . . . . . . . . . . . . . . . . . . . . beta and Av and Avf and Rif and Rof . . . . . . Avf and Rif and Rof . . . . . . . . . . . . . . . . Avf and Rif and Rof . . . . . . . . . . . . . . . . D and Avf and Rif and Rof . . . . . . . . . . . . voltage gain . . . . . . . . . . . . . . . . . . . . . Avf . . . . . . . . . . . . . . . . . . . . . . . . . Avf and Rif and Rof . . . . . . . . . . . . . . . . voltage gain and input and output resistance . . Ai and beta and Aif . . . . . . . . . . . . . . . . beta and Av and Avf and Rif and Rof . . . . . . gain and new bandwidth . . . . . . . . . . . . . . show voltage gain with feedback . . . . . . . . . GMf and Rif and Rof . . . . . . . . . . . . . . . feedback factor and Rif and Rof . . . . . . . . . gain with feedback and new bandwidth . . . . . overall voltage gain and bandwidth . . . . . . . . 4
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
6 6 8 8 9 9 10 11 12 14 14 15 16 18 19 21 23 24 25 27 28 30 32 32 33 34 35 36
Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa
4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10 4.11 4.12 4.13 4.14 4.15 4.16 4.17 4.18 4.19 4.20 4.21 4.22 4.23 4.24 4.25 4.26 4.27 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 5.10
C and hfe . . . . . . . . . . . . . . . . . . . . . . . . . frequency of oscillation . . . . . . . . . . . . . . . . . R and C . . . . . . . . . . . . . . . . . . . . . . . . . . C and RD . . . . . . . . . . . . . . . . . . . . . . . . . minimum and maximum R2 . . . . . . . . . . . . . . . range over capacitor is varied . . . . . . . . . . . . . . frequency of oscillation . . . . . . . . . . . . . . . . . frequency of oscillation . . . . . . . . . . . . . . . . . calculate C . . . . . . . . . . . . . . . . . . . . . . . . series and parallel resonant freqency . . . . . . . . . . series and parallel resonant freqency . . . . . . . . . . Varify Barkhausen criterion and find frequency of oscillation . . . . . . . . . . . . . . . . . . . . . . . . . . . minimum and maximum values of R2 . . . . . . . . . frequency of oscillation and minimum hfe . . . . . . . range of frequency of oscillation . . . . . . . . . . . . . frequency of oscillation . . . . . . . . . . . . . . . . . gain of the transistor . . . . . . . . . . . . . . . . . . . new frequency and inductance . . . . . . . . . . . . . new frequency of oscillation . . . . . . . . . . . . . . . R and hfe . . . . . . . . . . . . . . . . . . . . . . . . . component values of wien bridge . . . . . . . . . . . . values of C2 and new frequency of oscillation . . . . . series and parallel resonant freqency and Qfactor . . . change in frequency and trimmer capacitance . . . . . design RC phase shift oscillator . . . . . . . . . . . . . range of capacitor . . . . . . . . . . . . . . . . . . . . change in frequency of oscillation . . . . . . . . . . . . design a combinational logic circuit . . . . . . . . . . . design a circuit with control line C and data lines . . . design combinational circuit . . . . . . . . . . . . . . . design logic circuit . . . . . . . . . . . . . . . . . . . . design circuit to detect invalid BCD number . . . . . . design two level combinational circuit . . . . . . . . . design 32 to 1 multiplexer . . . . . . . . . . . . . . . . design a 32 to 1 multiplexer . . . . . . . . . . . . . . . implement boolean function using 8to1 multiplexer . . implement boolean function using 4to1 multiplexer . . 5
37 38 38 38 39 40 40 41 41 42 42 43 45 45 46 46 47 47 48 48 49 50 51 51 53 54 54 56 57 58 59 60 61 62 62 63 63
Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa
5.11 5.12 5.13 5.14 5.15 5.16 5.17 5.18 5.19 5.20 5.21 5.22 5.23 5.24 5.25 5.26 5.27 5.28 5.29 5.31 6.4 7.1 8.1 8.2 8.4 8.5 8.6 8.8 8.9 8.10 8.11 8.12 8.13 8.14 8.15 8.16 8.17 8.18
implement boolean function using 8to1 MUX implement boolean function using 4to1 MUX implement boolean function using 8to1 MUX implement boolean function using 8to1 MUX implement boolean function using 8to1 MUX determine boolean expression . . . . . . . . . realize using 4 to 1 MUX . . . . . . . . . . . design 1 to 8 DEMUX . . . . . . . . . . . . . implement full subtractor . . . . . . . . . . . construst 1 to 32 DEMUX . . . . . . . . . . . design 3 to 8 decoder . . . . . . . . . . . . . design 5 to 32 decoder . . . . . . . . . . . . . design 4 line to 16 line decoder . . . . . . . . implement using 74LS138 . . . . . . . . . . . implement full substractor . . . . . . . . . . . implement gray to binary code converter . . . design 2 bit comparator . . . . . . . . . . . . design full adder circuit . . . . . . . . . . . . implement BCD to 7 segment decoder . . . . implement 32 input to 5 output encoder . . . analyze the circuit . . . . . . . . . . . . . . . determine number of flip flops needed . . . . count after 12 pulse . . . . . . . . . . . . . . count in binary . . . . . . . . . . . . . . . . . draw logic diagram . . . . . . . . . . . . . . . output frequency . . . . . . . . . . . . . . . . maximum operating frequency . . . . . . . . design 4 bit up down ripple counter . . . . . design divide by 9 counter . . . . . . . . . . . design a divide by 128 counter . . . . . . . . design divide by 78 counter . . . . . . . . . . design divide by 6 counter . . . . . . . . . . . find fmax . . . . . . . . . . . . . . . . . . . . determine states . . . . . . . . . . . . . . . . design MOD 10 counter . . . . . . . . . . . . design down counter . . . . . . . . . . . . . . design programmable frequency divider . . . design a counter . . . . . . . . . . . . . . . . 6
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
65 65 66 67 68 68 69 70 70 71 72 73 74 74 75 75 76 77 78 78 80 82 83 83 84 84 84 85 85 86 86 87 87 88 88 89 90 90
Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa
8.19 8.20 8.21 8.22 8.23 8.24 8.25 8.26 8.28 8.30 8.31 8.32 8.33 8.34 8.35 8.36 8.37 8.38 8.39 8.40 8.41 8.42 8.44 8.45 9.1 9.3 9.4 9.5 9.6 9.8 9.9 9.10 9.11 9.12 9.13 9.17 9.18 9.19
programmable frequency divider . . . . . . design divide by 2 and divide by 5 counter . design mod 9 counter . . . . . . . . . . . . determine MOD number and counter range design a divide by 20 counter . . . . . . . . design divide by 96 counter . . . . . . . . . design divide by 93 counter . . . . . . . . . design divide by 78 counter . . . . . . . . . 7490 IC . . . . . . . . . . . . . . . . . . . . sketch output waveforms of counter . . . . . explain operation of circuit . . . . . . . . . design divide by 40000 counter . . . . . . . design modulo 11 counter . . . . . . . . . . design excess 3 decimal counter . . . . . . . modulus greater than 16 . . . . . . . . . . . modulo 8 counter . . . . . . . . . . . . . . . synchronous decade counter . . . . . . . . . flip flops . . . . . . . . . . . . . . . . . . . . design mod 5 synchronous counter . . . . . design MOD 4 down counter . . . . . . . . design MOD 12 synchronous counter . . . . design 4 bit 4 state ring counter . . . . . . design 4 bit 8 state johnson counter . . . . johnson counter . . . . . . . . . . . . . . . output voltage . . . . . . . . . . . . . . . . input bias current . . . . . . . . . . . . . . design inverting schmitt trigger . . . . . . . threshold voltage . . . . . . . . . . . . . . . tripping voltage . . . . . . . . . . . . . . . time duration . . . . . . . . . . . . . . . . . calculate R1 and R2 . . . . . . . . . . . . . calculate trip point and hysteresis . . . . . design schmitt trigger . . . . . . . . . . . . design op amp schmitt trigger . . . . . . . . VUT and VLT and frequency of oscillation design op amp circuit . . . . . . . . . . . . design monostable using IC 555 . . . . . . . design a timer . . . . . . . . . . . . . . . . 7
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
92 92 94 94 94 95 96 96 96 97 100 101 102 102 103 104 104 106 108 110 111 113 113 114 115 116 116 117 117 118 119 119 120 121 122 123 123 124
Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa
9.20 9.21 9.26 9.27 9.28 9.32 9.33 9.34 9.35 9.36 9.38 9.39 9.40 9.41 9.42 9.43 10.1 10.2 10.4 10.7 10.8
draw timer using IC 555 . . . . . . . . . . . . . . frequency of output and duty cycle . . . . . . . . design astable multivibrator . . . . . . . . . . . . design astable multivibrator . . . . . . . . . . . . design astable mode to generate square wave . . define resolution . . . . . . . . . . . . . . . . . . output voltage . . . . . . . . . . . . . . . . . . . find VoFS . . . . . . . . . . . . . . . . . . . . . . find out stepsize and analog output . . . . . . . . find output voltage . . . . . . . . . . . . . . . . . find resolution and digital output . . . . . . . . . calculate quantizing error . . . . . . . . . . . . . dual scope ADC . . . . . . . . . . . . . . . . . . find digital output of ADC . . . . . . . . . . . . find conversion time . . . . . . . . . . . . . . . . find maximum frequency of input sine wave . . . find line and load regulation and ripple refection design op amp series voltage regulator . . . . . . calculate output voltage . . . . . . . . . . . . . . determine regulated output voltage . . . . . . . . find the range . . . . . . . . . . . . . . . . . . . .
8
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
125 125 126 127 128 129 129 130 130 130 131 132 132 132 133 133 134 135 135 136 136
List of Figures 8.1
sketch output waveforms of counter . . . . . . . . . . . . . .
9
100
Chapter 1 Special Diodes
Scilab code Exa 1.1 current through LED 1 // Example 1 . 1 2 clc 3 format (5) 4 disp ( ” Assume t h e d r o p a c r o s s t h e LED a s 2 V . ” ) 5 disp ( ” T h e r e f o r e , VD = 2 V” ) 6 disp ( ”From f i g . 1 . 1 1 , RS = 2 . 2 k−ohm and VS = 15 V” ) 7 is =(15 -2) /(2.2) // i n mA 8 disp ( is , ” T h e r e f o r e , I S (mA) = VS−VD / RS =” )
Scilab code Exa 1.2 transition capacitance and constant K 1 // Example 1 . 2 2 clc 3 disp ( ” The t r a n s i s t o r c a p a c i t a n c e i s g i v e n by , ” ) 4 disp ( ” CT = C ( 0 ) / [ 1 + |VR/VJ | ˆ n ] ” ) 5 disp ( ”Now C ( 0 ) = 80pF , n = 1/3 a s d i f f u s e d j u n c t i o n 6
”) disp ( ”
VR = 4 . 2 V,
VJ = 0 . 7 V” ) 10
7 ct =((80*10^ -12) /((1+(4.2/0.7) ) ^(1/3) ) ) *10^12
// i n
pF 8 format (6) 9 disp ( ct , ” T h e r e f o r e , CT( pF ) = ” ) 10 disp ( ” t h e t r a n s i s t o r c a p a c i t a n c e i s 11 disp ( ” CT = K / [VR+VJ ] ˆ n” ) 12 format (10) 13 k =(41.82*10^ -12) *((4.2+0.7) ^(1/3) ) 14 disp (k , ” T h e r e f o r e , K = ” )
11
a l s o g i v e n by , ” )
Chapter 2 Frequency Response
Scilab code Exa 2.1 maximum voltage gain 1 // Example 2 . 1 2 clc 3 format (7) 4 disp ( ”We know t h a t maximam v o l t a g e g a i n o f
voltage
a m p l i f i e r i s given as ”) 5 mv =200* sqrt (2) 6 disp ( mv , ” T h e r e f o r e ,
Maximum v o l t a g e g a i n = Gain a t cut − o f f x s q r t ( 2 ) =” )
Scilab code Exa 2.2 gain of the amplifier 1 // Example 2 . 2 2 clc 3 format (6) 4 disp ( ”We know t h a t , ” ) 5 a =100/ sqrt (1+((1000/20) ^2) ) 6 disp (a , ” Below midband :
/ f ) ˆ 2 ) =” ) 12
A = A mid / s q r t (1+( f 1
Scilab code Exa 2.3 gain of an amplifier 1 // Example 2 . 3 2 clc 3 format (7) 4 a =200* sqrt (2) 5 disp (a , ”We know t h a t
A mid = 3dB g a i n x s q r t ( 2 ) =” ) 6 am =282.84/( sqrt (1+(((10/2) ^2) ) ) ) 7 format (6) 8 disp ( am , ” Above midband : A = A mid / s q r t (1+( f 1 / f ) ˆ 2 ) =” ) // a n s w e r i n t e x t b o o k i s wrong
Scilab code Exa 2.4 low frequency response of the amplifier 1 // Example 2 . 4 2 clc 3 format (6) 4 disp ( ” I t i s n e c e s s a r y t o a n a l y z e e a c h n e t w o r k t o
5 6 7 8 9 10 11 12
determine the c r i t i c a l frequency of the a m p l i f i e r ”) disp ( ” ( a ) I n p u t RC n e t w o r k ” ) fc1 =1/(2* %pi *[680+1031.7]*(0.1*10^ -6) ) disp ( fc1 , ” f c ( i n p u t ) ( i n Hz ) = 1 / 2∗ p i ∗ [ RS+( R1 | | R2 | | h i e ) ] C1 =” ) // i n Hz disp ( ” ( b ) Output RC n e t w o r k ” ) format (7) fc2 =1/(2* %pi *((2.2+10) *10^3) *(0.1*10^ -6) ) disp ( fc2 , ” f c ( o u t p u t ) ( i n Hz ) = 1 / 2∗ p i ∗ (RC+ RL) ∗C2 =” ) // i n Hz disp ( ” ( c ) Bypass RC n e t w o r k ” )
13
13 rth =((68*22*0.680) /((22*0.680) +(68*0.680) +(68*22) ) )
*10^3 14 disp ( rth , ” R th ( i n ohm ) = R1 | | R2 | | RS =” ) 15 format (6) 16 fc3 =1/(2* %pi *17.23*10*10^ -6) 17 disp ( fc3 , ” f c ( b y p a s s ) ( i n Hz ) = 1 / 2∗ p i ∗ [ (
R th+h i e / b e t a ) | | RE ] ∗ CE” ) disp ( ”We have c a l c u l a t e d a l l t h e t h r e e c r i t i c a l f r e q u e n c i e s : ”) 19 disp ( ” ( a ) f c ( i n p u t ) = 9 2 9 . 8 Hz” ) 20 disp ( ” ( b ) f c ( o u t p u t ) = 1 3 0 . 4 5 Hz” ) 21 disp ( ” ( c ) f c ( b y p a s s ) = 9 2 3 . 7 Hz” ) 18
Scilab code Exa 2.5 low frequency response of the FET amplifier 1 // Example 2 . 5 2 clc 3 disp ( ” I t i s n e c e s s a r y t o a n a l y z e e a c h n e t w o r k t o
4 5 6 7 8 9 10 11 12 13 14 15 16 17
determine the c r i t i c a l frequency of the a m p l i f i e r ”) disp ( ” ( a ) I n p u t RC Network ” ) disp ( ” f c = 1 / 2∗ p i ∗ R i n ∗C1” ) format (6) rin =(100*100) /(100+100) disp ( rin , ” where R i n ( i n M−ohm ) = RG | | R i n ( g a t e ) = RG | | | VGS/ IGSS | =” ) format (5) fc1 =1/(2* %pi *50*10^6*0.001*10^ -6) disp ( fc1 , ” T h e r e f o r e , f c ( i n Hz ) =” ) disp ( ” ( b ) Output RC Network ” ) format (6) fc2 =1/(2* %pi *(24.2*10^3) *(1*10^ -6) ) disp ( fc2 , ” f c ( i n Hz ) = 1 / 2∗ p i ∗ (RD+RL) ∗C2 =” ) disp ( ”We have c a l c u l a t e d two c r i t i c a l f r e q u e n c i e s ” ) disp ( ” ( a ) f c ( i n p u t ) = 3 . 1 8 Hz” ) 14
18
disp ( ” ( b ) f c ( o u t p u t ) = 6 . 5 7 7 Hz” )
Scilab code Exa 2.6 high frequency response of the amplifier 1 // Example 2 . 6 2 clc 3 disp ( ” B e f o r e c a l c u l a t i n g
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
critical frequencies it is n e c e s s a r y t o c a l c u l a t e mid f r e q u e n c y g a i n o f t h e given c i r c u i t . This i s r e q u i r e d t o c a l c u l a t e C in ( m i l l e r ) and C o u t ( m i l l e r ) ” ) disp ( ” Av = −h f e ∗Ro / Ri ” ) disp ( ” where Ri = h i e | | R1 | | R2” ) disp ( ” and Ro = RC | | RL” ) format (6) av =( -100*1.8) /1.032 disp ( av , ” T h e r e f o r e , Av = −h f e (RC | | RL) / h i e | | R1 | | R2 =” ) disp ( ” N e g a t i v e s i g n i n d i c a t e s 180 d e g r e e s h i f t b e t w e e n i n p u t and o u t p u t ” ) format (7) cin =(4*(174.4+1) ) *10^ -3 // i n nF disp ( cin , ” C i n ( m i l l e r ) ( i n nF ) = C bc ∗ ( Av+1) =” ) cout =(4*175.4) /(174.4) // i n pF format (4) disp ( cout , ” C o u t ( m i l l e r ) ( i n pF ) = C bc ∗ ( Av+1) / Av =” ) disp ( ”We now a n a l y z e i n p u t and o u t p u t n e t w o r k f o r c r i t i c a l frequency . ”) format (8) fci =(1/(2* %pi *410*0.7216*10^ -9) ) *10^ -3 // i n kHz disp ( fci , ” f c ( i n p u t ) ( i n kHz ) = 1 / 2∗ p i ∗ ( Rs | | R1 | | R2 | | h i e ) ∗ ( C be+C i n ( m i l l e r ) ) =” ) format (5) fco =(1/(2* %pi *((22*10^6) /(12.2*10^3) ) *(4*10^ -12) ) ) *10^ -6 // i n MHz 15
disp ( fco , ” f c ( o u t p u t ) ( i n MHz) = 1 / 2∗ p i ∗ (RC | | RL ) ∗ C o u t ( m i l l e r ) =” ) 24 disp ( ”We have c a l c u l a t e d b o t h t h e c r i t i c a l f r e q u e n c i e s ”) 25 disp ( ” ( a ) f c ( i n p u t ) = 5 3 7 . 9 4 7 kHz ” ) 26 disp ( ” ( b ) f c ( o u t p u t ) = 2 2 . 1 MHz” ) 23
Scilab code Exa 2.7 high frequency response of the amplifier 1 // Example 2 . 7 2 clc 3 disp ( ” B e f o r e c a l c u l a t i n g
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
critical frequencies it is n e c e s s a r y t o c a l c u l a t e mid f r e q u e n c y g a i n o f t h e given a m p l i f i e r c i r c u i t . This i s r e q u i r e d to c a l c u l a t e C i n ( m i l l e r ) and C o u t ( m i l l e r ) ” ) disp ( ” Av = −gm ∗ RD” ) disp ( ” Here , RD s h o u l d b r r e p l a c e d by RD | | RL” ) av = -6*2 disp ( av , ” T h e r e f o r e , Av = −gm∗ (RD | | RL) =” ) cin =2*(12+1) // i n pF disp ( cin , ” C i n ( m i l l e r ) ( i n pF ) = C gd ∗ ( Av+1) = C r s s ∗ ( Av+1) =” ) format (6) cout =(2*13) /12 // i n pF disp ( cout , ” C o u t ( m i l l e r ) ( i n pF ) = C gd ∗ ( Av+1) / Av = ”) disp ( ” G gs = C i s s − C r s s = 4 pF” ) disp ( ”We know a n a l y z e i n p u t and o u t p u t n e t w o r k f o r c r i t i c a l frequency ”) disp ( ” f c ( i n p u t ) = 1 / 2∗ p i ∗RS∗CT” ) disp ( ” = 1 / 2∗ p i ∗RS ∗ [ C g s+C i n ( m i l l e r ) ] ”) format (4) fc1 =(1/(2* %pi *100*30*10^ -12) ) *10^ -6 // i n MHz disp ( fc1 , ” f c ( i n p u t ) ( i n MHz)= ” ) 16
20 fc2 =(1/(2* %pi *((48.4*10^6) /(24.2*10^3) )
*(2.166*10^ -12) ) ) *10^ -6 // i n MHz format (6) disp ( fc2 , ” f c ( o u t p u t ) ( i n MHz) = 1 / 2∗ p i ∗ (RD | | RL ) ∗ C o u t ( m i l l e r ) =” ) 23 disp ( ”We have c a l c u l a t e d b o t h t h e c r i t i c a l f r e q u e n c i e s : ”) 24 disp ( ” ( a ) f c ( i n p u t ) = 53 MHz” ) 25 disp ( ” ( b ) f c ( o u t p u t ) = 3 6 . 7 4 MHz” ) 21 22
17
Chapter 3 Feedback Amplifiers
Scilab code Exa 3.1 gain fL and fH 1 // Example 3 . 1 2 clc 3 disp ( ” ( a ) Gain w i t h f e e d b a c k ” ) 4 format (5) 5 av =1000/(1+(0.05*1000) ) 6 disp ( av , ” AV mid = Av mid / 1+ b e t a ∗ Av mid =” ) 7 flf =50/(1+(0.05*1000) ) // i n Hz 8 disp ( flf , ” ( b ) f L f ( i n Hz ) = f L / 1+ b e t a ∗ Av mid
=” ) 9 fhf =((50*10^3) *(1+(0.05*1000) ) ) *10^ -6 // i n MHz 10 disp ( fhf , ” ( c ) f H f ( i n MHz) = f H ∗ (1+ b e t a ∗ Av mid ) =” )
Scilab code Exa 3.2 Vo and second harmonic distortion with feedback 1 // Example 3 . 2 2 clc 3 disp ( ” ( a ) b e t a :
−40 = 20∗ l o g [1+ b e t a ∗A ] ” ) 18
4 disp ( ” T h e r e f o r e , 1+ b e t a ∗A = 100 ” ) 5 b =99/1000 6 format (6) 7 disp (b , ” T h e r e f o r e , b e t a =” ) 8 disp ( ” Gain o f t h e a m p l i f i e r w i t h f e e d b a c k 9 10 11
12 13 14 15 16
i s given
as ”) avf =1000/100 disp ( avf , ” A Vf = A V / 1+ b e t a ∗A V =” ) disp ( ” ( b ) To m a i n t a i n o u t p u t power 10 W, we s h o u l d m a i n t a i n o u t p u t v o l t a g e c o n s t a n t and t o m a i n t a i n o u t p u t c o n s t a n t w i t h f e e d b a c k g a i n r e q u i r e d Vs i s ”) vsf =10*100*10^ -3 // i n V disp ( vsf , ” V s f ( i n V) = Vs ∗ 100 =” ) disp ( ” ( c ) S e c o n d h a r m o n i c d i s t o r t i o n i s r e d u c e d by f a c t o r 1 + b e t a ∗A” ) d2f =(0.1/100) *100 // i n p e r c e n t a g e disp ( d2f , ” D 2 f ( i n p e r c e n t a g e ) = D 2 / 1+ b e t a ∗A =” )
Scilab code Exa 3.3 beta and Af 1 // Example 3 . 3 2 clc 3 disp ( ” ( a ) We know t h a t ” ) 4 disp ( ” dAf / Af = 0 . 1 / 1 + b e t a ∗A ∗ dA/A” ) 5 disp ( ” T h e r e f o r e , 1+ b e t a ∗A = 3 7 . 5 ” ) 6 b =(36.5/2000) *100 // i n p e r c e n t a g e 7 format (6) 8 disp (b , ” T h e r e f o r e , b e t a ( i n p e r c e n t a g e ) =” ) 9 af =2000/(1+(0.01825*2000) ) 10 disp ( af , ” ( b ) Af = A / 1+ b e t a ∗A =” )
19
Scilab code Exa 3.4 beta and Av and Avf and Rif and Rof 1 // Example 3 . 4 2 clc 3 disp ( ” S t e p 1 : I d e n t i t y t o p o l o g y ” ) 4 disp ( ” The f e e d b a c k v o l t a g e i s a p p l i e d
5 6 7
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
a c r o s s the r e s i s t a n c e R e1 and i t i s i n s e r i e s w i t h i n p u t s i g n a l . Hence f e e d b a c k i s v o l t a g e s e r i e s f e e d b a c k . ”) disp ( ” ” ) disp ( ” S t e p 2 and S t e p 3 : Find i n p u t and o u t p u t c i r c u i t . ”) disp ( ” To f i n d i n p u t c i r c u i t , s e t Vo = 0 ( c o n n e c t i n g C2 t o g r o u n d ) , which g i v e s p a r a l l e l c o m b i n a t i o n o f Re w i t h Rf a t E1 . To f i n d o u t p u t c i r c u i t , s e t I i = 0 ( o p e n i n g t h e i n p u t node E1 a t e m i t t e r o f Q1 ) , which g i v e s s e r i e s c o m b i n a t i o n o f Rf and Re1 a c r o s s t h e o u t p u t . The r e s u l t a n t c i r c u i t i s shown i n F i g . 3 . 3 2 ” ) disp ( ” ” ) disp ( ” S t e p 4 : Find open l o o p v o l t a g e g a i n ( A v ) ” ) format (5) rl2 =(4.7*10.1) /(4.7+10.1) // i n k−ohm disp ( rl2 , ” R L2 ( i n k−ohm ) = R c2 | | ( R e1+Rf ) =” ) disp ( ” A i 2 = −h f e = −100 ” ) disp ( ” R i 2 = h i e = 1 1 0 0 ohm” ) format (7) av2 =( -100*3.21*10^3) /1100 disp ( av2 , ” A v2 = A i 2 ∗ R L2 / R i 2 =” ) disp ( ” A i 1 = −h f e = −100 ” ) format (5) rl1 =(22*220*22*1.100) /((220*22*1.100) +(22*22*1.100) +(22*220*1.100) +(22*220*22) ) // i n ohm disp ( rl1 *10^3 , ” R L1 ( i n ohm ) = R c1 | | R3 | | R4 | | R i 2 =” ) ri1 =1.1+(101*((0.1*10) /(0.1+10) ) ) // i n k−ohm format (5) disp ( ri1 , ” R i 1 ( i n k−ohm ) = h i e + (1+ h f e ) ∗ R e 1 e f f = 20
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
where R e 1 e f f = ( R e1 | | Rf ) ” ) av1 =( -100*995) /(11.099*10^3) disp ( av1 , ” T h e r e f o r e , A v1 = A i 1 ∗RL1 / Ri1 =” ) disp ( ” The o v e r a l l v o l t a g e g a i n w i t h o u t f e e d b a c k i s g i v e n as , ” ) av = -291.82* -8.96 format (7) disp ( av , ” Av = A v1 ∗ A v2 =” ) disp ( ” The o v e r a l l v o l t a g e g a i n t a k i n g Rs i n a c c o u n t i s g i v e n as , ” ) aV =(2614.7*11.099*10^3) /((11.099*10^3) +100) format (8) disp ( aV , ” Av = Vo / Vs = Av∗ R i 1 / R i 1+Rs =” ) disp ( ” ” ) disp ( ” S t e p 5 : C a l c u l a t e b e t a ” ) disp ( ” L o o k i n g a t F i g . 3 . 3 3 . ” ) beta =100/(100+(10*10^3) ) format (7) disp ( beta , ” b e t a = Vf / Vo =” ) d =1+(0.0099*2591.35) format (6) disp (d , ” D = 1 + b e t a ∗Av =” ) avf =2591.35/26.65 disp ( avf , ” A v f = Av/D =” ) rif =26.65*11.099 // i n k−ohm format (8) disp ( rif , ” R i f ( i n k−ohm ) = R i 1 ∗ D =” ) riff =(295.788*220*22) /((220*22) +(295.788*22) +(295.788*220) ) // i n k−ohm format (6) disp ( riff , ” R ’ ’ i f ( i n k−ohm ) = R i f | | R1 | | R2 =” ) disp ( ” R o f = Ro / D = i n f i n i t y / D = i n f i n i t y ” ) disp ( ” T h e r e f o r e , R ’ ’ o f = R ’ ’ o / D where R ’ ’ o = R L2 ” ) roff =(3.21*10^3) /26.65 // i n omh format (7) disp ( roff , ” T h e r e f o r e , R ’ ’ o f ( i n ohm ) = ” )
21
Scilab code Exa 3.5 Avf and Rif and Rof 1 // Example 3 . 5 2 clc 3 disp ( ” S t e p 1 : I d e n t i t y t o p o l o g y ” ) 4 disp ( ” The f e e d b a c k v o l t a g e i s a p p l i e d
5 6 7
8 9 10 11 12 13 14 15 16 17 18 19 20 21
a c r o s s R1 ( 1 0 0 ohm ) , which i s i n s e r i e s w i t h i n p u t s i g n a l . Hence f e e d b a c k i s v o l t a g e s e r i e s f e e d b a c k . ” ) disp ( ” ” ) disp ( ” S t e p 2 and S t e p 3 : Find i n p u t and o u t p u t c i r c u i t ”) disp ( ” To f i n d i n p u t c i r c u i t , s e t Vo = 0 , which g i v e s p a r a l l e l c o m b i n a t i o n o f R1 w i t h R2 a t E1 a s shown i n t h e f i g . 3 . 4 5 . To f i n d o u t p u t c i r c u i t , s e t I i = 0 by o p e n i n g t h e i n p u t node , E1 a t e m i t t e r o f Q1 , which g i v e s t h e s e r i e s c o m b i n a t i o n o f R2 and R1 a c r o s s t h e o u t p u t . The r e s u l t a n t c i r c u i t i s shown i n f i g . 3 . 4 5 ” ) disp ( ” ” ) disp ( ” S t e p 4 : Find t h e open l o o p v o l t a g e g a i n ( Av ) ” ) rl2 =(4.7*4.8) /(4.7+4.8) // i n k−ohm format (5) disp ( rl2 , ” R L2 ( i n k−ohm ) =” ) disp ( ” S i n c e h o e = h r e = 0 we can u s e a p p r o x i m a t e a n a l y s i s ”) disp ( ” A i 2 = −h f e = −50” ) disp ( ” R i 2 = h i e = 1 . 1 k−ohm” ) av2 =( -50*2.37) /1.1 format (7) disp ( av2 , ” A v2 = A i 2 ∗ R L2 / R i 2 =” ) rl1 =(10*47*33*1.1) /((47*33*1.1) +(10*33*1.1) +(10*47*1.1) +(10*47*33) ) // i n ohm format (5) disp ( rl1 *10^3 , ” R L1 ( i n ohm ) =” ) 22
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
disp ( ” A i 1 = −h f e = −50” ) ri1 =1.1+(51*((0.1*4.7) /(4.8) ) ) // i n k−ohm format (6) disp ( ri1 , ” R i 1 ( i n k−ohm ) = h i e + (1+ h f e ) ∗Re =” ) av1 =( -50*942) /(6.093*10^3) format (5) disp ( av1 , ” A v1 = A i 1 ∗ R L1 / R i 1 =” ) av = -7.73* -107.73 format (7) disp ( av , ” T h e r e f o r e , A v = A v1 ∗ A v2 =” ) disp ( ” ” ) disp ( ” S t e p 5 : C a l c u l a t e b e t a and D” ) disp ( ” b e t a = R1 / R1+R2 = 1 / 4 8 ” ) d =1+(832.75/48) // i n ohm format (6) disp (d , ” D( i n ohm ) = 1 + A∗ b e t a =” ) disp ( ” ” ) disp ( ” S t e p 5 : C a l c u l a t e A vf , R o f and R i f ” ) avf =832.75/18.35 disp ( avf , ” A v f = A v / D =” ) rif =6.093*18.35 // i n k−ohm disp ( rif , ” R i f ( i n k−ohm ) = R i 1 ∗ D =” ) rof =(2.37*10^3) /18.35 // i n ohm format (7) disp ( rof , ” R o f ( i n ohm ) = R o / D =” )
Scilab code Exa 3.6 Avf and Rif and Rof 1 // Example 3 . 6 2 clc 3 disp ( ” S t e p 1 : I d e n t i f y t o p o l o g y ” ) 4 disp ( ” The f e e d b a c k v o l t a g e i s a p p l i e d
a c r o s s R e1 = 1 . 5 k−ohm , which i s i n s e r i e s w i t h i n p u t s i g n a l . Hence f e e d b a c k i s v o l t a g e s e r i e s f e e d b a c k ” ) 5 disp ( ” ” ) 23
6 7
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
disp ( ” S t e p 2 and s t e p 3 : Find i n p u t and o u t p u t c i r c u i t ”) disp ( ” To f i n d i n p u t c i r c u i t , s e t Vo = 0 , which g i v e s p a r a l l e l c o m b i n a t i o n o f R e1 w i t h R f a t E1 a s shown i n f i g . 3 . 4 7 . To f i n d ouput c i r c u i t , s e t I i = 0 by o p e n i n g t h e i n p u t node , E1 a t e m i t t e r o f Q1 , which g i v e s t h e s e r i e s c o m b i n a t i o n o f R f and R e1 a c r o s s t h e o u t p u t . The r e s u l t a n t c i r c u i t i s shown i n f i g . 3 . 4 7 ” ) disp ( ” ” ) disp ( ” S t e p 4 : Find t h e open l o o p v o l t a g e g a i n ( Av ) ” ) rl2 =(2.2*57.5) /(2.2+57.5) // i n k−ohm format (6) disp ( rl2 , ” R L2 ( i n k−ohm ) = R c2 | | ( Rf + R e1 ) =” ) disp ( ” S i n c e hoe ∗ R L2 = 1 0 ˆ − 6 ∗ 2 . 1 1 9 k−ohm = 0 . 0 0 2 1 1 9 i s l e s s t h a n 0 . 1 we u s e a p p r o x i m a t e a n a l y s i s . ” ) disp ( ” A i 2 = − h f e = −200 ” ) disp ( ” R i 2 = h i e = 2 k−ohm” ) av2 =( -200*2.119) /2 disp ( av2 , ” A v2 = A i 2 ∗ R L2 / R i 2 =” ) rl1 =(120*2) /(122) // i n k−ohm disp ( rl1 , ” R L1 ( i n k−ohm ) = R C1 | | R i 2 =” ) disp ( ” S i n c e hoe ∗ R L1 = 1 0 ˆ − 6 ∗ 1 . 9 6 7 = 0 . 0 0 1 9 6 7 i s l e s s t h a n 0 . 1 we u s e a p p r o x i m a t e a n a l y s i s . ” ) disp ( ” A i 1 = −h f e = −200 ” ) ri1 =2+(201*((1.5*56) /(57.5) ) ) // i n k−ohm format (7) disp ( ri1 , ” R i 1 ( i n k−ohm ) = h i e + (1+ h f e ) ∗Re =” ) av1 =( -200*1.967) /295.63 format (5) disp ( av1 , ” T h e r e f o r e , A v1 = A i 1 ∗ R L1 / R i 1 =” ) disp ( ” The o v e r a l l g a i n w i t h o u t f e e d b a c k i s ” ) av = -1.33* -211.9 format (7) disp ( av , ” Av = A v1 ∗ A v2 =” ) disp ( ” ” ) disp ( ” S t e p 5 : C a l c u l a t e b e t a ” ) beta =1.5/57.5 24
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
format (6) disp ( beta , ” b e t a = Vf / Vo =” ) disp ( ” ” ) disp ( ” S t e p 6 : c a l c u l a t e D, A vf , R i f , R o f ” ) d =1+(0.026*281.82) disp (d , ” D = 1 + Av∗ b e t a =” ) avf =281.82/8.327 disp ( avf , ” T h e r e f o r e , A v f = Av / D =” ) ri =(295.63*150) /(295.63+150) // i n k−ohm format (5) disp ( ri , ” Ri ( i n k−ohm ) = R i 1 | | R =” ) rif =99.5*8.327 // i n k−ohm format (7) disp ( rif , ” R i f ( i n k−ohm ) = Ri ∗D =” ) disp ( ” Ro = 1/ hoe = 1 M−ohm” ) rof =((1*10^6) /8.327) *10^ -3 // i n k−ohm format (4) disp ( rof , ” R o f ( i n k−ohm ) = Ro / D =” ) ro =(1000*2.119) /(2.119+1000) // i n k−ohm format (7) disp ( ro , ” R ’ ’ o ( i n k−ohm ) = Ro | | R c2 | | ( Rf+R e1 ) = Ro | | R L2 =” ) 56 rof =(2.1145*10^3) /8.327 // i n ohm 57 format (4) 58 disp ( rof , ” R ’ ’ o f ( i n ohm ) = R ’ ’ o / D =” )
Scilab code Exa 3.7 D and Avf and Rif and Rof 1 // Example 3 . 7 2 clc 3 disp ( ” S t e p 1 : I d e n t i t y t o p o l o g y ” ) 4 disp ( ” By s h o r t i n g o u t p u t v o l t a g e ( Vo = 0 ) ,
f e e d b a c k v o l t a g e Vf becomes z e r o and h e n c e i t i s v o l t a g e s a m p l i n g . The f e e d b a c k v o l t a g e i s a a p l i e d in s e r i e s with input v o l t a g e hence the topology 25
5 6 7
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
i s v o l t a g e s e r i e s feedback . ”) disp ( ” ” ) disp ( ” S t e p 2 and S t e p 3 : Find i n p u t and o u t p u t c i r c u i t . ”) disp ( ” To f i n d i n p u t c i r c u i t , s e t Vo = 0 . T h i s p l a c e s t h e p a r a l l e l c o m b i n a t i o n o f r e s i s t o r 10 K and 200 ohm a t f i r s t s o u r c e . To f i n d o u t p u t c i r c u i t , s e t I i = 0 . T h i s p l a c e s t h e r e s i s t o r 10 K and 200 ohm i n s e r i e s a c r o s s t h e o u t p u t . The r e s u l t a n t c i r c u i t i s shown i n f i g . 3 . 5 0 . ” ) disp ( ” ” ) disp ( ” S t e p 4 : R e p l a c e FET w i t h i t s e q u i v a l e n t c i r c u i t a s shown i n f i g . 3 . 5 1 ” ) disp ( ” ” ) disp ( ” S t e p 5 : Find open l o o p t r a n s f e r g a i n . ” ) disp ( ” Av = Vo / Vs = A v1 ∗ A v2 ” ) disp ( ” A v2 = −u∗ R L2 / R L2+r d ” ) rl2 =(10.2*47) /(10.2+47) // i n k−ohm format (5) disp ( rl2 , ” where R L2 ( i n k−ohm ) =” ) av2 =( -40*8.38) /(8.38+10) format (7) disp ( av2 , ” T h e r e f o r e , A v2 =” ) disp ( ” A v1 = u∗ R D e f f / r d+R D e f f +(1+u ) ∗ R s e f f ” ) rdeff =(47*1000) /(47+1000) // i n k−ohm format (6) disp ( rdeff , ” where R D e f f ( i n k−ohm ) = R D | | R G2 =” ) disp ( ” R s e f f = 200 | | 10 K” ) av1 =( -40*44.98*10^3) /((10*10^3) +(44.89*10^3) +(41*((10*0.2) /(10.2) ) ) ) // a n s w e r i n t e x t b o o k i s disp ( av1 , ” A v1 =” ) wrong oav = -28.59* -18.237 format (7) disp ( oav , ” T h e r e f o r e , O v e r a l l Av =” ) disp ( ” ” ) disp ( ” S t e p 6 : C a l c u l a t e b e t a ” ) 26
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
beta =200/(10.2*10^3) disp ( beta , ” b e t a = Vf / Vo =” ) disp ( ” ” ) disp ( ” S t e p 7 : C a l c u l a t e D, A vf , R i f , R ’ ’ o f ” ) d =1+(0.0196*521.39) format (6) disp (d , ” D = 1 + Av∗ b e t a =” ) avf =521.39/11.22 disp ( avf , ” A v f = Av / D =” ) disp ( ” Ri = R G = 1 M−ohm” ) rif =11.22 disp ( rif , ” R i f ( i n M−ohm ) = Ri ∗ D =” ) disp ( ” Ro = r d = 10 k−ohm” ) ro =(10*8.38) /(18.38) // i n k−ohm disp ( ro , ” R ’ ’ o ( i n k−ohm ) = r d | | R L2 =” ) rof =(4.559*10^3) /11.22 // i n ohm format (4) disp ( rof , ” R ’ ’ o f ( i n ohm ) = R ’ ’ o / D =” )
Scilab code Exa 3.8 voltage gain 1 // Example 3 . 8 2 clc 3 disp ( ” Here , o u t p u t v o l t a g e
4 5 6 7 8 9
i s s a m p l e d and f e d i n s e r i e s w i t h t h e i n p u t s i g n a l . Hence t h e t o p o l o g y i s v o l t a g e s e r i e s feedback . ”) disp ( ” The open l o o p v o l t a g e g a i n f o r one s t a g e i s g i v e n as , ” ) disp ( ” Av = −gm∗ R eq ” ) req =(8*40*1000) /((40*1000) +(8*1000) +(8*40) ) // i n k −ohm format (5) disp ( req , ” R eq ( i n k−ohm ) = r d | | R d | | ( R i 1+R 2 ) =” ) av = -5*6.62 27
10 format (6) 11 disp ( av , ” Av =” ) 12 avm = -33.11^3 13 disp ( avm , ”Av = O v e r a l l 14 15 16 17 18 19 20 21
v o l t a g e g a i n = | A vmid | ˆ 3 =” ) // a n s w e r i n t e x t b o o k i s wrong beta =50/(10^6) format (7) disp ( beta , ” b e t a = Vf / Vo = −R 1 / R g = −R 1 / R 1+R 2 =” ) d =1+(( -5*10^ -5) * -36306) format (6) disp (d , ” D = 1 + | Av | ∗ b e t a =” ) avf = -36306/2.8153 disp ( avf , ” A v f = Av / D =” )
Scilab code Exa 3.9 Avf 1 // Example 3 . 9 2 clc 3 disp ( ” Here , o u t p u t t e r m i n a l s a r e B and ground , 4 5 6 7 8
9 10 11
thus t h e f o r w a r d g a i n i s t h e g a i n o f Q1 and i t i s , ” ) disp ( ” A BN = −33.11 ” ) disp ( ” However , Q2 and Q3 must be c o n s i d e r e d a s a part of feedback loop ”) disp ( ” Here beta BN = V f / V B = V f / V o ∗ V o /V C ∗ V C/V B” ) disp ( ” where V B and V C a r e v o l t a g e s a t p o i n t B and C, r e s p e c t i v e l y . ”) disp ( ” T h e r e f o r e , beta BN = V f / V o ∗ A v3 ∗ A v2 b e c a u s e V o /V C = A v3 and V C/V B = A v2 ”) bbn = -(5*10^ -5) *(33.11^2) format (7) disp ( bbn , ” T h e r e f o r e , beta BN = −R1/ R g ∗ A v3 ∗ A v2 =” ) 28
12 13
14 15 16
disp ( ” Note t h a t t h e l o o p g a i n − beta BN ∗ A BN = Aˆ3 Vo ∗ R1/Rg = −1.815 = −A∗ b e t a ” ) disp ( ” I t s h o u l d be c l e a r t h t r e g a r d l e s s o f w h e r e t h e output t e r m i n a l s a r e taken , the l o o p g a i n i s unchanged . ” ) avf = -33.11/2.815 format (6) disp ( avf , ” T h e r e f o r e , A v f = A BN / 1+A∗ b e t a =” )
Scilab code Exa 3.10 Avf and Rif and Rof 1 2 3
4 5 6
7 8 9 10 11 12 13
// Example 3 . 1 0 disp ( ” S t e p 1 : I d e n t i f y t o p o l o g y ” ) disp ( ” By s h o r t i n g o u t p u t v o l t a g e ( Vo = 0 ) , f e e d b a c k v o l t a g e Vf becomes z e r o and h e n c e i t i s v o l t a g e s a m p l i n g . The f e e d b a c k v o l t a g e i s a p p l i e d in s e r i e s with the input v o l t a g e hence the topology i s v o l t a g e s e r i e s feedback . ”) disp ( ” ” ) disp ( ” S t e p 2 and S t e p 3 : Find i n p u t and o u t p u t c i r c u i t . ”) disp ( ” To f i n d i n p u t c i r c u i t , s e t Vo = 0 . T h i s p l a c e s t h e p a r a l l e l c o m b i n a t i o n o f r e s i s t o r 10 K and 300 ohm a t f i r s t s o u r c e . To f i n d o u t p u t c i r c u i t , s e t I i = 0 . T h i s p l a c e s t h e r e s i s t o r 10K and 300 ohm i n s e r i e s a c r o s s t h e o u t p u t . The r e s u l t a n t c i r c u i t i s shown i n f i g . 3 . 5 4 . ” ) disp ( ” ” ) disp ( ” S t e p 4 : R e p l a c e FET w i t h i t s e q u i v a l e n t c i r c u i t a s shown i n f i g . 3 . 5 5 . ” ) disp ( ” ” ) disp ( ” S t e p 5 : Find open l o o p t r a n s f e r g a i n . ” ) disp ( ” Av = Vo / Vs = A v1 ∗ A v2 ” ) disp ( ” A v2 = −u∗ R L2 / R L2+r d ” ) rl2 =(10.3*22) /(10.3+22) // i n k−ohm 29
14 format (3) 15 disp ( rl2 , ” where R L2 ( i n k−ohm ) =” ) 16 av2 =( -50*7) /17 17 format (6) 18 disp ( av2 , ” A v2 =” ) 19 disp ( ” A v1 = u∗ R D e f f / r d+R D e f f +(1+u ) ∗ R s e f f ” ) 20 rdeff =(22*1000) /(22+1000) // i n k−ohm 21 disp ( rdeff , ” R D e f f ( i n k−ohm ) = R D | | R G2 =” ) 22 disp ( ” R s e f f = 330 | | 10K” ) 23 av1 =( -50*21.53) /(10+21.53+(51*((0.33*10) /(10+0.33) ) ) 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
) disp ( av1 , ” T h e r e f o r e , A v1 =” ) av = -20.59* -22.51 disp ( av , ” O v e r a l l Av = A v1 ∗ A v2 =” ) disp ( ” ” ) disp ( ” S t e p 6 : C a l c u l a t e b e t a ” ) beta =330/(330+10000) format (7) disp ( beta , ” b e t a = Vf / Vo = Rs / Rs+Rf =” ) disp ( ” ” ) disp ( ” s t e p 7 : C a l c u l a t e D, A vf , R i f , R ’ ’ o f ” ) d =1+(0.0319*463.5) disp (d , ” D = 1 + Av∗ b e t a =” ) avf =463.5/15.785 format (6) disp ( avf , ” A v f = Av / D =” ) disp ( ” Ri = R G = 1 M−ohm” ) rif =15.785 format (7) disp ( rif , ” R i f ( i n k−ohm ) = Ri ∗ D =” ) ro =(10*7) /(10+7) // i n k−ohm format (6) disp ( ro , ” R ’ ’ o ( i n k−ohm ) = r d | | R L2 =” ) rof =(4.118*10^3) /15.785 // i n ohm format (4) disp ( rof , ” R ’ ’ o f ( i n ohm ) = R ’ ’ o / D =” )
30
Scilab code Exa 3.11 voltage gain and input and output resistance 1 // Example 3 . 1 1 2 clc 3 disp ( ” S t e p 1 : I d e n t i f y t o p o l o g y ” ) 4 disp ( ” The f e e d b a c k v o l t a g e i s a p p l i e d
5 6 7
8 9 10 11 12 13 14 15 16 17 18 19 20 21
a c r o s s the r e s i s t a n c e R e1 and i t i s i n s e r i e s w i t h i n p u t s i g n a l . Hence f e e d b a c k i s v o l t a g e s e r i e s f e e d b a c k . ”) disp ( ” ” ) disp ( ” s t e p 2 and S t e p 3 : Find i n p u t and o u t p u t c i r c u i t . ”) disp ( ” To f i n d i n p u t c i r c u i t , s e t Vo = 0 ( c o n n e c t i n g C2 t o g r o u n d ) , which g i v e s p a r l l e l c o m b i n a t i o n o f Re w i t h Rf a t E1 . To f i n d o u t p u t c i r u i t , s e t I i = 0 ( o p e n i n g t h e i n p u t node E1 a t e m i t t e r o f Q1 ) , which g i v e s s e r i e s c o m b i n a t i o n od Rf and R e1 a c r o s s t h e o u t p u t . The r e s u l t a n t c i r c u i t i s shown i n f i g . 3 . 5 7 ” ) disp ( ” ” ) disp ( ” S t e p 4 : Find open l o o p v o l t a g e g a i n ( Av ) ” ) rl2 =(4.7*3.42) /(4.7+3.42) // i n k−ohm format (5) disp ( rl2 , ” R L2 ( i n k−ohm ) = R c2 | | ( Rs+R) =” ) disp ( ” A i 2 = −h f e = −50” ) disp ( ” R i 2 = h i e = 1 0 0 0 ohm = 1 k−ohm” ) av2 = -50*1.98 format (3) disp ( av2 , ” A v2 = A i 2 ∗ R L2 / R i 2 =” ) disp ( ” A i 1 = −h f e = −50” ) format (7) rl1 =((10*100*22*1) /((100*22) +(10*22) +(10*100) +(10*100*22) ) ) *10^3 // i n ohm disp ( rl1 , ” R L1 ( i n ohm ) = R c1 | | R3 | | R4 | | R i 2 31
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
=” ) disp ( ” R i 1 = h i e + (1+ h f e ) ∗ R e 1 e f f ” ) re1 =1+(51*((3.3*0.12) /(3.42) ) ) // i n k−ohm format (4) disp ( re1 , ” where R e 1 e f f ( i n k−ohm ) = Rs | | R =” ) av1 =( -50*865.46) /6900 format (5) disp ( av1 , ” A v1 = A i 1 ∗ R L1 / R i 1 =” ) disp ( ” The o v e r a l l v o l t a g e g a i n , ” ) av = -6.27* -99 format (7) disp ( av , ” Av = A v1 ∗ A v2 =” ) disp ( ” ” ) disp ( ” S t e p 5 : C a l c u l a t e b e t a ” ) beta =120/(120+3300) format (6) disp ( beta , ” b e t a = Vf / Vo = Rs / Rs+R =” ) disp ( ” ” ) disp ( ” S t e p 6 : C a l c u l a t e D, A vf , R i f , R o f and R ’ ’ o f ”) d =1+(0.035*620.73) format (7) disp (d , ” D = 1 + Av∗ b e t a =” ) avf =620.73/22.725 format (5) disp ( avf , ” A v f = Av / D =” ) rif =6.9*22.725 // i n k−ohm format (6) disp ( rif , ” R i f ( i n k−ohm ) = R i 1 ∗ D =” ) disp ( ” R o f = Ro / D = i n f i n i t y ” ) rof =(1.98*10^3) /22.725 // i n ohm disp ( rof , ” R ’ ’ o f ( i n ohm ) = R ’ ’ o / D = R L2 / D =” )
Scilab code Exa 3.12 Ai and beta and Aif
32
1 // Example 3 . 1 2 2 clc 3 disp ( ” S t e p 1 : I d e n t i f y t o p o l o g y ” ) 4 disp ( ” The f e e b d a c k i s g i v e n from e m i t t e r
5 6 7
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
o f Q2 t o t h e b a s e o f Q2 . I f I o = 0 t h e n f e e d b a c k c u r r e n t through 5 K r e g i s t e r i s zero , hence i t i s c u r r e n t s a m p l i n g . As f e e d b a c k s i g n a l i s mixed i n s h u n t with input , the a m p l i f i e r i s c u r r e n t shunt feedback a m p l i f i e r . ”) disp ( ” ” ) disp ( ” S t e p 2 and S t e p 3 : Find i n p u t and o u t p u t ” ) disp ( ” The i n p u t c i r c u i t o f t h e a m p l i f i e r w i t h o u t f e e d b a c k i s o b t a i n e d by o p e n i n g t h e o u t p u t l o o p a t t h e e m i t t e r o f Q2 ( I o = 0 ) . T h i s p l a c e s R ’ ’ ( 5 K ) i n s e r i e s w i t h Re from b a s e t o e m i t t e r o f Q1 . The o u t p u t c i r c u i t i s f o u n d by s h o r t i n g t h e i n p u t node , i . e . making Vi = 0 . T h i s p l a c e s R ’ ’ ( 5 K) i n p a r a l l e l w i t h Re . The r e s u l t a n t e q u i v a l e n t c i r c u i t i s shown i n f i g . 3 . 5 9 ” ) disp ( ” ” ) disp ( ” S t e p 4 : Find open c i r c u i t t r a n s f e r g a i n . ” ) disp ( ” A I = I o / I s = −I c / I b 2 ∗ I b 2 / I c 1 ∗ I c 1 / I b1 ∗ I b1 / I s ”) disp ( ”We know t h a t − I c 2 / I b 2 = A i 2 = −h f e = −50 and ” ) disp ( ” − I c 1 / I b 1 = A i 1 = −h f e = 50 ” ) disp ( ” I c 1 / I b 1 = 50 ” ) disp ( ” L o o k i n g a t f i g . 3 . 5 9 we can w r i t e , ” ) disp ( ” I b 2 / I c 1 = −R c1 / R c1+R i 2 ” ) ri2 =1.5+(51*((5*0.5) /(5.5) ) ) // i n k−ohm format (8) disp ( ri2 , ” where R i 2 ( i n k−ohm ) = h i e + (1+ h f e ) ∗ ( R e2 | | R ’ ’ ) =” ) x1 = -2/(2+24.6818) disp ( x1 , ” I b 2 / I c 1 =” ) disp ( ” I b 1 / I s = R / R+R i 1 where R = Rs | | ( R ’ ’ + R e2 ) ” ) r =((1*5.5) /(1+5.5) ) *10^3 // i n ohm 33
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
format (9) disp (r , ” T h e r e f o r e , R( i n ohm ) =” ) disp ( ” and R i 1 = h i e + (1+ h f e ) ∗ R e1 = 1 6 . 8 k−ohm” ) x1 =846.1538/(846.1538+(16.8*10^3) ) format (8) disp ( x1 , ” T h e r e f o r e , I b 1 / I s =” ) ai =50*0.07495*50*0.04795 format (7) disp ( ai , ” A I =” ) disp ( ” ” ) disp ( ” S t e p 5 : C a l c u l a t e b e t a ” ) beta =500/(500+(5*10^3) ) disp ( beta , ” b e t a = I f / I o = R e2 / R e2 | R ’ ’ =” ) disp ( ” ” ) disp ( ” S t e p 6 : C a l c u l a t e D, A I f ” ) d =1+(0.0909*8.9848) disp (d , ” D = 1 + A I ∗ b e t a =” ) aif =8.9848/1.8168 disp ( aif , ” A I f = A I / D =” )
Scilab code Exa 3.13 beta and Av and Avf and Rif and Rof 1 // Example 3 . 1 3 2 clc 3 disp ( ” S t e p 1 : I d e n t i f y t o p o l o g y ” ) 4 disp ( ” The f e e d b a c k v o l t a g e i s a p p l i e d
a c r o s s R1 ( 1 5 0 ohm ) , which i s i n s e r i e s w i t h i n p u t s i g n a l . Hence f e e d b a c k i s v o l t a g e s e r i e s f e e d b a c k . ” ) 5 disp ( ” ” ) 6 disp ( ” S t e p 2 and S t e p 3 : Find i n p u t and o u t p u t c i r c u i t ”) 7 disp ( ” To f i n d i n p u t c i r c u i t , s e t Vo = 0 , which g i v e s p a r a l l e l c o m b i n a t i o n o f R1 w i t h R2 a t E1 a s shown i n t h e f i g . 3 . 6 1 . To f i n d o u t p u t c i r c u i t , 34
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
s e t I i = 0 by o p e n i n g t h e i n p u t node , E1 a t e m i t t e r o f Q1 , which g i v e s t h e s e r i e s c o m b i n a t i o n o f R2 and R1 a c r o s s t h e o u t p u t . The r e s u l t a n t c i r c u i t i s shown i n f i g . 3 . 6 1 . ” ) disp ( ” ” ) disp ( ” S t e p 4 : Find t h e open l o o p v o l t a g e g a i n ( Av ) ” ) rl2 =(4.7*15.15) /(4.7+15.15) // i n k−ohm format (5) disp ( rl2 , ” RL2 ( i n k−ohm ) =” ) disp ( ” S i n c e hoe = h r e = 0 , we can u s e a p p r o x i m a t e a n a l y s i s . ”) disp ( ” A i 2 = − h f e = −500 ” ) disp ( ” R i 2 = h i e = 1 1 0 0 ohm” ) av2 =( -500*3.59*10^3) /1100 disp ( av2 , ” A v2 = A i 2 ∗ R L2 / R i 2 =” ) rl1 =((10*47*33*1.1) /((47*33*1.1) +(10*33*1.1) +(10*47*1.1) +(10*47*33) ) ) *10^3 // i n ohm disp ( rl1 , ” R L1 ( i n ohm ) = 10K | | 47K | | 33K | | R i 2 =” ) disp ( ” A i 1 = − h f e = −500 ” ) ri1 =1.1+(501*((0.15*15) /(0.15+15) ) ) // i n k−ohm disp ( ri1 , ” R i 1 ( i n k−ohm ) = h i e + (1+ h f e ) ∗Re =” ) av1 =( -500*942) /(75.5*10^3) format (6) disp ( av1 , ” A v1 = A i 1 ∗ R L1 / R i 1 =” ) av = -6.238* -1632 disp ( av , ” Av = A v1 ∗ A v2 =” ) disp ( ” ” ) disp ( ” S t e p 5 : C a l c u l a t e b e t a and D” ) beta =150/(150+15000) format (7) disp ( beta , ” b e t a = R1 / R1+R2 =” ) d =1+(10180*0.0099) format (8) disp (d , ” D = 1 + A∗ b e t a =” ) disp ( ” ” ) disp ( ” S t e p 6 : C a l c u l a t e A vf , R o f and R i f ” ) avf =10180/101.782 35
39 format (4) 40 disp ( avf , ” A v f = Av / D =” ) 41 rif =75.5*101.782*10^ -3 // i n M−ohm 42 format (6) 43 disp ( rif , ” R i f ( i n M−ohm ) = R i 1 ∗ D =” ) 44 rof =(3.59*10^3) /101.782 45 disp ( rof , ” R o f ( i n ohm ) = Ro / D = R L2 / D =” )
Scilab code Exa 3.14 gain and new bandwidth 1 // Example 3 . 1 4 2 clc 3 disp ( ” Given : A vmid = 5 0 0 , f L = 100 kHz , f H = 20 4 5 6 7 8 9 10 11 12 13
kHz and b e t a = 0 . 0 1 ” ) avf =500/(1+(0.01*500) ) format (6) disp ( avf , ” A v f = A vmid / 1+ b e t a ∗ A vmid =” ) flf =100/(1+(0.01*500) ) // i n Hz disp ( flf , ” f L f ( i n Hz ) = f L / 1+ b e t a ∗ A vmid =” ) fhf =20*(1+(0.01*500) ) // i n kHz disp ( fhf , ” f H f ( i n kHZ ) = f H ∗ ( 1 + b e t a ∗ A vmid ) = ”) bw =120 -0.01667 // i n kHZ format (9) disp ( bw , ” BW f ( i n kHz ) = f H f − f L f =” )
Scilab code Exa 3.15 show voltage gain with feedback 1 // Example 3 . 1 5 2 clc 3 disp ( ” S t e p 1 : I d e n t i f y t o p o l o g y ” ) 4 disp ( ” By s h o r t i n g o u t p u t ( Vo = 0 ) , f e e d b a c k v o l t a g e
d o e s n o t become z e r o . By o p e n i n g t h e o u t p u t l o o p 36
5 6 7
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
f e e d b a c k becomes z e r o and h e n c e i t i s c u r r e n t s a m p l i n g . The f e e d b a c k i s a p p l i e d i n s e r i e s w i t h the input s i g n a l , hence topology used i s c u r r e n t s e r i e s feedback . ”) disp ( ” ” ) disp ( ” S t e p 2 and S t e p 3 : Find i n p u t and o u t p u t c i r c u i t . ”) disp ( ” To f i n d i n p u t c i r c u i t , s e t I o = 0 . T h i s p l a c e s Re i n s e r i e s w i t h i n p u t . To f i n d o u t p u t c i r c u i t I i = 0 . T h i s p l a c e s Re i n o u t p u t s i d e . The r e s u l t a n t c i r c u i t i s shown i n f i g . 3 . 6 3 . ” ) disp ( ” ” ) disp ( ” S t e p 4 : R e p l a c e t r a n s i s t o r w i t h i t s h− p a r a m e t e r e q u i v a l e n t a s shown i n f i g . 3 . 6 4 . ” ) disp ( ” ” ) disp ( ” S t e p 5 : Find open l o o p t r a n s f e r g a i n . ” ) disp ( ” From q u a t i o n ( 5 ) o f s e c t i o n 3 . 9 . 1 we have ” ) disp ( ” A v f = I o ∗ R L / Vs = G Mf ∗ R L ” ) disp ( ” = − h f e ∗ R L / R ’ ’ s+ h i e +(1+ h f e ) ∗Re” ) disp ( ” Here R ’ ’ s = Rs | | R1 | | R2” ) disp ( ” = Rs | | Rb b e c a u s e R b = R1 | | R2” ) disp ( ” T h e r e f o r e , Vo / Vs = Vo/ Vi ∗ Vi / Vs ” ) disp ( ” where Vi / Vs = Rb / Rs+Rb” ) disp ( ” T h e r e f o r e , Vo / Vs = (− h f e ∗ R L / R ’ ’ s+ h i e +(1+ h f e ) ∗Re ) ∗ ( Rb / Rs+Rb ) ” ) disp ( ” D i v i d i n g b o t h n u m e r a t o r and d e n o m i n a t o r by Rs+ Rb we g e t , ” ) disp ( ” A v f = Vo / Vs = [− h f e ∗Rc ∗ ( Rb/Rb+Rs ) ] / R ’ ’ s+ h i e +(1+ h f e ) ∗Re b e c a u s e RL = Rc” ) disp ( ” = − h f e ∗Rc ∗ [ 1 / 1 + ( Rs /Rb ) ] / R ’ ’ s+ h i e +(1+ h f e ) ∗Re” )
Scilab code Exa 3.16 GMf and Rif and Rof
37
1 // Example 3 . 1 6 2 clc 3 disp ( ” R e f e r e x a m p l e 3 . 1 5 ” ) 4 disp ( ” A v f = − h f e ∗Rc ∗ [ 1 / 1 + ( Rs /Rb ) ] / R ’ ’ s+ h i e 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
+(1+ h f e ) ∗Re where R ’ ’ s = Rs | | R1 | | R2” ) avf =( -50*(1.8*10^3) *[1/(1+(1000/4272) ) ]) /(810+1000+((1+50) *1000) ) format (5) disp ( avf , ” A v f =” ) gmf = -1.38/(1.8*10^3) format (9) disp ( gmf , ” G Mf = A v f / R L =” ) disp ( ” b e t a = Vf / I o = I e ∗Re / I o = −I o ∗Re / I o = −Re = −1 K” ) disp ( ” G Mf = G M / 1+ b e t a ∗G M” ) gm =1/((1/( -7.66*10^ -4) ) +1000) format (10) disp ( gm , ” T h e r e f o r e , G M =” ) d =1+( -1000* -3.2735*10^ -3) format (7) disp (d , ” D = 1 + G M∗ b e t a =” ) ri =(1+1.36) // i n k−ohm format (5) disp ( ri , ” R i ( i n k−ohm ) = Rs+( h i e +Re ) | | R D =” ) rif =2.36*4.2735 // i n k−ohm format (3) disp ( rif , ” R i f ( i n k−ohm ) = R i ∗ D =” ) disp ( ” R o = i n f i n i t y ” ) disp ( ” R o f = R o ∗ D = i n f i n i t y ” ) disp ( ” R ’ ’ o f = R o f | | R L = R L = 1 . 8 k−ohm” )
Scilab code Exa 3.17 feedback factor and Rif and Rof 1 // Example 3 . 1 7 2 clc
38
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
disp ( ” R e f e r e x a m p l e 3 . 1 5 ” ) disp ( ” A v f = − h f e ∗Rc ∗ [ 1 / 1 + ( Rs /Rb ) ] / R ’ ’ s+ h i e +(1+ h f e ) ∗Re where R ’ ’ s = Rs | | R1 | | R2” ) avf =( -50*(4*10^3) *[1/(1+(1000/9000) ) ]) /(900+1000+((1+150) *1000) ) format (6) disp ( avf , ” A v f =” ) gmf = -1.177/(4*10^3) format (9) disp ( gmf , ” G Mf = A v f / R L =” ) disp ( ” b e t a = Vf / I o = I e ∗Re / I o = −I o ∗Re / I o = −Re = −1 K” ) disp ( ” G Mf = G M / 1+ b e t a ∗G M” ) gm =1/((1/( -2.943*10^ -4) ) +1000) format (9) disp ( gm , ” T h e r e f o r e , G M =” ) d =1+( -1000* -4.17*10^ -4) format (6) disp (d , ” D = 1 + G M∗ b e t a =” ) ri =1+((2*9) /(2+9) ) // i n k−ohm disp ( ri , ” R i ( i n k−ohm ) = Rs+( h i e +Re ) | | R D =” ) rif =2.636*1.417 // i n k−ohm format (6) disp ( rif , ” R i f ( i n k−ohm ) = R i ∗ D =” ) disp ( ” R o = i n f i n i t y ” ) disp ( ” R o f = R o ∗ D = i n f i n i t y ” ) disp ( ” R ’ ’ o f = R o f | | R L = R L = 4 k−ohm” )
Scilab code Exa 3.18 gain with feedback and new bandwidth 1 // Example 3 . 1 8 . 2 clc 3 disp ( ” Given : A v mid = 4 0 , f L = 100 Hz , f H = 15
kHz and b e t a = 0 . 0 1 ” ) 4 avf =400/(1+(0.01*400) )
39
5 format (3) 6 disp ( avf , ” A v f = A v mid / 1+ b e t a ∗ A v mid =” ) 7 flf =100/(1+(0.01*400) ) 8 disp ( flf , ” f L f = f L / 1+ b e t a ∗ A v mid =” ) 9 fhf =(15) *(1+(0.01*400) ) // i n kHz 10 disp ( fhf , ” f H f ( i n kHz ) = f H ∗ (1+ b e t a ∗ A v mid ) =”
) 11 bw =75 -0.02 // i n kHz 12 format (6) 13 disp ( bw , ” BW f ( i n kHz ) = f H f − f L f =” )
Scilab code Exa 3.19 overall voltage gain and bandwidth 1 // Example 3 . 1 9 2 clc 3 disp ( ” Given : Av = 1 0 , BW = 1 ∗ 1 0 ˆ 3 , n =3” ) 4 disp ( ” ( i ) O v e r a l l v o l t a g e g a i n ” ) 5 disp ( ” The g a i n o f c a s c a d e d a m p l i f i e r w i t h o u t
f e e d b a c k = 10∗10∗10 = 1000 ”) 6 avf =1000/(1+(0.1*1000) ) 7 format (4) 8 disp ( avf , ” A v f = Av / 1+Av∗ b e t a =” ) 9 disp ( ” ( i i ) Bandwidth o f c a s c a d e d s t a g e ” ) 10 disp ( ” Bandwidth o f c a s c a d e d a m p l i f i e r w i t h o u t 11 12 13 14 15 16
feedback ”) bw =((1*10^6) * sqrt ((2^(1/3) ) -1) ) *10^ -3 // i n kHz format (7) disp ( bw , ” BW( c a s c a d e ) ( i n kHz ) = BW∗ s q r t ( 2 ˆ ( 1 / n ) − 1 ) =” ) bwf =(509.82*10^3*(1+(0.1*1000) ) ) *10^ -6 // i n MHz format (6) disp ( bwf , ” BW f ( i n MHz) = BW ∗ ( 1 + b e t a ∗ A v mid ) = ”)
40
Chapter 4 Oscillators
Scilab code Exa 4.1 C and hfe 1 // Example 4 . 1 2 clc 3 disp ( ” R e f e r i n g t o e q u a t i o n ( 1 ) , ” ) 4 ri =(25*57*1.8) /((57*1.8) +(25*1.8) +(25*57) )
// i n k−
ohm 5 format (6) 6 disp ( ri , ” R ’ ’ i ( i n k−ohm ) = R1 | | R2 | | h i e =” ) 7 disp ( ”Now R ’ ’ i + R3 = R” ) 8 r3 =7.1 -1.631 // i n k−ohm 9 format (5) 10 disp ( r3 , ” T h e r e f o r e , R3 ( i n k−ohm ) = R − R ’ ’ i =” ) 11 k =20/7.1 12 format (6) 13 disp (k , ” K = R C / R =” ) 14 disp ( ”Now f = 1 / 2∗ p i ∗R∗C∗ s q r t (6+4K) ” ) 15 c =(1/( sqrt (6+(4*2.816) ) *2* %pi *7.1*10*10^6) ) *10^12 16 17 18 19
// i n pF format (8) disp (c , ” T h e r e f o r e , C( i n pF ) =” ) disp ( ” h f e >= 4K + 23 + 29/K” ) hfe =(4*2.816) +23+(29/2.816) 41
20 21
format (7) disp ( hfe , ”
h f e >=” )
Scilab code Exa 4.2 frequency of oscillation 1 // Example 4 . 2 2 clc 3 disp ( ” The g i v e n v a l u e s a r e , R = 4 . 7 k−ohm and C =
0 . 4 7 uF” ) 4 f =1/(2* %pi * sqrt (6) *(4.7*10^3) *(0.47*10^ -6) ) // i n Hz 5 format (7) 6 disp (f , ” f ( i n Hz ) = 1 / 2∗ p i ∗ s q r t ( 6 ) ∗R∗C =” )
Scilab code Exa 4.3 R and C 1 // Example 4 . 3 2 clc 3 disp ( ” f = 1 kHz ” ) 4 disp ( ”Now f = 1 / 2∗ p i ∗ s q r t ( 6 ) ∗R∗C” ) 5 disp ( ” Choose C = 0 . 1 uF” ) 6 r =1/( sqrt (6) *2* %pi *0.1*1*10^ -3) // i n ohm 7 format (8) 8 disp (r , ” T h e r e f o r e , R( i n ohm ) = ” ) 9 disp ( ” Choose R = 680 ohm standard value ”)
Scilab code Exa 4.4 C and RD 1 // Example 4 . 4 2 clc
42
3 disp ( ” U s i n g t h e e x p r e s s i o n f o r t h e f r e q u e n c y ” ) 4 disp ( ”Now , f = 1 / 2∗ p i ∗R∗C∗ s q r t ( 6 ) ” ) 5 f =(1/( sqrt (6) *2* %pi *9.7*5*10^6) ) *10^9 // i n nF 6 format (5) 7 disp (f , ” T h e r e f o r e , C( i n nF ) =” ) 8 disp ( ”Now u s i n g t h e e q u a t i o n ( 2 7 ) ” ) 9 disp ( ” |A| = g m ∗ R L”) 10 disp ( ” T h e r e f o r e , | A | >= 29 ” ) 11 disp ( ” T h e r e f o r e , g m ∗ R L >= 29 ” ) 12 rl =(29/(5000*10^ -6) ) *10^ -3 // i n k−ohm 13 format (4) 14 disp ( rl , ” T h e r e f o r e , R L ( i n k−ohm ) >= 29 / g m =” ) 15 disp ( ” R L = R D∗ r d / R D+r d ” ) 16 rd =(40) /4.8823 17 format (5) 18 disp ( rd , ” T h e r e f o r e , R D ( i n k−ohm ) = ” ) 19 disp ( ” While f o r minimum v a l u e o f R L = 5 . 8 k−ohm” ) 20 disp ( ” R D = 6 . 7 8 k−ohm” )
Scilab code Exa 4.5 minimum and maximum R2 1 // Example 4 . 5 2 clc 3 disp ( ” The f r e q u e n c y o f t h e o s c i l l a t o r i s g i v e n by , ” ) 4 disp ( ” f = 1 / 2∗ p i ∗ s q r t ( R1∗R2∗C1∗C2 ) ” ) 5 disp ( ” For f = 10 kHz , ” ) 6 r2 =(1/(4*( %pi ^2) *(100*10^6) *(10*10^3) *(0.001*10^ -12) 7 8 9 10 11 12
) ) // i n k−ohm format (6) disp ( r2 , ” T h e r e f o r e , R2 ( i n k−ohm ) =” ) disp ( ” For f = 50 kHz , ” ) r2 =(1/(4*( %pi ^2) *(2500*10^6) *(10*10^3) *(0.001*10^ -12) ) ) // i n k−ohm format (6) disp ( r2 , ” T h e r e f o r e , R2 ( i n k−ohm ) =” ) 43
13
disp ( ” So minimum v a l u e o f R2 i s 1 . 0 1 3 k−ohm w h i l e t h e maximum v a l u e o f R2 i s 2 5 . 3 3 k−ohm” )
Scilab code Exa 4.6 range over capacitor is varied 1 // Example 4 . 6 2 clc 3 disp ( ” The f r e q u e n c y i s g i v e n by , ” ) 4 disp ( ” f = 1 / 2∗ p i ∗ s q r t (C∗ L e q ) ” ) 5 leq =(2*10^ -3) +(20*10^ -6) 6 format (8) 7 disp ( leq , ” where L e q = L1 + L2 =” ) 8 disp ( ” For f = f m a x = 2 0 5 0 kHz ” ) 9 format (5) 10 c =(1/(4*( %pi ^2) *((2050*10^3) ^2) *0.00202) ) *10^12 11 12 13 14 15 16
// i n pF disp (c , ” T h e r e f o r e , C( i n pF ) =” ) disp ( ” For f = f m i n = 950 kHz ” ) c =(1/(4*( %pi ^2) *((950*10^3) ^2) *0.00202) ) *10^12 // i n pF format (6) disp (c , ” T h e r e f o r e , C( i n pF ) =” ) disp ( ” Hence C must be v a r i e d from 2 . 9 8 pF t o 1 3 . 8 9 pF , t o g e t t h e r e q u i r e d f r e q u e n c y v a r i a t i o n . ” )
Scilab code Exa 4.7 frequency of oscillation 1 // Example 4 . 7 2 clc 3 disp ( ” The g i v e n v a l u e s a r e , ” ) 4 disp ( ” L1 = 0 . 5 mH, L2 = 1 mH, C = 0 . 2 uF” ) 5 disp ( ”Now f = 1 / 2∗ p i ∗ s q r t (C∗ L e q ) ” ) 6 leq =0.5+1 // i n mH
44
7 disp ( leq , ” and L e q ( i n mH) = L1 + L2 =” ) 8 f =(1/(2* %pi * sqrt (1.5*0.2*10^ -9) ) ) *10^ -3 // i n kHz 9 format (5) 10 disp (f , ” T h e r e f o r e , f ( i n kHz ) =” )
Scilab code Exa 4.8 frequency of oscillation 1 // Example 4 . 8 2 clc 3 disp ( ” The e q u i v a l e n t c a p a c i t a n c e i s g i v e n by , ” ) 4 ceq =(150*1.5*10^ -21) /((150*10^ -12) +(1.5*10^ -9) ) 5 6 7 8 9 10
in F format (12) disp ( ceq , ” C eq ( i n F ) = C1∗C2 / C1+C2 =” ) disp ( ”Now , f = 1 / 2∗ p i ∗ s q r t ( L∗ C eq ) ” ) f =(1/(2* %pi * sqrt (50*136.363*10^ -18) ) ) *10^ -6 MHz format (6) disp (f , ” f ( i n MHz) =” )
//
// i n
Scilab code Exa 4.9 calculate C 1 // Example 4 . 9 2 clc 3 disp ( ” The g i v e n v a l u e s a r e , ” ) 4 disp ( ” L = 100 uH , C1 = C2 = C 5 6 7 8
and
f = 500
kHz ” ) disp ( ”Now , f = 1 / 2∗ p i ∗ s q r t ( L∗ C eq ) ” ) ceq =1/(4*( %pi ^2) *(100*10^ -6) *((500*10^3) ^2) ) F format (11) disp ( ceq , ” T h e r e f o r e , C eq ( i n F ) =” ) 45
// i n
9 10 11 12 13
disp ( ” but C eq = C1∗C2 / C1+C2 ”) disp ( ” T h e r e f o r e , C eq = C / 2 ” ) c =1.0132*2 format (6) disp (c , ” T h e r e f o r e , C( i n nF ) =” )
and C1 = C2 = C
Scilab code Exa 4.10 series and parallel resonant freqency 1 // Example 4 . 1 0 2 clc 3 fs =(1/(2* %pi * sqrt (0.4*0.085*10^ -12) ) ) *10^ -6 4 5 6 7 8 9 10 11 12 13 14
// i n MHz format (6) disp ( fs , ” ( i ) f s ( i n MHz) = 1 / 2∗ p i ∗ s q r t ( L∗C) =” ) ceq =0.085/1.085 // i n pF disp ( ceq , ” ( i i ) C eq ( i n pF ) = C∗C M / C+C M =” ) fp =(1/(2* %pi * sqrt (0.4*0.078*10^ -12) ) ) *10^ -6 // i n MHz ( t h e a n s w e r i n t e x t b o o k i s wrong ) disp ( fp , ” T h e r e f o r e , f p ( i n MHz) = 1 / 2∗ p i ∗ s q r t ( L∗ C eq ) =” ) inc =((0.899 -0.856) /0.856) *100 // i n p e r c e n t a g e disp ( inc , ” ( i i i ) % i n c r e a s e =” ) q =(2* %pi *0.4*0.856*10^6) /(5*10^3) format (8) disp (q , ” ( i v ) Q = o m e g a s ∗L / R = 2∗ p i ∗ f s ∗L / R =” )
Scilab code Exa 4.11 series and parallel resonant freqency 1 // Example 4 . 1 1 2 clc 3 disp ( ” C M = 2 pF” ) 4 fs =(1/(2* %pi * sqrt (2*0.01*10^ -12) ) ) *10^ -6
46
// i n MHz
5 format (6) 6 disp ( fs , ”Now f s ( i n MHz) = 1 / 2∗ p i ∗ s q r t ( L∗C) =” ) 7 ceq =(2*0.01*10^ -24) /(2.01*10^ -12) // i n F 8 format (9) 9 disp ( ceq , ” C eq ( i n F ) = C M∗C / C M+C =” ) 10 fp =(1/(2* %pi * sqrt (2*9.95*10^ -15) ) ) *10^ -6 // i n MHz 11 format (6) 12 disp ( fp , ” f p = 1 / 2∗ p i ∗ s q r t ( L∗ C eq ) =” ) 13 disp ( ” So f s a n d f p v a l u e s a r e a l m o s t same . ” )
Scilab code Exa 4.12 Varify Barkhausen criterion and find frequency of oscillation 1 // e x a m p l e 4 . 1 2 . 2 clc 3 disp ( ”From t h e g i v e n i n f o r m a t i o n we can w r i t e , ” ) 4 disp ( ” A = −16∗10ˆ6/ j ∗ omega and b e t a = 5
6
7 8 9 10 11
1 0 ˆ 3 / [ 2 ∗ 1 0 ˆ 3 + j ∗ omega ] ˆ 2 ” ) disp ( ”To v e r i f y t h e B a r k h a u s e n c o n d i t i o n means t o v e r i f y w h e t h e r | A∗ b e t a | = 1 a t a f r e q u e n c y f o r which A∗ b e t a = 0 d e g r e e . L e t u s e x p r e s s , A∗ b e t a i n i t s r e c t a n g l u a r form . ” ) disp ( ” A∗ b e t a = −16∗10ˆ6∗10ˆ3 / j ∗ omega ∗ [ 2 ∗ 1 0 ˆ 3 + j ∗ omega ] ˆ 2 = −16∗10ˆ9 / j ∗ omega ∗ [ 4 ∗ 1 0 ˆ 6 + 4 ∗ 1 0 ˆ 3 ∗ j ∗ omega+( j ∗ omega ) ˆ 2 ] ” ) disp ( ” = −16∗10ˆ9 / j ∗ omega ∗ [ 4 ∗ 1 0 ˆ 6 + 4 ∗ 1 0 ˆ 3 ∗ j ∗ omega−omega ˆ 2 ] a s j ∗2 = −1” ) disp ( ” = −16∗10ˆ9 / 4 ∗ 1 0 ˆ 6 ∗ j ∗ omega +4∗10ˆ3∗ j ˆ2∗ omegaˆ2− j ∗ omega ˆ 3 ] ” ) disp ( ” = −16∗10ˆ9 / j ∗ omega ∗[4∗10ˆ6 − omega ˆ 2 ] − [ omega ˆ 2 ∗ 4 ∗ 1 0 ˆ 3 ] ” ) disp ( ” R a t i o n a l i s i n g t h e d e n o m i n a t o r f u n c t i o n we g e t , ”) disp ( ” A∗ b e t a = −16∗10ˆ9[ − omega ˆ 2 ∗ 4 ∗ 1 0 ˆ 3 − j ∗ omega ∗[4∗10ˆ6 − omega ˆ 2 ] ] / [ − [ omega ˆ 2 ∗ 4 ∗ 1 0 ˆ 3 ] − j ∗ omega 47
12 13
14
15
16 17 18 19 20 21
22 23 24
25
26 27 28 29 30
∗[4∗10ˆ6 − omega ˆ 2 ] ] ∗ [ − omega ˆ 2 ∗ 4 ∗ 1 0 ˆ 3 − j ∗ omega ∗[4∗10ˆ6 − omega ˆ 2 ] ] ” ) disp ( ” U s i n g ( a−b ) ( a+b ) = a ˆ2 − b ˆ2 i n t h e denominator , ”) disp ( ” A∗ b e t a = 1 6 ∗ 1 0 ˆ 9 [ omega ˆ2∗4∗10ˆ3+ j ∗ omega ∗[4∗10ˆ6 − omega ˆ 2 ] ] / [− omega ˆ 2 ∗ 4 ∗ 1 0 ˆ 3 ] ˆ 2 − [ j ∗ omega ∗[4∗10ˆ6 − omega ˆ 2 ] ˆ 2 ” ) disp ( ” A∗ b e t a = 1 6 ∗ 1 0 ˆ 9 [ omega ˆ2∗4∗10ˆ3+ j ∗ omega ∗[4∗10ˆ6 − omega ˆ 2 ] ] / 1 6 ∗ 1 0 ˆ 6 ∗ omega ˆ4 + omega ˆ2(4∗10ˆ6 − omega ˆ 2 ) ˆ2 ” ) disp ( ”Now t o have A∗ b e t a = 0 d e g r e e , t h e i m a g i n a r y p a r t o f A∗ b e t a must be z e r o . T h i s i s p o s s i b l e when , ” ) disp ( ” T h e r e f o r e , omega ∗ ( 4 ∗ 1 0 ˆ 6 − omega ˆ 2 ) = 0 ” ) disp ( ” T h e r e f o r e , omega = 0 o r 4 ∗ 1 0 ˆ 6 − omega ˆ2 = 0”) disp ( ” T h e r e f o r e , omega ˆ2 = 4 ∗ 1 0 ˆ 6 N e g l e c t i n g zero value of frequency ”) disp ( ” T h e r e f o r e , omega = 2 ∗ 1 0 ˆ 3 r a d / s e c ” ) disp ( ” At t h i s f r e q u e n c y | A∗ b e t a | can be o b t a i n e d as , ”) disp ( ” | A∗ b e t a | = 1 6 ∗ 1 0 ˆ 9 [ 4 ∗ 1 0 ˆ 3 ∗ omega ˆ 2 ] / 1 6 ∗ 1 0 ˆ 6 ∗ omegaˆ4+omega ˆ2[4∗10ˆ6 − omega ˆ 2 ] ˆ 2 a t omega = 2 ∗ 1 0 ˆ 3 ” ) ab =(2.56*10^20) /(2.56*10^20) disp ( ab , ” | A∗ b e t a | =” ) disp ( ” T h e r e f o r e , At omega = 2 ∗ 1 0 ˆ 3 r a d / s e c , A∗ b e t a = 0 d e g r e e a s i m a g i n a r y p a r t i s z e r o w h i l e | A∗ b e t a | = 1 . Thus B a r k h a u s e n C r i t e r i o n i s s a t i s f i e d . ”) disp ( ” The f r e q u e n c y a t which c i r c u i t w i l l o s c i l l a t e i s t h e v a l u e o f omega f o r which | A∗ b e t a | = 1 and A∗ b e t a = 0 d e g r e e a t t h e same t i m e ” ) disp ( ” i . e . omega = 2 ∗ 1 0 ˆ 3 r a d / s e c ” ) disp ( ” But omega = 2∗ p i ∗ f ” ) f =(2*10^3) /(2* %pi ) // i n Hz format (9) disp (f , ” T h e r e f o r e , f ( i n Hz ) = omega / 2 p i =” ) 48
Scilab code Exa 4.13 minimum and maximum values of R2 1 // Example 4 . 1 3 2 clc 3 disp ( ” The f r e q u e n c y o f t h e o s c i l l a t o r i s g i v e n by , ” ) 4 disp ( ” f = 1 / 2∗ p i ∗ s q r t ( R1∗R2∗C1∗C2 ) ” ) 5 disp ( ” For f = 20 kHz , ” ) 6 r2 =(1/(4*( %pi ^2) *((20*10^3) ^2) *(10*10^3) 7 8 9 10 11 12 13
*((0.001*10^ -6) ^2) ) ) *10^ -3 format (5) disp ( r2 , ” T h e r e f o r e , R2 ( i n k−ohm ) =” ) disp ( ” For f = 70 kHz , ” ) r2 =(1/(4*( %pi ^2) *((70*10^3) ^2) *(10*10^3) *((0.001*10^ -6) ^2) ) ) *10^ -3 format (6) disp ( r2 , ” T h e r e f o r e , R2 ( i n k−ohm ) =” ) disp ( ” So minimum v a l u e o f R2 i s 0 . 5 1 7 k−ohm w h i l e t h e maximum v a l u e o f R2 i s 6 . 3 3 k−ohm” )
Scilab code Exa 4.14 frequency of oscillation and minimum hfe 1 // Example 4 . 1 4 . 2 clc 3 disp ( ”R = 6 k−ohm , C = 1 5 0 0 pF , R C = 18 k−ohm” ) 4 k =18/6 5 disp (k , ”Now K = R C / R =” ) 6 disp ( ” T h e r e f o r e , f = 1 / 2∗ p i ∗R∗C∗ s q r t (6+4K) ” ) 7 f =(1/(2* %pi *(6*10^3) *(1500*10^ -12) * sqrt (6+12) ) ) 8 9
*10^ -3 // i n kHZ format (6) disp (f , ” f ( i n kHz ) =” ) 49
10 hfe =(4*3) +23+(29/3) 11 disp ( hfe , ” ( h f e ) min = 4K + 23 + 29/K =” )
Scilab code Exa 4.15 range of frequency of oscillation 1 // Example 4 . 1 5 . 2 clc 3 format (6) 4 disp ( ” For a Wien b r i d g e o s c i l l a t o r , ” ) 5 disp ( ” f = 1 / 2∗ p i ∗R∗C” ) 6 fm =(1/(2* %pi *(100*10^3) *(50*10^ -12) ) ) *10^ -3
// i n
kHz 7 disp ( fm , ” T h e r e f o r e , f m a x ( i n kHz ) =” ) 8 fmi =(1/(2* %pi *(100*10^3) *(500*10^ -12) ) ) *10^ -3 9 disp ( fmi , ” and f m i n ( i n kHz ) =” ) 10 fn =31.83+50 11 disp ( fn , ”Now f n e w ( i n kHz ) = f m a x + 5 0 ∗ 1 0 ˆ 3 =” ) 12 disp ( ” The c o r r e s p o n d i n g R = R ’ ’ w i t h an a d d i t i o n a l 13 14 15 16 17 18
r e s i s t a n c e R x in p a r a l l e l ”) disp ( ” T h e r e f o r e , f = 1 / 2∗ p i ∗R’ ’ ∗ C” ) r =(1/(2* %pi *(50*10^ -12) *(81.83*10^3) ) ) *10^ -3 k−ohm disp (r , ” T h e r e f o r e , R ’ ’ ( i n k−ohm ) =” ) rx =1/((1/38.89) -(1/100) ) // i n k−ohm disp ( ” T h e r e f o r e , R ’ ’ = R∗ R x / R+R x ” ) disp ( rx , ” T h e r e f o r e , R x ( i n k−ohm ) = i n p a r a l l e l w i t h 100 k−ohm” )
Scilab code Exa 4.16 frequency of oscillation 1 // Example 4 . 1 6 . 2 clc 3 format (6)
50
// i n
4 5 6 7 8 9
disp ( ” For a H a r t l e y o s c i l l a t o r t h e f r e q u e n c y i s g i v e n by , ” ) disp ( ” f = 1 / 2∗ p i ∗ s q r t ( L e q ∗C) where L e q = L1+L2 ” ) leq =20+5 // i n mH disp ( leq , ” T h e r e f o r e , L e q ( i n mH) = 20+5 =” ) f =(1/(2* %pi * sqrt (25*500*10^ -15) ) ) *10^ -3 // i n kHz disp (f , ” T h e r e f o r e , f ( i n kHz ) =” )
Scilab code Exa 4.17 gain of the transistor 1 // Example 1 4 . 7 2 clc 3 disp ( ” For a H a r t l e y o s c i l l a t o r , ” ) 4 disp ( ” f = 1 / 2∗ p i ∗ s q r t ( L e q ∗C) 5 6 7 8 9 10 11 12
where L e q = L1 + L2 + 2M” ) leq =(1/(4*( %pi ^2) *((168*10^3) ^2) *(50*10^ -12) ) ) *10^3 // i n mH format (6) disp ( leq , ” T h e r e f o r e , L e q ( i n mH) =” ) l2 =((17.95*10^ -3) -(15*10^ -3) -(5*10^ -6) ) *10^3 // i n mH disp ( l2 , ” T h e r e f o r e , L2 ( i n mH) =” ) hfe =((15*10^ -3) +(5*10^ -6) ) /((2.945*10^ -3) +(5*10^ -6) ) format (5) disp ( hfe , ”Now h f e = L1+M / L2+M =” )
Scilab code Exa 4.18 new frequency and inductance 1 // Example 4 . 1 8 2 clc 3 disp ( ” For a C o l p i t t s o s c i l l a t o r , ” ) 4 disp ( ” f = 1 / 2∗ p i ∗ s q r t ( L∗ C eq ) ” )
51
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
disp ( ” where C eq = C1∗C2 / C1+C2 but C1 = C2 = 0 . 0 0 1 uF” ) ceq =((0.001*10^ -6) ^2) /(2*(0.001*10^ -6) ) // i n F format (7) disp ( ceq , ” T h e r e f o r e , C eq ( i n F ) =” ) disp ( ” L = 5∗10ˆ −6 H” ) f =(1/(2* %pi * sqrt (25*10^ -16) ) ) *10^ -6 // i n MHz format (6) disp (f , ” T h e r e f o r e , f ( i n MHz) =” ) disp ( ”Now L i s d o u b l e d i . e . 10 uH” ) f1 =(1/(2* %pi * sqrt (50*10^ -16) ) ) *10^ -6 // i n MHz format (5) disp ( f1 , ” T h e r e f o r e , f ( i n MHz) =” ) nf = 2*3.183 format (6) disp ( nf , ”New f r e q u e n c y ( i n MHz) = 2 ∗ 3 . 1 8 3 =” ) l =(1/(4*( %pi ^2) *((6.366*10^6) ^2) *(5*10^ -10) ) ) *10^6 // i n uH format (5) disp (l , ” T h e r e f o r e , L ( i n uH ) =” )
Scilab code Exa 4.19 new frequency of oscillation 1 // Example 4 . 1 9 2 clc 3 disp ( ” For a Clapp o s c i l l a t o r , ” ) 4 disp ( ” f = 1 / 2∗ p i ∗ s q r t ( L∗C3 ) ” ) 5 disp ( ” where C3 = 63 pF” ) 6 f =(1/(2* %pi * sqrt (315*10^ -18) ) ) *10^ -6 7 format (6) 8 disp (f , ” T h e r e f o r e , f ( i n MHz) =” )
Scilab code Exa 4.20 R and hfe 52
// i n MHz
1 // Example 4 . 2 0 2 clc 3 disp ( ” R e f e r i n g t o e q u a t i o n ( 1 ) 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
of s e c t i o n 4 . 5 . 3 , the i n p u t i m p e d a n c e i s g i v e n by , ” ) disp ( ”R ’ ’ i = R1 | | R2 | | h i e ” ) disp ( ”Now R1 = 25 k−ohm , R2 = 47 k−ohm , and h i e = 2 k−ohm” ) format (7) ri =(25*47*2) /((47*2) +(25*2) +(25*47) ) // i n k−ohm disp ( ri , ” T h e r e f o r e , R ’ ’ i ( i n k−ohm ) =” ) disp ( ” K = R C / R” ) . . . given ”) disp ( ”Now R C = 10 k−ohm disp ( ”Now f = 1 / 2∗ p i ∗R∗C∗ s q r t (6+4K) ” ) disp ( ” T h e r e f o r e , R∗ s q r t (6+4K) = 3 1 8 3 0 . 9 8 9 ” ) disp ( ”Now K = R C / R = 1 0 ∗ 1 0 ˆ 3 / R” ) disp ( ” T h e r e f o r e , R∗ s q r t ( 6 + ( 4 0 ∗ 1 0 ∗ 1 0 ˆ 3 /R) ) = 31830.989 ”) disp ( ” T h e r e f o r e , Rˆ 2 ∗ ( 6 + ( 4 0 ∗ 1 0 ∗ 1 0 ˆ 3 /R) ) = ( 3 1 8 3 0 . 9 8 9 ) ˆ2 ” ) R = poly (0 , ’R ’ ) p1 =6* R ^2+(40*10^3) *R -(31830.989) ^2 t1 = roots ( p1 ) ans1 = t1 (1) format (6) disp (( - ans1 ) *10^ -3 , ” T h e r e f o r e , R( i n k−ohm )= N e g l e c t i n g n e g a t i v e value ”) k =10/16.74 format (7) disp (k , ” T h e r e f o r e , K = R C / R =” ) disp ( ” T h e r e f o r e , h f e >= 4K + 23 + 29/K” ) hfe =(4*0.5973) +23+(29/0.5973) format (6) disp ( hfe , ” h f e >=” )
Scilab code Exa 4.21 component values of wien bridge 53
1 // Example 4 . 2 1 2 clc 3 disp ( ” The f r e q u e n c y i s g i v e n by , ” ) 4 disp ( ” f = 1 / 2∗ p i ∗R∗C” ) 5 disp ( ” L e t t h e r e s i s t a n c e v a l u e t o be s e l e c t e d as , ” ) 6 disp ( ” R1 = R2 = R = 50 k−ohm” ) 7 disp ( ” f = 1 / 2∗ p i ∗ 5 0 ∗ 1 0 ˆ 3 ∗C” ) 8 f =(1/(2* %pi *(50*10^3) *100) ) *10^9 // i n nF 9 format (6) 10 disp (f , ” f ( i n nF ) =” ) 11 disp ( ” and f m a x = 1 / 2∗ p i ∗ 5 0 ∗ 1 0 ˆ 3 ∗C” ) 12 c =(1/(2* %pi *(50*10^3) *(10*10^3) ) ) *10^9 // i n pF 13 disp (c , ” C( i n nF ) =” ) 14 disp ( ” Thus t o v a r y t h e f r e q u e n c y from 100 Hz t o 10
kHz , t h e c a p a c i t o r r a n g e s h o u l d be s e l e c t e d a s 0 . 3 1 8 nF t o 3 1 . 8 3 nF” ) 15 disp ( ” S i m i l a r l y k e e p i n g t h e c a p a c i t o r v a l u e c o n s t a n t , t h e r a n g e o f t h e r e s i s t a n c e v a l u e s can be obtained . ”)
Scilab code Exa 4.22 values of C2 and new frequency of oscillation 1 // Example 4 . 2 2 2 clc 3 disp ( ” f = 2 . 5 MHz, L = 10 uH , C1 = 0 . 0 2 uF” ) 4 disp ( ” For C o l p i t t s o s c i l l a t o r , t h e f r e q u e n c y i s 5 6 7 8 9 10 11
g i v e n by , ” ) disp ( ” f = 1 / 2 p i ∗ s q r t ( L∗ C eq ) ” ) ceq =(1/(4*( %pi ^2) *((2.5*10^6) ^2) *(10*10^ -6) ) ) *10^12 // i n pF format (8) disp ( ceq , ” T h e r e f o r e , C eq ( i n pF ) =” ) disp ( ” ( i ) But C eq = C1∗C2 / C1+C2” ) c2 =((0.02*10^ -6) /49.348) *10^9 // i n nF format (7) 54
12 13 14 15 16
disp ( c2 , ” T h e r e f o r e , C2 ( i n nF ) =” ) // a n s w e r i n t e x t b o o k i s wrong disp ( ” ( i i ) L = 2 ∗ 10 = 20 uH” ) disp ( ” and C eq = 4 0 5 . 2 8 4 pF” ) f =(1/(2* %pi * sqrt (20*405.284*10^ -18) ) ) *10^ -6 // i n MHz disp (f , ” f ( i n MHz) = 1 / 2∗ p i ∗ s q r t ( L∗ C eq ) =” )
Scilab code Exa 4.23 series and parallel resonant freqency and Qfactor 1 // Example 4 . 2 3 . 2 clc 3 f =(1/(2* %pi * sqrt (0.33*0.065*10^ -12) ) ) *10^ -6 4 5 6 7 8 9 10 11 12 13 14
// i n MHz format (6) disp (f , ” ( i ) f ( i n MHz) = 1 / 2∗ p i ∗ s q r t ( L∗C) =” ) ceq =0.065/1.065 // i n pF disp ( ceq , ” ( i i ) C eq ( i n pF ) = C∗C M / C+C M =” ) fp =(1/(2* %pi * sqrt (0.33*0.061*10^ -12) ) ) *10^ -6 // i n MHz disp ( fp , ” ( i ) f p ( i n MHz) = 1 / 2∗ p i ∗ s q r t ( L∗ C eq ) =” ) pi =((1.121 -1.087) /1.087) *100 // i n p e r c e n t a g e disp ( pi , ” ( i i i ) % i n c r e a s e =” ) q =(2* %pi *1.087*0.33*10^6) /(5.5*10^3) format (8) disp (q , ” ( i v ) Q = omega x ∗L / R = 2∗ p i ∗ f s ∗L / R =” )
Scilab code Exa 4.24 change in frequency and trimmer capacitance 1 // Examle 4 . 2 4 2 clc
55
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
disp ( ” ( i ) Assume one p e r t i c u l a r c o u p l i n g d i r e c t i o n f o r which , ” ) disp ( ” L e q = L1 + L2 + 2M = 0 . 2 5 mH” ) format (8) f =(1/(2* %pi * sqrt (0.25*100*10^ -15) ) ) *10^ -6 // i n MHz disp (f , ” T h e r e f o r e , f ( i n MHz) = 1 / 2∗ p i ∗ s q r t ( L e q ∗C ) =” ) disp ( ” L e t t h e d i r e c t i o n o f c o u p l i n g i s r e v e r s e d , ” ) disp ( ” L e q = L1 + L2 − 2M = 0 . 1 5 mH” ) fd =(1/(2* %pi * sqrt (0.15*100*10^ -15) ) ) *10^ -6 // i n MHz format (7) disp ( fd , ” T h e r e f o r e , f ’ ’ ( i n MHz) = 1 / 2∗ p i ∗ s q r t ( L e q ∗C) =” ) pc =((1.2994 -1.00658) /1.00658) *100 // i n p e r c e n t a g e format (6) disp ( pc , ” T h e r e f o r e , % c h a n g e = f ’ ’ − f / f ∗ 100 =” ) disp ( ” ( i i ) L e t u s assume d i r e c t i o n o f c o u p l i n g s u c h that , ”) disp ( ” L e q = L1 + L2 + 2M = 0 . 2 5 mH” ) disp ( ” C t = Trim c a p a c i t o r = 100 pF” ) disp ( ” T h e r e f o r e , C eq = C∗ C t / C+C t = 50 pF” ) f1 =(1/(2* %pi * sqrt (0.25*50*10^ -15) ) ) *10^ -6 // i n MHz format (7) disp ( f1 , ” T h e r e f o r e , f = 1 / 2∗ p i ∗ s q r t ( L e q ∗ C eq ) =” ) disp ( ” I f now d i r e c t i o n o f c o u p l i n g i s r e v e r s e d , ” ) disp ( ” L e q = L1 + L2 − 2M = 0 . 1 5 mH” ) f2 =(1/(2* %pi * sqrt (0.15*50*10^ -15) ) ) *10^ -6 // i n MHz format (8) disp ( f2 , ” T h e r e f o r e , f ’ ’ = 1 / 2∗ p i ∗ s q r t ( L e q ∗ C eq ) =” ) pc1 =((1.83776 -1.4235) /1.4235) *100 format (7) disp ( pc1 , ” T h e r e f o r e , % c h a n g e = f ’ ’ − f / f ∗ 100 =” )
56
Scilab code Exa 4.25 design RC phase shift oscillator 1 // Example 4 . 2 5 2 clc 3 disp ( ” For RC p h a s e s h h i f t o s c i l l a t o r , ” ) 4 disp ( ” h f e = 4K + 23 + 29/K
. . . given
h f e = 150 ” ) 5 disp ( ” T h e r e f o r e , 150 = 4K + 23 + 29/K” ) 6 disp ( ” T h e r e f o r e , 4Kˆ2 − 127K + 29 = 0 ” ) 7 K = poly (0 , ’K ’ ) 8 p1 =4* K ^2 -127* K +29 9 t1 = roots ( p1 ) 10 format (6) 11 disp ( t1 , ” T h e r e f o r e , K =” ) 12 disp ( ” f = 1 / 2∗ p i ∗R∗C∗ s q r t (6+4K) 13 14 15 16 17 18
19 20 21 22 23
. . . given f = 5 kHz ” ) disp ( ” T h e r e f o r e , Choose C = 100 pF” ) r =(1/(2* %pi *(1000*10^ -12) *(5*10^3) * sqrt (6+(4*0.23) ) ) ) *10^ -3 // i n k−ohm format (3) disp (r , ” T h e r e f o r e , R( i n k−ohm ) =” ) disp ( ” K = R C / R i . e . R C = KR = 2 . 7 k−ohm” ) disp ( ” N e g l e c t i n g e f f e c t o f b i a s i n g r e s i s t a n c e s a s s u m i n g them t o be l a r g e and s e l e c t i n g t r a n s i s t o r w i t h h i e = 2 k−ohm” ) disp ( ” R ’ ’ i = h i e = 2 k−ohm” ) disp ( ” T h e r e f o r e , L a s t r e s i s t a n c e i n p h a s e n e t w o r k ” ) r3 =12 -2 disp ( r3 , ” R3 = R − R ’ ’ i =” ) disp ( ” U s i n g t h e back t o back c o n n e c t e d z e n e r d i o d e s o f 9 . 3 V ( Vz ) e a c h a t t h e o u t p u t o f e m i t t e r f o l l o w e r and u s i n g t h i s a t t h e o u t p u t o f t h e o s c i l l a t o r , t h e o u t p u t a m p l i t u d e can be c o n t r o l l e d t o 10 V i . e . 20 V peak t o peak . The 57
z e n e r d i o d e 9 . 3V and f o r w a r d b i a s e d d i o d e o f 0 . 7 V g i v e s t o t a l 10 V” ) 24 disp ( ” The d e s i g n e d c i r c u i t i s shown i n f i g . 4 . 4 9 ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 4.26 range of capacitor 1 // Example 4 . 2 6 2 clc 3 disp ( ” L1 = 20 uH , L2 = 2 mH” ) 4 leq =((20*10^ -6) +(2*10^ -3) ) *10^3 // i n mH 5 format (7) 6 disp ( leq , ” T h e r e f o r e , L e q ( i n mH) = L1 + L2 =” ) 7 disp ( ” For f = f m a x = 2 . 5 MHz” ) 8 disp ( ” f = 1 / 2∗ p i ∗ s q r t (C∗ L e q ) ” ) 9 c =(1/(4*( %pi ^2) *((2.5*10^6) ^2) *(2.002*10^ -3) ) ) *10^12 10 11 12 13 14 15 16 17
// i n pF format (7) disp (c , ” T h e r e f o r e , C( i n pF ) =” ) disp ( ” For f = f m i n = 1 MHz” ) disp ( ” f = 1 / 2∗ p i ∗ s q r t (C∗ L e q ) ” ) c1 =(1/(4*( %pi ^2) *((1*10^6) ^2) *(2.002*10^ -3) ) ) *10^12 // i n pF format (8) disp ( c1 , ” T h e r e f o r e , C( i n pF ) =” ) disp ( ” Thus C must be v a r i e d from 2 . 0 2 4 4 pF t o 1 2 . 6 5 2 5 pF” )
Scilab code Exa 4.27 change in frequency of oscillation 1
// Example 4 . 2 7 58
2 clc 3 ceq =((0.02*12*10^ -24) /(12.02*10^ -12) ) *10^12 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
// i n pF format (8) disp ( ceq , ” C eq ( i n pF ) = C1∗C2 / C1+C2 =” ) fs =(1/(2* %pi * sqrt (50*0.02*10^ -15) ) ) *10^ -6 // i n MHz format (7) disp ( fs , ” T h e r e f o r e , f s ( i n MHz) = 1 / 2∗ p i ∗ s q r t ( L∗ C1 ) =” ) fp =(1/(2* %pi * sqrt (50*0.01996*10^ -15) ) ) *10^ -6 // i n MHz format (7) disp ( fp , ” T h e r e f o r e , f p ( i n MHz) = 1 / 2∗ p i ∗ s q r t ( L∗ C eq ) =” ) disp ( ” L e t C s = 5 pF c o n n e c t e d a c r o s s t h e c r y s t a l ” ) c2 =12+5 disp ( c2 , ” T h e r e f o r e , C ’ ’ 2 ( i n pF ) = C2 + C x =” ) format (10) ceq1 =0.019976 disp ( ceq1 , ” T h e r e f o r e , C ’ ’ e q ( i n pF ) = C1∗C ’ ’ 2 / C1+ C ’ ’ 2 =” ) fp1 =5.03588 disp ( fp1 , ” T h e r e f o r e , f ’ ’ p ( i n MHz) = 1 / 2∗ p i ∗ s q r t ( L∗ C eq ) =” ) disp ( ”New C x = 6 pF i s c o n n e c t e d then , ” ) c21 =12+6 disp ( c21 , ” C ’ ’ ’ ’ 2 ( i n pF ) = C2 + C x =” ) ceq2 =0.0199778 disp ( ceq2 , ” T h e r e f o r e , C ’ ’ ’ ’ e q ( i n pF ) = C1∗C ’ ’ ’ ’ 2 / C1+C ’ ’ ’ ’ 2 =” ) fp2 =5.035716 disp ( fp2 , ” T h e r e f o r e , f ’ ’ ’ ’ p ( i n MHz) = 1 / 2∗ p i ∗ s q r t ( L∗C ’ ’ ’ ’ e q ) =” ) c =(5.03588 -5.035716) *10^6 disp (c , ” T h e r e f o r e , Change ( i n Hz ) = f ’ ’ p − f ’ ’ ’ ’ p =” )
59
Chapter 5 Combinational Logic Circuits
Scilab code Exa 5.1 design a combinational logic circuit 1 // Example 5 . 1 2 clc 3 disp ( ” Given p r o b l e m
4 5 6 7 8 9 10 11 12 13
s p e c i f i c that there are three i n p u t v a r i a b l e s and one o u t p u t v a r i a b l e . We a s s i g n A, B and C l e t t e r s y m b o l s t o t h r e e i n p u t v a r i a b l e s and a s s i g n Y l e t t e r symbol t o one o u t p u t v a r i a b l e . The r e l a t i o n s h i p b e t w e e n i n p u t v a r i a b l e s and o u t p u t v a r i a b l e can be t a b u l a t e d a s shown i n t r u t h t a b l e 5 . 1 ” ) disp ( ” A B C Y” ) disp ( ” 0 0 0 0”) disp ( ” 0 0 1 0”) disp ( ” 0 1 0 0”) disp ( ” 0 1 1 1”) disp ( ” 1 0 0 0”) disp ( ” 1 0 1 1”) disp ( ” 1 1 0 1”) disp ( ” 1 1 1 1”) disp ( ”Now we o b t a i n t h e s i m p l i f i e d B o o l e a n e x p r e s s i o n f o r o u t p u t v a r i a b l e Y u s i n g K−map s i m p l i f i c a t i o n . ”) 60
14 15 16 17
disp ( ” BC BC’ ’ B’ ’C’ ’ disp ( ”A 0 0 1 disp ( ”A’ ’ 0 1 1 disp ( ” Y = AC + BC + AB” )
B ’ ’ C” ) 0”) 1”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.2 design a circuit with control line C and data lines 1 // Example 5 . 2 2 clc 3 disp ( ” The t r u t h 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
t a b l e f o r the g i v e n problem i s as shown b e l o w . ” ) disp ( ” C D3 D2 D1 Output ” ) disp ( ” 0 x x x 0”) disp ( ” 0 0 0 0 0”) disp ( ” 0 0 0 1 1”) disp ( ” 0 0 1 0 1”) disp ( ” 0 1 0 0 1”) disp ( ” ” ) disp ( ”K−map s i m p l i f i c a t i o n ” ) disp ( ” D1 ’ ’ D2 ’ ’ D1 ’ ’ D2 D1D2 D1D2 ’ ’ ”) disp ( ”C ’ ’ D3 ’ ’ 0 0 0 0”) disp ( ”C ’ ’ D3 0 0 0 0”) disp ( ”CD3 1 X X X” ) disp ( ”CD3 ’ ’ 0 1 X 1”) disp ( ” ” ) disp ( ” T h e r e f o r e , Y = CD3 + CD2 + CD1” )
This code can be downloaded from the website wwww.scilab.in
61
Scilab code Exa 5.3 design combinational circuit 1 // Example 5 . 3 2 clc 3 disp ( ” Truth t a b l e ” ) 4 disp ( ” Input 5 disp ( ” Decimal D i g i t 6 7 8 9 10 11 12 13 14 15 16 17 18
) disp ( ” A B C Y0” ) disp ( ” 0 0 0 0”) disp ( ” 0 0 0 1”) disp ( ” 0 0 1 0”) disp ( ” 0 0 1 1”) disp ( ” 0 1 0 0”) disp ( ” 0 1 0 1”) disp ( ” 0 1 1 0”) disp ( ” 0 1 1 1”) disp ( ” 1 0 0 0”) disp ( ” 1 0 0 1”) disp ( ” ” ) disp ( ” Here Y0 = C , Y5 = B , given c i r c u i t l i n e s without
Output ” ) Digit 1 Digit 0”
D
Y7
Y6
Y5
Y4
Y3
Y2
Y1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
1
0
0
0
1
0
1
0
0
0
0
1
0
0
0
0
1
0
0
1
0
0
1
0
0
0
0
1
1
0
0
0
1
0
0
1
1
0
1
0
0
0
1
0
0
0
0
0
1
0
1
0
0
0
1
0
D, Y1 = 0 , Y2 Y6 = A and Y7 = can be o b t a i n e d u s i n g any l o g i c
62
= D, Y3 = 0 , Y4 = 0. Therefore , the from t h e i n p u t g a t e s ”)
Scilab code Exa 5.4 design logic circuit 1 // Example 5 . 4 2 clc 3 disp ( ” L e t u s c o n s i d e r D f o r Door ,
4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19 20 21 22
I for ignition , L f o r L i g h t . Then c o n d i t i o n s t o a c t i v a t e t h e a l a r m are : ”) disp ( ” 1 . The h e a d l i g h t s a r e ON w h i l e t h e i g n i t i o n i s OFF . ” ) disp ( ” i . e . L = 1 , I = 0 and D may be a n y t h i n g . ” ) disp ( ” 2 . The d d o r i s open w h i l e t h e i g n i t i o n i s ON” ) disp ( ” i . e . D = 1 , I = 1 , L may be a n y t h i n g . ” ) disp ( ” A l s o a l a r m w i l l sound i f l o g i c c i r c u i t o u t p u t i s zero . ”) disp ( ” T h e r e f o r e , o u t p u t f o r a b o v e c o n d i t i o n i s z e r o and f o r r e s t o f t h e c o n d i t i o n i t i s 1 which i s summarized i n t h e f o l l o w i n g t a b l e . ” ) disp ( ” D I L Y” ) disp ( ” 0 0 0 1”) disp ( ” X 0 1 0”) disp ( ” 0 1 0 1”) disp ( ” 0 1 1 1”) disp ( ” 1 0 0 1”) disp ( ” 1 1 X 0”) disp ( ” T h e r e f o r e , K−map f o r l o g i c c i r c u i t . ” ) disp ( ” I ’ ’L’ ’ I ’ ’L IL IL ’ ’ ” ) disp ( ”D’ ’ 1 0 1 1”) disp ( ”D 1 0 0 0”) disp ( ” Output = Y = I ’ ’ L ’ ’ + D’ ’ I ” ) disp ( ” As AND−OR l o g i c can be d i r e c t l y r e p l a c e d by NAND−NAND, l o g i c c i r c u i t u s i n g o n l y NAND g a t e s i s a s shown i n f i g . 5 . 9 and f i g . 5 . 1 0 ” )
63
This code can be downloaded from the website wwww.scilab.in This code
can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.5 design circuit to detect invalid BCD number 1 // Example 5 . 5 2 clc 3 disp ( ” Truth t a b l e ” ) 4 disp ( ” Dec A B C D Output Y” ) 5 disp ( ” 0 0 0 0 0 0”) 6 disp ( ” 1 0 0 0 1 0”) 7 disp ( ” 2 0 0 1 0 0”) 8 disp ( ” 3 0 0 1 1 0”) 9 disp ( ” 4 0 1 0 0 0”) 10 disp ( ” 5 0 1 0 1 0”) 11 disp ( ” 6 0 1 1 0 0”) 12 disp ( ” 7 0 1 1 1 0”) 13 disp ( ” 8 1 0 0 0 0”) 14 disp ( ” 9 1 0 0 1 0”) 15 disp ( ” 10 1 0 1 0 1”) 16 disp ( ” 11 1 0 1 1 1”) 17 disp ( ” 12 1 1 0 0 1”) 18 disp ( ” 13 1 1 0 1 1”) 19 disp ( ” 14 1 1 1 0 1”) 20 disp ( ” 15 1 1 1 1 1”) 21 disp ( ” ” ) 22 disp ( ”K−map s i m p l i f i c a t i o n ” ) 23 disp ( ” C ’ ’ D’ ’ C’ ’D CD 24 25
) disp ( ”A’ ’ B ’ ’ disp ( ”A’ ’ B
0 0
0 0 64
0 0
CD’ ’ ” 0”) 0”)
26 27 28
disp ( ”AB 1 disp ( ”AB’ ’ 0 disp ( ” Y = AB + AC” )
1
1 0
1
1”) 1”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.6 design two level combinational circuit 1 // Example 5 . 6 2 clc 3 disp ( ” I n p u t 1 −> P r e s s u r e i n f u e l t a n k ” ) 4 disp ( ” I n p u t 2 −> P r e s s u r e i n o x i d i z e r t a n k ” ) 5 disp ( ” Input = 1 I n d i c a t e s p r e s s u r e i s equal to or 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
a b o v e t h e r e q u i r e d minimum” ) disp ( ” = 0 Otherwise ”) disp ( ” I n p u t 3 −> From t i m e r ” ) disp ( ” i f i n p u t 3 = 1 I n d i c a t e s t h a t t h e r e a r e l e s s t h a n o r e x a c t l y 10 m i n u t e s f o r l i f t o f f ” ) disp ( ” = 0 Otherwise ”) disp ( ” Output −> P a n e l l i g h t , i f l i g h t g o e s on then ”) disp ( ” Output = 1 ” ) disp ( ” e l s e Output = 0 ” ) disp ( ” ” ) disp ( ” Truth t a b l e ” ) disp ( ” L e t i n p u t 1 = A, input 2 = B, input 3 = C. ”) disp ( ” Inputs Output ” ) disp ( ” A B C Y” ) disp ( ” 0 0 0 1”) disp ( ” 0 0 1 0”) disp ( ” 0 1 0 1”) disp ( ” 0 1 1 0”) disp ( ” 1 0 0 1”) disp ( ” 1 0 1 0”) 65
disp ( ” 1 disp ( ” 1 disp ( ” ” ) disp ( ”K−map disp ( ” disp ( ”A’ ’ disp ( ”A disp ( ” Y = disp ( ” = disp ( ” = A + B] ”) 34 disp ( ” = 35 disp ( ” =
24 25 26 27 28 29 30 31 32 33
1 1
0 1
0”) 1”)
s i m p l i f i c a t i o n ”) B’ ’C’ ’ B’ ’C BC BC’ ’ ” ) 1 0 0 1”) 1 0 1 0”) ABC + A’ ’ B ’ ’ C ’ ’ + B ’ ’ C ’ ’ ” ) ABC + C ’ ’ ( B’ ’ +A’ ’ B) ” ) ABC + C ’ ’ ( B’ ’ +A ’ ’ ) [ A’ ’ +A’ ’ B = ABC + C ’ ’ ( A’ ’ B ’ ’ ) ” ) A’ ’ B ’ ’ XOR C ’ ’ ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.7 design 32 to 1 multiplexer 1 // Example 5 . 7 2 clc 3 disp ( ” F i g . 5 . 2 0 shows a 32 t o 1 m u l t i p l e x e r
u s i n g 74
LS150 I C s . ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.8 design a 32 to 1 multiplexer 1 // Example 5 . 8 2 clc 3 disp ( ” F i g . 5 . 2 1 shows a 32 t o 1 m u l t i p l e x e r
using f o u r 8 t o 1 m u l t i p l x e r e s and 2 t o 4 d e c o d e r . . ” ) 66
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.9 implement boolean function using 8to1 multiplexer 1 // Example 5 . 9 2 clc 3 disp ( ” The f u n c t i o n can be i m p l e m e n t e d w i t h a 8 t o 1
m u l t i p l e x e r , a s shown i n f i g . 5 . 2 2 . Three v a r i a b l e s A, B and C a r e a p p l i e d t o t h e s e l e c t l i n e s . The m i n t e r m s t o be i n c l u d e d ( 1 , 3 , 5 and 6 ) a r e c h o s e n by making t h e i r c o r r e s p o n d i n g i n p u t l i n e s e q u a l t o 1 . Mintems 0 , 2 , 4 and 7 a r e n o t i n c l u d e d by making t h e i r i n p u t l i n e s e q u a l t o 0 . ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.10 implement boolean function using 4to1 multiplexer 1 // Example 5 . 1 0 2 clc 3 disp ( ” F i g . 5 . 2 3 shows t h e i m p l e m e n t a t i o n o f
function w i t h 4 t o 1 m u l t i p l e x e r . Two o f t h e v a r i a b l e s , B and C , a r e a p p l i e d t o t h e s e l e c t i o n l i n e s . B i s c o n n e c t e d t o S1 and C i s c o n n e c t e d t o S0 . The i n p u t s f o r m u l t i p l e x e r a r e d e r i v e d from t h e implementation t a b l e . ”) 4 disp ( ” Truth t a b l e ” ) 5 disp ( ” Minterm A B C F” ) 67
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
22
23
24
25
disp ( ” 0 0 0 0 0”) disp ( ” 1 0 0 1 1”) disp ( ” 2 0 1 0 0”) disp ( ” 3 0 1 1 1”) disp ( ” 4 1 0 0 0”) disp ( ” 5 1 0 1 1”) disp ( ” 6 1 1 0 1”) disp ( ” 7 1 1 1 0”) disp ( ” ” ) disp ( ” I m p l e m e n t a t i o n t a b l e ” ) disp ( ” D0 D1 D2 D3” ) disp ( ”A’ ’ 0 1 2 3 Row 1 ” ) disp ( ”A 4 5 6 7 Row 2 ” ) disp ( ” 0 1 A A’ ’ ” ) disp ( ” ” ) disp ( ” As shown i n f i g . 5 . 2 3 ( c ) t h e i m p l e m e n t a t i o n t a b l e i s n o t h i n g but t h e l i s t o f t h e i n p u t s o f t h e m i l t i p l e x e r s and u n d e r them l i s t o f a l l t h e m i n t e r m s i n two r o w s . The f i r s t row l i s t s a l l t h o s e m i n t e r m s where A i s complemented , and t h e s e c o n d row l i s t s a l l t h e m i n t e r m s w i t h A uncomplemented . The m i n t e r m s g i v e n i n t h e f u n c t i o n a r e c i r c l e d and t h e n e a c h column i s i n s e r t e d s e p a r a t e l y as f o l l o w s . ”) disp ( ” 1 . I f t h e two m i n t e r m s i n a column a r e n o t c i r c l e d , O i s applied to the corresponding m u l t i p l e x e r i n p u t ( s e e column 1 ) . ” ) disp ( ” 2 . I f t h e two m i n t e r m s i n a column a r e c i r c l e d , 1 i s applied to the corresponding m u l t i p l e x e r i n p u t ( s e e column 2 ) . ” ) disp ( ” 3 . I f t h e minterm i n t h e s e c o n d row i s c i r c l e d and m i n t e r m s i n t h e f i r s t row i s n o t c i r c l e d , A i s applied to the corresponding m u l t i p l e x e r input ( s e e column 3 ) . ” ) disp ( ” 4 . I f t h e minterm i n t h e f i r s t row i s c i r c l e d and minterm i n t h e s e c o n d row i s n o t c i r c l e d , A’ ’ i s applied to the corresponding m u l t i p l e x e r i n p u t ( s e e column 4 ) . ” ) 68
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.11 implement boolean function using 8to1 MUX 1 // Example 5 . 1 1 2 clc 3 disp ( ” F i g 5 . 2 5 shows t h e i m p l e m e n t a t i o n o f g i v e n 4 5 6 7 8
Booolean f u n c t i o n with 8 : 1 m i l t i p l e x e r . ”) disp ( ” I m p l e m e n t a t i o n t a b l e ” ) disp ( ” D0 D1 D2 D3 D4 D5 D6 D7” ) disp ( ”A’ ’ 0 1 2 3 4 5 6 7”) disp ( ”A 8 9 10 11 12 13 14 15 ” ) disp ( ” 1 1 0 A’ ’ A’ ’ 0 0 A” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.12 implement boolean function using 4to1 MUX 1 // Example 5 . 1 2 2 clc 3 disp ( ” The f u n c t i o n h a s f o u r
v a r i a b l e s . To i m p l e m e n t t h i s f u n c t i o n we r e q u i r e 8 : 1 m u l t i p l e x e r . i . e . , two 4 : 1 m u l t i p l e x e r s . We have a l r e a d y s e e n how t o c o n s t r u c t 8 : 1 m u l t i p l e x e r u s i n g two 4 : 1 m u l t i p l e x e r s . The same c o n c e p t i s u s e d h e r e t o implement g i v e n Boolean f u n c t i o n . ”) 4 disp ( ” ” ) 5 disp ( ” I m p l e m e n t a t i o n t a b l e ” ) 6 disp ( ” D0 D1 D2 D3 D4 D5 D6 D7” ) 69
7 8 9
disp ( ”A’ ’ disp ( ”A disp ( ”
0
1
8 9 A’ ’ 1
2 3 4 5 6 7”) 10 11 12 13 14 15 ” ) A’ ’ 0 1 0 1 0”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.13 implement boolean function using 8to1 MUX 1 // Example 5 . 1 3 2 clc 3 disp ( ” The g i v e n B o o l e a n e x p r e s s i o n
4 5
6 7 8 9 10 11 12 13 14 15 16 17 18 19
i s not in s t a n d a r d SOP form . L e t u s f i r s t c o n v e r t t h i s i n s t a n d a r d form . ” ) disp ( ” F (A, B , C , D) = A’ ’ BD’ ’ ( C+C ’ ’ ) + ACD(B+B ’ ’ ) + B ’ ’CD(A+A ’ ’ ) + A’ ’ C ’ ’ D(B+B ’ ’ ) ” ) disp ( ” = A’ ’ BCD’ ’ + A’ ’ BC’ ’ D’ ’ + ABCD + AB’ ’CD + AB’ ’CD + A’ ’ B ’ ’CD + A’ ’ BC’ ’ D + A’ ’ B ’ ’ C ’ ’ D” ) disp ( ” = A’ ’ BCD’ ’ + A’ ’ BC’ ’ D’ ’ + ABCD + AB’ ’CD + A’ ’ B ’ ’CD + A’ ’ BC’ ’ D + A’ ’ B ’ ’ C ’ ’ D” ) disp ( ” ” ) disp ( ” The t r u t h t a b l e f o r t h i s s t a n d a r d SOP form can be g i v e n a s ” ) disp ( ” No . Minterms A B C D Y” ) disp ( ” 0 0 0 0 0 0”) disp ( ” 1 A’ ’ B ’ ’ C ’ ’ D 0 0 0 1 1”) disp ( ” 2 0 0 1 0 0”) disp ( ” 3 A’ ’ B ’ ’CD 0 0 1 1 1”) disp ( ” 4 A’ ’ BC’ ’ D’ ’ 0 1 0 0 1”) disp ( ” 5 A’ ’ BC’ ’ D 0 1 0 1 1”) disp ( ” 6 A’ ’ BCD’ ’ 0 1 1 0 1”) disp ( ” 7 0 1 1 1 0”) disp ( ” 8 1 0 0 0 0”) disp ( ” 9 1 0 0 1 0”) 70
20 21 22 23 24 25 26 27
28 29 30 31 32
disp ( ” 10 1 0 1 0 0”) disp ( ” 11 AB’ ’CD 1 0 1 1 1”) disp ( ” 12 1 1 0 0 0”) disp ( ” 13 1 1 0 1 0”) disp ( ” 14 1 1 1 0 0”) disp ( ” 15 ABCD 1 1 1 1 1”) disp ( ” ” ) disp ( ”From t h e t r u t h t a b l e B o o l e a n f u n c t i o n can be implemented u s i n g 8 : 1 m u l t i p l e x e r as f o l l o w s : ” ) disp ( ” I m p l e m e n t a t i o n t a b l e : ” ) disp ( ” D0 D1 D2 D3 D4 D5 D6 D7” ) disp ( ”A’ ’ 0 1 2 3 4 5 6 7”) disp ( ”A 8 9 10 11 12 13 14 15 ” ) disp ( ” 0 A’ ’ 0 1 A’ ’ A’ ’ A’ ’ A” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.14 implement boolean function using 8to1 MUX 1 // Example 5 . 1 4 . 2 clc 3 disp ( ” Here , i n s t e a d
4 5 6 7 8 9
o f minterms , maxterms a r e s p e c i f i e d . Thus , we have t o c i r c l e maxterms which are not i n c l u d e d in the Boolean f u n c t i o n . Fig . 5 . 2 8 shows t h e i m p l e m e n t a t i o n o f B o o l e a n f u n c t i o n with 8 : 1 m u l t i p l e x e r . ”) disp ( ” ” ) disp ( ” I m p l e m e n t a t i o n t a b l e : ” ) disp ( ” D0 D1 D2 D3 D4 D5 D6 D7” ) disp ( ”A’ ’ 0 1 2 3 4 5 6 7”) disp ( ”A 8 9 10 11 12 13 14 15 ” ) disp ( ” 0 A’ ’ A’ ’ A A’ ’ A 0 1”)
71
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.15 implement boolean function using 8to1 MUX 1 // Example 5 . 1 5 2 clc 3 disp ( ” I n t h e g i v e n B o o l e a n f u n c t i o n
4 5 6 7 8 9 10 11
t h r e e don ’ ’ t c a r e c o n d i t i o n s a r e a l s o s p e c i f i e d . We know t h a t don . . t c a r e c o n d i t i o n s can be t r e a t e d a s e i t h e r 0 s o r 1 s . F i g . 5 . 2 9 shows t h e i m p l e m e n t a t i o n o f given Boolean f u n c t i o n using 8 : 1 m u l t i p l e x e r . ”) disp ( ” ” ) disp ( ” I m p l e m e n t a t i o n t a b l e : ” ) disp ( ” D0 D1 D2 D3 D4 D5 D6 D7” ) disp ( ”A’ ’ 0 1 2 3 4 5 6 7”) disp ( ”A 8 9 10 11 12 13 14 15 ” ) disp ( ” 1 0 1 1 A A 1 0”) disp ( ” ” ) disp ( ” I n t h i s example , by t a k i n g don ’ ’ t c a r e c o n d i t i o n s 8 and 14 we have e l i m i n a t e d A’ ’ term and h e n c e t h e i n v e r t e r . ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.16 determine boolean expression 1 // Example 1 5 . 6 2 clc 3 disp ( ” D’ ’ D” ) 4 disp ( ”D 0 1”)
72
5 6 7 8 9 10 11 12 13
14 15 16
17
18
19
disp ( ” 0 2 3”) disp ( ” 0 4 5”) disp ( ” 1 6 7”) disp ( ”D 8 9”) disp ( ” 1 10 11 ” ) disp ( ”D’ ’ 12 13 ” ) disp ( ” 0 14 15 ” ) disp ( ” ” ) disp ( ” Here , i m p l e m e n t a t i o n t a b l e i s l i s t e d f o r l e a s t s i g n i f i c a n t b i t i . e . D . The f i r s t column l i s t a l l m i n t e r m s w i t h D i s c o m p l e m e n t a t e d and t h e s e c o n d column l i s t s a l l t h e m i n t e r m s w i t h D uncomplemented , a s shown i n f i g . 5 . 3 0 ( a ) . Then a c c o r d i n g to data i n p u t s given to the m u l t i p l e x e r minterms a r e c i r c l e d a p p l y i n g f o l l o w i n g r u l e s . ”) disp ( ” 1 . I f m u l t i p l e x e r i n p u t i s 0 , don ’ ’ t c i r c l e any minterm i n t h e c o r r e s p o n d i n g row . ” ) disp ( ” 2 . I f m u l t i p l e x e r i n p u t 1 , c i r c l e b o t h t h e m i n t e r m s i n t h e c o r r e s p o n d i n g row . ” ) disp ( ” 3 . I f m u l t i p l e x e r i n p u t i s D, c i r c l e t h e minterm b e l o n g s t o cloumn D i n t h e c o r r e s p o n d i n g row . ” ) disp ( ” 4 . I f m u l t i p l e x e r i n p u t i s D’ ’ , c i r c l e t h e minterm b e l o n g s t o column D’ ’ i n t h e c o r r e s p o n d i n g row . ” ) disp ( ” T h i s i s i l l u s t r a t e d i n f i g . 5 . 3 0 ( b ) . Now c i r c l e d m i n t e r m s can be w r i t t e n t o g e t B o o l e a n e x p r e s s i o n as f o l l o w s : ”) disp ( ” Y = A’ ’ B ’ ’ C ’ ’ D + A’ ’ BCD’ ’ + A’ ’BCD + AB’ ’ C ’ ’ D + AB’ ’ CD’ ’ + AB’ ’CD + ABC’ ’ D’ ’ ” )
Scilab code Exa 5.17 realize using 4 to 1 MUX 1 // Example 5 . 1 7 2 clc
73
3 4 5 6 7 8 9 10 11 12
disp ( ” disp ( ”w ’ ’ x ’ ’ disp ( ”w ’ ’ x disp ( ”wx ’ ’ disp ( ”wx disp ( ” ” ) disp ( ”D0 = w ’ disp ( ”D1 = w ’ disp ( ”D2 = w ’ disp ( ”D3 = w ’
D0
D3” ) 0 1 2 3”) 4 5 6 7”) 8 9 10 11 ” ) 12 13 14 15 ” )
’x + ’x’ ’ ’x + ’x +
D1
D2
wx ’ ’ = + wx ’ ’ wx ’ ’ = wx ’ ’ +
w XOR x ” ) = x ’ ’ ”) w XOR x ” ) wx = x + wx ’ ’ = w + x ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.18 design 1 to 8 DEMUX 1 // Example 5 . 1 8 2 clc 3 disp ( ” The c a s c a d i n g
of d e m u l t i p l e x e r s i s s i m i l a r to t h e c a s c a d i n g o f d e c o d e r . F i g . 5 . 3 3 shows c a s c a d i n g o f two 1 : 4 d e m u l t i p l e x e r s t o form 1 : 8 d e m u l t i p l e x e r . ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.19 implement full subtractor 1 // Example 5 . 1 9 2 clc 3 disp ( ” L e t u s s e e t h e t r u t h
”) 4 disp ( ”
A
B
Bin
D
table of f u l l subtractor .
Bout ” ) 74
disp ( ” 0 0 0 0 0”) disp ( ” 0 0 1 1 1”) disp ( ” 0 1 0 1 1”) disp ( ” 0 1 1 0 1”) disp ( ” 1 0 0 1 0”) disp ( ” 1 0 1 0 0”) disp ( ” 1 1 0 0 0”) disp ( ” 1 1 1 1 1”) disp ( ” ” ) disp ( ” For f u l l s u b t r a c t o r d i f f e r e n c e D f u n c t i o n can be w r i t t e n a s D = f (A, B , C) = summation m( 1 , 2 , 4 , 7 ) and Bout f u n c t i o n can be w r i t t e n a s ” ) 15 disp ( ” Bout = F (A, B , C) = summation m( 1 , 2 , 3 , 7) ”) 16 disp ( ” With Din i n p u t 1 , d e m u l t i p l e x e r g i v e s m i n t e r m s a t t h e o u t p u t s o by l o g i c a l l y ORing r e q u i r e d m i n t e r m s we can i m p l e m e n t B o o l e a n f u n c t i o n s f o r f u l l s u b t r a c t o r . F i g . 5 . 3 4 shows t h e implementation of f u l l subtractor using d e m u l t i p l e x e r . ”)
5 6 7 8 9 10 11 12 13 14
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.20 construst 1 to 32 DEMUX 1 // Exmaple 5 . 2 0 2 clc 3 disp ( ” The f i g . 5 . 3 7 shows t h e i m p l e m e n t a t i o n o f 1 t o
32 d e m u l t i p l e x e r u s i n g two 74 X154 I C s . Here , t h e most s i g n i f i c a n t b i t o f s e l e c t s i g n a l ( A4 ) i s u s e d t o e n a b l e e i t h e r u p p e r 1 t o 16 d e m u l t i p l e x e r o r l o w e r 1 t o 16 d e m u l t i p l e x e r . The d a t a i n p u t and o t h e r s e l e c t s i g n a l s a r e c o n n e c t e d p a r a l l e l t o b o t h t h e d e m u l t i p l e x e r I C s . When A4 = 0 , u p p e r 75
d e m u l t i p l e x e r i s e n a b l e d and t h e d a t a i n p u t i s routed to the output corresponds to the s t a t u s of A0 A1 A2 and A3 l i n e s . When A4 = 1 , l o w e r m i l t i p l e x e r i s e n a b l e d and t h e d a t a i n p u t i s routed to the output corresponds to the s t a t u s of A0 A1 A2 and A3 l i n e s . ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.21 design 3 to 8 decoder 1 // Example 5 . 2 1 2 clc 3 disp ( ” F i g . 5 . 4 0 shows 3 t o 8 l i n e
4 5 6 7 8 9 10 11
d e c o d e r . Here , 3 i n p u t s are decoded i n t o e i g h t outputs , each o u t p u t r e p r e s e n t one o f t h e m i n t e r m s o f t h e 3 i n p u t v a r i a b l e s . The t h r e e i n v e r t e r s p r o v i d e t h e complement o f t h e i n p u t s , and e a c h one o f t h e e i g h t AND g a t e s g e n e r a t e s one o f t h e m i n t e r m s . Enable input i s provided to a c t i v a t e decoded o u t p u t b a s e d on d a t a i n p u t s A, B and C . The t a b l e shows t h e t r u t h t a b l e f o r 3 t o 8 d e c o d e r . ” ) disp ( ” ” ) disp ( ” Truth t a b l e f o r a 3 t o 8 d e c o d e r ” ) disp ( ” Inputs | Outputs ” ) disp ( ”EN A B C | Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 ”) disp ( ” 0 X X X | 0 0 0 0 0 0 0 0” ) disp ( ” 1 0 0 0 | 0 0 0 0 0 0 0 1” ) disp ( ” 1 0 0 1 | 0 0 0 0 0 0 1 0” ) disp ( ” 1 0 1 0 | 0 0 0 0 0 1 0 0” 76
12 13 14 15 16
) disp ( ” 1 ) disp ( ” 1 ) disp ( ” 1 ) disp ( ” 1 ) disp ( ” 1 )
0
1
1
|
0
0
0
0
1
0
0
0”
1
0
0
|
0
0
0
1
0
0
0
0”
1
0
1
|
0
0
1
0
0
0
0
0”
1
1
0
|
0
1
0
0
0
0
0
0”
1
1
1
|
1
0
0
0
0
0
0
0”
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.22 design 5 to 32 decoder 1 // Example 5 . 2 2 2 clc 3 disp ( ” The F i g . 5 . 4 5 shows t h e c o n s t r u c t i o n
of 5 to 32 d e c o d e r u s i n g f o u r 74 LS138s and h a l f 74 LS139 . The h a l f s e c t i o n o f 74 LS139 IC u s e d a s a 2 t o 4 d e c o d e r t o d e c o d e t h e two h i g h e r o r d e r i n p u t s , D and E . The f o u r o u t p u t s o f t h i s d e c o d e r a r e u s e d t o e n a b l e one o f t h e f o u r 3 t o 8 d e c o d e r s . The t h r e e l o w e r i n p u t s A, B and C a r e c o n n e c t e d i n p a r a l l e l t o f o u r 3 t o 8 d e c o d e r s . T h i s means t h a t t h e same o u t p u t p i n o f e a c h o f t h e f o u r 3 t o 8 d e c o d e r s i s s e l e c t e d but o n l y one i s e n a b l e . The remaining enables s i g n a l s of four 3 to 8 decoders ICs a r e co nn ect ed i n p a r a l l e l to c o n s t r u c t e n a b l e s i g n a l s f o r 5 t o 32 d e c o d e r . ” )
77
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.23 design 4 line to 16 line decoder 1 // Example 5 . 2 3 2 clc 3 disp ( ” 4 l i n e t o 16 l i n e 4
decoder using 1 l i n e to 4
l i n e decoder ”) disp ( ” As shown i n f i g . 5 . 4 6 f i v e numbers o f 2 : 4 d e c o d e r a r e r e q u i r e d t o d e s i g n 4 : 16 d e c o d e r . D e c o d e r 1 i s u s e d t o e n a b l e one o f t h e d e c o d e r 2 , 3 , 4 and 5 . I n p u t s o f f i r s t d e c o d e r a r e t h e A and B MSB i n p u t s o f 4 : 16 d e c o d e r . The i n p u t s o f d e c o d e r a r e c o n n e c t e d t o g e t h e r f o r m i n g C and D LSB i n p u t s o f 4 : 16 d e c o d e r . ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.24 implement using 74LS138 1 // Example 5 . 2 4 2 clc 3 disp ( ” I n t h i s example , we u s e IC 74 LS138 , 3 : 8
decoder to implement m u l t i p l e output f u n c t i o n . The o u t p u t s o f 74 LS138 a r e a c t i v e low , t h e r e f o r e , SOP f u n c t i o n ( f u n c t i o n F1 ) can be i m p l e m e n t e d u s i n g NAND g a t e and POS f u n c t i o n ( f u n c t i o n F2 ) can be i m p l e m e n t e d u s i n g AND g a t e , a s shown i n f i g . 5 . 5 0 ”)
78
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.25 implement full substractor 1 // Example 5 . 2 5 2 clc 3 disp ( ” The t r u t h 4 5 6 7 8 9 10 11 12 13 14 15 16
table for
f u l l s u b t r a c t o r i s as
shown b e l o w ” ) disp ( ” ” ) disp ( ” I n p u t s Outputs ” ) disp ( ”A B Bin D Bout ” ) disp ( ” 0 0 0 0 0”) disp ( ” 0 0 1 1 1”) disp ( ” 0 1 0 1 1”) disp ( ” 0 1 1 0 1”) disp ( ” 1 0 0 1 0”) disp ( ” 1 0 1 0 0”) disp ( ” 1 1 0 0 0”) disp ( ” 1 1 1 1 1”) disp ( ” ” ) disp ( ” I m p l e m e n t a t i o n o f f u l l s u b t r a c t o r u s i n g 3 : 8 d e c o d e r i s shown i n f i g . 5 . 5 1 ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.26 implement gray to binary code converter 1 // Example 5 . 2 6 2 clc
79
3 4 5 6 7 8 9 10 11 12 13 14 15
disp ( ” The t r u t h t a b l e f o r 3− b i t b i n a r y t o g r a y c o d e c o n v e r t e r i s a s shown b e l o w ” ) disp ( ” ” ) disp ( ”A B C G2 G1 G0” ) disp ( ” 0 0 0 0 0 0”) disp ( ” 0 0 1 0 0 1”) disp ( ” 0 1 0 0 1 1”) disp ( ” 0 1 1 0 1 0”) disp ( ” 1 0 0 1 1 0”) disp ( ” 1 0 1 1 1 1”) disp ( ” 1 1 0 1 0 1”) disp ( ” 1 1 1 1 0 0”) disp ( ” ” ) disp ( ” The f i g . 5 . 5 2 shows t h e i m p l e m e n t a t i o n o f 3− b i t binary to gray code c o n v e r t e r using 3 : 8 d e c o d e r . As o u t p u t s o f 7 4 1 3 8 a r e a c t i v e low we have t o u s e NAND g a t e i n s t e a d o f OR g a t e . The a c t i v e low o u t p u t from t h e d e c o d e r f o r c e s o u t p u t ( s ) o f c o n n e c t e d NAND g a t e ( s ) t o become HIGH , t h u s implementing the f u n c t i o n . ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.27 design 2 bit comparator 1 // Example 2 clc 3 disp ( ” ” ) 4 disp ( ”A1 5 disp ( ” 0 6 disp ( ” 0 7 disp ( ” 0 8 disp ( ” 0 9 disp ( ” 0
5.27
A0 0 0 0 0 1
B1 0 0 1 1 0
B0 0 1 0 1 0
A>B 0 0 0 0 1 80
A=B 0 0 0 0 0
A
10 11 12 13 14 15 16 17 18 19 20
disp ( ” 0 disp ( ” 0 disp ( ” 0 disp ( ” 1 disp ( ” 1 disp ( ” 1 disp ( ” 1 disp ( ” 1 disp ( ” 1 disp ( ” 1 disp ( ” 1
1 1 1 0 0 0 0 1 1 1 1
0 1 1 0 0 1 1 0 0 1 1
1 0 1 0 1 0 1 0 1 0 1
0 0 0 1 1 0 0 1 1 1 0
1 0 0 0 0 1 0 0 0 0 1
0”) 1”) 1”) 0”) 0”) 0”) 1”) 0”) 0”) 0”) 0”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.28 design full adder circuit 1 // Example 5 . 2 8 2 clc 3 disp ( ” Truth t a b l e 4 5 6 7 8 9 10 11 12 13
) disp ( ” I n p u t s disp ( ”A B Cin disp ( ” 0 0 0 disp ( ” 0 0 1 disp ( ” 0 1 0 disp ( ” 0 1 1 disp ( ” 1 0 0 disp ( ” 1 0 1 disp ( ” 1 1 0 disp ( ” 1 1 1
for
f u l l a d d e r i s a s shown b e l o w . ”
Outputs ” ) C a r r y Sum” ) 0 0”) 0 1”) 0 1”) 1 0”) 0 1”) 1 0”) 1 0”) 1 1”)
81
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.29 implement BCD to 7 segment decoder 1 // Example 5 . 2 9 2 clc 3 disp ( ”BCD−to −common anode 7−s e g m e n t d e c o d e r ” ) 4 disp ( ” D i g i t A B C D a b c d e f 5 disp ( ” 0 0 0 0 0 0 0 0 0 0 0 6 disp ( ” 1 0 0 0 1 1 0 0 1 1 1 7 disp ( ” 2 0 0 1 0 0 0 1 0 0 1 8 disp ( ” 3 0 0 1 1 0 0 0 0 1 1 9 disp ( ” 4 0 1 0 0 1 0 0 0 1 1 10 disp ( ” 5 0 1 0 1 0 1 0 0 1 0 11 disp ( ” 6 0 1 1 0 0 1 0 0 0 0 12 disp ( ” 7 0 1 1 1 0 0 0 1 1 1 13 disp ( ” 8 1 0 0 0 0 0 0 0 0 0 14 disp ( ” 9 1 0 0 1 0 0 0 0 1 0
g”) 1”) 1”) 0”) 0”) 0”) 0”) 0”) 1”) 0”) 0”)
This code can be downloaded from the website wwww.scilab.in This code
can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.31 implement 32 input to 5 output encoder 1 // Example 5 . 3 1 2 clc 3 disp ( ” F i g . 5 . 7 5 shows how f o u r 74 LS148 can be
c o n n e c t e d t o a c c e p t 32 i n p u t s and p r o d u c e a 5− b i t 82
e n c o d e d o u t p u t , A0 − A4 . EO’ ’ s i g n a l i s c o n n e c t e d t o t h e EI ’ ’ i n p u t o f t h e n e x t l o w e r p r i o r i t y e n c o d e r and EI ’ ’ i n p u t o f t h e h i g h e s t p r i o r i t y e n c o d e r i s g r o u n d e d . T h e r e f o r e , a t any t i m e o n l y one e n c o d e r i s e n a b l e d . S i n c e , t h e A2 − A0 o u t p u t s o f a t t h e most one 74 LS148 w i l l be e n a b l e d a t a time , t h e o u t p u t s o f t h e i n d i v i d u a l 74 LS148s can be ORed t o p r o d u c e A2 − A0 . L i k e w i s e , t h e i n d i v i d u a l GS ’ ’ o u t p u t s can be combined i n a 4 t o 2 e n c o d e r t o p r o d u c e A4 and A3 . The GS o u t p u t f o r 32− b i t e n c o d e r i s p r o d u c e d b y ORing GS ’ ’ outputs of a l l encoders . ”)
This code can be downloaded from the website wwww.scilab.in
83
Chapter 6 Sequential Logic Circuits
Scilab code Exa 6.4 analyze the circuit 1 // Example 6 . 4 2 clc 3 disp ( ”To a n a l y z e t h e 4 5 6 7 8 9 10 11 12
c i r c u i t means t o d r i v e t h e truth t a b l e f o r i t . ”) disp ( ”We have , D = I n p u t XOR Q n ” ) disp ( ” ” ) disp ( ”CLK Input Q n D = i n p u t XOR Q n Q n+1” ) disp ( ” down 0 0 0 0”) disp ( ” down 0 1 1 1”) disp ( ” down 1 0 1 1”) disp ( ” down 1 1 0 0”) disp ( ” ” ) disp ( ” I n t h e c i r c u i t f i g . 6 . 5 3 , o u t p u t d o e s n o t c h a n g e when i n p u t i s 0 and i t t o g g l e s when i n p u t i s 1 . T h i s i s t h e c h a r a c t e r i s t i c s o f T f l i p −f l o p . Hence , t h e g i v e n c i r c u i i s T f l i p −f l o p 84
c o n s t r u c t e d u s i n g D f l i p −f l o p . ” )
This code can be downloaded from the website wwww.scilab.in
85
Chapter 7 Shift Registers
Scilab code Exa 7.1 determine number of flip flops needed 1 // Example 7 . 1 2 clc 3 disp ( ” ( i ) A 6− b i t 4 5
6 7
8 9
b i n a r y number r e q u i r e s r e g i s t e r with 6 f l i p −f l o p s . ”) disp ( ” ” ) disp ( ” ( i i ) ( 3 2 ) 1 0 = ( 1 0 0 0 0 0 ) 2 . The number o f b i t s r e q u i r e d t o r e p r e s e n t 32 i n b i n a r y a r e s i x , t h e r e f o r e , 6 f l i p −f l o p s a r e needed to c o n s t r u c t a r e g i s t e r c a p a b l e od s t o r i n g 32 d e c i m a l . ” ) disp ( ” ” ) disp ( ” ( i i i ) ( F ) 1 6 = ( 1 1 1 1 ) 2 . The number o f b i t s r e q u i r e d to r e p r e s e n t (F) 16 in binary are four , t h e r e f o r e f o u r f l i p −f l o p s a r e needed to c o n s t r u c t a r e g i s t e r c apable o f s t o r i n g (F) 16 ”) disp ( ” ” ) disp ( ” ( i v ) ( 1 0 ) 8 = ( 1 0 0 0 ) 2 . The number o f b i t s r e q u i r e d to r e p r e s e n t (10) 8 in binary are four , t h e r e f o r e , f o u r f l i p −f l o p s a r e needed to c o n s t r u c t a r e g i s t e r capable of s t o r i n g (10) 8 . ”)
86
Chapter 8 Counters
Scilab code Exa 8.1 count after 12 pulse 1 // Example 8 . 1 2 clc 3 disp ( ” A f t e r 12 p u l s e s ,
t h e c o u n t w i l l be ( 1 1 0 0 ) 2 , i
. e . 12 i n d e c i m a l . ” )
Scilab code Exa 8.2 count in binary 1 // Example 8 . 2 2 clc 3 a = dec2bin (144) 4 disp (a , ” d e c i m a l ( 1 4 4 ) =” ) 5 disp ( ” S i n c e c o u n t e r i s a 5− b i t c o u n t e r ,
it resets
a f t e r 2ˆ5 = 32 c l o c k p u l s e s . ” ) 6 disp ( ” D i v i d i n g 144 by 32 we g e t q u o t i e n t 2 and remainder 6”) 7 disp ( ” T h e r e f o r e , c o u n t e r r e s e t s f o u r t i m e s and t h e n i t c o u n t s r e m a i n i n g 16 c l o c k p u l s e s . Thus , t h e c o u n t w i l l be b i n a r y ( 1 1 0 0 0 0 ) , i . e . , 16 i n decimal ”) 87
Scilab code Exa 8.4 draw logic diagram 1 // Example 8 . 4 2 clc 3 disp ( ”When f l i p − f l o p s
are negatively the Q output of pre vi ous stage i s the c l o c k input of the next stage . 3− s t a g e a s y n c h r o n o u s c o u n t e r w i t h t r i g g e r e d f l i p −f l o p s . ”)
edge t r i g g e r e d , connected to F i g . 8 . 5 shows n e g a t i v e edge
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.5 output frequency 1 // e x a m p l e 8 . 5 2 clc 3 of =50/14 4 format (5) 5 disp ( of , ” Output f r e q u e n c y = 50 kHz / 14 =” )
Scilab code Exa 8.6 maximum operating frequency 1 // Example 8 . 6 2 clc 3 disp ( ”We know t h a t MOD−32 u s e s
f i v e f l i p − f l o p s . With t p d = 50 ns , t h e f m a x f o r r i p p l e c o u n t e r can be g i v e n as , ” ) 4 fm =(1/(250*10^ -9) ) *10^ -6 88
5
disp ( fm , ” f m a x ( r i p p l e ) = ” )
Scilab code Exa 8.8 design 4 bit up down ripple counter 1 // Example 8 . 8 2 clc 3 disp ( ” The 4− b i t
c o u n t e r n e e d s f o u r f l i p − f l o p s . The c i r c u i t f o r 4− b i t up / down r i p p l e c o u n t e r i s s i m i l a r t o 3− b i t up / down r i p p l e c o u n t e r e x c e p t t h a t 4− b i t c o u n t e r h a s one more f l i p −f l o p and i t s c l o c k d r i v i n g c i r c u i t i n g . ”) 4 disp ( ” The f i g . 8 . 1 4 shows t h e 4− b i t up / down r i p p l e counter . ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.9 design divide by 9 counter 1 // Example 8 . 9 2 clc 3 disp ( ” I n t e r n a l
s t r u c t u r e o f 7 4 9 2 i s a s shown i n f i g . 8 . 1 6 . ”) 4 disp ( ” ” ) 5 disp ( ” The c i r c u i t d i a g r a m f o r d i v i d e −by−9 c o u n t e r i s a s shown i n f i g . 8 . 1 7 . ” )
This code can be downloaded from the website wwww.scilab.in This code
89
can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.10 design a divide by 128 counter 1 // Example 8 . 1 0 2 clc 3 disp ( ” S i n c e 128 = 16 x 8 , a d i v i d e −by −16 c o u n t e r
f o l l o w e d by a d i v i d e −by−8 c o u n t e r w i l l become a d i v i d e −by −128 c o u n t e r . IC 7 4 9 3 i s a 4− b i t b i n a r y c o u n t e r ( i . e . mod−16 o r d i v i d e −by −16) , t h e r e f o r e , two IC p a c k a g e s w i l l be r e q u i r e d . ” ) 4 disp ( ” The c i r c u i t d i a g r a m i s a s shown i n f i g . 8 . 1 8 . ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.11 design divide by 78 counter 1 // Example 8 . 1 1 2 clc 3 disp ( ” S i n c e 78 = 13 x 6 , we have t o u s e 7 4 9 3 a s mod−
a3 and 7 4 9 2 a s mod−6 c o u n t e r s . For t h e mod−13 c o u n t e r QD, QC and QA o u t p u t s o f 7 4 9 3 a n s ANDed and u s e d t o c l e a r t h e c o u n t when t h e c o u n t r e a c h e s 1 1 0 1 . For t h e mod−6 c o u n t e r , c l o c k i s a p p l i e d to B input of 7492. ”) 4 disp ( ” The c i r c u i t d i a g r a m i s a s shown i n t h e f i g . 8.19 ”)
This code can be downloaded from the website wwww.scilab.in
90
Scilab code Exa 8.12 design divide by 6 counter 1 // Example 8 . 1 2 2 clc 3 disp ( ” The f i g . 8 . 2 0 shows d i v i d e d −by−6 (MOD 6 )
c o u n t e r u s i n g 7 4 9 3 . As shown i n t h e f i g . 8 . 2 0 , t h e c l o c k i s a p p l i e d t o i n o u t B o f IC 7 4 9 3 and t h e o u t p u t c o u n t s e q u e n c e i s t a k e n from QD, QC and QB. As s o o n a s c o u n t i s 1 1 0 , i . e . QD and QC = 1 , t h e i n t e r n a l NAND g a t e o u t p u t g o e s low and i t r e s e t s the counter . ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.13 find fmax 1 // Example 8 . 1 3 2 clc 3 disp ( ” For a s y n c h r o n o u s c o u n t e r t h e
4 5 6 7
8 9 10
t o t a l delay that must be a l l o w e d b e t w e e n i n p u t c l o c k p u l s e s i s e q u a l t o f l i p −f l o p t p d + AND g a t e t p d . Thus T c l o c k >= 50 + 20 = 70 n s and s o t h e c o u n t e r h a s ”) fm =(1/(70*10^ -9) ) *10^ -6 format (5) disp ( fm , ” f m a x ( i n MHz) =” ) disp ( ”We know t h a t MOD−16 r i p p l e c o u n t e r u s e d f o u r f l i p − f l o p s . With f l i p −f l o p t p d = 50 ns , t h e f m a x f o r r i p p l e c o u n t e r can be g i v e n as , ” ) fma =(1/(4*(50*10^ -9) ) ) *10^ -6 format (3) disp ( fma , ” f m a x ( r i p p l e ) ( i n MHz) =” )
91
Scilab code Exa 8.14 determine states 1 // Example 8 . 1 4 2 clc 3 disp ( ” IC 7 4 1 9 1
i s a 4− b i t c o u n t e r . Thus i t i s MOD−16 c o u n t e r . However , we r e q u i r e MOD−11 c o u n t e r . The d i f f e r e n c e b e t w e e n 16 and 11 i s 5 . Hence 5 s t e p s must be s k i p p e d from t h e f u l l modulus s e q u e n c e . T h i s can be a c h i e v e d by p r e s e t t i n g c o u n t e r t o v a l u e 5 . Each t i m e when c o u n t e r r e c y c l e s i t s t a r t s c o u n t i n g from 5 u p t o 16 on e a c h f u l l c y c l e . Therefore , each f u l l c y c l e o f the counter c o n s i s t s o f 11 s t a t e s . ” )
Scilab code Exa 8.15 design MOD 10 counter 1 // Example 8 . 1 5 2 clc 3 disp ( ” IC 7 4 1 9 1
i s a 4− b i t c o u n t e r . Thus i t i s MOD−16 c o u n t e r . However , we r e q u i r e MOD−10 c o u n t e r . The d i f f e r e n c e b e t w e e n 16 and 10 i s 6 . Hence 6 s t e p s must be s k i p p e d from t h e f u l l modulus s e q u e n c e . T h i s can be a c h i e v e d by p r e s e t t i n g c o u n t e r t o v a l u e 6 . Each t i m e when c o u n t e r r e c y c l e s i t s t a r t s c o u n t i n g from 6 u p t o 16 on e a c h f u l l c y c l e . Therefore , each f u l l c y c l e o f the counter c o n s i s t s o f 10 s t a t e s . ” )
This code can be downloaded from the website wwww.scilab.in
92
Scilab code Exa 8.16 design down counter 1 // Example 8 . 1 6 2 clc 3 disp ( ” The f i g 8 . 3 6 shows t h e c o n n e c t i o n s
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
f o r 74 LS191 t o g e t d e s i r e o p e r a t i o n . We can d e s i g n t h e c o m b i n a t i o n a l c i r c u i t f o r s u c h c o u n t e r from t h e t r u t h t a b l e shown b e l o w . ” ) disp ( ” ” ) disp ( ”Q3 Q2 Q1 Q0 Y” ) disp ( ” 0 0 0 0 0”) disp ( ” 0 0 0 1 0”) disp ( ” 0 0 1 0 0”) disp ( ” 0 0 1 1 1”) disp ( ” 0 1 0 0 1”) disp ( ” 0 1 0 1 1”) disp ( ” 0 1 1 0 1”) disp ( ” 0 1 1 1 1”) disp ( ” 1 0 0 0 1”) disp ( ” 1 0 0 1 1”) disp ( ” 1 0 1 0 1”) disp ( ” 1 0 1 1 1”) disp ( ” 1 1 0 0 1”) disp ( ” 1 1 0 1 1”) disp ( ” 1 1 1 0 0”) disp ( ” 1 1 1 1 0”) disp ( ” ” ) disp ( ”K=map s i m p l i f i c a t i o n ” ) disp ( ” Q1 ’ ’ Q0 ’ ’ Q1 ’ ’ Q0 Q1Q0 Q1Q0 ’ ’ ” ) disp ( ”Q3 ’ ’ Q2 ’ ’ 0 0 1 0”) disp ( ”Q3 ’ ’ Q2 1 1 1 1”) disp ( ”Q3Q2 1 1 0 0”) disp ( ”Q3Q2 ’ ’ 1 1 1 1”) disp ( ” ” ) disp ( ” T h e r e f o r e , PL ’ ’ = Y = Q3 ’ ’ Q1Q0 + Q3 ’ ’ Q2 + Q3Q1 ’ ’ + Q3Q2 ’ ’ ” ) disp ( ” A f t e r s w i t c h ON, i f t h e c o u n t e r o u t p u t i s o t h e r t h a n 1 1 0 1 t h r o u g h 0 0 1 1 , t h e PL ’ ’ g o e s low 93
and c o u n t 1 1 0 1 i s l o a d e d i n t h e c o u n t e r . The c o u n t e r i s t h e n d e c r e m e n t e d on t h e o c c u r r e n c e o f c l o c k p u l s e s . When c o u n t e r r e a c h e s 0 0 1 0 , t h e PL ’ ’ a g a i n g o e s low and c o u n t 1 1 0 1 i s l o a d e d i n t h e counter ”)
This code can be downloaded from the website wwww.scilab.in This code
can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.17 design programmable frequency divider 1 // Example 8 . 1 7 2 clc 3 disp ( ” The IC 7 4 1 9 1
i s a 4− b i t b i n a r y c o u n t e r , t h e r e f o r e f o u t = f CLK / 16 i n up and down c o u n t e r mode . I f f CLK = 500 Hz and f o u t = 50 Hz we n e e d mod 10 ( 5 0 0 / 5 0 ) c o u n t e r . The f i g . 8 . 3 9 shows t h e mod−10 c o u n t e r u s i n g IC 7 4 1 9 1 ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.18 design a counter 1 // Example 8 . 1 8 2 clc 3 disp ( ” The f i g shows t h e c o n n e c t i o n s
f o r 74 LS191 t o g e t d e s i r e o p e r a t i o n . We can d e s i g n t h e c o m b i n a t i o n a l c i r c u i t f o r s u c h c o u n t e r from t h e t r u t h t a b l e shown b e l o w . ” ) 94
disp ( ” ” ) disp ( ”Q3 Q2 Q1 Q0 Y” ) disp ( ” 0 0 0 0 0”) disp ( ” 0 0 0 1 0”) disp ( ” 0 0 1 0 0”) disp ( ” 0 0 1 1 1”) disp ( ” 0 1 0 0 1”) disp ( ” 0 1 0 1 1”) disp ( ” 0 1 1 0 1”) disp ( ” 0 1 1 1 1”) disp ( ” 1 0 0 0 1”) disp ( ” 1 0 0 1 1”) disp ( ” 1 0 1 0 1”) disp ( ” 1 0 1 1 1”) disp ( ” 1 1 0 0 1”) disp ( ” 1 1 0 1 1”) disp ( ” 1 1 1 0 1”) disp ( ” 1 1 1 1 0”) disp ( ” ” ) disp ( ”K=map s i m p l i f i c a t i o n ” ) disp ( ” Q1 ’ ’ Q0 ’ ’ Q1 ’ ’ Q0 Q1Q0 Q1Q0 ’ ’ ” ) disp ( ”Q3 ’ ’ Q2 ’ ’ 0 0 1 0”) disp ( ”Q3 ’ ’ Q2 1 1 1 1”) disp ( ”Q3Q2 1 1 0 1”) disp ( ”Q3Q2 ’ ’ 1 1 1 1”) disp ( ” ” ) disp ( ” T h e r e f o r e , PL ’ ’ = Y = Q3 ’ ’ Q1Q0 + Q3 ’ ’ Q2 + Q3Q1 ’ ’ + Q3Q2 ’ ’ + Q2Q1Q0 ’ ’ ” ) 31 disp ( ” A f t e r s w i t c h ON, i f t h e c o u n t e r o u t p u t i s o t h e r t h a n 1 1 1 0 t h r o u g h 0 0 1 1 , t h e PL ’ ’ g o e s low and c o u n t 1 1 1 0 i s l o a d e d i n t h e c o u n t e r . The c o u n t e r i s t h e n d e c r e m e n t e d on t h e o c c u r r e n c e o f c l o c k p u l s e s . When c o u n t e r r e a c h e s 0 0 1 0 , t h e PL ’ ’ a g a i n g o e s low and c o u n t 1 1 1 0 i s l o a d e d i n t h e counter ”) 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
95
This code can be downloaded from the website wwww.scilab.in This code
can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.19 programmable frequency divider 1 // Example 8 . 1 9 2 clc 3 disp ( ” IC 7 4 1 9 1
i s a 4− b i t b i n a r y c o u n t e r . Thus i t d i v i d e s t h e i n p u t f r e q u e n c y by 1 6 . However , we can d e s i g n MOD−N c o u n t e r u s i n g IC 7 4 1 9 1 . For MOD− N c o u n t e r t h e o u t p u t f r e q u e n c y w i l l be f o u t = f i n / N . Thus by c h a n g i n g N we can c h a n g e t h e o u t p u t f r e q u e n c y . The f i g . 8 . 4 0 shows t h e programmable f r e q u n c y d i v i d e r u s i n g IC 7 4 1 9 1 . ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.20 design divide by 2 and divide by 5 counter 1 // Example 8 . 2 0 2 clc 3 disp ( ” F i g . 8 . 4 1 shows D i v i d i n g −by−2 f o r up c o u n t i n g ”
) 4 disp ( ” D i v i d e −by−2 i s a mod−2 c o u n t e r . S i n c e , a f t e r p r e s e t above c o u n t e r g o e s through 2 s t a t e s 1110 and 1 1 1 1 , i t i s a mod−2 c o u n t e r . Thus , a b o v e c i r c u i t i s a d i v i d e −by−2 c o u n t e r f o r up c o u n t i n g mode . ” ) 96
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
disp ( ” ” ) disp ( ” D i v i d e −by−5 f o r down c o u n t i n g mode : ” ) disp ( ” ” ) disp ( ”Q3 Q2 Q1 Q0 Y” ) disp ( ” 0 0 0 0 0”) disp ( ” 0 0 0 1 0”) disp ( ” 0 0 1 0 0”) disp ( ” 0 0 1 1 0”) disp ( ” 0 1 0 0 0”) disp ( ” 0 1 0 1 0”) disp ( ” 0 1 1 0 0”) disp ( ” 0 1 1 1 0”) disp ( ” 1 0 0 0 0”) disp ( ” 1 0 0 1 0”) disp ( ” 1 0 1 0 0”) disp ( ” 1 0 1 1 1”) disp ( ” 1 1 0 0 1”) disp ( ” 1 1 0 1 1”) disp ( ” 1 1 1 0 1”) disp ( ” 1 1 1 1 1”) disp ( ” ” ) disp ( ”K=map s i m p l i f i c a t i o n ” ) disp ( ” Q1 ’ ’ Q0 ’ ’ Q1 ’ ’ Q0 Q1Q0 Q1Q0 ’ ’ ” ) disp ( ”Q3 ’ ’ Q2 ’ ’ 0 0 0 0”) disp ( ”Q3 ’ ’ Q2 0 0 0 0”) disp ( ”Q3Q2 1 1 1 1”) disp ( ”Q3Q2 ’ ’ 0 0 1 0”) disp ( ” ” ) disp ( ” T h e r e f o r e , Y = Q3Q2 + Q3Q1Q0” )
This code can be downloaded from the website wwww.scilab.in This code
can be downloaded from the website wwww.scilab.in
97
Scilab code Exa 8.21 design mod 9 counter 1 // Example 8 . 2 1 2 clc 3 disp ( ” IC 7 4 1 9 1
i s a 4− b i t c o u n t e r . Thus i t i s MOD−16 c o u n t e r . However , we r e q u i r e MOD−9 c o u n t e r . The d i f f e r e n c e b e t w e e n 16 and 9 i s 7 . Hence 7 s t e p s must be s k i p p e d from t h e f u l l modulus s e q u e n c e . T h i s can be a c h i e v e d by p r e s e t t i n g c o u n t e r t o v a l u e 7 . Each t i m e when c o u n t e r r e c y c l e s i t s t a r t s c o u n t i n g from 7 u p t o 16 on e a c h f u l l c y c l e . Therefore , each f u l l c y c l e o f the counter c o n s i s t s of 9 s t a t e s . ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.22 determine MOD number and counter range 1 // Example 8 . 2 2 2 clc 3 disp ( ” C l o c k f r e q u e n c y = 256 kHz ” ) 4 disp ( ” Output f r e q u e n c y = 2 kHz ” ) 5 format (4) 6 mn =256/2 7 disp ( mn , ” T h e r e f o r e , Mod number = n =” ) 8 disp ( ” T h e r e f o r e , C o u n t e r i s MOD−128 c o u n t e r ” ) 9 disp ( ”Mod−128 c o u n t e r can c o u n t t h e numbers from 0
to 127. ”)
Scilab code Exa 8.23 design a divide by 20 counter 1
// Example 8 . 2 3 98
2 clc 3 disp ( ” I n t e r n a l 4 5
6 7 8 9 10
s t r u c t u r e o f 7 4 9 0 r i p p l e c o u n t e r IC i s a s shown i n f i g . 8 . 5 0 ” ) disp ( ” ” ) disp ( ”We know t h a t , one IC can work a s mod−10 (BCD) c o u n t e r . T h e r e f o r e , we n e e d two I C s . The c o u n t e r w i l l go t h r o u g h s t a t e s 0−19 and s h o u l d be r e s e t on s t a t e 2 0 . i . e . ” ) disp ( ” QD QC QB QA QD QC QB QA” ) disp ( ” 0 0 1 0 0 0 0 0”) disp ( ” 7490(2) 7490(1) ”) disp ( ” ” ) disp ( ” The d i a g r a m o f d i v i d e −by −20 c o u n t e r u s i n g IC 7 4 9 0 i s a s shown i n f i g . 8 . 5 1 ” )
This code can be downloaded from the website wwww.scilab.in This code
can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.24 design divide by 96 counter 1 // Example 8 . 2 4 2 clc 3 disp ( ” IC 7 4 9 0 i s a d e c a d e c o u n t e r . When two s u c h I C s
a r e c a s c a d e d , i t becomes a d i v i d e −by −100 c o u n t e r . To g e t a d i v i d e −by −96 c o u n t e r , t h e c o u n t e r i s r e s e t a s s o o n a s i t becomes 1 0 0 1 0 1 1 0 . The d i a g r a m i s shown i n f i g . 8 . 5 2 . ” )
This code can be downloaded from the website wwww.scilab.in
99
Scilab code Exa 8.25 design divide by 93 counter 1 // Example 8 . 2 5 . 2 clc 3 disp ( ” IC 7 4 9 0 i s a d e c a d e c o u n t e r . Whentwo s u c h I C s
a r e c a s c a d e d , i t becomes a d i v i d e −by −100 c o u n t e r . To g e t a d i v i d e −by −93 c o u n t e r , t h e c o u n t e r i s r e s e t a s s o o n a s o t becomes 1 0 0 1 0 0 1 1 . The d i a g r a m i s a s shown i n f i g . 8 . 5 3 ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.26 design divide by 78 counter 1 // Example 8 . 2 6 2 clc 3 disp ( ” IC 7 4 9 0 i s a d e c a d e c o u n t e r . When two s u c h I C s
a r e c a s c a d e d , i t becomes a d i v i d e −by −100 c o u n t e r . To g e t a d i v i d e by 78 o r MOD−78 c o u n t e r , t h e c o u n t e r i s r e s e t a s s o o n a s o t becomes 0 1 1 1 1 0 0 0 a s shown i n f i g . 8 . 5 4 ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.28 7490 IC 1 // Example 8 . 2 8 2 clc 3 disp ( ” I f t h e QD o u t p u t
i s connected to A input of 7 4 9 0 IC and , i n p u t c l o c k i s a p p l i e d t o B i n p u t
100
4 5 6 7 8 9 10 11 12 13 14 15
d i v i d e by t e n s q u a r e wave i s o b t a i n e d a t o u t p u t QA. ” ) disp ( ” C l o c k Outputs ” ) disp ( ” QA QD QC QB” ) disp ( ” 0 L L L L” ) disp ( ” 1 L L L H” ) disp ( ” 2 L L H L” ) disp ( ” 3 L L H H” ) disp ( ” 4 L H L L” ) disp ( ” 5 H L L L” ) disp ( ” 6 H L L H” ) disp ( ” 7 H L H L” ) disp ( ” 8 H L H H” ) disp ( ” 9 H H L L” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.30 sketch output waveforms of counter 1 // e x a m p l e 1 0 . 9 2 3 clc ; 4 clear ; 5 close ; 6 c = [0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 7 8 9 10 11
0]; q = [0 0]; a = [0 0]; b = [0 0]; y1 = q ; y2 = a ;
// t a k i n g t h e v a l u e s f o r a mod −6 c o u n t e r 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1
101
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
y3 = b ; y11p =1; y22p =1; y33p =1; y44p =1; cp =1; yf1p =1; for i =1:25 // making a r r a y s t o draw t h e o u t p u t if y1 ( i ) ==1 then for o =1:100 y11 ( y11p ) =1; y11p = y11p +1; end else for o =1:100 y11 ( y11p ) =0; y11p = y11p +1; end end if y2 ( i ) ==1 then for o =1:100 y21 ( y22p ) =1; y22p = y22p +1; end else for o =1:100 y21 ( y22p ) =0; y22p = y22p +1; end end if y3 ( i ) ==1 then for o =1:100 y31 ( y33p ) =1; y33p = y33p +1; end else 102
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
for o =1:100 y31 ( y33p ) =0; y33p = y33p +1; end end if c ( i ) ==1 then for o =1:100 c1 ( cp ) =1; cp = cp +1; end else for o =1:100 c1 ( cp ) =0; cp = cp +1; end end end z =[2 2]; subplot (4 ,1 ,1) ; // p l o t i n g t h e o u t put title ( ’ Timing Diagram ’ ) ; plot ( c1 ) ; plot ( z ) ; ylabel ( ’QA ’ ) ; subplot (4 ,1 ,2) ; plot ( y11 ) ; ylabel ( ’QB ’ ) ; plot ( z ) ; subplot (4 ,1 ,3) ; plot ( y21 ) ; ylabel ( ’QC ’ ) ; plot ( z ) ; subplot (4 ,1 ,4) ; plot ( z ) ; ylabel ( ’QD ’ ) ; plot ( y31 ) ; disp ( ” The c o u n t e r g o e s t h r o u g h s t a t e s 0 0 0 0 ( D e c i m a l 103
Figure 8.1: sketch output waveforms of counter 0 ) t o 1 0 1 1 ( D e c i m a l 1 1 ) , i . e . , t h r o u g h 12 s t a t e s . Thus i t i s a MOD−12 c o u n t e r . ” )
Scilab code Exa 8.31 explain operation of circuit 1 // Example 8 . 3 1 2 clc 3 disp ( ” The f i g . 8 . 6 3 shows t h e c a s c a d e d c o n n e c t i o n o f
4− b i t b i n a r y c o u n t e r s . L e t u s s e e t h e c i r c u i t o p e r a t i o n . The c o u n t e r IC1 o p e r a t e s a s a c o u n t e r f o r c o u n t i o n i n t h e UP d i r e c t i o n s i n c e CLEAR = 104
LOAD = 1 . When t h e c o u n t r e a c h e s t h e maximum v a l u e ( 1 1 1 1 ) i t s RC ( R i p p l e C a r r y Output ) g o e s HIGH which makes P and T ( E n a b l e ) i n p u t s o f IC2 HIGH f o r one c l o c k c y c l e a d v a n c i n g i t s o u t p u t by 1 and making Q o u t p u t s o f IC1 , 0 a t t h e n e x t clock cycle . After this clock cycle P = T = 0 for IC2 and IC1 w i l l go on c o u n t i n g t h e p u l s e s . When t h e o u t p u t s o f IC1 and IC2 b o t h r e a c h t h e maximum count , RC o u t p u t s o f b o t h o f t h e s e I C s w i l l go HIGH . T h i s w i l l make P = T o f IC3 HIGH and t h e r e f o r e , i n t h e n e x t c l o c k c y c l e IC3 c o u n t w i l l be i n c r e m e n t e d and s i m u l t a n e o u s l y IC1 and IC2 w i l l be c l e a r e d . T h i s way t h e c o u n t i n g w i l l continue . ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.32 design divide by 40000 counter 1 // Example 8 . 3 2 2 clc 3 disp ( ” C a s c a d i n g f o u r 7 4 1 6 1 ( e a c h 4− b i t ) c o u n t e r s we
g e t 16 ( 4 x 4 ) b i t c o u n t e r a s shown i n f i g 8 . 6 3 . ” ) 4 disp ( ” T h e r e f o r e , we g e t 2 ˆ 1 6 = 6 5 , 5 3 6 modulus counter ”) 5 disp ( ” However , we r e q u i r e d i v i d e −by −40 ,000 c o u n t e r . The d i f f e r e n c e b e t w e e n 6 5 , 5 3 6 and 4 0 , 0 0 0 i s 2 5 , 5 3 6 , which i s t h e number o f s t a t e s t h o s e must be s k i p p e d from t h e f u l l modulus s e q u e n c e . T h i s can be a c h i e v e d by p r e s e t t i n g t h e c o u n t i n g from 2 5 , 5 3 6 u p t o 6 5 , 5 3 6 on e a c h f u l c y c l e . T h e r e f o r e , each f u l l c y c l e o f the counter c o n s i s t s o f 40 ,000 s t a t e s . ”) 105
Scilab code Exa 8.33 design modulo 11 counter 1 // Example 8 . 3 3 2 clc 3 disp ( ” A l t h o u g h t h e 74 X163 i s a modulo −16 c o u n t e r ,
it can be made t o c o u n t i n a modulus l e s s t h a n 16 by u s i n g t h e CLR’ ’ o r LD ’ ’ i n p u t t o s h o r t e n t h e n o r m a l c o u n t i n g s e q u e n c e . The f i g . 8 . 6 9 shows c i r c u i t c o n n e c t i o n s f o r modulo −11 c o u n t e r . Here , l o a d i n p u t i s a c t i v a t e d upon a c t i v a t i o n o f RCO ( r i p p l e −c a r r y −o u t p u t ) . S i n c e l o a d i n p u t i s a d j u s t e d t o s t a t e 5 , c o u n t e r c o u n t s from 5 t o 15 and t h e n s t a r t s a t 5 a g a i n , f o r a t o t a l o f 11 s t a t e s per counting c y c l e . ”) 4 disp ( ” ” ) 5 disp ( ”We can a l s o d e s i g n modulo −11 c o u n t e r u s i n g CLR ’ ’ i n p u t a s shown i n f i g . 8 . 7 0 . h e r e , NAND g a t e i s u s e d t o d e t e c t s t a t e 10 and f o r c e t h e n e x t s t a t e t o 0 . A 2− i n p u t g a t e i s u s e d t o d e t e c t s t a t e 10 ( b i n a r y 1 0 1 0 ) by c o n n e c t i n g Q1 and Q3 t o t h e i n p u t s o f t h e NAND g a t e . ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.34 design excess 3 decimal counter 1 // Example 8 . 3 4 2 clc 3 disp ( ”An e x c e s s −3 d e c i m a l c o u n t e r s h o u l d
start c o u n t i n g from c o u n t 3 ( b i n a r y 0 0 1 1 ) and c o u n t 106
u p t o c o u n t 12 ( b i n a r y 1 1 0 0 ) . S t a r t i n g c o u n t i s a d j u s t e d by l o a d i n g 0 0 1 1 a t l o a d i n p u t s . To r e c y c l e c o u n t from 1 1 0 0 t o 0 0 1 1 , Q3 and Q2 o u t p u t a r e c o n n e c t e d a s i n p u t s f o r 2− i n p u t NAND g a t e . Thus , NAND g a t e d e t e c t s s t a t e 1 1 0 0 and f o r c e s 0 0 1 1 t o be l o a d e d a s t h e n e x t s t a t e . ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.35 modulus greater than 16 1 // Example 8 . 3 5 2 clc 3 disp ( ”A b i n a r y c o u n t e r w i t h a modulus g r e a t e r t h a n
16 can be b u i l t by c a s c a d i n g 74 X163s . When c o u n t e r s a r e c a s c a d e d , CLK, CLR’ ’ and LD ’ ’ o f a l l t h e 74 X163s a r e c o n n e c t e d i n p a r a l l e l , s o t h a t a l l o f them c o u n t o r a r e c l e a r e d o r l o a d e d a t t h e same t i m e . The RCO s i g n a l d r i v e s t h e ENT i n p u t o f t h e n e x t c o u n t e r . The f i g . 8 . 7 3 shows modulo −60 c o u n t e r . To have a modulo 60 c o u n t we n e e d a t l e a s t 6− b i t c o u n t e r , t h u s two 74 X163s a r e c a s c a d e d . C o u n t e r i s d e s i g n e d t o c o u n t from 196 t o 2 5 5 . The MAXCNT s i g n a l d e t e c t s t h e s t a t e 255 and s t o p s t h e c o u n t e r u t i l GO’ ’ i s a s s e r t e d . When GO’ ’ i s a s s e r t e d t h e c o u n t e r i s r e l o a d e d w i t h 196 ( b i n a r y 1 1 0 0 0 1 0 0 ) and c o u n t s u p t o 2 5 5 . To e n a b l e c o u n t i n g , CNTEN i s c o n n e c t e d t o t h e ENP i n p u t s i n p a r a l l e l . A NAND g a t e a s s e t s RELOAD’ ’ t o g e t back t o s t a t e 196 o n l y i f GO’ ’ i s a s s e r t e d and t h e c o u n t e r i s i n s t a t e 2 5 5 . ” )
107
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.36 modulo 8 counter 1 // Example 8 . 3 6 2 clc 3 disp ( ”A b i n a r y c o u n t e r may be combined w i t h a
d e c o d e r t o o b t a i n a s e t o f 1−out−o f −M c o d e d s i g n a l s , where one s i g n a l i s a s s e r t e d i n e a c h c o u n t s t a t e . T h i s i s u s e f u l when c o u n t e r s a r e u s e d t o c o n t r o l a s e t o f d e v i c e s , where a d i f f e r e n t d e v i c e s i s enabled in each counter s t a t e . ”) 4 disp ( ” The f i g . 8 . 7 4 shows how a 74 X163 c o n n e c t e d a s a modulo −8 c o u n t e r can be combined w i t h a 74 X138 3−8 d e c o d e r t o p r o v i d e e i g h t s i g n a l s , e a c h one r e p r e s e n t i n g a counter s t a t e . ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.37 synchronous decade counter 1 // Example 8 . 3 7 2 clc 3 disp ( ” E x c i t a t i o n t a b l e ” ) 4 disp ( ” P r e s e n t S t a t e
Next S t a t e F l i p −f l o p I n p u t s ” ) 5 disp ( ”QD QC QB QA Q D+1 Q C+1 Q B+1 JK D JK C JK B JK A” )
108
Q A+1
6
disp ( ” 0
7
disp ( ” 0
8
disp ( ” 0
0 0 0 0 0 0
9
disp ( ” 0
0 0
10
disp ( ” 0
1 0
11
disp ( ” 0
12
disp ( ” 0
13
disp ( ” 0
1 0 1 0 1 1
14
disp ( ” 1
0 0
15
disp ( ” 1
16
disp ( ” 1
17
disp ( ” 1
0 1 0 X 0 X
18
disp ( ” 1
1 X
19
disp ( ” 1
1 X
20
disp ( ” 1
21
disp ( ” 1
1 X 1 X
22 23 24 25 26 27
0 0 0 0 1 0 1 1 0 0 0 0 1 0 1 1 0 0 0 0 1 X 1 X 0 X 0 X 1 X 1 X
0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 0 0 X 1 X 0 X 1 X 0 X 1 X
0 1”) 0 1”) 0 1”) 0 1”) 0 1”) 0 1”) 0 1”) 1 1”) 1 1”) 0 1”) X 1”) X 1”) X X” ) X X” ) X X” ) X X” )
0
0
1
0
1
0
0
1
1
1
0
0
1
0
1
1
1
0
1
1
1
0
0
0
0
0
1
0
0
0
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
disp ( ” ” ) disp ( ”K−map S i m p l i f i c a t i o n ” ) disp ( ” For JK D” ) disp ( ” QB’ ’ QA’ ’ QB’ ’QA QBQA disp ( ”QD’ ’ QC’ ’ 0 0 0 disp ( ”QD’ ’QC 0 0 1 109
QBQA’ ’ ” ) 0”) 0”)
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
disp ( ”QDQC X X X X” ) disp ( ”QDQC’ ’ 0 1 X X” ) disp ( ”JK D = QA QD + QA QB QC” ) disp ( ” ” ) disp ( ” For JK C” ) disp ( ” QB’ ’ QA’ ’ QB’ ’QA QBQA QBQA’ ’ ” ) disp ( ”QD’ ’ QC’ ’ 0 0 1 0”) disp ( ”QD’ ’QC 0 0 1 0”) disp ( ”QDQC X X X X” ) disp ( ”QDQC’ ’ 0 0 X X” ) disp ( ”JK C = QA QB” ) disp ( ” ” ) disp ( ” For JK B” ) disp ( ” QB’ ’ QA’ ’ QB’ ’QA QBQA QBQA’ ’ ” ) disp ( ”QD’ ’ QC’ ’ 0 1 1 0”) disp ( ”QD’ ’QC 0 1 1 0”) disp ( ”QDQC X X X X” ) disp ( ”QDQC’ ’ 0 0 X X” ) disp ( ”JK B = QA QD’ ’ ” ) disp ( ” ” ) disp ( ” For JK A” ) disp ( ” QB’ ’ QA’ ’ QB’ ’QA QBQA QBQA’ ’ ” ) disp ( ”QD’ ’ QC’ ’ 1 1 1 1”) disp ( ”QD’ ’QC 1 1 1 1”) disp ( ”QDQC X X X X” ) disp ( ”QDQC’ ’ 1 1 X X” ) disp ( ”JK A = 1 ” ) disp ( ” ” ) disp ( ” F i g shows t h e l o g i c d i a g r a m f o r t h e s y n c h r o n o u s d e c a d e c o u n t e r u s i n g JK f l i p −f l o p ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.38 flip flops 110
1 // Example 8 . 3 8 2 clc 3 disp ( ” E x c i t a t i o n 4 disp ( ” I n p u t 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
t a b l e ”) Present State F l i p −f l o p I n p u t s ” ) disp ( ”UP/DOWN’ ’ QC QB QA JK C JK B JK A” ) Q A+1 disp ( ” UD” ) disp ( ” 0 0 0 0 1 1 1 1”) disp ( ” 0 0 0 1 0 0 0 1”) disp ( ” 0 0 1 0 1 0 1 1”) disp ( ” 0 0 1 1 0 0 0 1”) disp ( ” 0 1 0 0 1 1 1 1”) disp ( ” 0 1 0 1 0 0 0 1”) disp ( ” 0 1 1 0 1 0 1 1”) disp ( ” 0 1 1 1 0 0 0 1”) disp ( ” 1 0 0 0 1 0 0 1”) disp ( ” 1 0 0 1 0 0 1 1”) disp ( ” 1 0 1 0 1 0 0 1”) disp ( ” 1 0 1 1 0 1 1 1”) disp ( ” 1 1 0 0 1 0 0 1”) disp ( ” 1 1 0 1 0 0 1 1”) disp ( ” 1 1 1 0 1 0 0 1”) 111
Next S t a t e Q C+1
Q B+1
1
1
0
0
0
0
0
1
0
1
1
0
1
0
1
1
0
0
0
1
0
1
1
0
1
0
1
1
1
1
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
disp ( ”
1 1 1 1 0 0 0 1 1 1”) disp ( ” ” ) disp ( ”K−map S i m p l i f i c a t i o n ” ) disp ( ” For JK C” ) disp ( ” QB’ ’ QA’ ’ QB’ ’QA QBQA QBQA’ ’ ” ) disp ( ”QD’ ’ QC’ ’ 1 0 0 0”) disp ( ”QD’ ’QC 1 0 0 0”) disp ( ”QDQC 0 0 1 0”) disp ( ”QDQC’ ’ 0 0 1 0”) disp ( ”JK C =UD’ ’ QB’ ’ QB’ ’ + UD QB QA” ) disp ( ” ” ) disp ( ” For JK B” ) disp ( ” QB’ ’ QA’ ’ QB’ ’QA QBQA QBQA’ ’ ” ) disp ( ”QD’ ’ QC’ ’ 1 0 0 1”) disp ( ”QD’ ’QC 1 0 0 1”) disp ( ”QDQC 0 1 1 0”) disp ( ”QDQC’ ’ 0 1 1 0”) disp ( ”TB =UD’ ’ QA’ ’ + UD QA” ) disp ( ” ” ) disp ( ” For JK A” ) disp ( ” QB’ ’ QA’ ’ QB’ ’QA QBQA QBQA’ ’ ” ) disp ( ”QD’ ’ QC’ ’ 1 1 1 1”) disp ( ”QD’ ’QC 1 1 1 1”) disp ( ”QDQC 1 1 1 1”) disp ( ”QDQC’ ’ 1 1 1 1”) disp ( ”TA = 1 ” ) disp ( ” ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.39 design mod 5 synchronous counter 1
// Example 8 . 3 9 112
2 clc 3 disp ( ” For mod−5 c o u n t e r we r e q u i r e 3 f l i p − f l o p s . ” ) 4 disp ( ” E x c i t a t i o n t a b l e ” ) 5 disp ( ” Present State Next S t a t e 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
F l i p −f l o p I n p u t s ” ) QC QB QA TA T B T C” ) 0 0 0 0 0 1”) 0 0 1 0 1 1”) 0 1 0 0 0 1”) 0 1 1 1 1 1”) 1 0 0 1 0 0”)
disp ( ” Q C+1 disp ( ” 0 1 disp ( ” 1 0 disp ( ” 2 1 disp ( ” 3 0 disp ( ” 4 0 disp ( ” ” ) disp ( ”K−map disp ( ” disp ( ”QA’ ’ disp ( ”QA disp ( ”T A = disp ( ” ” ) disp ( ” disp ( ”QA’ ’ disp ( ”QA disp ( ”T B = disp ( ” ” ) disp ( ” disp ( ”QA’ ’ disp ( ”QA disp ( ”T C = disp ( ” ” )
S i m p l i f i c a t i o n ”) QB’ ’ QC’ ’ QB’ ’QC 0 0 1 X QA + QB QC” )
Q A+1
Q B+1
0
0
0
1
0
1
1
0
0
0
QBQC 1 X
QBQC’ ’ ” ) 0”) X” )
QB’ ’ QC’ ’ 0 0 QC” )
QB’ ’QC 1 X
QBQC 1 X
QBQC’ ’ ” ) 0”) X” )
QB’ ’ QC’ ’ 1 0 QA’ ’ ” )
QB’ ’QC 1 X
QBQC 1 X
QBQC’ ’ ” ) 1”) X” )
113
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.40 design MOD 4 down counter 1 // Example 8 . 4 0 2 clc 3 disp ( ” E x c i t a t i o n t a b l e ” ) 4 disp ( ” P r e s e n t S t a t e 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Next S t a t e f l o p Inputs ”) disp ( ” QC QB A+ B+ K B” ) J B disp ( ” 0 0 1 1 1 X” ) disp ( ” 0 1 0 0 X 1”) disp ( ” 1 0 0 1 1 X” ) disp ( ” 1 1 1 0 X 1”) disp ( ” ” ) disp ( ”K−map S i m p l i f i c a t i o n ” ) disp ( ” For J A ” ) disp ( ” B’ ’ B” ) disp ( ”A’ ’ 1 0”) disp ( ”A X X” ) disp ( ” J A = B ’ ’ ” ) disp ( ” ” ) disp ( ” For K A” ) disp ( ” B’ ’ B” ) disp ( ”A’ ’ X X” ) disp ( ”A 1 0”) disp ( ”K A = B ’ ’ ” ) disp ( ” ” ) 114
Flip − J A
KA
1
X
0
X
X
1
X
0
24 25 26 27 28 29 30 31 32 33 34 35
disp ( ” For J B ” ) disp ( ” B’ ’ B” ) disp ( ”A’ ’ 1 X” ) disp ( ”A 1 X” ) disp ( ” J B = 1 ” ) disp ( ” ” ) disp ( ” For K B” ) disp ( ” B’ ’ B” ) disp ( ”A’ ’ X 1”) disp ( ”A X 1”) disp ( ”K B = 1 ” ) disp ( ” ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.41 design MOD 12 synchronous counter 1 // Example 8 . 4 1 2 clc 3 disp ( ”Mod−12 s y n c h r o n o u s c o u n t e r u s i n g D f l i p −f l o p 4 5 6 7 8 9 10 11 12 13 14 15 16
: ”) disp ( ” L e t Number o f f l i p −f l o p r e q u i r e d = n” ) disp ( ” 2ˆ n >= 12 ” ) disp ( ” n = 4”) disp ( ” E x c i t a t i o n t a b l e ” ) disp ( ” P r e s e n t S t a t e Next S t a t e ”) disp ( ”QD QC QB QA Q D+1 Q C+1 Q B+1 Q A+1” ) disp ( ” 0 0 0 0 0 0 0 1”) disp ( ” 0 0 0 1 0 0 1 0”) disp ( ” 0 0 1 0 0 0 1 1”) disp ( ” 0 0 1 1 0 1 0 0”) disp ( ” 0 1 0 0 0 1 0 1”) disp ( ” 0 1 0 1 0 1 1 0”) disp ( ” 0 1 1 0 0 1 1 1”) 115
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
disp ( ” 0 1 1 1 1 0 0 0”) disp ( ” 1 0 0 0 1 0 0 1”) disp ( ” 1 0 0 1 1 0 1 0”) disp ( ” 1 0 1 0 1 0 1 1”) disp ( ” 1 0 1 1 0 0 0 0”) disp ( ” ” ) disp ( ”K−map S i m p l i f i c a t i o n ” ) disp ( ” For D A” ) disp ( ” QB’ ’ QA’ ’ QB’ ’QA QBQA QBQA’ ’ ” ) disp ( ”QD’ ’ QC’ ’ 1 0 0 1”) disp ( ”QD’ ’QC 1 0 0 1”) disp ( ”QDQC X X X X” ) disp ( ”QDQC’ ’ 1 0 0 1”) disp ( ”D A = QA’ ’ ” ) disp ( ” ” ) disp ( ” For D B” ) disp ( ” QB’ ’ QA’ ’ QB’ ’QA QBQA QBQA’ ’ ” ) disp ( ”QD’ ’ QC’ ’ 0 1 0 1”) disp ( ”QD’ ’QC 0 1 0 1”) disp ( ”QDQC X X X X” ) disp ( ”QDQC’ ’ 0 1 0 1”) disp ( ”D B = QB’ ’ QaA + QA’ ’ QB” ) disp ( ” = QA XOR QB” ) disp ( ” ” ) disp ( ” For D C” ) disp ( ” QB’ ’ QA’ ’ QB’ ’QA QBQA QBQA’ ’ ” ) disp ( ”QD’ ’ QC’ ’ 0 0 1 0”) disp ( ”QD’ ’QC 1 1 0 1”) disp ( ”QDQC X X X X” ) disp ( ”QDQC’ ’ 0 0 0 0”) disp ( ”D C = QC QB’ ’ + QC QA’ ’ + QD’ ’ QC’ ’ QB QA” ) disp ( ” ” ) disp ( ” For D D” ) disp ( ” QB’ ’ QA’ ’ QB’ ’QA QBQA QBQA’ ’ ” ) disp ( ”QD’ ’ QC’ ’ 0 0 0 0”) disp ( ”QD’ ’QC 0 0 1 0”) disp ( ”QDQC X X X X” ) disp ( ”QDQC’ ’ 1 1 0 1”) 116
55
disp ( ”D D = QD QB’ ’ + QC QB QA + QD QA’ ’ ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.42 design 4 bit 4 state ring counter 1 // Example 8 . 4 2 2 clc 3 disp ( ” The f i g . 8 . 9 9 shows t h e
c i r c u i t diagram f o r a 4− b i t , 4− s t a t e r i n g c o u n t e r w i t h a s i n g l e c i r c u l a t i n g 1 . Here , 74 X194 u n i v e r s a l s h i f t r e g i s t e r i s connected so that i t normally p r e f o r m s a l e f t − s h i f t . However , when RESET i s a s s e r t e d i t l o a d s 0 0 0 1 . Once RESET i s n e g a t e d , t h e 7 4 1 9 4 s h i f t s l e f t on e a c h c l o c k p u l s e . The D SL s e r i a l i n p u t i s c o n n e c t e d t o t h e l e f t m o s t o u t p u t ( Q3 : MSB) , s o t h e n e x t s t a t e s a r e 0 0 1 0 , 0 1 0 0 , 1 0 0 0 , 0 0 0 1 , 0 0 1 0 , . . . . . Thus t h e c o u n t e r counter v i s i t s four unique s t a t e s b e f o r e r e p e a t i n g . ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.44 design 4 bit 8 state johnson counter 1 // Example 8 . 4 4 2 clc 3 disp ( ” J o h n s o n c o u n t e r
is basically a twisted ring c o u n t e r . The f i g . 8 . 1 0 4 ( a ) shows t h e b a s i c c i r c u i t f o r a J o h n s o n c o u n t e r . The t a b l e shows t h e s t a t e s o f a 4− b i t J o h n s o n c o u n t e r . ” ) 117
4 5 6 7 8 9 10 11 12 13 14 15 16
disp ( ” ” ) disp ( ” S t a t e s o f 4− b i t J o h n s o n c o u n t e r ” ) disp ( ” S t a t e name Q3 Q2 Q1 Q0” ) disp ( ” S1 0 0 0 0”) disp ( ” S2 0 0 0 1”) disp ( ” S3 0 0 1 1”) disp ( ” S4 0 1 1 1”) disp ( ” S5 1 1 1 1”) disp ( ” S6 1 1 1 0”) disp ( ” S7 1 1 0 0”) disp ( ” S8 1 0 0 0”) disp ( ” ” ) disp ( ” T h i s c o u n t e r can be m o d i f i e d t o have s e l f c o r r e c t i n g J o h n s o n c o u n t e r a s shown i n f i g . 8 . 1 0 4 ( c ) . Here , t h e c o n n e c t i o n s a r e made s u c h t h a t c i r c u i t oads 0001 as the next s t a t e whenever the c u r r e n t s t a t e i s 0XX0 . ” )
This code can be downloaded from the website wwww.scilab.in This code
can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.45 johnson counter 1 // Example 8 . 4 5 2 clc 3 disp ( ” J o h n s o n c o u n t e r
w i l l p r o d u c e a modulus o f 2 xn where n i s t h e number o f s t a g e s ( i . e . f l i p − f l o p s ) i n t h e c o u n t e r . T h e r e f o r e , Mod 10 r e q u i r e s 5 f l i p − f l o p s and Mod 16 r e q u i r e s 8 f l i p − f l o p s . ” )
118
Chapter 9 Op amp Applications
Scilab code Exa 9.1 output voltage 1 // Example 9 . 1 2 clc 3 disp ( ” The d i f f e r e n t i a l 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
a m p l i f i e r i s r e p r e s e n t e d as
shown i n f i g . 9 . 5 . ” ) disp ( ” ( i ) CMRR = 100 ” ) vd =300 -240 disp ( vd , ” Vd ( i n uV ) = V1 − V2 = ” ) vc =(300+240) /2 disp ( vc , ” Vc ( i n uV ) = V1+V2 / 2 =” ) disp ( ”CMRR = Ad / Ac” ) ac =5000/100 disp ( ac , ” T h e r e f o r e , Ac =” ) format (6) vo =((5000*60) +(50*270) ) *10^ -3 disp ( vo , ” T h e r e f o r e , Vo ( i n mV) = Ad∗Vd + Ac∗Vc =” ) disp ( ” ( i i ) CMRR = 1 0 ˆ 5 ” ) ac =5000/(10^5) disp ( ac , ” T h e r e f o r e , Ac = Ad / CMRR =” ) vo =((5000*60) +(0.05*270) ) *10^ -3 format (9) disp ( vo , ” T h e r e f o r e , Vo ( i n mV) = Ad∗Vd + Ac∗Vc =” ) 119
21
disp ( ” I d e a l l y Ac must be z e r o and o u t p u t s h o u l d be o n l y Ad∗Vd which i s 5000∗60∗10ˆ −6 i . e . 300 mV. I t can be s e e n t h a t h i g h e r t h e v a l u e o f CMRR, t h e output i s almost p r o p o r t i o n a l to the d i f f e r e n c e v o l t a g e Vd , r e j e c t i n g t h e common mode s i g n a l . So i d e a l v a l u e o f CMRR f o r a d i f f e r e n t i a l a m p l i f i e r i s i n f i n i t y . ”)
Scilab code Exa 9.3 input bias current 1 // Example 9 . 3 2 clc I b = 60 nA” ) 3 disp ( ” I i O S = 20 nA , 4 disp ( ”Now I i O S = I b 1 − I b 2 = 20 ” ) 5 disp ( ” I b = I b 1+I b 2 / 2 = 60 ” ) 6 disp ( ” T h e r e f o r e , I b 1 + I b 2 = 120 ” ) 7 disp ( ” T h e r e f o r e , 2∗ I b 1 = 140 ” ) I b 2 = 50 nA” ) 8 disp ( ” T h e r e f o r e , I b 1 = 70 nA ,
Scilab code Exa 9.4 design inverting schmitt trigger 1 2 3 4 5 6 7 8 9 10 11 12
// Example 9 . 4 clc disp ( ”V UT = +4 V, V LT = −4 V, S u p p l y = +− 15 V” ) disp ( ”+− V s a t = 0 . 9 x [ S u p p l y ] = +− 1 3 . 5 V = Vo” ) disp ( ” For op−amp 7 4 1 , I B ( max ) = 500 nA” ) disp ( ” T h e r e f o r e , I 2 = 100 I B ( max ) = 50 uA” ) r2 =(4/(50*10^ -6) ) *10^ -3 disp ( r2 , ” T h e r e f o r e , R2 ( i n k−ohm ) = V UT / I 2 =” ) i2 =(4/(82*10^3) ) *10^6 format (6) disp ( i2 , ” R e c a l c u l a t i n g I2 , I 2 = V UT / R2 =” ) r1 =((13.5 -4) /(48.78*10^ -6) ) *10^ -3 120
13 14
format (7) disp ( r1 , ” T h e r e f o r e , R1 = Vo−V UT / I 2 = +V s a t −V UT / I 2 =” ) 15 disp ( ” The d e s i g n e d c i r c u i t i s shown i n f i g ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 9.5 threshold voltage 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// Example 9 . 5 clc disp ( ”V CC = +15 V” ) vsat =0.9*15 format (5) disp ( vsat , ” T h e r e f o r e , V s a t ( i n V) = 0 . 9 V CC =” ) disp ( ” R1 = 51 k−ohm , R2 = 120 ohm” ) vut =(13.5*120) /((51*10^3) +120) format (8) disp ( vut , ”V UT ( i n V) = +V s a t ∗R2 / R1+R2 =” ) vlt =( -13.5*120) /((51*10^3) +120) disp ( vlt , ”V LT ( i n V) = −V s a t ∗R2 / R1+R2 =” ) h =(0.03169*2) *10^3 format (6) disp (h , ”H( i n mV) = V UT − V LT =” )
Scilab code Exa 9.6 tripping voltage 1 // Example 9 . 6 2 clc 3 disp ( ” As i n p u t
i s a p p l i e d t o t h e non−i n v e r t i n g t e r m i n a l , t h e c i r c u i t i s non−i n v e r t i n g S c h m i t t t r i g g e r . ”) 121
4 disp ( ” R1 = 100 k−ohm , R2 = 1 k−ohm” ) 5 vut =13.5*(1/100) 6 format (6) 7 disp ( vut , ” T h e r e f o r e , V UT ( i n V) = +V s a t ∗ R2/R1 =”
) 8 vlt = -13.5*(1/100) 9 disp ( vlt , ” T h e r e f o r e , )
V LT ( i n V) = −V s a t ∗ R2/R1 =”
Scilab code Exa 9.8 time duration 1 // Example 9 . 8 2 clc 3 disp ( ”LTP = −1.5 V and H = 2 V” ) 4 disp ( ”Now H = UTP − LTP” ) 5 disp ( ” T h e r e f o r e , 2 = UTP − ( − 1 . 5 ) ” ) 6 disp ( ” T h e r e f o r e , UTP = 0 . 5 V” ) 7 disp ( ” I n t h e f i g . 9 . 4 7 , t h e a n g l e t h e t a can be
8 9 10 11 12 13 14 15 16 17 18 19 20 21
o b t a i n e d from e q u a t i o n o f s i n e wave . S i n e wave i s r e p r e s e n t e d as , ” ) when p i < omega ∗ t disp ( ” V i n = V p ∗ s i n ( p i+t h a t a ) < 2 pi ”) disp ( ” At LTP , −1.5 = 5∗ s i n ( p i+t h e t a ) ” ) disp ( ” = − 5∗ s i n ( t h e t a ) ” ) disp ( ” T h e r e f o r e , s i n ( theta ) = 0 . 3 ”) t = asind (0.3) format (6) disp (t , ” T h e r e f o r e , t h e t a ( i n d e g r e e ) =” ) disp ( ” The t i m e p e r i o d o f s i n e wave i s , ” ) T =1 disp (T , ” T( i n ms ) = 1/ f =” ) disp ( ” At UTP, 0 . 5 = V p∗ s i n ( theta ) ”) disp ( ” T h e r e f o r e , 0 . 5 = 5 ∗ s i n ( t h e t a ) ” ) disp ( ” T h e r e f o r e , s i n ( t h e t a ) = 0 . 1 ” ) t = asind (0.1) 122
22 23 24 25 26 27 28 29 30
disp (t , ” T h e r e f o r e , t h e t a ( i n d e g r e e ) =” ) disp ( ” The t i m e T1 f o r o u t p u t i s from 5 . 7 3 9 d e g r e e t o (180 degree + 17.45 degree ) ”) t1 =197.45 -5.739 format (7) disp ( t1 , ” T h e r e f o r e , T1 ( i n d e g r e e ) =” ) T1 =(191.71/360) disp ( T1 , ” i . e . T1 ( ms ) =” ) t2 =1 -0.5325 disp ( t2 , ” and T2 ( i n ms ) = T − T1 =” )
Scilab code Exa 9.9 calculate R1 and R2 1 // Example 9 . 9 2 clc 3 disp ( ” Given +V s a t = 12 V,
−V s a t = −12 V,
V H = 6 V” ) 4 disp ( ”We know t h a t h y s t e r e s i s w i d t h i s g i v e n a s ” ) 5 disp ( ” V H = ( R2/R1+R2 ) [+ V s a t −V s a t ] ” ) 6 disp ( ” T h e r e f o r e , R2 / R1+R2 = V H / +V s a t −V s a t ” ) 7 r =6/(24) 8 disp (r , ” T h e r e f o r e , R2 / R1+R2 =” ) 9 disp ( ” T h e r e f o r e , R2 = 0 . 2 5 R1 + 0 . 2 5 R2” ) 10 disp ( ” T h e r e f o r e , 0 . 7 5 R2 = 0 . 2 5 R1” ) 11 r2 =0.25/0.75 12 format (7) 13 disp ( r2 , ” T h e r e f o r e , R2 / R1 =” ) 14 disp ( ” Assuming R2 = 10 k−ohm” ) 15 r1 =(10000/0.3333) *10^ -3 16 format (3) 17 disp ( r1 , ” R1 ( i n k−ohm ) =” )
Scilab code Exa 9.10 calculate trip point and hysteresis 123
1 // Example 9 . 1 0 2 clc 3 disp ( ”From f i g 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
9 . 4 5 , R1 = 68 k−ohm , R2 = 1 . 5 k−ohm and V s a t = 1 3 . 5 V” ) vut =(1.5/(1.5+68) ) *13.5 format (7) disp ( vut , ”V UT ( i n V) = R2/R1+R2 ∗ V s a t =” ) vlt =( -1.5/(1.5+68) ) *13.5 disp ( vlt , ”V LT ( i n V) = −R2/R1+R2 ∗ V s a t =” ) h =2*0.2913 disp (h , ” T h e r e f o r e , H( i n V) = V UT − V LT =” ) disp ( ”Now H = ( 2 ∗ R2 / R1+R2 ) ∗ V s a t ” ) disp ( ” For minimum H, R2 must be minimum and R1 must be maximum” ) r2min =((1.5) -(0.05*1.5) ) format (6) disp ( r2min , ” T h e r e f o r e , R2 min ( i n k−ohm ) = R2 − 5%∗ R2 =” ) r2max =((68) +(0.05*68) ) disp ( r2max , ” T h e r e f o r e , R1 max ( i n k−ohm ) = R1 + 5%∗ R1 =” ) hm =((2*1.425) /(71.4+1.425) ) *13.5 disp ( hm , ” T h e r e f o r e , H min ( i n V) =” )
Scilab code Exa 9.11 design schmitt trigger 1 // Example 9 . 1 1 2 clc 3 disp ( ” Choose op−amp LM318 w i t h V s a t a s +− 1 3 . 5 V 4 5 6 7 8
w i t h s u p p l y v o l t a g e +− 15 V” ) disp ( ” V UT = + 5 V” ) disp ( ”Now V UT = ( R2 / R1+R2 ) ∗ V s a t ” ) disp ( ” T h e r e f o r e , 5 = ( R2 / R1+R2 ) ∗ 1 3 . 5 ” ) disp ( ” T h e r e f o r e , R1 + R2 = 2 . 7 ∗ R2” ) disp ( ” T h e r e f o r e , R1 = 1 . 7 ∗ R2” ) 124
9 disp ( ” Choose R2 = 10 k−ohm” ) 10 r1 =1.7*10 11 disp ( r1 , ” T h e r e f o r e , R1 ( i n k−ohm ) =” ) 12 disp ( ” The d e s i g n e d c i r c u i t i s shown i n
f i g . 9 . 4 6 ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 9.12 design op amp schmitt trigger 1 // Example 9 . 1 2 2 clc 3 disp ( ” For t h e S c h m i t t t r i g g e r ” ) V LT = −4 V, 4 disp ( ”V UT = 2 V, 5 6
7 8 9 10 11 12 13 14 15 16 17 18 19 20
+−V s a t = +−10
V” ) disp ( ” For u n e q u a l UTP and LTP v a l u e s , a m o d i f i e d c i r c u i t i s r e q u i r e d a s shown i n t h e f i g . 9 . 5 2 . ” ) disp ( ” The v o l t a g e V1 d e c i d e s t h e UTP and LTP l e v e l s . A p p l y i n g KVL t o t h e o u t p u t c i r c u i t and n e g l e c t i n g op−amp i n p u t c u r r e n t we can w r i t e , ” ) disp ( ”−IR2 − IR1 − x + V0 = 0 ” ) disp ( ” T h e r e f o r e , I = V0−x / R1+R2” ) disp ( ”And V1 = IR1 + x ” ) disp ( ” T h e r e f o r e , V1 = ( V0−x /R1+R2 ) ∗R1 + x ” ) disp ( ” For +V s a t = 10 V, ” ) disp ( ”V1 = V UT = 2 V, ” ) disp ( ”V0 = 10 V” ) disp ( ” T h e r e f o r e , 2 = (10 − x /R1+R2 ) ∗R1 + x ( 1) ”) disp ( ” For −V s a t = −10 V, ” ) disp ( ”V1 = V LT = −4 V, ” ) disp ( ”V0 = −10 V” ) disp ( ” T h e r e f o r e , −4 = (−10−x /R1+R2 ) ∗R1 + x (2) ” ) disp ( ” S u b t r a c t i n g e q u a t i o n s ( 2 ) and ( 1 ) , ” ) disp ( ” T h e r e f o r e , 6 = 20∗ R1 / R1+R2” ) 125
21 disp ( ” T h e r e f o r e , R1+R2 = 3 . 3 3 3 ∗ R1” ) 22 disp ( ” T h e r e f o r e , R2 = 2 . 3 3 3 ∗ R1 ( 3 ) ”) 23 disp ( ” S u b s t i t u t i n g ( 3 ) i n e q u a t i o n ( 1 ) ” ) 24 disp ( ” 2 = ((10 − x ) ∗R1 / 3 . 3 3 3 ∗ R1 ) + x ” ) 25 disp ( ” T h e r e f o r e , 2 . 3 3 3 ∗ x = −3.3334 ” ) 26 x = -3.3334/2.333 27 format (7) 28 disp (x , ” T h e r e f o r e , x =” ) 29 disp ( ” So a c t u a l l y p o l a r i t y o f t h e v o l t a g e s o u r c e
’ ’x ’ ’ must be o p p o s i t e t o what i s assumed e a r l i e r a s shown i n f i g . 9 . 5 2 . ” ) 30 disp ( ” Choose R1 = 1 k−ohm h e n c e R2 = 2 . 3 3 3 k− ohm” ) 31 disp ( ” T h e r e f o r e , R comp = R1 | | R2 = 0 . 7 k−ohm” ) 32 disp ( ”Now a s l o n g a s V i n i s l e s s t h a n V UT , t h e o u t p u t i s a t +V s a t = 10 V and when V i n > V UT , t h e o u t p u t s w i t c h e s from +V s a t t o −V s a t . While a s l o n g a s V i n > V LT , t h e o u t p u t i s a t −V s a t = −10 V and when V i n < V LT , t h e o u t p u t s w i t c h e s from −V s a t t o +V s a t . ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 9.13 VUT and VLT and frequency of oscillation 1 // Example 9 . 1 3 2 clc 3 disp ( ” ( a ) We know t h a t 4 vut =(86*15) /(86+100) 5 format (5) 6 disp ( vut , ” V UT ( i n V) 7 vlt =(86* -15) /(86+100) 8 disp ( ” ( b ) We know t h a t 9 disp ( vlt , ” V LT ( i n V)
, ”)
= R1∗+ V s a t / R1+R2 =” ) , ”) = R1∗− V s a t / R1+R2 =” ) 126
10 disp ( ” ( c ) We know t h a t , ” ) 11 f0 =1/0.02 12 disp ( f0 , ” f 0 ( i n Hz ) = 1 / 2∗ Rf ∗ C i n ∗[+ V s a t −V LT/+
V s a t −V UT ] =” )
Scilab code Exa 9.17 design op amp circuit 1 // Example 9 . 1 7 2 clc 3 disp ( ” The m o n o s t a b l e m u l t i v i b r a t o r
4 5 6 7 8 9 10 11 12 13 14
u s i n g op−amp p r o d u c e s t h e p u l s e waveform . The p u l s e w i d t h i s g i v e n by , ” ) disp ( ” T = RC∗ l n [1+ V D1/ V s a t / 1− b e t a ] ” ) disp ( ” where V D1 = 0 . 7 V, +v s a t = +−12 V f o r op− amp 741 ” ) disp ( ” b e t a = R2 / R1+R2 = 0 . 5 w i t h R1 = R2” ) t =1/(2*10^3) format (6) disp (t , ”T( i n s e c ) = 1/ f ” ) disp ( ” Choose C = 0 . 1 uF” ) disp ( ” T h e r e f o r e , 5∗10ˆ −4 = R∗ 0. 1 ∗ 10 ˆ − 6 ∗ l n [1+(0.7/12) /1 −0.5] ”) disp ( ” T h e r e f o r e , R = 6 . 7 k−ohm” ) disp ( ” Choose R1 = R2 = 10 k−ohm” ) disp ( ” The d e s i g n e d c i r c u i t i s shown i n f i g . 9 . 6 3 ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 9.18 design monostable using IC 555 1 // Example 9 . 1 8 2 clc
127
3 4 5 6 7 8 9 10 11
disp ( ” The r e q u i r e d p u l s e w i d t h i s , ” ) disp ( ” W = 10 ms” ) disp ( ” The p u l s e w i d t h i s g i v e n by , ” ) disp ( ” W = 1 . 1 ∗R∗C” ) disp ( ” T h e r e f o r e , 10∗10ˆ −3 = 1 . 1 ∗R∗C” ) disp ( ” T h e r e f o r e , RC = 9 . 0 9 0 9 ∗ 1 0 ˆ − 3 ” ) disp ( ” Choose C = 0 . 1 uF” ) disp ( ” T h e r e f o r e , R = 9 0 . 9 0 9 k−ohm ˜ 91 k−ohm” ) disp ( ” The d e s i g n e d c i r c u i t i s shown i n f i g . 9 . 7 8 ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 9.19 design a timer 1 // Example 9 . 1 9 2 clc 3 disp ( ” F i g . 9 . 7 9 shows m o n o s t a b l e 4
5 6 7 8
9 10 11 12 13 14
c i r c u i t used to d r i v e the r e l a y . ”) disp ( ” T h i s r e l a y s h o u l d be e n e r g i z e d f o r 5 s e c o n d t o h o l d h e a t e r ’ ’ON’ ’ f o r 5 s e c o n d s . Thus , T ON f o r monostable i s 5 seconds . ”) disp ( ”We know t h a t t h e p u l s e w i d t h i s g i v e n by , ” ) disp ( ” W = 1 . 1 RC” ) disp ( ” T h e r e f o r e , 5 = 1 . 1 RC” ) disp ( ”Now , t h e r e a r e two unknowns . I n t h i s c a s e , we have t o s e l e c t v a l u e f o r c a p a c i t o r and w i t h t h e s e l e c t e d v a l u e we have t o f i n d t h e v a l u e o f r e s i s t a n c e from t h e f o r m u l a . ” ) disp ( ” T h e r e f o r e , I f c a p a c i t o r v a l u e i s 10 uF” ) disp ( ” t h e n 5 = 1 . 1 ∗R∗10 uF” ) r =(5/(1.1*10*10^ -6) ) *10^ -3 format (7) disp (r , ” T h e r e f o r e , R( i n k−ohm ) =” ) disp ( ” The c a l c u l a t e d v a l u e i s n o t s t a n d a r d v a l u e , 128
but we can a d j u s t t h i s v a l u e by c o n n e c t i n g v a r i a b l e r e s i s t a n c e i . e . potentiometer . ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 9.20 draw timer using IC 555 1 // Example 9 . 2 0 2 clc 3 disp ( ” The r e q u i r e m e n t
4 5 6 7 8 9 10 11 12
i s t h a t t h e d o o r must be open f o r 15 s e c a f t e r r e c e i v i n g a t r i g g e r s i g n a l and then g e t s shut door a u t o m a t i c a l l y . This r e q u i r e s IC 555 i n a m o n o s t a b l e mode w i t h a p u l s e w i d t h o f 15 s e c . ” ) disp ( ” T h e r e f o r e , W = 15 s e c ” ) disp ( ”Now W = 1 . 1 RC” ) disp ( ” T h e r e f o r e , 15 = 1 . 1 RC” ) disp ( ” Choose C = 100 uF” ) r =(15/(1.1*100*10^ -6) ) *10^ -3 format (8) disp (r , ” T h e r e f o r e , R( i n k−ohm ) =” ) disp ( ” The d e s i g n e d c i r c u i t i s shown i n t h e f i g . 9 . 8 0 ”) disp ( ” The s u p p l y v o l t a g e 10 o r 15 V h a s no e f f e c t on the operation of the c i r c u i t or the values of R and C s e l e c t e d . ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 9.21 frequency of output and duty cycle
129
1 // / Example 9 . 2 1 2 clc 3 disp ( ” The f r e q u e n c y o f o u t p u t i s g i v e n by , ” ) 4 f =(1.44/(12*0.01*10^ -3) ) *10^ -3 5 format (3) 6 disp (f , ” f ( i n kHz ) = 1 . 4 4 / ( R A+2∗R B ) ∗C =” ) 7 disp ( ” The duty c y c l e i s g i v e n by , ” ) 8 d =8/12 9 format (7) 10 disp (d , ” D = R A+R B / R A+2∗R B =” ) 11 disp ( ” Thus t h e duty c y c l e 6 6 . 6 7%” )
Scilab code Exa 9.26 design astable multivibrator 1 // Example 9 . 2 6 2 clc 3 disp ( ” f = 1 kHz ” ) 4 disp ( ”D = 75% = 0 . 7 5 ” ) 5 disp ( ”Now f = 1 . 4 4 / ( R A+2∗R B ) ∗C” ) 6 disp ( ” T h e r e f o r e , 1 ∗ 1 0 ˆ 3 = 1 . 4 4 / ( R A+2∗R B ) ∗C” ) 7 disp ( ” T h e r e f o r e , ( R A+2∗R B ) ∗C = 1.44 ∗10ˆ −3 8 9 10 11 12 13 14 15 16 17
. . . . ( 1 ) ”) disp ( ” T h e r e f o r e , w h i l e %D = ( ( R A+R B ) / ( R A+2∗R B ) ) ∗ 100 ” ) disp ( ” T h e r e f o r e , 0 . 7 5 = R A+R B / R A+2∗R B” ) disp ( ” T h e r e f o r e , R A+2∗R B = ( R A+R B ) / 0 . 7 5 ” ) disp ( ” T h e r e f o r e , R A+2∗R B = 1 . 3 3 ∗ ( R A+R B ) ” ) disp ( ” T h e r e f o r e , 0 . 6 6 ∗ R B = 0 . 3 3 ∗ R A” ) disp ( ” T h e r e f o r e , R B = 0 . 5 ∗ R A . . . . ( 2 ) ”) disp ( ” Choose C = 0 . 1 uF” ) disp ( ” S u b s t i t u t i n g i n ( 1 ) , ” ) disp ( ” ( R A+2∗R B ) ∗0.1∗10ˆ −6 = 1.44 ∗10ˆ −3 ” ) disp ( ” T h e r e f o r e , R A+2∗R B = 1 4 4 0 0 . . . . ( 3 ) ”) 130
18 disp ( ” S u b s t i t u t i n g ( 2 ) i n ( 3 ) , ” ) 19 disp ( ”R A + 2 ( 0 . 5 ∗ R A ) = 1 4 4 0 0 ” ) 20 ra =(14400/2) *10^ -3 21 format (4) 22 disp ( ra , ” T h e r e f o r e , R A ( i n k−ohm ) =” ) 23 rb =0.5*7.2 24 disp ( rb , ” T h e r e f o r e , R B ( i n k−ohm ) =” ) 25 disp ( ” and C = 0 . 1 uF” ) 26 disp ( ” Hence t h e c i r c u i t d i a g r a m i s a s shown i n
fig
. 9 . 1 0 0 ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 9.27 design astable multivibrator 1 // Example 9 . 2 7 2 clc 3 disp ( ”T ON = 0 . 6 ms , T = 1 ms” ) 4 d =0.6*100 5 disp (d , ” T h e r e f o r e , D( i n p e r c e n t a g e ) = t ON / T =” ) 6 disp ( ”Now D = R A+R B / R A+2∗R B = 0 . 6 ” ) 7 disp ( ” T h e r e f o r e , R A+R B = 0 . 6 ∗ R A + 1 . 2 ∗ R B” ) 8 disp ( ” T h e r e f o r e , 0 . 4 ∗ R B = 0 . 2 ∗ R B” ) 9 disp ( ” T h e r e f o r e , R B = 2∗R A . . . . ( 1 ) ”) 10 disp ( ” f = 1 . 4 4 / ( R A+2∗R B ) ∗C = 1/T = 1 0 0 0 ” 11 12 13 14 15 16 17 18
) disp ( ” Choose C = 0 . 1 uF” ) disp ( ” T h e r e f o r e , R A+2∗R B = 1 4 4 0 0 ” ) disp ( ” U s i n g ( 1 ) , 5∗R A = 1 4 4 0 0 ” ) ra =(14400/5) *10^ -3 format (5) disp ( ra , ” T h e r e f o r e , R A ( i n k−ohm ) =” ) rb =2.88*2 disp ( rb , ” R B ( i n k−ohm ) =” ) 131
19
disp ( ” The c i r c u i t
i s shown i n t h e f i g . 9 . 1 0 1 ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 9.28 design astable mode to generate square wave 1 // Example 9 . 2 8 2 clc 3 disp ( ”T ON = T OFF = 0 . 5 ms” ) 4 disp ( ” T h e r e f o r e , T = T ON + T OFF = 1 ms” ) 5 disp ( ” i . e . f = 1/T = 1 kHz ” ) 6 disp ( ”Now T d = T OFF = 0 . 6 9 ∗ R B∗C” ) 7 disp ( ” Choose C = 0 . 1 uF” ) 8 rb =((0.5*10^ -3) /(0.69*0.1*10^ -6) ) *10^ -3 9 format (6) 10 disp ( rb , ” T h e r e f o r e , R B ( i n k−ohm ) =” ) 11 disp ( ”Now duty c y c l e i s 50% s o R A = R B = 7 . 2 4 6 k− 12
13 14 15 16 17 18 19
ohm” ) disp ( ” P r a c t i c a l l y a m o d i f i e d c i r c u i t i s r e q u i r e d f o r 50% duty c y c l e where d i o d e i s c o n n e c t e d a c r o s s R B and c h a r g i n g t a k e s p l a c e t h r o u g h R A and d i o d e . And R B must be e q u a l t o sum o f R A and d i o d e f o r w a r d r e s i s t a n c e . So t o have p e r f e c t s q u a r e wave , R A i s k e p t v a r i a b l e i . e . p o t o f s a y 10 k−ohm i n t h i s c a s e . I t i s t h e n a d j u s t e d t o o b t a i n p r e c i s e s q u a r e wave . The r e s i s t a n c e r e q u i r e d i n s e r i e s w i t h LED t o be c o n n e c t e d i s , ” ) disp ( ”R = V 0−V LED / I LED ” ) disp ( ” Assuming V LED = 0 . 7 V” ) r =(5 -0.7) /(50*10^ -3) format (3) disp (r , ” C u r r e n t l i m i t i n g R( ohm ) = ” ) disp ( ” The v o l t a g e o f R i s ” ) disp ( ”P = (50∗10ˆ −3) ˆ2 ∗ 100 ” ) 132
20 p = ((50*10^ -3) ^2) *100 21 disp (p , ”P( i n W) =” ) 22 disp ( ” Both r e s i s t o r s R can be o f 1/4 W” ) 23 disp ( ” The r e q u i r e d c i r c u i t i s shown i n t h e
fig .9.102
”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 9.32 define resolution 1 // Example 9 . 3 2 2 clc 3 disp ( ” For t h e g i v e n DAC, ” ) 4 disp ( ” n = Number o f b i t s = 8 ” ) 5 disp ( ” ( i ) R e s o l u t i o n = 2ˆ n = 2ˆ8 = 256 ” ) 6 disp ( ” i . e . t h e o u t p u t v o l t a g e can have 256 d i f f e r e n t
v a l u e s i n c l u d i n g zero . ”) disp ( ” ( i i ) V 0FS = F u l l s c a l e o u t p u t v o l t a g e ” ) disp ( ” = 2 . 5 5 V” ) disp ( ” T h e r e f o r e , R e s o l u t i o n = V 0FS / 2ˆ n − 1 = 2 . 5 5 / 2ˆ8 − 1 = 10mV / 1LSB” ) 10 disp ( ” Thus an i n p u t c h a n g e o f 1LSB c a u s e s t h e o u t p u t t o c h a n g e by 10mV” ) 7 8 9
Scilab code Exa 9.33 output voltage 1 // Example 9 . 3 3 2 clc 3 disp ( ” For g i v e n DAC, ” ) 4 disp ( ” n = 4 ” ) 5 disp ( ” T h e r e f o r e , V 0FS = 15 V” )
133
disp ( ” T h e r e f o r e / LSB” ) 7 disp ( ” T h e r e f o r e 8 disp ( ”Now D = 9 disp ( ” T h e r e f o r e
6
,
R e s o l u t i o n = V 0FS / 2ˆ n − 1 = 1V
, V0 = R e s o l u t i o n ∗ D” ) Decimal o f 0110 = 6”) , V0 = 1V / LSB ∗ 6 = 6 V” )
Scilab code Exa 9.34 find VoFS 1 // Example 9 . 3 4 2 clc 3 disp ( ” R e s o l u t i o n = V 0FS / 2ˆ n − 1 ” ) 4 disp ( ” T h e r e f o r e , 20 = V 0FS / 2ˆ n − 1 ” ) 5 disp ( ” T h e r e f o r e , V 0FS = 5 . 1 V” ) 6 disp ( ” D = E q u i v a l e n t o f 1 0 0 0 0 0 0 0 = 128 ” ) 7 disp ( ” T h e r e f o r e , V0 = R e s o l u t i o n ∗ D = 20 ∗ 128 =
2 . 5 6 V” )
Scilab code Exa 9.35 find out stepsize and analog output 1 // Example 9 . 3 5 2 clc 3 disp ( ” For g i v e n DAC, n = 4 , V 0FS = +5 V” ) 4 disp ( ” R e s o l u t i o n = V 0FS / 2ˆ n − 1 = 1/3 V/LSB” ) 5 disp ( ” T h e r e f o r e , V0 = R e s o l u t i o n ∗ D” ) 6 disp ( ” For D = D e c i m a l od 1 0 0 0 0 = 8 ” ) 7 disp ( ” V0 = 1/3 ∗ 8 = 2 . 6 6 6 7 V” ) 8 disp ( ” For D = D e c i m a l o f 1 1 1 1 = 15 ” ) 9 disp ( ” V0 = 1/3 ∗ 15 = 5 V” )
Scilab code Exa 9.36 find output voltage 134
1 2 3 4 5 6 7 8 9 10 11 12
// Example 9 . 3 6 clc disp ( ” For 12− b i t DAC, s t e p s i z e i s 8 mV” ) v =(8*10^ -3) *((2^12) -1) format (6) disp (v , ” V 0FS = 8 mV ∗ 2 ˆ 1 2 − 1 =” ) r =((8*10^ -3) /32.76) *100 format (8) disp (r , ”% R e s o l u t i o n = 8mV/ 3 2 . 7 6V ∗ 100 =” ) q =(8*10^ -3) *1389 format (7) disp (q , ” The o u t p u t v o l t a g e f o r t h e i n p u t 0 1 0 1 0 1 1 0 1 1 0 1 i s = 8mV ∗ 1 3 8 9 =” )
Scilab code Exa 9.38 find resolution and digital output 1 // Example 9 . 3 8 . 2 clc 3 disp ( ” ( a ) From e q u a t i o n ( 1 ) we have , ” ) 4 r =2^8 5 format (4) 6 disp (r , ” R e s o l u t i o n = 2ˆ8 =” ) 7 disp ( ” and from e q u a t i o n ( 2 ) we have , ” ) 8 disp ( ” R e s o l u t i o n = 5 . 1V/ ( 2 ˆ 8 − 1 ) = 20 mV/LSB” ) 9 disp ( ” T h e r e f o r e , we can s a y t h a t t o c h a n g e o u t p u t by 10 11 12 13 14
1 LSB we have t o c h a n g e disp ( ” ( b ) For 1 . 2 8 V a n a l o g can be c a l c u l a t e d as , ” ) d =1.28/(20*10^ -3) format (3) disp (d , ”D ( i n LSBs ) = 1 . 2 8V disp ( ” The b i n a r y e q u i v a l e n t
135
i n p u t by 20 mV” ) input , d i g i t a l output
/ 20 mV/LSB =” ) o f 64 i s 0 1 0 0 0 0 0 0 ” )
Scilab code Exa 9.39 calculate quantizing error 1 // Example 9 . 3 9 2 clc 3 disp ( ”From e q u a t i o n ( 3 ) we g e t ” ) 4 qe =(4.095/(4095*2) ) *10^3 5 format (4) 6 disp ( qe , ”Q E ( i n mV) = 4 . 0 9 5 / (4096 −1) ∗2 =” )
Scilab code Exa 9.40 dual scope ADC 1 // Example 9 . 4 0 2 clc 3 disp ( ”We know t h a t , ” ) 4 disp ( ” t 2 = ( V1/VR) ∗ t 1 ” ) 5 t2 =83.33 6 format (6) 7 disp ( t2 , ” ( i ) t 2 ( i n ms ) = ( 1 0 0 / 1 0 0 ) ∗ 8 3 . 3 3 =” ) 8 disp ( ” ( i i ) V1 = 200 mV” ) 9 t2 =83.33*2 10 disp ( t2 , ” T h e r e f o r e , t 2 ( i n ms ) = ( 2 0 0 / 1 0 0 ) ∗ 8 3 . 3 3 =” )
Scilab code Exa 9.41 find digital output of ADC 1 // Example 8 . 4 1 2 clc 3 disp ( ” The d i g i t a l o u t p u t i s g i v e n as , ” ) 4 disp ( ” D i g i t a l o u t p u t = ( Counts / S e c o n d ) ∗ t 1 ∗ ( V i /V R ) ” 5 6 7 8
) disp ( ”Now C l o c k f r e q u e n c y = 12 kHz ” ) disp ( ” i . e . = 12000 counts / second ”) d =12000*83.33*(100/100) *10^ -3 format (5) 136
9
disp (d , ” T h e r e f o r e , D i g i t a l output ( in counts ) = 1 2 0 0 0 ∗ 8 3 . 3 3 ∗ ( 1 0 0 / 1 0 0 ) ∗10ˆ −3 =” )
Scilab code Exa 9.42 find conversion time 1 // Example 9 . 4 2 . 2 clc 3 disp ( ” f = 1 MHz” ) 4 disp ( ” T h e r e f o r e , T = 1/ f = 1 / 1 ∗ 1 0 ˆ 6 = 1 u s e c ” ) 5 disp ( ” n = 8”) 6 tc =1*(8+1) 7 format (2) 8 disp ( tc , ” T h e r e f o r e , T C ( i n u s e c ) = T∗ ( n+1) =” )
Scilab code Exa 9.43 find maximum frequency of input sine wave 1 // Example 9 . 4 3 2 clc 3 disp ( ” The maximum f r e q u e n c y i s g i v e n by , ” ) 4 f =1/(2* %pi *(9*10^ -6) *2^8) 5 format (6) 6 disp (f , ” f m a x ( i n Hz ) = 1 / 2∗ p i ∗ ( T C ) ∗2ˆ n =” )
137
Chapter 10 Voltage Regulators
Scilab code Exa 10.1 find line and load regulation and ripple refection 1 // Example 1 0 . 1 2 clc 3 disp ( ” Z Z = 7 ohm , 4 5 6 7 8 9 10 11 12 13 14 15 16 17
R3 = 330 ohm ,
V 0 = 4 . 7 V,
V i n = 15 V” ) disp ( ” The s p e c i f i e d c h a n g e i n V i n i s 10%, ” ) vin =0.1*15 format (4) disp ( vin , ” T h e r e f o r e , d e l t a V i n ( i n V) = 10% o f V i n =” ) vo =(1.5*7) /330 format (8) disp ( vo , ” T h e r e f o r e , d e l t a V 0 ( i n V) = d e l t a V i n ∗ Z Z / R3 =” ) lr =0.03181*100/4.7 format (6) disp ( lr , ” T h e r e f o r e , Line r e g u l a t i o n ( in percentage ) = d e l t a V 0 ∗ 100 / V 0 =” ) disp ( ” For I L ( max ) = 50 mA, ” ) dvo =(20*7*50*10^ -3) /330 format (8) disp ( dvo , ” T h e r e f o r e , d e l t a V 0 ( i n V) = I L ( max ) ∗ R S ∗ 138
18 19 20 21 22 23 24 25 26 27
Z Z / R3 =” ) lr =0.02121*100/4.7 format (7) disp ( lr , ” T h e r e f o r e , Line r e g u l a t i o n ( in precentage ) = d e l t a V 0 ∗ 100 / V 0 =” ) disp ( ”Now V R ( o u t ) = V R ( i n ) ∗ Z Z / R3” ) zz =7/330 format (8) disp ( zz , ” T h e r e f o r e , V R ( o u t ) /V R ( i n ) = Z Z /R3 =” ) rr =20* log10 (0.02121) format (6) disp ( rr , ” T h e r e f o r e , RR( i n dB ) = 20∗ l o g ( 0 . 0 2 1 2 1 ) = ” )
Scilab code Exa 10.2 design op amp series voltage regulator 1 // Example 1 0 . 4 2 clc 3 disp ( ”R1 = 5 k−ohm , R2 = 10 k−ohm” ) 4 disp ( ” The IC i s 7 8 0 8 i . e . V r e g = +8 V” ) 5 vt =8*(3) 6 format (3) 7 disp ( vt , ” T h e r e f o r e , V out ( i n V) = V r e g ∗ [ 1 + R2/R1 ]
=” ) 8 disp ( ”Now R2 = 1 k−ohm then , ” ) 9 vo =8*(1+(1/5) ) 10 format (4) 11 disp ( vo , ” V out ( i n V) = 8 ∗ [ 1 + 1 / 5 ] =” ) 12 disp ( ” Thus t h e V out can be v a r i e d from 9 . 6 V t o 24
V, by v a r i n g R2 from 1 k−ohm t o 10 k−ohm . ” )
Scilab code Exa 10.4 calculate output voltage 139
1 // Example 1 0 . 4 2 clc 3 disp ( ”R1 = 5 k−ohm , R2 = 10 k−ohm” ) 4 disp ( ” The IC i s 7 8 0 8 i . e . V r e g = +8 V” ) 5 vo =8*3 6 format (3) 7 disp ( vo , ” T h e r e f o r e , V out ( i n V) = V r e g ∗ [ 1 + R2/R1 ] 8 9 10 11 12
=” ) disp ( ”Now R2 = 1 k−ohm then , ” ) vou =8*(1+(1/5) ) format (4) disp ( vou , ” V out ( i n V) =” ) disp ( ” Thus t h e V out can be v a r i e d from 9 . 6 V t o 24 V, by v a r i n g R2 from 1 k−ohm t o 10 k−ohm” )
Scilab code Exa 10.7 determine regulated output voltage 1 // Example 1 0 . 7 2 clc 3 disp ( ” The r e s i s t a n c e u s e d a r e , ” ) 4 disp ( ” R1 = 220 ohm and R2 = 1 . 5 k−ohm” ) 5 disp ( ” w h i l e f o r LM 3 1 7 , I ADJ = 100 uA” ) 6 disp ( ” T h e r e f o r e , V 0 = 1 . 2 5 ∗ [ 1 + R2/R1 ] + I ADJ ∗R2” ) 7 vo =(1.25*(1+((1.5*10^3) /220) ) ) +(100*1.5*10^ -3) 8 format (5) 9 disp ( vo , ” T h e r e f o r e , V 0 ( i n V) =” )
Scilab code Exa 10.8 find the range 1 // Example 1 0 . 8 2 clc 3 disp ( ” For LM 3 1 7 , t h e c u r r e n t I ADJ = 100 uA” ) 4 disp ( ”When R2 i s maximum i . e . R2 = 0 then , ” )
140
5 disp ( ” V 0 = 1 . 2 5 ∗ [ 1 + R2/R1 ] + I ADJ ∗R2 = 1 . 2 5 V” ) 6 disp ( ”When R2 i s maximum , i . e . R2 = 10 k−ohm t h e n ” ) 7 vo =(1.25*(1+((10*10^3) /820) ) ) +(100*10*10^ -3) 8 format (6) 9 disp ( vo , ” V 0 ( i n V) = ” ) 10 disp ( ” Thus t h e o u t p u t v o l t a g e can be v a r i e d i n t h e
r a n g e 1 . 2 5 V t o 1 7 . 4 9 V” )
141