Scilab Textbook Companion for Analog And Digital Electronics by U. A. Bakshi And A. P. Godse 1 Created by Priyank Bangar B.Tech Electronics Engineering NMIMS College Teacher No Teacher Cross-Checked by
August 10, 2013
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
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
10
2 Frequency Response
12
3 Feedback Amplifiers
18
4 Oscillators
41
5 Combinational Logic Circuits
60
6 Sequential Logic Circuits
84
7 Shift Registers
86
8 Counters
87
9 Op amp Applications
119
10 Voltage Regulators
138
3
List of Scilab Codes Exa 1.1 Exa 1.2 Exa 2.1 Exa 2.2 Exa 2.3 Exa 2.4 Exa 2.5 Exa 2.6 Exa 2.7 Exa 3.1 Exa 3.2 Exa 3.3 Exa 3.4 Exa 3.5 Exa 3.6 Exa 3.7 Exa 3.8 Exa 3.9 Exa 3.10 Exa 3.11 Exa 3.12 Exa 3.13 Exa 3.14 Exa 3.15 Exa 3.16 Exa 3.17 Exa 3.18 Exa 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
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
10 10 12 12 13 13 14 15 16 18 18 19 20 22 23 25 27 28 29 31 32 34 36 36 37 38 39 40
Exa 4.1 Exa 4.2 Exa 4.3 Exa 4.4 Exa 4.5 Exa 4.6 Exa 4.7 Exa 4.8 Exa 4.9 Exa 4.10 Exa 4.11 Exa 4.12 Exa 4.13 Exa 4.14 Exa 4.15 Exa 4.16 Exa 4.17 Exa 4.18 Exa 4.19 Exa 4.20 Exa 4.21 Exa 4.22 Exa 4.23 Exa 4.24 Exa 4.25 Exa 4.26 Exa 4.27 Exa 5.1 Exa 5.2 Exa 5.3 Exa 5.4 Exa 5.5 Exa 5.6 Exa 5.7 Exa 5.8 Exa 5.9 Exa 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
41 42 42 42 43 44 44 45 45 46 46 47 49 49 50 50 51 51 52 52 53 54 55 55 57 58 58 60 61 62 63 64 65 66 66 67 67
Exa 5.11 Exa 5.12 Exa 5.13 Exa 5.14 Exa 5.15 Exa 5.16 Exa 5.17 Exa 5.18 Exa 5.19 Exa 5.20 Exa 5.21 Exa 5.22 Exa 5.23 Exa 5.24 Exa 5.25 Exa 5.26 Exa 5.27 Exa 5.28 Exa 5.29 Exa 5.31 Exa 6.4 Exa 7.1 Exa 8.1 Exa 8.2 Exa 8.4 Exa 8.5 Exa 8.6 Exa 8.8 Exa 8.9 Exa 8.10 Exa 8.11 Exa 8.12 Exa 8.13 Exa 8.14 Exa 8.15 Exa 8.16 Exa 8.17 Exa 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
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
69 69 70 71 72 72 73 74 74 75 76 77 78 78 79 79 80 81 82 82 84 86 87 87 88 88 88 89 89 90 90 91 91 92 92 93 94 94
Exa 8.19 Exa 8.20 Exa 8.21 Exa 8.22 Exa 8.23 Exa 8.24 Exa 8.25 Exa 8.26 Exa 8.28 Exa 8.30 Exa 8.31 Exa 8.32 Exa 8.33 Exa 8.34 Exa 8.35 Exa 8.36 Exa 8.37 Exa 8.38 Exa 8.39 Exa 8.40 Exa 8.41 Exa 8.42 Exa 8.44 Exa 8.45 Exa 9.1 Exa 9.3 Exa 9.4 Exa 9.5 Exa 9.6 Exa 9.8 Exa 9.9 Exa 9.10 Exa 9.11 Exa 9.12 Exa 9.13 Exa 9.17 Exa 9.18 Exa 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
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
96 96 98 98 98 99 100 100 100 101 104 105 106 106 107 108 108 110 112 114 115 117 117 118 119 120 120 121 121 122 123 123 124 125 126 127 127 128
Exa 9.20 Exa 9.21 Exa 9.26 Exa 9.27 Exa 9.28 Exa 9.32 Exa 9.33 Exa 9.34 Exa 9.35 Exa 9.36 Exa 9.38 Exa 9.39 Exa 9.40 Exa 9.41 Exa 9.42 Exa 9.43 Exa 10.1 Exa 10.2 Exa 10.4 Exa 10.7 Exa 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
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
129 129 130 131 132 133 133 134 134 134 135 136 136 136 137 137 138 139 139 140 140
List of Figures 8.1 sketch output waveforms of counter . . . . . . . . . . . . . .
9
104
Chapter 1 Special Diodes
Scilab code Exa 1.1 current through LED
1 2 3 4 5 6 7 8
/ / E xa mp le 1 . 1
clc format (5) disp ( ” Assume t h e d ro p a c r o s s t h e LED a s 2 V . ” ) disp ( ” T he re fo re , VD = 2 V” ) disp ( ”From f i g . 1 . 1 1 , RS = 2 . 2 k−o h m a n d V S = 1 5 V ” ) i s = ( 1 5 - 2 ) / ( 2 . 2 ) / / i n mA I S (mA) = VS−VD / RS =” ) disp ( i s , ” T h e re fo r e ,
Scilab code Exa 1.2 transition capacitance and constant K
1 2 3 4 5
/ / E xa mp le 1 . 2
6
clc 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 ve n by , ” ) disp ( ” CT = C( 0 ) / [ 1+ |VR/VJ | ˆ n ] ” ) disp ( ”Now C( 0 ) = 80 pF , n = 1/3 a s d i f f u s e d j u n c ti o n ”) VR = 4 . 2 V, VJ = 0 . 7 V” ) disp ( ”
10
7 ct=((80*10^-12)/((1+(4.2/0.7))^(1/3)))*10^12
// i n
pF 8 9 10 11 12 13 14
format (6) disp ( c t , ” T h e r e fo r e , CT( pF ) = ” ) disp ( ” t he t r a n s i s t o r c a pa c it a n c e i s disp ( ” CT = K / [ VR+VJ ] ˆ n ” ) format (10) k=(41.82*10^-12)*((4.2+0.7)^(1/3)) disp (k , ” T h er ef or e , K = ” )
11
a l s o g i v en by , ” )
Chapter 2 Frequency Response
Scilab code Exa 2.1 maximum voltage gain
1 2 3 4
/ / E xa mp le 2 . 1
clc format (7) disp ( ”We know t h a t maximam v o l t a g e g a i n o f v o l t a g e a m p l i f i e r i s g iv en a s ” ) 5 m v = 2 0 0 * sqrt (2) 6 disp ( m v , ” T h e r e fo r e , Maximum v o l t a g e g a i n = Ga in a t cu t − o f f x s q r t ( 2 ) =” )
Scilab code Exa 2.2 gain of the amplifier
1 2 3 4 5 6
/ / E xa mp le 2 . 2
clc format (6) disp ( ”We know tha t , ” ) a = 1 0 0 / sqrt ( 1 + ( ( 1 0 0 0 / 2 0 ) ^ 2 ) ) 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 2 3 4 5
/ / E xa mp le 2 . 3
6 7 8
clc format (7) a = 2 0 0 * sqrt (2) A mid = 3dB g a in x s q r t ( 2 ) disp (a , ”We know t ha t =” ) a m = 2 8 2 . 8 4 / ( sqrt ( 1 + ( ( ( 1 0 / 2 ) ^ 2 ) ) ) ) format (6) A = A mid / s q r t (1+( disp ( a m , ” Above midband : f 1 / f ) ˆ2 ) =” ) // a ns we r i n t ex tb o ok i s wrong
Scilab code Exa 2.4 low frequency response of the amplifier
1 2 3 4
/ / E xa mp le 2 . 4 clc format (6) disp ( ” I t i s
n e c e s s a r y t o a n al y ze e a ch n et w o r k t o d e te r m in e t h e c r i t i c a l f r e q u e n c y o f t h e a m p l i f i e r ”) 5 disp ( ” ( a ) I n p ut RC n e tw o rk ” ) 6 fc1=1/(2*%pi*[680+1031.7]*(0.1*10^-6)) 7 disp ( f c 1 , ” f c ( i n p u t ) ( i n Hz ) = 1 / 2 ∗ p i ∗ [RS+( R1 | | R2 | | h ie ) ] C1 =” ) // i n Hz 8 disp ( ” ( b ) O ut pu t RC n e tw o r k ” ) 9 format (7) 10 f c 2 = 1 / ( 2 * % p i * ( ( 2 . 2 + 1 0 ) * 1 0 ^ 3 ) * ( 0 . 1 * 1 0 ^ - 6 ) ) 11 disp ( f c 2 , ” f c ( o u t p u t ) ( i n Hz ) = 1 / 2 ∗ p i ∗ (RC+ RL) ∗C2 =” ) // i n Hz 12 disp ( ” ( c ) B y p as s RC n e t w o r k ” )
13
13 r t h = ( ( 6 8 * 2 2 * 0 . 6 8 0 ) / ( ( 2 2 * 0 . 6 8 0 ) + ( 6 8 * 0 . 6 8 0 ) + ( 6 8 * 2 2 ) )) *10^3 14 disp ( r t h , ” R t h ( i n ohm ) = R1 | | R2 | | RS =” ) 15 format (6) 16 f c 3 = 1 / ( 2 * % p i * 1 7 . 2 3 * 1 0 * 1 0 ^ - 6 ) 17 disp ( f c 3 , ” f c ( b y p a s s ) ( i n Hz ) = 1 / 2 ∗ p i ∗ [ ( R t h+ h i e / b e t a ) | | RE] ∗CE” ) 18 disp ( ”We h av e 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 en 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 pu t ) = 1 3 0 . 4 5 Hz ” ) 21 disp ( ” ( c ) f c ( b y p a s s ) = 9 2 3 . 7 Hz ” )
Scilab code Exa 2.5 low frequency response of the FET amplifier
1 / / E xa mp le 2 . 5 2 clc 3 disp ( ” I t i s n e c e s s a r y t o a n al y ze e a ch n et w o r k t o
d e te r m in e t h e c r i t i c a l f r e q u e n c y o f t h e a m p l i f i e r ”) 4 disp ( ” ( a ) I n p ut RC N et wo rk ” ) 5 disp ( ” f c = 1 / 2∗ p i ∗ R i n ∗C1” ) 6 format (6) 7 rin=(100*100)/(100+100) 8 disp ( r i n , ” wher e R i n ( i n M−ohm) = RG | | R i n ( g a t e ) = RG | | | VGS/IGSS | =” ) 9 format (5) 10 f c 1 = 1 / ( 2 * % p i * 5 0 * 1 0 ^ 6 * 0 . 0 0 1 * 1 0 ^ - 6 ) 11 disp ( f c 1 , ” T h e r e fo r e , f c ( i n Hz ) =” ) 12 disp ( ” ( b ) O ut pu t RC N et wo rk ” ) 13 format (6) 14 f c 2 = 1 / ( 2 * % p i * ( 2 4 . 2 * 1 0 ^ 3 ) * ( 1 * 1 0 ^ - 6 ) ) 15 disp ( f c 2 , ” f c ( i n Hz ) = 1 / 2 ∗ p i ∗ (RD+RL ) ∗C2 =” ) 16 disp ( ”We h av e 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 ” ) 17 disp ( ” ( a ) f c ( i n p u t ) = 3 . 1 8 Hz” )
14
18 disp ( ” ( b ) f c ( o u t pu p u t ) = 6 . 5 7 7 Hz ” )
Scilab code Exa 2.6 high frequency response of the amplifier
1 / / E xa x a mp m p le le 2 . 6 2 clc 3 disp ( ” B e f o r e c a l c u l a t i n g
cri tica l frequencies it is n e c e s s a r y t o c a l c u l a t e m i d f re r e q u e n cy c y g ai a i n o f t he he g iv i v en e n c i r c u i t . T h i s i s r e q u i r e d t o c a l c u l a t e C in in ( m i l l e r ) a n d C o ut ut ( m i l l e r ) ” ) 4 disp ( ” Av = − h f e ∗ R o / R i ” ) 5 disp ( ” wh w h e r e R i = h i e | | R1 | | R2” R2 ” ) 6 disp ( ” a n d Ro = RC | | RL” ) 7 format ( 6 ) 8 av=(-100*1.8)/1.032 9 disp ( a v , ” T h e re r e fo f o r e , Av = − h f e (RC (RC | | RL ) / h i e | | R1 | R1 | | | R2 | R2 =” ) 10 disp ( ” N eg e g at a t iv i v e s i g n i n d i c a t e s 1 8 0 d eg e g re re e s h i f t b et e t we w e en e n i n p u t a n d o u t pu pu t ” ) 11 format ( 7 ) 12 c i n = ( 4 * ( 1 7 4 . 4 + 1 ) ) * 1 0 ^ - 3 / / i n nF nF 13 disp ( c i n , ” C in i n ( m i l l e r ) ( i n nF ) = C bc b c ∗ (Av+1) =” ) 14 c o u t = ( 4 * 1 7 5 . 4 ) / ( 1 7 4 . 4 ) / / i n pF pF 15 format ( 4 ) 16 disp ( c o u t , ” C oou u t ( m i l l e r ) ( i n pF ) = C bc b c ∗ (Av+ (Av+1) 1) / Av =” ) 17 disp ( ”We no now a n a l y z e i n p u t a n d o u tp t p ut u t n et e t wo w o rk rk f o r c r i t i c a l fr eq ue nc y . ” ) 18 format ( 8 ) 19 f c i = ( 1 / ( 2 * % p i * 4 1 0 * 0 . 7 2 1 6 * 1 0 ^ - 9 ) ) * 1 0 ^ - 3 / / i n kH k Hz 20 disp ( f c i , ” f c ( i np n p ut u t ) ( i n k H z ) = 1 / 2 ∗ p i ∗ ( Rs | Rs | | R1 | R1 e+ C i n ( m i l l e r ) ) =” ) | | R2 | R2 | | | h i e ) ∗ ( C b e+ 21 format ( 5 ) 22 f c o = ( 1 / ( 2 * % p i * ( ( 2 2 * 1 0 ^ 6 ) / ( 1 2 . 2 * 1 0 ^ 3 ) ) * ( 4 * 1 0 ^ - 1 2 ) ) ) * 1 0 ^ - 6 / / i n MH MHz
15
23 disp ( f c o , ”
f c ( o ut u t pu 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 h a ve v e c a l c u l a t e d b o th th t h e c r i t i c a l freque ncies ”) 25 disp ( ” ( a ) f c ( i n p u t ) = 5 3 7 . 9 4 7 k H z ” ) 26 disp ( ” ( b ) f c ( o u t p u t ) = 2 2 . 1 MHz” )
Scilab code Exa 2.7 high frequency response of the amplifier
1 / / E xa x a mp m p le le 2 . 7 2 clc 3 disp ( ” B e f o r e c a l c u l a t i n g
cri tica l frequencies it is n e c e s s a r y t o c a l c u l a t e m i d f re r e q u e n cy c y g ai a i n o f t he he g iv i v en en a m p l i f i e r c i r c u i t . T h i s i s r e q u i r e d t o 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 ) ” ) 4 disp ( ” Av = −gm ∗ RD” ) 5 disp ( ” H er er e , RD s h o u l d b r r e p l a c e d b y RD RD | | RL” ) 6 7 8 9
10 11 12 13 14 15 16 17 18 19
av=-6*2 disp ( a v , ” T h e r e f o r e , Av = −gm∗ gm ∗ (RD| (RD | | RL) =” ) pF c i n = 2 * ( 1 2 + 1 ) / / i n pF disp ( c i n , ” C i n ( m i l l e r ) ( i n pF ) = C g d ∗ ( A v + 1 ) = C r s s ∗ (Av+1) =” ) format ( 6 ) c o u t = ( 2 * 1 3 ) / 1 2 / / i n pF pF Av +1 +1 ) / Av = disp ( c o u t , ” C o u t ( m i l l e r ) ( i n pF ) = C g d ∗ ( Av ”) disp ( ” G g s = C i s s − C r s s = 4 p F ” ) disp ( ”We k n o w a n a l y z e i n p u t a n d o u tp t p u t n et e t wo wo r k f o r c r i t i c a l fr eq ue nc y ” ) disp ( ” f c ( i n p u t ) = 1 / 2 ∗ p i ∗ RS∗ RS ∗CT” ) = 1 / 2 ∗ p i ∗ RS ∗ [ C g s+ s+ C i n ( m i l l e r disp ( ” ) ] ”) format ( 4 ) MHz f c 1 = ( 1 / ( 2 * % p i * 1 0 0 * 3 0 * 1 0 ^ - 1 2 ) ) * 1 0 ^ - 6 / / i n MH disp ( f c 1 , ” f c ( i n p u t ) ( i n MHz ) = ” )
16
20 f c 2 = ( 1 / ( 2 * % p i * ( ( 4 8 . 4 * 1 0 ^ 6 ) / ( 2 4 . 2 * 1 0 ^ 3 ) ) * ( 2 . 1 6 6 * 1 0 ^ - 1 2 ) ) ) * 1 0 ^ - 6 / / i n MH MHz 21 format ( 6 ) 22 disp ( f c 2 , ” f c ( o ut u t pu 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 h a ve v e c a l c u l a t e d b o th th t h e c r i t i c a l f r e q u en c i e s : ”) 24 disp ( ” ( a ) f c ( i n p u t ) = 5 3 MHz” ) 25 disp ( ” ( b ) f c ( o u t p u t ) = 3 6 . 7 4 MHz” )
17
Chapter 3 Feedback Amplifiers
Scilab code Exa 3.1 gain fL and fH
1 2 3 4 5 6 7 8
/ / E xa mp le 3 . 1
9 10
clc disp ( ” ( a ) Gain w it h f e ed b a ck ” ) format (5) av=1000/(1+(0.05*1000)) AV mid = Av mid / 1+ b e t a ∗ Av mid =” ) disp ( a v , ” f l f = 5 0 / ( 1 + ( 0 . 0 5 * 1 0 0 0 ) ) // i n Hz f L f ( i n Hz ) = f L / 1+ b e t a ∗ Av mid disp ( f l f , ” (b ) =” ) f h f = ( ( 5 0 * 1 0 ^ 3 ) * ( 1 + ( 0 . 0 5 * 1 0 0 0 ) ) ) * 1 0 ^ - 6 / / i n MHz f H f ( i n MHz) = f H ∗ ( 1 + b e t a ∗ disp ( f h f , ” ( c ) Av mid) =” )
Scilab code Exa 3.2 Vo and second harmonic distortion with feedback
1 / / E xa mp le 3 . 2 2 clc 3 disp ( ” ( a ) b et a :
−4 0 = 2 0∗ l o g [ 1+ b e t a ∗A ] ” ) 18
disp ( ” T h e r e fo r e , 1+ be t a ∗A = 1 0 0 ” ) b=99/1000 format (6) disp (b , ” Th e r e f o r e , b e t a =” ) disp ( ” Gain o f t h e a m p l i f i e r w i t h f ee db a c k i s g iv en as ”) 9 avf=1000/100 10 disp ( a v f , ” A Vf = A V / 1+ b e t a ∗A V =” ) 11 disp ( ” ( b ) To m a in t ai n o ut p ut p ower 1 0 W, we s h o ul d 4 5 6 7 8
12 13 14 15 16
m a in ta in o ut pu t v o l t a g e c o n st a n t and t o m a in ta i n o ut pu t c o n s ta n t w i th f ee db a ck g a i n r e q u i r e d Vs i s ”) v s f = 1 0 * 1 0 0 * 1 0 ^ - 3 // i n V V s f ( i n V) = Vs ∗ 1 0 0 = ” ) disp ( v s f , ” disp ( ” ( c ) S eco nd h ar mo ni c d i s t o r t i o n i s r ed uc ed by f a c t o r 1 + b et a ∗A” ) d 2 f = ( 0 . 1 / 1 0 0 ) * 1 0 0 // i n p e rc e nt a ge D 2 f ( i n p er c en ta ge ) = D 2 / 1+ b e t a ∗A disp ( d 2 f , ” =” )
Scilab code Exa 3.3 beta and Af
1 2 3 4 5 6 7 8 9 10
/ / E xa mp le 3 . 3
clc disp ( ” ( a ) We know t h a t ” ) disp ( ” dAf / Af = 0 . 1 / 1 + b e t a ∗A ∗ dA/A” ) disp ( ” T h e r e fo r e , 1+ be t a ∗A = 3 7 . 5 ” ) b = ( 3 6 . 5 / 2 0 0 0 ) * 1 0 0 // i n p e rc e nt a ge format (6) disp (b , ” T h e r e fo r e , b e ta ( i n p e r c e n t a g e ) =” ) af=2000/(1+(0.01825*2000)) disp ( a f , ” ( 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 2 3 4
/ / E xa mp le 3 . 4 clc disp ( ” S t e p 1 : I d e n t i t y t o p o l og y ” ) disp ( ” The f e e db ac k v o l t a g e i s a p p l i e d a c r o s s t h e
5 6 7
8 9 10 11 12 13 14 15 16 17 18 19 20
21 22 23 24
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 ee db ac k i s v o l t a g e s e r i e s f ee db ac k .”) disp ( ” ” ) disp ( ” S te p 2 and S te p 3 : Fi nd i n pu t and o ut pu t ci rc ui 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 ec t i ng C2 t o g ro un d ) , wh ich g i v e s p a r a l l e l c om bi na ti o n o f Re w it h Rf a t E1 . To f i n d o ut pu t c i r c u i t , s e t I i = 0 ( o pe n in g t h e i np ut node E1 a t e m i tt e r o f Q1 ) , whi ch g i v e s s e r i e s c om bi na ti on o f Rf and Re1 a c r o s s t he o ut pu 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 te p 4 : Find open l o o p v o l t a g e g a i n ( A v ) ” ) format (5) r l 2 = ( 4 . 7 * 1 0 . 1 ) / ( 4 . 7 + 1 0 . 1 ) // i n k−ohm disp ( r l 2 , ” R L2 ( i n k−o h m ) = R c 2 | | ( R e 1+Rf ) =” ) A i 2 = −h f e = −100” ) disp ( ” disp ( ” R i 2 = h i e = 11 0 0 ohm” ) format (7) av2=(-100*3.21*10^3)/1100 disp ( a v 2 , ” A v2 = A i 2 ∗ R L2 / R i 2 =” ) disp ( ” A i 1 = −h f e = −100” ) format (5) r l 1 = ( 2 2 * 2 2 0 * 2 2 * 1 . 1 0 0 ) / ( ( 2 2 0 * 2 2 * 1 . 1 0 0 ) + ( 2 2 * 2 2 * 1 . 1 0 0) + ( 2 2 * 2 2 0 * 1 . 1 0 0 ) + ( 2 2 * 2 2 0 * 2 2 ) ) / / i n ohm disp ( r l 1 * 1 0 ^ 3 , ” R L1 ( i n ohm ) = R c1 | | R3 | | R4 | | R i2 =”) r i 1 = 1 . 1 + ( 1 0 1 * ( ( 0 . 1 * 1 0 ) / ( 0 . 1 + 1 0 ) ) ) // i n k−ohm format (5) R i 1 ( i n k−ohm ) = h i e + (1+ h f e ) ∗ R e 1 e f f = disp ( r i 1 , ”
20
w he re R e 1 e f f = ( R e 1 | | R f ) ” ) 25 a v 1 = ( - 1 0 0 * 9 9 5 ) / ( 1 1 . 0 9 9 * 1 0 ^ 3 ) 26 disp ( a v 1 , ” T h er ef or e , A v1 = A i 1 ∗RL1 / R i 1 =” ) 27 disp ( ” The o v e r a l l v o l t ag e g a i n w it ho ut f ee d b a c k i s given as , ”) 28 a v = - 2 9 1 . 8 2 * - 8 . 9 6 29 format (7) 30 disp ( a v , ” Av = A v1 ∗ A v 2 = ” ) 31 disp ( ” The o v e r a l l v o l t ag e g a i n t a ki n g Rs i n a cc ou nt i s g i ve n as , ” ) 32 a V = ( 2 6 1 4 . 7 * 1 1 . 0 9 9 * 1 0 ^ 3 ) / ( ( 1 1 . 0 9 9 * 1 0 ^ 3 ) + 1 0 0 ) 33 format (8) 34 disp ( a V , ” Av = Vo / Vs = Av∗ R i 1 / R i 1 +Rs =” ) 35 disp ( ” ” ) 36 disp ( ” S te p 5 : C a l c u l a t e b et a ” ) 37 disp ( ” L oo ki ng a t F ig . 3 . 3 3 . ” ) 38 b e t a = 1 0 0 / ( 1 0 0 + ( 1 0 * 1 0 ^ 3 ) ) 39 format (7) 40 disp ( b e t a , ” b e ta = Vf / Vo =” ) 41 d = 1 + ( 0 . 0 0 9 9 * 2 5 9 1 . 3 5 ) 42 format (6) 43 disp (d , ” D = 1 + b e t a ∗Av =” ) 44 a v f = 2 5 9 1 . 3 5 / 2 6 . 6 5 45 disp ( a v f , ” A v f = Av/D =” ) 46 r i f = 2 6 . 6 5 * 1 1 . 0 9 9 // i n k−ohm 47 format (8) 48 disp ( r i f , ” R i f ( i n k−o h m ) = R i 1 ∗ D =” ) 49 r i f f = ( 2 9 5 . 7 8 8 * 2 2 0 * 2 2 ) / ( ( 2 2 0 * 2 2 ) + ( 2 9 5 . 7 8 8 * 2 2 ) + ( 2 9 5 . 7 8 8 * 2 2 0 ) ) // i n k−ohm 50 format (6) 51 disp ( r i f f , ” R’ ’ i f ( i n k−o h m ) = R i f | | R1 | | R2 =” ) 52 disp ( ” R of = Ro / D = i n f i n i t y / D = i n f i n i t y ” ) 53 disp ( ” T h e r e f o r e , R’ ’ o f = R ’ ’ o / D wh ere R ’ ’ o = R L2 ” ) 54 r o f f = ( 3 . 2 1 * 1 0 ^ 3 ) / 2 6 . 6 5 / / i n omh 55 format (7) 56 disp ( r o f f , ” T h e r e fo r e , R ’ ’ o f ( i n ohm ) = ” )
21
Scilab code Exa 3.5 Avf and Rif and Rof
1 2 3 4
/ / E xa mp le 3 . 5 clc disp ( ” S t e p 1 : I d e n t i t y t o p o l og y ” ) disp ( ” The f ee db ac k v o lt a g e i s a p pl i ed a c r o s s R1
5 6 7
8 9 10 11 12 13 14 15 16 17 18 19 20 21
( 10 0 ohm ) , wh ich i s i n s e r i e s w it h i n p ut s i g n a l . Hence f ee db a ck i s v o l t a g e s e r i e s f ee db a ck . ” ) disp ( ” ” ) disp ( ” S te p 2 and S te p 3 : Fi nd i n pu t and o ut pu t c i r c u i t ”) disp ( ” To f i n d i np ut c i r c u i t , s e t Vo = 0 , wh ich g i v e s p a r a l l e l c om bi na ti on 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 ut p u t c i r c u i t , s e t I i = 0 b y o pe ni ng t he i np ut node , E1 a t e m i t t e r o f Q1 , whi ch g i v e s t he s e r i e s c om bi na ti on o f R2 a nd R1 a c r o s s t he o ut pu 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 te p 4 : Find t he open l o o p v o l t a g e g a i n ( Av ) ” ) r l 2 = ( 4 . 7 * 4 . 8 ) / ( 4 . 7 + 4 . 8 ) // i n k−ohm
format (5) disp ( r l 2 , ” R L2 ( i n k−ohm) =” ) h o e = h r e = 0 we can u s e a pp ro x i ma te disp ( ” S i nc e a n a l y s i s ”) A i 2 = −h f e = −50 ” ) disp ( ” R i 2 = h i e = 1 . 1 k−ohm” ) disp ( ” av2=(-50*2.37)/1.1 format (7) disp ( a v 2 , ” A v2 = A i 2 ∗ R L2 / R i 2 =” ) rl1=(10*47*33*1.1)/((47*33*1.1)+(10*33*1.1) + ( 1 0 * 4 7 * 1 . 1 ) + ( 1 0 * 4 7 * 3 3 ) ) / / i n ohm format (5) disp ( r l 1 * 1 0 ^ 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
A i 1 = −h f e = −50 ” ) disp ( ” r i 1 = 1 . 1 + ( 5 1 * ( ( 0 . 1 * 4 . 7 ) / ( 4 . 8 ) ) ) // i n k−ohm format (6) disp ( r i 1 , ” 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 ( a v 1 , ” A v1 = A i 1 ∗ R L1 / R i 1 =” ) av=-7.73*-107.73 format (7) disp ( a v , ” T h er ef or e , A v = A v1 ∗ A v 2 = ” ) disp ( ” ” ) disp ( ” S te p 5 : C a l c u l a te b et a and D” ) disp ( ” b e t a = R1 / R1+R2 = 1/ 48 ” ) d = 1 + ( 8 3 2 . 7 5 / 4 8 ) / / i n ohm format (6) disp (d , ” D( i n ohm ) = 1 + A∗ b e t a = ” ) disp ( ” ” ) disp ( ” S te p 5 : C a l c u l a t e A vf , R of and R i f ” ) avf=832.75/18.35 A v f = A v / D =” ) disp ( a v f , ” r i f = 6 . 0 9 3 * 1 8 . 3 5 // i n k−ohm R i f ( i n k−o h m ) = R i 1 ∗ D =” ) disp ( r i f , ” r o f = ( 2 . 3 7 * 1 0 ^ 3 ) / 1 8 . 3 5 / / i n ohm format (7) R o f ( i n ohm ) = R o / D =” ) disp ( r o f , ”
Scilab code Exa 3.6 Avf and Rif and Rof
1 2 3 4
/ / E xa mp le 3 . 6 clc disp ( ” S t e p 1 : I d e n t i f y t o p ol o g y ” ) disp ( ” The f e e db ac 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 , wh ich i s i n s e r i e s w i t h i np ut s i g n a l . Hence f ee db a c k i s v o l t a g e s e r i e s f ee db ac k ” ) 5 disp ( ” ” ) 23
6 disp ( ” S te t e p 2 a n d s t ep e p 3 : F i n d i n p ut u t a n d o ut u t p ut ut c i r c u i t ”) 7 disp ( ” To f i n d i np n p ut u t c i r c u i t , s e t Vo = 0 , w h i c h
g i v e s p a r a l l e l c om o m bi b i na n a ti t i on o n o f R e 1 w i t h R f a t E1 E1 a s s h o w n i n f i g . 3 . 4 7 . To f i n d o u p u t c i r c u i t , s e t I i = 0 b y o pe p e ni n i ng n g t he h e i np n p u t n o d e , E1 a t e m i t t e r o f Q1 Q1 , w h i c h g i v e s t he h e s e r i e s c o mb m b in i n at a t io io n o f R f a n d R e 1 a c r o s s t he h e o ut u t pu 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 ” ) 8 disp ( ” ” ) 9 disp ( ” S te t e p 4 : F i n d t he h e o p e n l o o p v o l t a g e g a i n ( Av Av ) ” ) 10 r l 2 = ( 2 . 2 * 5 7 . 5 ) / ( 2 . 2 + 5 7 . 5 ) / / i n k−ohm 11 format ( 6 ) 12 disp ( r l 2 , ” R L 2 ( i n k−o h m ) = R c 2 | | ( R f + R e 1 ) =” ) 13 disp ( ” S i n c e h o e∗ e ∗ R L 2 = 1 0 ˆ − 6 ∗ 2 .1 . 1 19 1 9 k−o h m = 0 . 0 0 2 1 1 9 i s l e s s t h a n 0 . 1 we u se s e a pp p p ro ro x xii ma m a te te a n a l y s i s . ” ) 14 disp ( ” A i 2 = − h f e = − 200” ) 15 disp ( ” R i 2 = h i e = 2 k− k−ohm” ) 16 a v 2 = ( - 2 0 0 * 2 . 1 1 9 ) / 2 17 disp ( a v 2 , ” A v 2 = A i 2 ∗ R L 2 / R i 2 =” ) 18 r l 1 = ( 1 2 0 * 2 ) / ( 1 2 2 ) / / i n k− k−ohm 19 disp ( r l 1 , ” R L 1 ( i n k−ohm) = R C1 C1 | | R i 2 =” =” ) 20 disp ( ” S i n c e h o e∗ e ∗ R L 1 = 1 0 ˆ − 6 ∗ 1 .9 . 9 6677 = 0 . 0 0 19 19 6 7 i s l e s s t ha h a n 0 . 1 we u se s e a pp p p ro r o xi x i ma m a te te a n a l y s i s . ”) 21 disp ( ” A i 1 = − h f e = − 200” ) 22 r i 1 = 2 + ( 2 0 1 * ( ( 1 . 5 * 5 6 ) / ( 5 7 . 5 ) ) ) / / i n k− k−ohm 23 format ( 7 ) 24 disp ( r i 1 , ” R i 1 ( i n k−ohm ) = h i e + ( 1 + h f e ) ∗ Re =” ) 25 a v 1 = ( - 2 0 0 * 1 . 9 6 7 ) / 2 9 5 . 6 3 26 format ( 5 ) 27 disp ( a v 1 , ” T h er e r ef e f or o r e , A v 1 = A i 1 ∗ R L 1 / R i 1 =” =” ) 28 disp ( ” T h e o v e r a l l g a i n w it i t ho h o ut u t f ee ee db ac k i s ” ) 29 a v = - 1 . 3 3 * - 2 1 1 . 9 30 format ( 7 ) 31 disp ( a v , ” Av = A v 1 ∗ A v 2 = ” ) 32 disp ( ” ” ) 33 disp ( ” S te t e p 5 : C a l c u l a t e b et et a ” ) 34 b e t a = 1 . 5 / 5 7 . 5
24
format ( 6 ) disp ( b e t a , ” b e ta t a = Vf Vf / Vo V o =” ) disp ( ” ” ) disp ( ” S t e p 6 : c a l c u l a t e D , A v f , R i f , R of of ” ) d=1+(0.026*281.82) disp ( d , ” D = 1 + Av ∗ b e t a = ” ) avf=281.82/8.327 disp ( a v f , ” T h er e r e fo fo r e , A vf v f = Av Av / D =” ) r i = ( 2 9 5 . 6 3 * 1 5 0 ) / ( 2 9 5 . 6 3 + 1 5 0 ) / / i n k−ohm format ( 5 ) disp ( r i , ” R i ( i n k−o h m ) = R i 1 | | R =” ) r i f = 9 9 . 5 * 8 . 3 2 7 / / i n k−ohm format ( 7 ) R i f ( i n k−o h m ) = R i ∗D =” ) disp ( r i f , ” disp ( ” Ro = 1/ 1 / ho h o e = 1 M−ohm” ) k−ohm r o f = ( ( 1 * 1 0 ^ 6 ) / 8 . 3 2 7 ) * 1 0 ^ - 3 / / i n k− format ( 4 ) R of o f ( i n k−ohm ) = Ro R o / D =” =” ) disp ( r o f , ” r o = ( 1 0 0 0 * 2 . 1 1 9 ) / ( 2 . 1 1 9 + 1 0 0 0 ) / / i n k−ohm format ( 7 ) disp ( r o , ” R ’ ’ o ( i n k−ohm) = Ro | | R c 2 | | ( Rf+ Rf+R e1 ) = Ro | | R L2 =” ) 56 r o f = ( 2 . 1 1 4 5 * 1 0 ^ 3 ) / 8 . 3 2 7 / / i n ohm 57 format ( 4 ) 58 disp ( r o f , ” R ’ ’ o f ( i n ohm ) = R’ R ’ ’ o / D =” =” ) 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
Scilab code Exa 3.7 D and Avf and Rif and Rof
1 2 3 4
/ / E xa x a mp m p le le 3 . 7 clc og y ”) disp ( ” S t e p 1 : I d e n t i t y t o p o l og disp ( ” By s h o r t i n g o ut u t p ut u t v o l t a g e ( Vo Vo = 0 ) ,
f ee e e d b a c k v o l t a g e V f b e c o m e s z e ro r o a n d h en e n ce ce i t i s v o l t a g e s am a m pl p l in i n g . T h e f ee ee db ac k v o l t ag e i s a a p l i ed i n s e r i e s w i t h i np n p ut u t v o l t a g e h e n c e t h e t op op ol og y 25
5 6 7
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
i s v o l t a g e s e r i e s f ee e e db db a c k . ” ) disp ( ” ” ) t e p 2 a n d S te t e p 3 : F i nd n d i n pu p u t a n d o ut u t pu pu t disp ( ” S te ci rc ui t . ”) p u t c i r c u i t , s e t Vo = 0 . T h i s disp ( ” To f i n d i n pu p l a c es e s t h e p a r a l l e l c o m b i n a ti ti o n o f r e s i s t o r 1 0 K a n d 2 00 0 0 ohm a t f i r s t s o u r c e . To f i n d o ut u t pu pu t c i rc u i t , s et I i = 0 . This p l a ce s t h e r e s i s t o r 10 K an a n d 2 0 0 ohm i n s e r i e s a c r o s s t he h e o ut u t pu p u t . Th e 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 ( ” ” ) t e p 4 : R ep e p la l a ce c e FE FET wi w i th th i t s e q u i v a l e n t disp ( ” S te c i r c u i t a s shown i n f i g . 3 . 5 1 ” ) disp ( ” ” ) disp ( ” S te te p 5 : F i n d o p e n l o o p t r a n s f e r g a i n . ” ) disp ( ” Av = Vo / V s = A v 1 ∗ A v 2 ” ) disp ( ” A v 2 = −u ∗ R L2 L 2 / R L2 L 2+ r d ” ) r l 2 = ( 1 0 . 2 * 4 7 ) / ( 1 0 . 2 + 4 7 ) / / i n k−ohm
format ( 5 ) w h e r e R L 2 ( i n k−ohm) ohm) =” ) disp ( r l 2 , ” wh av2=(-40*8.38)/(8.38+10) format ( 7 ) disp ( a v 2 , ” T h er e r e fo f o r e , A v 2 =” =” ) disp ( ” A v 1 = u ∗ R D e f f / r d +R +R D e f f +( +(1+ u ) ∗ R s e f f ” ) r d e f f = ( 4 7 * 1 0 0 0 ) / ( 4 7 + 1 0 0 0 ) / / i n k−ohm format ( 6 ) h e r e R D ef e f f ( i n k−ohm ) = R D | | R G2 =” disp ( r d e f f , ” w he ) 24 disp ( ” R s e f f = 2 0 0 | | 10 K” ) 25 a v 1 = ( - 4 0 * 4 4 . 9 8 * 1 0 ^ 3 ) / ( ( 1 0 * 1 0 ^ 3 ) + ( 4 4 . 8 9 * 1 0 ^ 3 ) +(41*((10*0.2)/(10.2)))) 26 disp ( a v 1 , ” A v 1 =” ) / / a ns n s w e r i n t ex e x tb t b oo oo k i s
wrong 27 28 29 30 31
oav=-28.59*-18.237 format ( 7 ) e r e fo fo r e , O v e r al a l l Av =” ) disp ( o a v , ” T h er disp ( ” ” ) t e p 6 : C a l c u l a t e b et et a ” ) disp ( ” S te
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 ( b e t a , ” b e ta = Vf / Vo =” ) disp ( ” ” ) disp ( ” S te 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 A vf = Av / D =” ) disp ( a v f , ” disp ( ” Ri = R G = 1 M−ohm” ) rif=11.22 R i f ( i n M−o h m ) = R i ∗ D =” ) disp ( r i f , ” disp ( ” Ro = r d = 10 k−ohm” ) r o = ( 1 0 * 8 . 3 8 ) / ( 1 8 . 3 8 ) // i n k−ohm disp ( r o , ” R ’ ’ o ( i n k−o h m ) = r d | | R L2 =” ) r o f = ( 4 . 5 5 9 * 1 0 ^ 3 ) / 1 1 . 2 2 / / i n ohm format (4) disp ( r o f , ” R ’ ’ o f ( i n ohm ) = R’ ’ o / D =” )
Scilab code Exa 3.8 voltage gain
1 / / E xa mp le 3 . 8 2 clc 3 disp ( ” Here , o ut pu t v o l t a g e
i s s am pl ed and f e d i n s e r i e s w i th t he i n p ut s i g n a l . Hence t he t o p o lo g y i s v o l t a g e s e r i e s f ee db a c k . ” ) 4 disp ( ” The open l oo p v o l t a g e g ai n f o r on e s t a g e i s given as , ”) 5 disp ( ” Av = −gm∗ R e q ” ) 6 r e q = ( 8 * 4 0 * 1 0 0 0 ) / ( ( 4 0 * 1 0 0 0 ) + ( 8 * 1 0 0 0 ) + ( 8 * 4 0 ) ) // i n k −ohm 7 format (5) 8 disp ( r e q , ” ) =” ) 9 av=-5*6.62
R eq ( i n k−o h m ) = r d
27
| | R d | | ( R i1+R 2
10 11 12 13
format (6) disp ( a v , ” Av =” ) avm=-33.11^3 disp ( a v m , ”Av = O v e r a l l v o l t a g e g a in = | A vmid | ˆ 3 = ” )
// a ns we r i n t ex tb o ok i s wrong 14 b e t a = 5 0 / ( 1 0 ^ 6 ) 15 format (7) 16 disp ( b e t a , ” b e t a = Vf / Vo = −R 1 / R g = −R 1 / R 1+R 2 =” ) 17 d = 1 + ( ( - 5 * 1 0 ^ - 5 ) * - 3 6 3 0 6 ) 18 format (6) 19 disp (d , ” D = 1 + | Av | ∗ b e t a =” ) 20 a v f = - 3 6 3 0 6 / 2 . 8 1 5 3 21 disp ( a v f , ” A vf = Av / D =” )
Scilab code Exa 3.9 Avf
1 / / E xa mp le 3 . 9 2 clc 3 disp ( ” Here , o ut p ut t e r m i n a l s a r e B a nd g ro un d , t h us t h e f or wa rd g ai n i s t he g ai n o f Q1 a nd i t i s , ” ) 4 disp ( ” A BN = −3 3 . 1 1 ” ) 5 disp ( ” However , Q2 and Q3 must b e c o n s i d e r e d a s a p a r t o f f ee db a ck l o o p ” ) 6 disp ( ” Her e beta BN = V f / V B = V f / V o ∗ V o / V C ∗ V C/V B” ) 7 disp ( ” wh ere V B and V C a r e v o l t a g e s a t p o in t B a nd C, r e s p e c t i v e l y . ” ) 8 disp ( ” T h e re fo 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 ”) 9 bbn=-(5*10^-5)*(33.11^2) 10 format (7) 11 disp ( b b n , ” T h er e fo r e , beta BN = −R1/R g ∗ A v3 ∗ A v2 =” )
28
12 disp ( ” N Noo t e t ha h a t t he h e l o o p g a i n − b e t a B N ∗ A BN = Aˆ3 V o ∗ R1/Rg = − 1 . 8 1 5 = −A∗ b e t a ” ) 13 disp ( ” I t s ho h o ul u l d b e c l e a r t ht h t r e g a r d l e s s o fw f w he h e re re t h e
o ut u t pu pu t t e r m i n a l s a r e t a k kee n , t he he l oo p g ai n i s unch ange d . ” ) 14 a v f = - 3 3 . 1 1 / 2 . 8 1 5 15 format ( 6 ) 16 disp ( a v f , ” T h e r e fo fo r e ,
A v f = A BN / 1+A∗ b e t a = ” )
Scilab code Exa 3.10 Avf and Rif and Rof
1 / / E x am am pl pl e 3 . 1 0 2 disp ( ” S t e p 1 : I d e n t i f y t o p ol ol og y ”) 3 disp ( ” By s h o r t i n g o ut u t p ut u t v o l t a g e ( Vo Vo = 0 ) ,
4 5 6
7 8 9 10 11 12 13
f ee e e d b a c k v o l t a g e V f b e c o m e s z e ro r o a n d h en e n ce ce i t i s v o l t a g e s am a m pl p l in i n g . T h e f ee e e d b a c k v o l t a g e i s a p p li li e d i n s e r i e s w i t h t h e i np n p ut u t v o lt l t a g e h e n c e t he he t o p o lo l o g y i s v o l t a g e s e r i e s f ee ee db ac k . ” ) disp ( ” ” ) t e p 2 a n d S te t e p 3 : F i nd n d i n pu p u t a n d o ut u t pu pu t disp ( ” S te ci rc ui t . ”) p u t c i r c u i t , s e t Vo = 0 . T h i s disp ( ” To f i n d i n pu p l a c es e s t h e p a r a l l e l c o m b i n a ti ti o n o f r e s i s t o r 1 0 K a n d 3 00 0 0 ohm a t f i r s t s o u r c e . To f i n d o ut u t pu pu 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 1 0K a n d 3 0 0 ohm i n s e r i e s a c r o s s t he h e o ut u t pu 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 ( ” ” ) t e p 4 : R ep e p la l a ce c e FE FET wi w i th th i t s e q u i v a l e n t disp ( ” S te c i r c u i t a s shown i n f i g . 3 . 5 5 . ” ) disp ( ” ” ) disp ( ” S te te p 5 : F i n d o p e n l o o p t r a n s f e r g a i n . ” ) disp ( ” Av = Vo / V s = A v 1 ∗ A v 2 ” ) L 2 / R L2 L 2+ r d ” ) disp ( ” A v 2 = −u ∗ R L2 r l 2 = ( 1 0 . 3 * 2 2 ) / ( 1 0 . 3 + 2 2 ) / / i n k−ohm 29
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
format ( 3 ) disp ( r l 2 , ” wh w h e r e R L 2 ( i n k−ohm) ohm) =” ) av2=(-50*7)/17 format ( 6 ) disp ( a v 2 , ” A v 2 =” ) disp ( ” A v 1 = u ∗ R D e f f / r d +R +R D e f f +( +(1+ u ) ∗ R s e f f ” ) r d e f f = ( 2 2 * 1 0 0 0 ) / ( 2 2 + 1 0 0 0 ) / / i n k−ohm disp ( r d e f f , ” R D e f f ( i n k−ohm ) = R D | | R G2 =” ) R s e f f = 3 3 0 | | 10K” ) disp ( ” a v 1 = ( - 5 0 * 2 1 . 5 3 ) / ( 1 0 + 2 1 . 5 3 + ( 5 1 * ( ( 0 . 3 3 * 1 0 ) / ( 1 0 + 0 . 3 3 )) ) ) e r e fo f o r e , A v 1 =” =” ) disp ( a v 1 , ” T h er av=-20.59*-22.51 O v e r a l l Av Av = A v 1 ∗ A v 2 = ” ) disp ( a v , ” disp ( ” ” ) t e p 6 : C a l c u l a t e b et et a ” ) disp ( ” S te beta=330/(330+10000) format ( 7 ) disp ( b e t a , ” b e ta t a = V f / Vo = Rs Rs / R s+R f =” =” ) disp ( ” ” ) disp ( ” s t ep e p 7 : C a l c u l a t e D , A vf 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 ( a v f , ” A vf v f = Av / D =” ) R i = R G = 1 M−ohm” ) disp ( ” Ri rif=15.785 format ( 7 ) disp ( r i f , ” R i f ( i n k−o h m ) = R i ∗ D =” ) r o = ( 1 0 * 7 ) / ( 1 0 + 7 ) / / i n k−ohm format ( 6 ) disp ( r o , ” R ’ ’ o ( i n k−o h m ) = r d | | R L2 =” ) r o f = ( 4 . 1 1 8 * 1 0 ^ 3 ) / 1 5 . 7 8 5 / / i n ohm format ( 4 ) R ’ ’ o / D =” =” ) disp ( r o f , ” R ’ ’ o f ( i n ohm ) = R’
30
Scilab code Exa 3.11 voltage gain and input and output resistance
1 2 3 4
/ / E x am am pl pl e 3 . 1 1 clc ol og y ”) disp ( ” S t e p 1 : I d e n t i f y t o p ol disp ( ” T h e f e e db d b ac ac k v o l t a g e i s a p p l i ed a c r o s s t h e
5 6 7
8 9 10 11 12 13 14 15 16 17 18 19 20
r e s i s t a n c e R e 1 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 . H e n c e f ee e e db d b ac a c k i s v o l t a g e s e r i e s f ee e e db d b ac ac k .”) disp ( ” ” ) t e p 3 : F i nd n d i n pu p u t a n d o ut u t pu pu t disp ( ” s t e p 2 a n d S te ci rc ui 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 ro r o un u n d ) , w hi h i ch ch g i v e s p a r l l e l c om o m bi b i na n a ti t i o n o f Re w iitt h R f a t E1 E 1 . To f i n d o ut u t pu pu t c i r u i t , s e t I i = 0 ( o pe p e n in i n g t he h e i np n p ut u t n o d e E1 a t e m i t t e r o f Q1 ) , w h i c h g i v e s s e r i e s c oom m bi b i na n a ti t i on o n od R f a n d R e 1 a c r o s s t he h e o ut u t pu 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 te t e p 4 : F i n d o p e n l o o p v o l t a g e g a i n ( Av ) ” ) r l 2 = ( 4 . 7 * 3 . 4 2 ) / ( 4 . 7 + 3 . 4 2 ) / / i n k−ohm
format ( 5 ) Rs+R) =” ) disp ( r l 2 , ” R L 2 ( i n k−o h m ) = R c 2 | | ( Rs+ disp ( ” A i 2 = − h f e = −50 ” ) 0 0 0 ohm = 1 k−ohm” ) disp ( ” R i 2 = h i e = 1 00 av2=-50*1.98 format ( 3 ) disp ( a v 2 , ” A v 2 = A i 2 ∗ R L 2 / R i 2 =” ) disp ( ” A i 1 = − h f e = −50 ” ) format ( 7 ) rl1=((10*100*22*1)/((100*22)+(10*22)+(10*100) + ( 1 0 * 1 0 0 * 2 2 ) ) ) * 1 0 ^ 3 / / i n ohm 21 disp ( r l 1 , ” R L 1 ( i n ohm ) = R c1 c 1 | | R3 | | R4 | | R i 2
31
=” ) 22 disp ( ”
R i 1 = h i e + (1+ h f e ) ∗ R e 1 e f f ” ) 23 r e 1 = 1 + ( 5 1 * ( ( 3 . 3 * 0 . 1 2 ) / ( 3 . 4 2 ) ) ) // i n k−ohm 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
format (4) R e 1 e f f ( i n k−ohm) = Rs | | R =” ) disp ( r e 1 , ” wher e av1=(-50*865.46)/6900 format (5) disp ( a v 1 , ” 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 ai n , ” ) av=-6.27*-99 format (7) disp ( a v , ” Av = A v1 ∗ A v 2 = ” ) disp ( ” ” ) disp ( ” S te p 5 : C a l c u l a t e b et a ” ) beta=120/(120+3300) format (6) disp ( b e t a , ” b e ta = Vf / Vo = Rs / Rs+R =” ) disp ( ” ” ) disp ( ” S te p 6 : C a l c u l a t e D, A vf , R i f , R of and R ’ ’ of ”) 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 ( a v f , ” A vf = Av / D =” ) r i f = 6 . 9 * 2 2 . 7 2 5 // i n k−ohm format (6) R i f ( i n k−o h m ) = R i 1 ∗ D =” ) disp ( r i f , ” disp ( ” R of = Ro / D = i n f i n i t y ” ) r o f = ( 1 . 9 8 * 1 0 ^ 3 ) / 2 2 . 7 2 5 / / i n ohm disp ( r o f , ” R ’ ’ o f ( i n ohm ) = R’ ’ o / D = R L2 / D =” )
Scilab code Exa 3.12 Ai and beta and Aif
32
1 2 3 4
/ / E x am pl e 3 . 1 2 clc disp ( ” S t e p 1 : I d e n t i f y t o p ol o g y ” ) disp ( ” The f e eb da ck i s g i v en fro m e m i t te r o f Q2 t o
5 6 7
8 9 10 11 12 13 14 15 16 17 18
t h e b a se o f Q2 . I f I o = 0 t h e n f ee db 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 ur re nt s am pl in g . As f ee d b a c k s i g n a l i s mixed i n s hu nt w i t h i n p u t , t h e a m p l i f i e r i s c u rr e n t s h u n t f e ed b ac k a m p l i f i e r . ” ) disp ( ” ” ) disp ( ” S te p 2 and S te p 3 : Fi nd i n p ut and o ut p ut ” ) disp ( ” The i np 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 ee d b a c k i s o b ta i ne d by o pe ni ng t he o ut pu t l o o p a t t he e m i t t e r o f Q2 ( I o = 0 ) . T h is p l a c e s R ’ ’ ( 5 K ) i n s e r i e s w i t h Re f rom b as e t o e m i t te r o f Q1 . The o ut p u t c i r c u i t i s f o u n d by s h o rt i n g t he i np ut node , i . e . making Vi = 0 . T hi 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 ai n . ” ) A I = I o / I s = −I c / I b 2 ∗ I b 2 / I c 1 ∗ I c 1 / disp ( ” I b 1 ∗ I b1 / Is ”) disp ( ”We know th at − I c 2 / I b 2 = A i2 = −h f e = −50 and” ) disp ( ” − I c 1 / I b 1 = A i1 = −h f e = 5 0 ” ) I c 1 / I b 1 = 50 ” ) disp ( ” disp ( ” L oo ki ng a t f i g . 3 . 5 9 we ca n w ri te , ” ) I b 2 / I c 1 = −R c1 / R c1+R i 2 ” ) disp ( ” r i 2 = 1 . 5 + ( 5 1 * ( ( 5 * 0 . 5 ) / ( 5 . 5 ) ) ) // i n k−ohm
format (8) disp ( r i 2 , ” wher e
R i 2 ( i n k−ohm ) = h i e + (1+ h f e ) ∗ (
R e2 | | R ’ ’ ) =” ) 19 x 1 = - 2 / ( 2 + 2 4 . 6 8 1 8 ) 20 disp ( x 1 , ” I b 2 / I c 1 =” ) 21 disp ( ” I b 1 / I s = R / R+R i 1 where R = Rs | | ( R ’ ’+R e2 ) ”) 22 r = ( ( 1 * 5 . 5 ) / ( 1 + 5 . 5 ) ) * 1 0 ^ 3 / / i n ohm
33
23 format (9) 24 disp (r , ” T h e r e f o r e , R( i n ohm ) =” ) 25 disp ( ” and R i 1 = h i e + (1+ h f e ) ∗ R e1 = 1 6 . 8 k−ohm” ) 26 x 1 = 8 4 6 . 1 5 3 8 / ( 8 4 6 . 1 5 3 8 + ( 1 6 . 8 * 1 0 ^ 3 ) ) 27 format (8) 28 disp ( x 1 , ” T he r e f o re , I b1 / I s =” ) 29 a i = 5 0 * 0 . 0 7 4 9 5 * 5 0 * 0 . 0 4 7 9 5 30 format (7) 31 disp ( a i , ” A I =” ) 32 disp ( ” ” ) 33 disp ( ” S te p 5 : C a l c u l a t e b et a ” ) 34 b e t a = 5 0 0 / ( 5 0 0 + ( 5 * 1 0 ^ 3 ) ) 35 disp ( b e t a , ” b e t a = I f / I o = R e2 / R e2 | R ’ ’ =” ) 36 disp ( ” ” ) 37 disp ( ” S te p 6 : C a l c u l a t e D , A I f ” ) 38 d = 1 + ( 0 . 0 9 0 9 * 8 . 9 8 4 8 ) 39 disp (d , ” D = 1 + A I ∗ b e t a = ” ) 40 a i f = 8 . 9 8 4 8 / 1 . 8 1 6 8 41 disp ( a i f , ” A I f = A I / D =” )
Scilab code Exa 3.13 beta and Av and Avf and Rif and Rof
1 2 3 4
/ / E x am pl e 3 . 1 3 clc disp ( ” S t e p 1 : I d e n t i f y t o p ol o g y ” ) disp ( ” The f ee db ac k v o lt a g e i s a p pl i ed a c r o s s R1
( 15 0 ohm ) , wh ich i s i n s e r i e s w it h i n p ut s i g n a l . Hence f ee db a ck i s v o l t a g e s e r i e s f ee db a ck . ” ) 5 disp ( ” ” ) 6 disp ( ” S te p 2 and S te p 3 : Fi nd i n pu t and o ut pu t c i r c u i t ”) 7 disp ( ” To f i n d i np ut c i r c u i t , s e t Vo = 0 , wh ich g i v e s p a r a l l e l c om bi na ti on 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 ut p u t c i r c u i t , 34
set Ii = 0 e m it t er o f o f R2 a nd circuit is 8 disp ( ” ” ) 9 disp ( ” S te p 4 :
b y o pe ni ng t he i np ut node , E1 a t Q1 , whi ch g i v e s t he s e r i e s c om bi na ti on R1 a c r o s s t he o ut pu t . The r e s u l t a n t shown i n f i g . 3 . 6 1 . ” )
Find t he open l o o p v o l t a g e g a i n ( Av ) ” ) 10 r l 2 = ( 4 . 7 * 1 5 . 1 5 ) / ( 4 . 7 + 1 5 . 1 5 ) // i n k−ohm 11 format (5) 12 disp ( r l 2 , ” RL2 ( i n k−ohm) =” ) 13 disp ( ” S i n c e ho e = h re = 0 , we ca n u se a pp ro xi ma te a n a l y s i s . ”) 14 disp ( ” A i 2 = − h f e = −500” ) 15 disp ( ” R i 2 = h i e = 1 1 0 0 ohm” ) 16 a v 2 = ( - 5 0 0 * 3 . 5 9 * 1 0 ^ 3 ) / 1 1 0 0 17 disp ( a v 2 , ” A v2 = A i 2 ∗ R L2 / R i 2 =” ) 18 r l 1 = ( ( 1 0 * 4 7 * 3 3 * 1 . 1 ) / ( ( 4 7 * 3 3 * 1 . 1 ) + ( 1 0 * 3 3 * 1 . 1 ) + ( 1 0 * 4 7 * 1 . 1 ) + ( 1 0 * 4 7 * 3 3 ) ) ) * 1 0 ^ 3 / / i n ohm 19 disp ( r l 1 , ” R L1 ( i n ohm ) = 10K | | 47K | | 33K | | R i 2 =” ) 20 disp ( ” A i 1 = − h f e = −500” ) 21 r i 1 = 1 . 1 + ( 5 0 1 * ( ( 0 . 1 5 * 1 5 ) / ( 0 . 1 5 + 1 5 ) ) ) // i n k−ohm 22 disp ( r i 1 , ” R i 1 ( i n k−ohm ) = h i e + (1+ h f e ) ∗Re =” ) 23 a v 1 = ( - 5 0 0 * 9 4 2 ) / ( 7 5 . 5 * 1 0 ^ 3 ) 24 format (6) 25 disp ( a v 1 , ” A v1 = A i 1 ∗ R L1 / R i 1 =” ) 26 a v = - 6 . 2 3 8 * - 1 6 3 2 27 disp ( a v , ” Av = A v1 ∗ A v 2 = ” ) 28 disp ( ” ” ) 29 disp ( ” S te p 5 : C a l c u l a te b et a and D” ) 30 b e t a = 1 5 0 / ( 1 5 0 + 1 5 0 0 0 ) 31 format (7) 32 disp ( b e t a , ” b e t a = R1 / R1+R2 =” ) 33 d = 1 + ( 1 0 1 8 0 * 0 . 0 0 9 9 ) 34 format (8) 35 disp (d , ” D = 1 + A∗ b e t a = ” ) 36 disp ( ” ” ) 37 disp ( ” S te p 6 : C a l c u l a t e A vf , R of and R i f ” ) 38 a v f = 1 0 1 8 0 / 1 0 1 . 7 8 2
35
39 40 41 42 43 44 45
format (4) disp ( a v f , ” A vf = Av / D =” ) r i f = 7 5 . 5 * 1 0 1 . 7 8 2 * 1 0 ^ - 3 // i n M−ohm format (6) R i f ( i n M−o h m ) = R i 1 ∗ D =” ) disp ( r i f , ” rof=(3.59*10^3)/101.782 R o f ( i n ohm ) = Ro / D = R L2 / D =” ) disp ( r o f , ”
Scilab code Exa 3.14 gain and new bandwidth
1 / / E x am pl e 3 . 1 4 2 clc 3 disp ( ” Given : A vmid = 5 00 , f L = 10 0 kHz , f H = 2 0 kHz and b e t a = 0 . 0 1 ” ) 4 avf=500/(1+(0.01*500)) 5 format (6) 6 disp ( a v f , ” A vf = A vmid / 1+ be ta ∗ A vmid =” ) 7 f l f = 1 0 0 / ( 1 + ( 0 . 0 1 * 5 0 0 ) ) // i n Hz 8 disp ( f l f , ” f L f ( i n Hz ) = f L / 1+ b et a ∗ A vmid =” ) 9 f h f = 2 0 * ( 1 + ( 0 . 0 1 * 5 0 0 ) ) // i n kHz 10 disp ( f h f , ” f H f ( i n kHZ ) = f H ∗ ( 1 + b e t a ∗ A v m i d ) = ”) 11 b w = 1 2 0 - 0 . 0 1 6 6 7 / / i n kHZ 12 format (9) 13 disp ( b w , ” BW f ( i n kHz ) = f H f − f L f = ” )
Scilab code Exa 3.15 show voltage gain with feedback
1 2 3 4
/ / E x am pl e 3 . 1 5 clc disp ( ” S t e p 1 : I d e n t i f y t o p ol o g y ” ) disp ( ” By s h o r t i n g o ut pu t ( Vo = 0 ) , f e ed b ac k v o l t a g e
d o es n ot become z e r o . By o p en i ng t h e o u tp ut l o o p 36
5 6 7
8 9 10 11 12 13 14 15 16
17 18 19 20 21 22
f ee db a ck beco m es z e ro and h en ce i t i s c u r re n t s am pl in g . The f ee d b a c k i s a p p l i e d i n s e r i e s w i th t he i np u t s i g n a l , h en ce t o po l og y u se d i s c u r r e n t s e r i e s f e ed b ac k . ” ) disp ( ” ” ) disp ( ” S te p 2 and S te p 3 : Fi nd i n pu t and o ut pu t ci rc ui 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 it h i n p ut . To f i n d o ut pu 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 ar am et er e q u i v a l e n t a s shown i n f i g . 3 . 6 4 . ” ) disp ( ” ” ) disp ( ” S te p 5 : Find open l o o p t r a n s f e r g a i n . ” ) disp ( ” From q ua t i o n ( 5 ) o f s e c t i o n 3 . 9 . 1 we h ave ” ) A v f = I o ∗R L / Vs = G Mf ∗ R L ” ) disp ( ” disp ( ” = − h f e ∗ R L / R ’ ’ s+ h i e +(1+ h f e ) ∗Re ” ) disp ( ” H er e 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 fo r e , Vo / Vs = Vo/ Vi ∗ Vi/Vs” ) disp ( ” wh ere Vi / Vs = Rb / Rs+Rb” ) Vo / Vs = (− h f e ∗ R L / R ’ ’ s+ h i e disp ( ” T h er ef or e , +(1+ h f e ) ∗Re ) ∗ ( Rb / Rs+Rb) ” ) disp ( ” D i v i d i n g b ot h n u me ra t or and d e n om i n at o r by Rs+ Rb we g e t , ” ) A v f = Vo / Vs = [ − h f e ∗Rc ∗ (Rb/Rb+Rs ) ] / R’ ’ disp ( ” s+ h i e +(1+ h f e ) ∗Re b e c a us e RL = Rc” ) = − h f e ∗Rc ∗ [ 1 / 1 + ( R s /Rb ) ] / R ’ ’ s+ h i e disp ( ” +(1+ h f e ) ∗Re ” )
Scilab code Exa 3.16 GMf and Rif and Rof
37
1 2 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
/ / E x am pl e 3 . 1 6 clc disp ( ” R e f e r e xa mp le 3 . 1 5 ” ) disp ( ” A v f = − h f e ∗Rc ∗ [ 1 / 1 + ( R s /Rb ) ] / R ’ ’ s+ h i e +(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) A v f =” ) disp ( a v f , ” gmf=-1.38/(1.8*10^3) format (9) disp ( g m f , ” 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 et a ∗G M” ) gm=1/((1/(-7.66*10^-4))+1000) format (10) disp ( g m , ” T h e r e fo r e , G M =” ) d=1+(-1000*-3.2735*10^-3) format (7) disp (d , ” D = 1 + G M∗ b e t a = ” ) r i = ( 1 + 1 . 3 6 ) // i n k−ohm format (5) disp ( r i , ” R i ( i n k−ohm ) = Rs +( h i e +Re ) | | R D =” ) r i f = 2 . 3 6 * 4 . 2 7 3 5 // i n k−ohm format (3) R i f ( i n k−o h m ) = R i ∗ D =” ) disp ( r i f , ” disp ( ” R o = i n f i n i t y ” ) R of = R o ∗ D = i n f i n i t y ”) disp ( ” 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 / / E x am pl e 3 . 1 7 2 clc
38
3 disp ( ” R e f e r e xa mp le 3 . 1 5 ” ) 4 disp ( ” A v f = − h f e ∗Rc ∗ [ 1 / 1 + ( R s /Rb ) ] / R ’ ’ s+ h i e +(1+ h f e ) ∗Re where R’ ’ s = Rs | | R1 | | R2” ) 5 avf=(-50*(4*10^3)*[1/(1+(1000/9000))]) /(900+1000+((1+150)*1000)) 6 format (6) 7 disp ( a v f , ” A v f =” ) 8 gmf=-1.177/(4*10^3) 9 format (9) 10 disp ( g m f , ” G Mf = A v f / R L =” ) 11 disp ( ” b e t a = Vf / I o = I e ∗Re / I o = −I o ∗Re / I o = −Re = −1 K” ) 12 disp ( ” G Mf = G M / 1+ b et a ∗G M” ) 13 g m = 1 / ( ( 1 / ( - 2 . 9 4 3 * 1 0 ^ - 4 ) ) + 1 0 0 0 ) 14 format (9) 15 disp ( g m , ” T h e r e fo r e , G M =” ) 16 d = 1 + ( - 1 0 0 0 * - 4 . 1 7 * 1 0 ^ - 4 ) 17 format (6) 18 disp (d , ” D = 1 + G M∗ b e t a = ” ) 19 r i = 1 + ( ( 2 * 9 ) / ( 2 + 9 ) ) // i n k−ohm 20 disp ( r i , ” R i ( i n k−ohm ) = Rs +( h i e +Re ) | | R D =” ) 21 r i f = 2 . 6 3 6 * 1 . 4 1 7 // i n k−ohm 22 format (6) 23 disp ( r i f , ” R i f ( i n k−o h m ) = R i ∗ D =” ) 24 disp ( ” R o = i n f i n i t y ” ) 25 disp ( ” R of = R o ∗ D = i n f i n i t y ”) 26 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 / / E xam ple 3 . 1 8 . 2 clc 3 disp ( ” Given : A v mid = 4 0 , f L = 1 00 Hz , kHz and b e t a = 0 . 0 1 ” ) 4 avf=400/(1+(0.01*400))
39
f H = 15
format (3) disp ( a v f , ” A vf = A v mid / 1+ be ta ∗ A v m id =” ) flf=100/(1+(0.01*400)) disp ( f l f , ” f L f = f L / 1+ b e t a ∗ A v m id =” ) f h f = ( 1 5 ) * ( 1 + ( 0 . 0 1 * 4 0 0 ) ) // i n kHz disp ( f h f , ” f H f ( i n kHz ) = f H ∗ ( 1 + b e t a ∗ A v mid ) =” ) 11 b w = 7 5 - 0 . 0 2 // i n kHz 12 format (6) 13 disp ( b w , ” BW f ( i n kHz ) = f H f − f L f = ” ) 5 6 7 8 9 10
Scilab code Exa 3.19 overall voltage gain and bandwidth
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/ / E x am pl e 3 . 1 9 clc disp ( ” G i v e n : Av = 1 0 , BW = 1 ∗ 1 0 ˆ 3 , n =3 ” ) disp ( ” ( i ) O v er a l l v o l t ag e g a i n ” ) disp ( ” The g a i n o f c as ca de d a m p l i f i e r w it ho ut f e e d b a c k = 1 0 ∗10∗1 0 = 1 0 0 0 ”) avf=1000/(1+(0.1*1000)) format (4) disp ( a v f , ” A v f = A v / 1 + A v∗ b e t a = ” ) disp ( ” ( i i ) B an dw id th o f c a s c a d e d s t a g e ” ) disp ( ” Bandwidth o f c as c ad e d a m p l i f i e r w it ho ut f e e d b a c k ”) b w = ( ( 1 * 1 0 ^ 6 ) *sqrt ( ( 2 ^ ( 1 / 3 ) ) - 1 ) ) * 1 0 ^ - 3 // i n kHz format (7) disp ( b w , ” BW( ca sc ad e ) ( in kHz ) = BW∗ s q r t ( 2 ˆ ( 1 / n ) − 1) =”) b w f = ( 5 0 9 . 8 2 * 1 0 ^ 3 * ( 1 + ( 0 . 1 * 1 0 0 0 ) ) ) * 1 0 ^ - 6 / / i n MHz format (6) disp ( b w f , ” 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 2 3 4
/ / E xa mp le 4 . 1 clc disp ( ” R e f e r i n g t o e q u a t i o n ( 1 ) , ” ) ri=(25*57*1.8)/((57*1.8)+(25*1.8)+(25*57))
// i n k−
ohm 5 6 7 8 9 10 11 12 13 14 15
format (6) disp ( r i , ” R ’ ’ i ( i n k−ohm) = R1 | | R2 | | h i e =” ) disp ( ”Now R ’ ’ i + R3 = R” ) r 3 = 7 . 1 - 1 . 6 3 1 // i n k−ohm format (5) R3 ( i n k−ohm ) = R − R’ ’ i =” ) disp ( r 3 , ” T h e re fo r e , k=20/7.1 format (6) disp (k , ” K = R C / R =” ) disp ( ”Now f = 1 / 2∗ p i ∗R∗C∗ s q r t (6+4K)” ) c = ( 1 / ( sqrt ( 6 + ( 4 * 2 . 8 1 6 ) ) * 2 * % p i * 7 . 1 * 1 0 * 1 0 ^ 6 ) ) * 1 0 ^ 1 2
// i n pF 16 17 18 19
format (8) disp (c , ” T h e r e fo r e , C( i n pF ) =” ) h f e >= 4 K + 2 3 + 2 9 / K ” ) disp ( ” hfe=(4*2.816)+23+(29/2.816)
41
20 format (7) 21 disp ( h f e , ”
h fe
=” )
>
Scilab code Exa 4.2 frequency of oscillation
1 / / E xa mp le 4 . 2 2 clc 3 disp ( ” The g i v en v a l ue s a re , R = 4 . 7 k−o h m a n d C = 0 . 4 7 uF ” ) 4 f = 1 / ( 2 * % p i *sqrt ( 6 ) * ( 4 . 7 * 1 0 ^ 3 ) * ( 0 . 4 7 * 1 0 ^ - 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 2 3 4 5 6 7 8 9
/ / E xa mp le 4 . 3
clc disp ( ” f = 1 kHz ” ) disp ( ”Now f = 1 / 2∗ p i ∗ s q r t ( 6 ) ∗R∗C” ) disp ( ” Choos e C = 0 . 1 uF” ) r = 1 / ( sqrt ( 6 ) * 2 * % p i * 0 . 1 * 1 * 1 0 ^ - 3 ) / / i n ohm format (8) disp (r , ” T h e r e fo r e , R( i n ohm ) = ” ) s ta nd ar d v al ue ” ) disp ( ” Choos e R = 6 80 ohm
Scilab code Exa 4.4 C and RD
1 / / E xa mp le 4 . 4 2 clc
42
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
disp ( ” U si n g t he e x p r e s s i o n f o r t he f r eq u en c y ” ) disp ( ”Now , f = 1 / 2 ∗ p i ∗R∗C∗ s q r t ( 6 ) ” ) f = ( 1 / ( sqrt ( 6 ) * 2 * % p i * 9 . 7 * 5 * 1 0 ^ 6 ) ) * 1 0 ^ 9 // i n nF format (5) disp (f , ” T h e r e fo r e , C( i n nF ) =” ) disp ( ”Now u s i n g t h e e q u a t i o n ( 2 7 ) ” ) disp ( ” |A| = g m ∗ R L”) disp ( ” T h e r e f o r e , | A | >= 2 9 ” ) g m ∗ R L >= 2 9 ” ) disp ( ” T h er ef or e , r l = ( 2 9 / ( 5 0 0 0 * 1 0 ^ - 6 ) ) * 1 0 ^ - 3 // i n k−ohm format (4) R L ( i n k−ohm) >= 2 9 / g m =” ) disp ( r l , ” T h er ef or e , disp ( ” R L = R D∗ r d / R D+r d ” ) rd=(40)/4.8823 format (5) T h er e f o re , R D ( i n k−o h m ) = ” ) disp ( r d , ” disp ( ” While f o r minimum v a lu e o f R L = 5 . 8 k−ohm” ) R D = 6 . 7 8 k−ohm” ) disp ( ”
Scilab code Exa 4.5 minimum and maximum R2
1 2 3 4 5 6 7 8 9 10
/ / E xa mp le 4 . 5
11 12
clc 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 , ” ) f = 1 / 2∗ p i ∗ s q r t ( R1∗R2∗C1∗C 2 ) ” ) disp ( ” disp ( ” For f = 10 kHz , ” ) r 2 = ( 1 / ( 4 * ( % p i ^ 2 ) * ( 1 0 0 * 1 0 ^ 6 ) * ( 1 0 * 1 0 ^ 3 ) * ( 0 . 0 0 1 * 1 0 ^ - 12 ) ) ) // i n k−ohm format (6) disp ( r 2 , ” T h e re fo r e , R2 ( i n k−ohm) =” ) f = 50 kHz , ” ) disp ( ” For r2=(1/(4*(%pi^2)*(2500*10^6)*(10*10^3) * ( 0 . 0 0 1 * 1 0 ^ - 1 2 ) ) ) // i n k−ohm format (6) disp ( r 2 , ” T h e re fo r e , R2 ( i n k−ohm) =” )
43
13 disp ( ” So minimum v a l ue 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 2 3 4 5 6 7 8 9 10
/ / E xa mp le 4 . 6
clc disp ( ” The f r e q u e n c y i s g i v e n by , ” ) f = 1 / 2∗ p i ∗ s q r t (C∗ L e q ) ” ) disp ( ” leq=(2*10^-3)+(20*10^-6) format (8) disp ( l e q , ” wher e L eq = L1 + L2 =” ) f = f ma x = 20 5 0 kHz ” ) disp ( ” For format (5) c=(1/(4*(%pi^2)*((2050*10^3)^2)*0.00202))*10^12
//
i n pF 11 disp (c , ” T h e r e fo r e , C( i n pF ) =” ) 12 disp ( ” For f = f m in = 950 kHz ” ) 13 c = ( 1 / ( 4 * ( % p i ^ 2 ) * ( ( 9 5 0 * 1 0 ^ 3 ) ^ 2 ) * 0 . 0 0 2 0 2 ) ) * 1 0 ^ 1 2
//
i n pF 14 format (6) 15 disp (c , ” T h e r e fo r e , C( i n pF ) =” ) 16 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 he r e q u i r e d f r e q ue n cy v a r i a t i o n . ” )
Scilab code Exa 4.7 frequency of oscillation
1 2 3 4 5 6
/ / E xa mp le 4 . 7
clc disp ( ” The g i v e n v a l u e s a re , ” ) L2 = 1 mH, C = 0 . 2 uF” ) disp ( ” L1 = 0 . 5 mH, disp ( ”Now f = 1 / 2∗ p i ∗ s q r t (C∗ L e q ) ” ) l e q = 0 . 5 + 1 / / i n mH
44
7 8 9 10
L e q ( i n mH) = L 1 + L2 =” ) disp ( l e q , ” a nd f = ( 1 / ( 2 * % p i * sqrt ( 1 . 5 * 0 . 2 * 1 0 ^ - 9 ) ) ) * 1 0 ^ - 3 // i n kHz format (5) disp (f , ” T h e r e fo r e , f ( i n kHz ) =” )
Scilab code Exa 4.8 frequency of oscillation
1 2 3 4
/ / E xa mp le 4 . 8 clc disp ( ” The e q u i v a l e n t c a p a c i t a n ce i s g i ve n by , ” ) ceq=(150*1.5*10^-21)/((150*10^-12)+(1.5*10^-9))
//
in F 5 6 7 8
format (12) disp ( c e q , ” C eq ( i n F) = C1 ∗C2 / C1+C2 =” ) disp ( ”Now , f = 1 / 2 ∗ p i ∗ s q r t ( L∗ C e q ) ” ) f = ( 1 / ( 2 * % p i * sqrt ( 5 0 * 1 3 6 . 3 6 3 * 1 0 ^ - 1 8 ) ) ) * 1 0 ^ - 6
// i n
MHz 9 format (6) 10 disp (f , ” f ( i n MHz) =” )
Scilab code Exa 4.9 calculate C
1 2 3 4
/ / E xa mp le 4 . 9
5 6
clc disp ( ” The g i v e n v a l u e s a re , ” ) disp ( ” L = 1 00 uH , C1 = C2 = C and f = 50 0 kHz” ) disp ( ”Now , f = 1 / 2∗ p i ∗ s q r t ( L∗ C e q ) ” ) c e q = 1 / ( 4 * ( % p i ^ 2 ) * ( 1 0 0 * 1 0 ^ - 6 ) * ( ( 5 0 0 * 1 0 ^ 3 ) ^ 2 ) ) // i n
F 7 format (11) 8 disp ( c e q , ” T h e r e f o r e , C e q ( i n F ) =” )
45
9 disp ( ” b ut C eq = C1∗C2 / C1+C2 ”) 10 disp ( ” T he re fo re , C eq = C / 2 ” ) 11 c = 1 . 0 1 3 2 * 2 12 format (6) 13 disp (c , ” T h e r e fo r e , C( i n nF ) =” )
and C1 = C2 = C
Scilab code Exa 4.10 series and parallel resonant freqency
1 / / E x am pl e 4 . 1 0 2 clc 3 f s = ( 1 / ( 2 * % p i *sqrt ( 0 . 4 * 0 . 0 8 5 * 1 0 ^ - 1 2 ) ) ) * 1 0 ^ - 6
// i n
MHz 4 5 6 7 8
format (6) f s ( i n MHz) = 1 / 2 ∗ p i ∗ s q r t ( L∗C) =” ) disp ( f s , ” ( i ) c e q = 0 . 0 8 5 / 1 . 0 8 5 // i n pF disp ( c e q , ” ( i i ) C e q ( i n pF ) = C∗C M / C+C M =” ) f p = ( 1 / ( 2 * % p i *sqrt ( 0 . 4 * 0 . 0 7 8 * 1 0 ^ - 1 2 ) ) ) * 1 0 ^ - 6 // i n
MHz
( t he a ns we r i n t ex tb o ok i s wrong ) 9 disp ( f p , ” T h e re fo r e , f p ( i n MHz) = 1 / 2 ∗ p i ∗ s q r t ( L∗ C eq ) =” ) 10 i n c = ( ( 0 . 8 9 9 - 0 . 8 5 6 ) / 0 . 8 5 6 ) * 1 0 0 // i n p e rc e n t ag e 11 disp ( i n c , ” ( i i i ) % i n c re a s e =” ) 12 q = ( 2 * % p i * 0 . 4 * 0 . 8 5 6 * 1 0 ^ 6 ) / ( 5 * 1 0 ^ 3 ) 13 format (8) 14 disp (q , ” ( i v ) Q = o me ga s ∗L / R = 2 ∗ p i ∗ f s ∗L / R =” )
Scilab code Exa 4.11 series and parallel resonant freqency
1 2 3 4
/ / E x am pl e 4 . 1 1 clc disp ( ” C M = 2 pF” ) f s = ( 1 / ( 2 * % p i *sqrt ( 2 * 0 . 0 1 * 1 0 ^ - 1 2 ) ) ) * 1 0 ^ - 6
46
/ / i n MHz
5 6 7 8 9 10 11 12 13
format (6) disp ( f s , ”Now f s ( i n MHz) = 1 / 2 ∗ p i ∗ s q r t ( L∗C) =” ) c e q = ( 2 * 0 . 0 1 * 1 0 ^ - 2 4 ) / ( 2 . 0 1 * 1 0 ^ - 1 2 ) // i n F format (9) disp ( c e q , ” C eq ( i n F) = C M∗C / C M+C =” ) f p = ( 1 / ( 2 * % p i *sqrt ( 2 * 9 . 9 5 * 1 0 ^ - 1 5 ) ) ) * 1 0 ^ - 6 / / i n MHz format (6) disp ( f p , ” f p = 1 / 2∗ p i ∗ s q r t ( L∗ C eq ) =” ) disp ( ” So f s a n d f p v a l ue s a r e a lm os t same . ” )
Scilab code Exa 4.12 Varify Barkhausen criterion and find frequency of
oscillation 1 2 3 4
/ / ex am pl e 4 . 1 2 .
clc disp ( ” From t h e g i v e n i n f o r m a t i o n we c an w r it e , ” ) disp ( ” A = −16∗10ˆ6/ j ∗ omega and b et a = 1 0 ˆ 3 / [ 2∗ 1 0 ˆ 3 + j ∗ omega ] ˆ 2 ” ) 5 disp ( ”To v e r i f y t he B ar kh au sen c o n d i t i o n means t o
6
7 8 9 10 11
v e r i f y w he th er | A∗ b e t a | = 1 a t a f re qu en cy f o r w h i c h A∗ b et a = 0 d e gr e e . L e t u s e xp 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 fo rm . ” ) disp ( ” A∗ b e t a = −16∗10ˆ6∗10ˆ3 / j ∗ omega ∗ [ 2 ∗10ˆ3 + j ∗ o me ga ] ˆ 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 a s j ∗2 = −1” ) ∗ omega−omega ˆ 2 ] 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∗1 0 ˆ 6 − omega ˆ 2 ] − [ o m e g a ˆ 2 ∗ 4 ∗ 1 0 ˆ 3 ] ” ) disp ( ” R a t i o n a l i s i n g t he d en om in at or f u n c t i o n we g et , ”) disp ( ” A∗ b e t a = −16∗10ˆ9[ − omegaˆ2∗ 4 ∗ 1 0 ˆ 3 − j ∗ omega ∗[ 4∗1 0 ˆ 6 − omega ˆ 2 ] ] / [ − [omegaˆ2 ∗4∗1 0 ˆ 3 ] − j ∗ omega 47
12 13
14
15
16 17 18 19 20 21
∗[ 4∗1 0 ˆ 6 − o m e g a ˆ 2 ] ]∗ [ − omegaˆ2∗ 4 ∗ 1 0 ˆ 3 − j ∗ omega ∗[ 4∗1 0 ˆ 6 − omega ˆ 2 ] ] ” ) disp ( ” U si ng ( 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 [ o m e g a ˆ 2∗4∗10ˆ3+ j ∗ omega ∗[ 4∗1 0 ˆ 6 − omega ˆ 2 ] ] / [−omegaˆ2 ∗ 4 ∗ 1 0 ˆ 3 ] ˆ 2 − [ j ∗ omega ∗[ 4∗1 0 ˆ 6 − o m e g a ˆ 2 ] ˆ 2 ” ) disp ( ” A∗ b e t a = 1 6 ∗ 1 0 ˆ 9 [ o m e g a ˆ 2∗4∗10ˆ3+ j ∗ omega ∗[ 4∗1 0 ˆ 6 − omega ˆ 2 ] ] / 1 6∗ 1 0 ˆ 6∗ omegaˆ4 + omega ˆ2(4∗10ˆ6 − omegaˆ 2) ˆ2” ) disp ( ”Now t o h a ve A∗ b et a = 0 d eg re e , t he i m ag i na r y p ar t o f A∗ b et a must be z e ro . T h is i s p o s s i b l e when , ” ) omega ∗ ( 4 ∗ 1 0 ˆ 6 − o m e g a ˆ 2 ) = 0 ” ) disp ( ” T h e r e fo r e , disp ( ” T h er e f o re , omega = 0 o r 4 ∗1 0 ˆ 6 − o m e g a ˆ 2 = 0”) disp ( ” T h e r e fo r e , omega ˆ 2 = 4∗1 0 ˆ 6 N e g l e c ti n g z e r o v a l u e o f f r eq u en c y ” ) disp ( ” T h e re fo r e , omega = 2 ∗ 1 0 ˆ 3 r a d / s e c ” ) disp ( ” At t h i s f r eq u e nc y | A∗ b e t a | ca n be o b ta i ne d as , ”) disp ( ” | A∗ b e t a | = 1 6 ∗ 1 0 ˆ 9 [ 4∗ 1 0 ˆ 3∗ o me ga ˆ 2 ] / 1 6 ∗ 1 0 ˆ 6∗ omegaˆ4+omegaˆ2[4 ∗1 0 ˆ 6 − o m e g a ˆ 2 ] ˆ 2 a t omega = 2 ∗1 0 ˆ 3 ” )
22 a b = ( 2 . 5 6 * 1 0 ^ 2 0 ) / ( 2 . 5 6 * 1 0 ^ 2 0 ) 23 disp ( a b , ” | A∗ b e t a | =” ) 24 disp ( ” T h e r e fo r e , At omega = 2∗ 1 0ˆ 3 r ad / s e c , A∗ b e t a
25
26 27 28 29 30
= 0 d eg r e e a s i ma gi na ry p ar t i s z er o w hi l e | A∗ b e t a | = 1 . Thus B a rk ha u se 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 w hi ch c i r c u i t w i l l o s c i l l a t e i s t he v a l u e o f omega f o r wh ich | A∗ b e t a | = 1 a nd A∗ b et a = 0 d e g re e a t t he same t im e ” ) disp ( ” i . e . omega = 2 ∗ 1 0ˆ 3 r ad / s e c ” ) omega = 2∗ p i ∗ f ” ) disp ( ” But f = ( 2 * 1 0 ^ 3 ) / ( 2 * % p i ) // i n Hz
format (9) disp (f , ” T h e r e fo r e ,
f ( i n Hz ) = o mega / 2 p i =” ) 48
Scilab code Exa 4.13 minimum and maximum values of R2
1 2 3 4 5 6 7 8 9 10
/ / E x am pl e 4 . 1 3
11 12 13
clc 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 , ” ) disp ( ” f = 1 / 2∗ p i ∗ s q r t ( R1∗R2∗C1∗C 2 ) ” ) f = 2 0 kHz , ” ) disp ( ” For r2=(1/(4*(%pi^2)*((20*10^3)^2)*(10*10^3) *((0.001*10^-6)^2)))*10^-3 format (5) disp ( r 2 , ” T h e re fo r e , R2 ( i n k−ohm) =” ) f = 7 0 kHz , ” ) disp ( ” For r2=(1/(4*(%pi^2)*((70*10^3)^2)*(10*10^3) *((0.001*10^-6)^2)))*10^-3 format (6) R2 ( i n k−ohm) =” ) disp ( r 2 , ” T h e re fo r e , disp ( ” So minimum v a l ue 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 2 3 4 5 6 7
/ / E xam ple 4 . 1 4 .
8 9
clc disp ( ”R = 6 k−ohm , C = 15 0 0 pF , R C = 18 k−ohm” ) k=18/6 disp (k , ”Now K = R C / R =” ) f = 1 / 2 ∗ p i ∗R∗C∗ s q rt (6+4K)” ) disp ( ” T h e r e f o r e , f = ( 1 / ( 2 * % p i * ( 6 * 1 0 ^ 3 ) * ( 1 5 0 0 * 1 0 ^ - 1 2 ) *sqrt ( 6 + 1 2 ) ) ) * 1 0 ^ - 3 / / i n kHZ format (6) f ( i n kHz ) =” ) disp (f , ”
49
10 h f e = ( 4 * 3 ) + 2 3 + ( 2 9 / 3 ) 11 disp ( h f e , ” ( h f e ) m in = 4K + 2 3 + 2 9/K =” )
Scilab code Exa 4.15 range of frequency of oscillation
1 2 3 4 5 6
/ / E xam ple 4 . 1 5 .
clc format (6) disp ( ” For a Wien b r i d g e o s c i l l a t o r , ” ) disp ( ” f = 1 / 2∗ p i ∗R∗C” ) fm=(1/(2*%pi*(100*10^3)*(50*10^-12)))*10^-3
// i n
kHz f m ax ( i n kHz ) =” ) disp ( f m , ” T h e r e fo r e , fmi=(1/(2*%pi*(100*10^3)*(500*10^-12)))*10^-3 f m i n ( i n kHz ) =” ) disp ( f m i , ” and fn=31.83+50 disp ( f n , ”Now f n e w ( i n kHz ) = f m ax + 5 0 ∗ 1 0 ˆ 3 = ” ) disp ( ” The c o r r es p o n d i ng R = R’ ’ w it h an a d d i t i o n a l r e s i s ta n c e R x i n p a r a l l e l ”) 13 disp ( ” T h e r e f o r e , f = 1 / 2 ∗ p i ∗R’ ’ ∗ C” ) 14 r = ( 1 / ( 2 * % p i * ( 5 0 * 1 0 ^ - 1 2 ) * ( 8 1 . 8 3 * 1 0 ^ 3 ) ) ) * 1 0 ^ - 3 // i n 7 8 9 10 11 12
k−ohm 15 disp (r , ” T h e re fo r e ,
R ’ ’ ( i n k−ohm) =” ) 16 rx =1/((1/3 8.89) -(1/100)) // i n k−ohm 17 disp ( ” T h e re fo r e , R’ ’ = R∗ R x / R+R x ” ) 18 disp ( r x , ” T h er ef or e , R x ( i n k−ohm) = i n p a r a l l e l w i t h 10 0 k−ohm” )
Scilab code Exa 4.16 frequency of oscillation
1 / / E xam ple 4 . 1 6 . 2 clc 3 format (6)
50
4 disp ( ” F or 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 , ” ) 5 disp ( ” f = 1 / 2∗ p i ∗ s q r t ( L e q ∗C) wh ere L e q = L1+L2” ) 6 l e q = 2 0 + 5 / / i n mH 7 disp ( l e q , ” T h e r e f o r e , L e q ( i n mH) = 20+5 =” ) 8 f = ( 1 / ( 2 * % p i * sqrt ( 2 5 * 5 0 0 * 1 0 ^ - 1 5 ) ) ) * 1 0 ^ - 3 // i n kHz 9 disp (f , ” T h e r e fo r e , f ( i n kHz ) =” )
Scilab code Exa 4.17 gain of the transistor
1 2 3 4
/ / E x am pl e 1 4 . 7
clc disp ( ” For a H a r tl e y o s c i l l a t o r , ” ) f = 1 / 2∗ p i ∗ s q r t ( L e q ∗C) wh ere L e q disp ( ” = L1 + L2 + 2M” ) 5 l e q = ( 1 / ( 4 * ( % p i ^ 2 ) * ( ( 1 6 8 * 1 0 ^ 3 ) ^ 2 ) * ( 5 0 * 1 0 ^ - 1 2 ) ) ) * 1 0 ^3
/ / i n mH 6 format (6) 7 disp ( l e q , ” T h e r e f o r e , L e q ( i n mH) =” ) 8 l2= ((17.95*10^ -3) -(15*10^-3) -(5*10^-6)) *10^3
// i n
mH 9 10 11 12
disp ( l 2 , ” T h e r e fo r e , L2 ( i n mH) =” ) h f e = ( ( 1 5 * 1 0 ^ - 3 ) + ( 5 * 1 0 ^ - 6 ) ) / ( ( 2 . 9 4 5 * 1 0 ^ - 3 ) + ( 5 * 1 0 ^ - 6) ) format (5) h f e = L1+M / L 2+M =” ) disp ( h f e , ”Now
Scilab code Exa 4.18 new frequency and inductance
1 2 3 4
/ / E x am pl e 4 . 1 8 clc disp ( ” For a C o l p i t t s o s c i l l a t o r , ” ) f = 1 / 2∗ p i ∗ s q r t ( L∗ C e q ) ” ) disp ( ”
51
5 disp ( ” wh ere
C eq = C1 ∗C2 / C1+C2
b u t C1 = C2 =
0 . 0 0 1 uF” ) 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
c e q = ( ( 0 . 0 0 1 * 1 0 ^ - 6 ) ^ 2 ) / ( 2 * ( 0 . 0 0 1 * 1 0 ^ - 6 ) ) // i n F format (7) C eq ( i n F ) =” ) disp ( c e q , ” T h e r e fo r e , disp ( ” L = 5∗10ˆ −6 H” ) f = ( 1 / ( 2 * % p i * sqrt ( 2 5 * 1 0 ^ - 1 6 ) ) ) * 1 0 ^ - 6 / / i n MHz format (6) f ( i n MHz) =” ) disp (f , ” T h e r e f o r e , disp ( ”Now L i s d o u bl e d i . e . 1 0 uH” ) f 1 = ( 1 / ( 2 * % p i *sqrt ( 5 0 * 1 0 ^ - 1 6 ) ) ) * 1 0 ^ - 6 / / i n MHz format (5) disp ( f 1 , ” T h e r e f o r e , f ( i n MHz ) =” ) n f = 2 * 3 .1 8 3 format (6) disp ( n f , ” 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 21 format (5) 22 disp (l , ” T h e r e fo r e ,
L ( i n uH ) =” )
Scilab code Exa 4.19 new frequency of oscillation
1 2 3 4 5 6 7 8
/ / E x am pl e 4 . 1 9
clc disp ( ” For a Clapp o s c i l l a t o r , ” ) f = 1 / 2∗ p i ∗ s q r t ( L∗C 3 ) ” ) disp ( ” disp ( ” wh ere C3 = 63 pF” ) f = ( 1 / ( 2 * % p i * sqrt ( 3 1 5 * 1 0 ^ - 1 8 ) ) ) * 1 0 ^ - 6 format (6) f ( i n MHz) =” ) disp (f , ” T h e r e f o r e ,
Scilab code Exa 4.20 R and hfe
52
/ / i n MHz
1 / / E x am pl e 4 . 2 0 2 clc 3 disp ( ” R e fe r i n g t o e q u a ti o n ( 1 ) o f s e c t i o n 4 . 5 . 3 , t he i n p u t i mp ed an ce i s g i v e n by , ” ) 4 disp ( ”R ’ ’ i = R1 | | R2 | | h i e ” ) 5 disp ( ”Now R1 = 25 k−ohm , R2 = 47 k−ohm , and h i e = 2 k−ohm” ) 6 format (7) 7 r i = ( 2 5 * 4 7 * 2 ) / ( ( 4 7 * 2 ) + ( 2 5 * 2 ) + ( 2 5 * 4 7 ) ) // i n k−ohm 8 disp ( r i , ” T h e re fo r e , R’ ’ i ( i n k−ohm) =” ) 9 disp ( ” K = R C / R” ) 10 disp ( ”Now R C = 10 k−ohm . . . g i ve n ”) 11 disp ( ”Now f = 1 / 2∗ p i ∗R∗C∗ s q r t (6+4K)” ) 12 disp ( ” T h er ef or e , R∗ s q r t ( 6+4K) = 3 1 8 3 0 . 9 8 9 ” ) 13 disp ( ”Now K = R C / R = 1 0∗ 1 0ˆ 3 / R” ) 14 disp ( ” T h er ef or e , R∗ s q r t ( 6 + ( 4 0∗ 1 0 ∗ 1 0 ˆ 3 / R ) ) = 3 1 8 3 0 . 9 8 9 ”) 15 disp ( ” T h e re fo r e , Rˆ 2∗ ( 6 + ( 4 0 ∗ 1 0 ∗ 1 0 ˆ 3 / R) ) = ( 3 1 8 3 0 . 9 8 9 ) ˆ 2 ”) 16 R = poly (0 , ’ R ’ ) 17 p 1 = 6 * R ^ 2 + ( 4 0 * 1 0 ^ 3 ) * R - ( 3 1 8 3 0 . 9 8 9 ) ^ 2 18 t1 = roots ( p 1 ) 19 a n s 1 = t 1 ( 1 ) 20 format (6) 21 disp ( ( - a n s 1 ) * 1 0 ^ - 3 , ” T h er e fo r e , R( i n k−ohm)= N e g le c t i n g n e g a t i ve v a l u e ” ) 22 k = 1 0 / 1 6 . 7 4 23 format (7) 24 disp (k , ” T h e re fo r e , K = R C / R =” ) 25 disp ( ” T he re fo re , h f e >= 4 K + 2 3 + 2 9 / K ” ) 26 h f e = ( 4 * 0 . 5 9 7 3 ) + 2 3 + ( 2 9 / 0 . 5 9 7 3 ) 27 format (6) 28 disp ( h f e , ” h f e >=” )
Scilab code Exa 4.21 component values of wien bridge
53
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/ / E x am pl e 4 . 2 1
clc disp ( ” The f r e q u e n c y i s g i v e n by , ” ) disp ( ” f = 1 / 2∗ p i ∗R∗C” ) disp ( ” Le t t he r e s i s t a n c e v al ue t o be s e l e c t e d as , ” ) disp ( ” R1 = R2 = R = 5 0 k−ohm” ) f = 1 / 2∗ p i ∗ 5 0 ∗ 1 0 ˆ 3∗C” ) disp ( ” f = ( 1 / ( 2 * % p i * ( 5 0 * 1 0 ^ 3 ) * 1 0 0 ) ) * 1 0 ^ 9 // i n nF format (6) disp (f , ” f ( i n nF ) =” ) f m a x = 1 / 2∗ p i ∗ 5 0 ∗ 1 0 ˆ 3∗C” ) disp ( ” and c = ( 1 / ( 2 * % p i * ( 5 0 * 1 0 ^ 3 ) * ( 1 0 * 1 0 ^ 3 ) ) ) * 1 0 ^ 9 // i n pF disp (c , ” C( i n nF ) =” ) disp ( ” Thus t o v ar y t he f r e qu e n cy fro m 1 00 Hz t o 10
kHz , t he c a p a c i t o r r an ge s ho u l d be s e l e c t e d a s 0 . 3 1 8 nF t o 3 1 . 83 nF” ) 15 disp ( ” S i m i l a r l y k ee pi n g t he c a p a c i t o r v a l u e c on st an 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 ca n be obt ain ed . ”)
Scilab code Exa 4.22 values of C2 and new frequency of oscillation
1 2 3 4
/ / E x am pl e 4 . 2 2
clc f = 2 . 5 MHz, L = 10 uH , C1 = 0 . 0 2 uF” ) disp ( ” 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 qu e n c y i s g i v e n by , ” ) 5 disp ( ” f = 1 / 2 p i ∗ s q r t ( L∗ C e q ) ” ) 6 c e q = ( 1 / ( 4 * ( % p i ^ 2 ) * ( ( 2 . 5 * 1 0 ^ 6 ) ^ 2 ) * ( 1 0 * 1 0 ^ - 6 ) ) ) * 1 0 ^ 12
// i n pF 7 8 9 10 11
format (8) disp ( c e q , ” T h e r e fo r e , C eq ( i n pF ) =” ) C eq = C1 ∗C2 / C1+C2” ) disp ( ” ( i ) But c 2 = ( ( 0 . 0 2 * 1 0 ^ - 6 ) / 4 9 . 3 4 8 ) * 1 0 ^ 9 // i n nF format (7)
54
12 disp ( c 2 , ” T h e r e fo r e ,
C2 ( i n nF ) =” )
// a ns we r i n
t e xt b o ok i s wrong 13 disp ( ” ( i i ) L = 2 ∗1 0 = 2 0 u H ” ) 14 disp ( ” and C eq = 4 05 . 2 84 pF” ) 15 f = ( 1 / ( 2 * % p i * sqrt ( 2 0 * 4 0 5 . 2 8 4 * 1 0 ^ - 1 8 ) ) ) * 1 0 ^ - 6
// i n
MHz 16 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 / / E xam ple 4 . 2 3 . 2 clc 3 f = ( 1 / ( 2 * % p i * sqrt ( 0 . 3 3 * 0 . 0 6 5 * 1 0 ^ - 1 2 ) ) ) * 1 0 ^ - 6
// i n
MHz 4 5 6 7 8
format (6) f ( i n MHz) = 1 / 2 ∗ p i ∗ s q r t ( L∗C) =” ) disp (f , ” ( i ) c e q = 0 . 0 6 5 / 1 . 0 6 5 // i n pF C e q ( i n pF ) = C∗C M / C+C M =” ) disp ( c e q , ” ( i i ) f p = ( 1 / ( 2 * % p i *sqrt ( 0 . 3 3 * 0 . 0 6 1 * 1 0 ^ - 1 2 ) ) ) * 1 0 ^ - 6 // i n
MHz 9 disp ( f p , ” ( i ) f p ( i n MHz) = 1 / 2 ∗ p i ∗ s q r t ( L∗ C eq ) =” ) 10 p i = ( ( 1 . 1 2 1 - 1 . 0 8 7 ) / 1 . 0 8 7 ) * 1 0 0 // i n p e rc e nt a g e 11 disp ( p i , ” ( i i i ) % i n c r e a s e =” ) 12 q = ( 2 * % p i * 1 . 0 8 7 * 0 . 3 3 * 1 0 ^ 6 ) / ( 5 . 5 * 1 0 ^ 3 ) 13 format (8) 14 disp (q , ” ( i v ) Q = o meg a x ∗L / R = 2 ∗ p i ∗ f s ∗L / R =” )
Scilab code Exa 4.24 change in frequency and trimmer capacitance
1 / / E xa ml e 4 . 2 4 2 clc
55
3 disp ( ” ( i )
Assume o ne 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 w hi ch , ” ) 4 disp ( ” L e q = L1 + L2 + 2M = 0 . 2 5 mH” ) 5 format (8) 6 f = ( 1 / ( 2 * % p i * sqrt ( 0 . 2 5 * 1 0 0 * 1 0 ^ - 1 5 ) ) ) * 1 0 ^ - 6 / / i n MHz 7 disp (f , ” T h e r e fo r e , f ( i n MHz) = 1 / 2 ∗ p i ∗ s q r t ( L e q ∗C ) =” ) 8 disp ( ” Le t t he d i r e c t i o n o f c o u p li n g i s r ev er se d , ” ) 9 disp ( ” L e q = L1 + L2 − 2M = 0. 15 mH” ) 10 f d = ( 1 / ( 2 * % p i *sqrt ( 0 . 1 5 * 1 0 0 * 1 0 ^ - 1 5 ) ) ) * 1 0 ^ - 6 // i n
MHz 11 format (7) 12 disp ( f d , ” T h e re fo r e , f ’ ’ ( i n MHz) = 1 / 2 ∗ p i ∗ s q r t ( L e q ∗C) =” ) 13 p c = ( ( 1 . 2 9 9 4 - 1 . 0 0 6 5 8 ) / 1 . 0 0 6 5 8 ) * 1 0 0 // i n p e rc e nt a g e 14 format (6) 15 disp ( p c , ” T h e re fo r e , % c h an ge = f ’ ’ − f / f ∗ 1 0 0 = ” ) 16 disp ( ” ( i i ) L e t u s a ssume d i r e c t i o n o f c o u p li n g s u c h that , ” ) 17 disp ( ” L e q = L1 + L2 + 2M = 0 . 2 5 mH” ) 18 disp ( ” C t = Trim c a p a c i t o r = 10 0 pF” ) 19 disp ( ” T h er ef or e , C eq = C∗ C t / C+C t = 5 0 pF ” ) 20 f 1 = ( 1 / ( 2 * % p i *sqrt ( 0 . 2 5 * 5 0 * 1 0 ^ - 1 5 ) ) ) * 1 0 ^ - 6 / / i n MHz 21 format (7) 22 disp ( f 1 , ” T h e r e f o r e , f = 1 / 2 ∗ p i ∗ s q r t ( L e q ∗ C eq ) =” ) 23 disp ( ” I f now d i r e c t i o n o f c o u p l i ng i s r e v e r s ed , ” ) 24 disp ( ” L e q = L1 + L2 − 2M = 0. 15 mH” ) 25 f 2 = ( 1 / ( 2 * % p i *sqrt ( 0 . 1 5 * 5 0 * 1 0 ^ - 1 5 ) ) ) * 1 0 ^ - 6 / / i n MHz 26 format (8) 27 disp ( f 2 , ” T he re fo re , f ’ ’ = 1 / 2 ∗ p i ∗ s q r t ( L e q ∗ C eq ) =” ) 28 p c 1 = ( ( 1 . 8 3 7 7 6 - 1 . 4 2 3 5 ) / 1 . 4 2 3 5 ) * 1 0 0 29 format (7) 30 disp ( p c 1 , ” T h er e fo r e , % c ha ng e = f ’ ’ − f / f ∗ 1 0 0 = ” )
56
Scilab code Exa 4.25 design RC phase shift oscillator
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/ / E x am pl e 4 . 2 5 clc disp ( ” For RC p ha se s h h i f t o s c i l l a t o r , ” ) disp ( ” h f e = 4K + 23 + 2 9/K . . . given h fe = 150”) disp ( ” T h e r e fo r e , 1 50 = 4K + 2 3 + 2 9 /K” ) 4Kˆ 2 − 1 2 7 K + 2 9 = 0 ” ) disp ( ” T h e r e fo r e , K = poly (0 , ’K ’ ) p1=4*K^2-127*K+29 t1 = roots ( p 1 ) format (6) disp ( t 1 , ” T h e r e fo r e , K =” ) f = 1 / 2∗ p i ∗R∗C∗ s q r t (6+4K) . . . given disp ( ” f = 5 kHz”) disp ( ” T h e re fo r e , Choos e C = 100 pF” ) r = ( 1 / ( 2 * % p i * ( 1 0 0 0 * 1 0 ^ - 1 2 ) * ( 5 * 1 0 ^ 3 ) *sqrt ( 6 + ( 4 * 0 . 2 3 ) ) ) ) * 1 0 ^ - 3 // i n k−ohm format (3) disp (r , ” T h e re fo r e , R( i n k−ohm) =” ) R C = KR = 2 . 7 k−ohm” ) disp ( ” K = R C / R i . e . disp ( ” N e g l e ct 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 ss um in 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” ) 19 disp ( ” R’ ’ i = h i e = 2 k−ohm” ) 20 disp ( ” T h e re fo r e , L as t r e s i s t a n c e i n p ha se n et wo rk ” ) 21 r 3 = 1 2 - 2 22 disp ( r 3 , ” R3 = R − R’ ’ i =” ) 23 disp ( ” U si ng t he b ack t o ba ck c on n ec te d z e ne r d i o d es
o f 9 . 3 V ( Vz ) e a c h a t t h e o ut p u t o f e m i t te 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 ut p u t o f t h e o s c i l l a t o r , t he o ut pu t a mp li tu de can be c o n t r o l l e d t o 10 V i . e . 20 V p eak t o pea k . The 57
z e n e r d i o d e 9 . 3V and f or wa rd b i a s e d d io d e o f 0 . 7 V g i v e s t o t a l 10 V” ) 24 disp ( ” The d e si g ne 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 2 3 4 5 6 7 8 9
/ / E x am pl e 4 . 2 6
clc disp ( ” L1 = 20 uH , L2 = 2 mH” ) l e q = ( ( 2 0 * 1 0 ^ - 6 ) + ( 2 * 1 0 ^ - 3 ) ) * 1 0 ^ 3 / / i n mH format (7) L e q ( i n mH) = L 1 + L 2 =” ) disp ( l e q , ” T h e r e f o r e , disp ( ” For f = f ma x = 2 . 5 MHz” ) disp ( ” f = 1 / 2∗ p i ∗ s q r t (C∗ L e q ) ” ) c = ( 1 / ( 4 * ( % p i ^ 2 ) * ( ( 2 . 5 * 1 0 ^ 6 ) ^ 2 ) * ( 2 . 0 0 2 * 1 0 ^ - 3 ) ) ) * 1 0 ^1 2
// i n pF 10 11 12 13 14
format (7) disp (c , ” T h e r e fo r e , C( i n pF ) =” ) disp ( ” For f = f mi n = 1 MHz” ) disp ( ” f = 1 / 2∗ p i ∗ s q r t (C∗ L e q ) ” ) c 1 = ( 1 / ( 4 * ( % p i ^ 2 ) * ( ( 1 * 1 0 ^ 6 ) ^ 2 ) * ( 2 . 0 0 2 * 1 0 ^ - 3 ) ) ) * 1 0 ^ 12
// i n pF 15 format (8) 16 disp ( c 1 , ” T h e r e fo r e , C( i n pF ) =” ) 17 disp ( ” Thus C must b e v a r i e d f ro m 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 / / E x am pl e 4 . 2 7
58
2 clc 3 ceq=((0.02*12*10^-24)/(12.02*10^-12))*10^12
// i n
pF format (8) disp ( c e q , ” C eq ( i n pF ) = C1 ∗C2 / C1+C2 =” ) f s = ( 1 / ( 2 * % p i *sqrt ( 5 0 * 0 . 0 2 * 1 0 ^ - 1 5 ) ) ) * 1 0 ^ - 6 / / i n MHz format (7) disp ( f s , ” T h e re fo r e , f s ( i n MHz) = 1 / 2 ∗ p i ∗ s q r t ( L∗ C1) =” ) 9 f p = ( 1 / ( 2 * % p i *sqrt ( 5 0 * 0 . 0 1 9 9 6 * 1 0 ^ - 1 5 ) ) ) * 1 0 ^ - 6 // i n 4 5 6 7 8
MHz 10 format (7) 11 disp ( f p , ” T h e re fo r e , f p ( i n MHz) = 1 / 2 ∗ p i ∗ s q r t ( L∗ C eq ) =” ) 12 disp ( ” L e t C s = 5 pF c on ne ct ed a c r o s s t he c r y s t a l ” ) 13 c 2 = 1 2 + 5 14 disp ( c 2 , ” T h e r e fo r e , C ’ ’ 2 ( i n pF ) = C2 + C x =” ) 15 format (10) 16 c e q 1 = 0 . 0 1 9 9 7 6 17 disp ( c e q 1 , ” T h e r e fo r e , C ’ ’ e q ( i n pF ) = C1 ∗C ’ ’ 2 / C1+ C ’ ’ 2 =” ) 18 f p 1 = 5 . 0 3 5 8 8 19 disp ( f p 1 , ” T h e r e fo r e , f ’ ’ p ( i n MHz) = 1 / 2 ∗ p i ∗ s q r t ( L∗ C eq ) =” ) 20 disp ( ”New C x = 6 pF i s c o n n e c te d t he n , ” ) 21 c 2 1 = 1 2 + 6 22 disp ( c 2 1 , ” C ’ ’ ’ ’ 2 ( i n pF ) = C2 + C x =” ) 23 c e q 2 = 0 . 0 1 9 9 7 7 8 24 disp ( c e q 2 , ” T h e r e f o r e , C ’ ’ ’ ’ e q ( i n pF ) = C1 ∗C ’ ’ ’ ’ 2 / C1+C’ ’ ’ ’ 2 =” ) 25 f p 2 = 5 . 0 3 5 7 1 6 26 disp ( f p 2 , ” T h e r e fo r e , f ’ ’ ’ ’ p ( i n MHz) = 1 / 2 ∗ p i ∗ s q r t ( L∗C ’ ’ ’ ’ e q ) =” ) 27 c = ( 5 . 0 3 5 8 8 - 5 . 0 3 5 7 1 6 ) * 1 0 ^ 6 28 disp (c , ” T h e r e fo 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 / / E xa mp le 5 . 1 2 clc 3 disp ( ” G ive n p ro bl em
4 5 6 7 8 9 10 11 12 13
s pe ci f ic that there are three i n pu t v a r i a b l e s and on e o ut pu 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 np ut v a r i a b l e s and a s s i g n Y l e t t e r sy mb ol t o on e o ut pu t v a r i a b l e . The r e l a t i o n s h i p b et we en i n pu t v a r i a b l e s and o ut pu 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” ) 0 0 0 ”) disp ( ” 0 disp ( ” 0 0 1 0 ”) 1 0 0 ”) disp ( ” 0 disp ( ” 0 1 1 1 ”) 0 0 0 ”) disp ( ” 1 disp ( ” 1 0 1 1 ”) 1 0 1 ”) disp ( ” 1 disp ( ” 1 1 1 1 ”) disp ( ”Now we o b t ai n t he s i m p l i f i e d B oo le an e x p r e s s i o n f o r o u t p ut 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
BC BC’ ’ B’ ’C’ ’ disp ( ” disp ( ”A 0 0 1 0 1 1 disp ( ”A’ ’ 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 / / E xa mp le 5 . 2 2 clc 3 disp ( ” The t ru t h t a b l e f o r t h e g iv en p r o b l e m i s a s shown below . ” ) 4 disp ( ” C D3 D2 D1 Output ” ) 5 disp ( ” 0 x x x 0”) 6 disp ( ” 0 0 0 0 0 ”) 7 disp ( ” 0 0 0 1 1 ”) 8 disp ( ” 0 0 1 0 1 ”) 9 disp ( ” 0 1 0 0 1 ”) 10 disp ( ” ” ) 11 disp ( ”K−map s i m p l i f i c a t i o n ” ) 12 disp ( ” D1 ’ ’ D2 ’ ’ D1 ’ ’ D2 D1D2 D1D2 ’ ’ ”) 13 disp ( ”C ’ ’ D3 ’ ’ 0 0 0 0”) 14 disp ( ”C ’ ’ D3 0 0 0 0 ”) 15 disp ( ”CD3 1 X X X” ) 16 disp ( ”CD3 ’ ’ 0 1 X 1 ”) 17 disp ( ” ” ) 18 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 2 3 4 5
/ / E xa mp le 5 . 3
6 7 8 9 10 11 12 13 14 15 16 17 18
clc disp ( ” T ru th t a b l e ” ) disp ( ” Input Decimal D i g i t disp ( ” ) A B C D Y7 disp ( ” Y0” ) 0 0 0 0 0 disp ( ” 0”) disp ( ” 0 0 0 1 0 1”) disp ( ” 0 0 1 0 0 0”) disp ( ” 0 0 1 1 0 1”) disp ( ” 0 1 0 0 0 0”) disp ( ” 0 1 0 1 0 1”) disp ( ” 0 1 1 0 0 0”) 0 1 1 1 0 disp ( ” 1”) 1 0 0 0 0 disp ( ” 0”) 1 0 0 1 0 disp ( ” 1”) disp ( ” ” ) disp ( ” Her e Y0 = D, Y1 = 0 ,
Output ” ) Digit 1 Digit 0” Y6
Y5
Y4
Y3
Y2
Y1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
1
0
1
0
0
1
0
0
0
0
0
1
0
0
1
0
0
1
1
0
0
0
0
1
1
0
1
0
1
0
0
0
0
0
1
0
0
0
1
0
Y2 C , Y5 = B , Y6 = A and Y7 = g i ve n c i r c u i t ca n be o b t a i n e d l i n e s w i th ou t u s i n g any l o g i c
62
= D, Y3 = 0 , Y4 = 0 . T he re fo re , t he fro m t he i np u t g at es ”)
Scilab code Exa 5.4 design logic circuit
1 / / E xa mp le 5 . 4 2 clc 3 disp ( ” Le t u s c o n s i d er D f o r Door , I f o r i g n i t i o n , L
4 5 6 7 8
9
10 11 12 13 14 15 16 17 18 19 20 21 22
f o r L ig h t . Then c o n d i t i o n s t o a c t i v a t e t he a l ar m a re : ” ) disp ( ” 1 . The h e a d l i g h t s a re ON w h il e t he i g n i t i o n i s OFF. ” ) disp ( ” i . e . L = 1 , I = 0 and D may be a ny th in g . ” ) disp ( ” 2 . The d d o r i s open w h il e t he i g n i t i o n i s ON” ) disp ( ” i . e . D = 1 , I = 1 , L may be a ny th in g . ” ) disp ( ” A l so a l a r m w i l l so un d i f l o g i c c i r c u i t o u tp u t is zero . ”) disp ( ” T h er ef or e , o ut pu t f o r a b o ve c o n d i t i o n i s z e ro 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 w h ich i s su mma rized i n t he f o l l o w i n g t a b l e . ” ) I L Y” ) disp ( ” D disp ( ” 0 0 0 1 ”) 0 1 0 ”) disp ( ” X disp ( ” 0 1 0 1 ”) 1 1 1 ”) disp ( ” 0 disp ( ” 1 0 0 1 ”) 1 X 0 ”) disp ( ” 1 disp ( ” T h e r e fo r e , K−map f o r l o g i c c i r c u i t . ” ) I ’ ’L’ ’ I ’ ’L IL IL ’ ’ ” ) disp ( ” 1 0 1 1 ”) disp ( ”D’ ’ 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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/ / E xa mp le 5 . 5
24 25
clc disp ( ” T ru th t a b l e ” ) disp ( ” Dec A B C D Output Y” ) 0 0 0 0 0 0”) disp ( ” disp ( ” 1 0 0 0 1 0”) 2 0 0 1 0 0”) disp ( ” 3 0 0 1 1 0”) disp ( ” disp ( ” 4 0 1 0 0 0”) 5 0 1 0 1 0”) disp ( ” disp ( ” 6 0 1 1 0 0”) 7 0 1 1 1 0”) disp ( ” disp ( ” 8 1 0 0 0 0”) 9 1 0 0 1 0”) disp ( ” disp ( ” 10 1 0 1 0 1”) 1 0 1 1 1”) disp ( ” 11 disp ( ” 12 1 1 0 0 1”) 1 1 0 1 1”) disp ( ” 13 1 1 1 0 1”) disp ( ” 14 disp ( ” 15 1 1 1 1 1”) disp ( ” ” ) disp ( ”K−map s i m p l i f i c a t i o n ” ) C ’ ’ D’ ’ C’ ’D CD disp ( ” ) 0 0 0 disp ( ”A’ ’ B ’ ’ disp ( ”A’ ’ B 0 0 0
64
CD’ ’ ” 0 ”) 0 ”)
26 disp ( ”AB 1 27 disp ( ”AB’ ’ 0 28 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 2 3 4 5
/ / E xa mp le 5 . 6 clc disp ( ” disp ( ” disp ( ”
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
I n p u t 1 −> P r e s s u r e i n f u e l t a n k ” ) I n p u t 2 −> Pr e s s u r e i n o x i d i z e r t a n k ” ) Input = 1 I n d ic at es p re ss ur e i s e qu a l to or a b ov e t h e r e q u i r e d minimum ” ) = 0 Otherwise ”) disp ( ” disp ( ” I n p u t 3 −> From t i m e r ” ) disp ( ” i f i np ut 3 = 1 I n d i c a t e s t h at t h e re a re l e s s t h a n o r e x a c t l y 10 m in ut es f o r l i f t o f f ” ) = 0 Otherwise ”) disp ( ” Output −> Pa n e l l i g h t , i f l i g h t g oe s on disp ( ” then”) Output = 1 ” ) disp ( ” disp ( ” e l s e Ou tp ut = 0 ” ) disp ( ” ” ) disp ( ” T ru th t a b l e ” ) i np ut 2 = B , i n pu t 3 = C . ” ) disp ( ” Le t i np u t 1 = A, disp ( ” Inputs Output ” ) B C Y” ) disp ( ” A disp ( ” 0 0 0 1 ”) 0 1 0 ”) disp ( ” 0 disp ( ” 0 1 0 1 ”) disp ( ” 0 1 1 0 ”) 0 0 1 ”) disp ( ” 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 / / E xa mp le 5 . 7 2 clc 3 disp ( ” F i g . 5 . 2 0 s ho ws a 32 t o 1 m u l ti p l e x e r u s i n g 74 LS150 ICs . ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.8 design a 32 to 1 multiplexer
1 / / E xa mp le 5 . 8 2 clc 3 disp ( ” F i g . 5 . 2 1 s ho ws a 32 t o 1 m u l ti p l e x e r u s i n g 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 ec od er . . ” )
66
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.9 implement boolean function using 8to1 multiplexer
1 / / E xa mp le 5 . 9 2 clc 3 disp ( ” The f u n c t i o n ca n be i mp le men te d w it h a 8 t o 1
m u l t i p l e xe r , a s shown i n f i g . 5 . 2 2 . Th ree 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 mi nte rm s t o be i n c l u de d ( 1 , 3 , 5 and 6 ) a r e c ho se n by making t h e i r c o r r e sp o n di n g i np u t l i n e s e qu a l t o 1 . Mintems 0 , 2 , 4 and 7 a re n o t i n cl u de d by making t h e i r i np ut l i n e s e qu al 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 / / E x am pl e 5 . 1 0 2 clc 3 disp ( ” F ig . 5 . 2 3 s ho ws t he i m pl em en ta t io n o f f u n c t i o n
w i th 4 t o 1 m u l t i p l e x e r . Two o f t he v a r i a b l e s , B and C, a re 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 on n ec te d t o S1 and C i s c o nn e ct ed 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 re d e r i v e d from t he i m p l e m en t a t i o n t a b l e . ” ) 4 disp ( ” T ru th 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
0 0 0 0 0 ”) disp ( ” disp ( ” 1 0 0 1 1 ”) 2 0 1 0 0 ”) disp ( ” disp ( ” 3 0 1 1 1 ”) 4 1 0 0 0 ”) disp ( ” disp ( ” 5 1 0 1 1 ”) 6 1 1 0 1 ”) disp ( ” disp ( ” 7 1 1 1 0 ”) disp ( ” ” ) disp ( ” I m p l e m e n ta t i o n t a b l e ” ) D0 D1 D2 D3” ) disp ( ” 0 1 2 3 Row 1 ” ) disp ( ”A’ ’ disp ( ”A 4 5 6 7 Row 2 ” ) 0 1 A A’ ’ ” ) disp ( ” disp ( ” ” ) disp ( ” As shown i n f i g . 5 . 2 3 ( c ) t h e i m p le m en t a ti o n t a b l e i s n ot hi ng but t h e l i s t o f t he i n p u t s o f t he m i l t i p l e x e r s and u n de r them l i s t o f a l l t he m in te rm s i n two r ow s . The f i r s t row l i s t s a l l t h o s e m in te rm s w he re A i s c om pl em en te d , a nd t h e s e co n d row l i s t s a l l t h e m in te rm s w it h A u nc om pl em en te d . The m i nt er m s g i v e n i n t h e f u n c ti o n a r e c i r c l e d and t he n e ac h column i s i n s e r te d s e p ar a t el y a s f o l l o w s . ”) disp ( ” 1 . I f t he two m in te rm s i n a column a r e n ot c i r c l e d , O i s a p p l i ed t o t he c o r r e s p o n d in g m u l t i p l e x e r i n p u t ( s e e co lu mn 1 ) . ” ) disp ( ” 2 . I f t he two m i n te rm s i n a column a r e c i r c l e d , 1 i s a p p l i e d t o t he c o r r e s p o nd i n g m u l t i p l e x e r i n p u t ( s e e c ol um n 2 ) . ” ) disp ( ” 3 . I f t h e minterm i n t he s ec o nd row i s c i r c l e d and m in ter ms i n t he f i r s t row i s n ot c i r c l e d , A i s a p pl i ed t o t h e c o r r e s p o n d i n g m u l t i p l e x e r i np ut ( s e e c ol um n 3 ) . ” ) disp ( ” 4 . I f t he minterm i n t he f i r s t row i s c i r c l e d and minterm i n t he s ec on d row i s n ot c i r c l e d , A’ ’ i s a p p l i e d t o t he c o r r e s p o n d in g m u l t i p l e x e r i n p u t ( s e e c ol um n 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 / / E x am pl e 5 . 1 1 2 clc 3 disp ( ” F ig 5 . 2 5 sh ows t he i m pl em e nt a ti o n o f g i ve n B oo ol ea n f u n c t i o n w it h 8 : 1 m i l t i p l e x e r . ” ) 4 disp ( ” I m p l e m e n ta t i o n t a b l e ” ) 5 disp ( ” D0 D1 D2 D3 D4 D5 D6 D7” ) 6 disp ( ”A’ ’ 0 1 2 3 4 5 6 7 ”) 7 disp ( ”A 8 9 10 1 1 1 2 1 3 1 4 1 5 ” ) 8 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 / / E x am pl e 5 . 1 2 2 clc 3 disp ( ” The f u n c t i o n h as f o u r v a r i a b l e s . To i mp le men 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 dy s ee 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 si ng two 4 : 1 m u l t i p l e x e r s . The s ame c o nc ep t i s u se d h e re t o i m pl em en t g i v e n B o ol e an f u n c t i o n . ” ) 4 disp ( ” ” ) 5 disp ( ” I m p l e m e n ta t i o n t a b l e ” ) 6 disp ( ” D0 D1 D2 D3 D4 D5 D6 D7” ) 69
7 disp ( ”A’ ’ 8 disp ( ”A 9 disp ( ”
0
1
8 9 A’ ’ 1
2 3 4 5 6 7 ”) 10 1 1 1 2 1 3 1 4 1 5 ” ) 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 / / E x am pl e 5 . 1 3 2 clc 3 disp ( ” The g i v en B oo le an 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 n ot i n s t a nd a r d SOP f or m . L et 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 f o rm . ” ) 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” ) = A’ ’ BCD’ ’ + A’ ’ BC’ ’ D’ ’ + ABCD disp ( ” + AB’ ’CD + A’ ’B’ ’CD + A’ ’BC’ ’D + A’ ’B’ ’C’ ’D” ) disp ( ” ” ) disp ( ” The t r u th t a b l e f o r t h i s s t an d ar d SOP form ca n be g i ve n a s ” ) Minterms A B C D Y” ) disp ( ” No . disp ( ” 0 0 0 0 0 0”) A’ ’ B ’ ’ C ’ ’ D 0 0 0 1 1 ”) disp ( ” 1 disp ( ” 2 0 0 1 0 0”) A’ ’ B ’ ’ CD 0 0 1 1 1 ”) disp ( ” 3 disp ( ” 4 A’ ’ BC’ ’ D’ ’ 0 1 0 0 1 ”) A’ ’ BC’ ’ D 0 1 0 1 1 ”) disp ( ” 5 disp ( ” 6 A’ ’ BCD’ ’ 0 1 1 0 1 ”) disp ( ” 7 0 1 1 1 0”) 1 0 0 0 0”) disp ( ” 8 disp ( ” 9 1 0 0 1 0”) 70
20 21 22 23 24 25 26 27
1 0 1 0 0”) disp ( ” 10 disp ( ” 1 1 AB’ ’CD 1 0 1 1 1”) 1 1 0 0 0”) disp ( ” 12 disp ( ” 13 1 1 0 1 0”) 1 1 1 0 0”) disp ( ” 14 disp ( ” 15 ABCD 1 1 1 1 1 ”) disp ( ” ” ) disp ( ”From t he t r u th t a b l e B oo le an f u n c t i o n ca n b e i m p l e m e n t e d u s i ng 8 : 1 m u l t i p l e x e r a s f o l l o w s : ”
28 29 30 31 32
) disp ( ” I m p l em e nt a ti o n t a b l e : ” ) D0 D1 D2 D3 D4 D5 D6 D7” ) disp ( ” disp ( ”A’ ’ 0 1 2 3 4 5 6 7 ”) 8 9 10 11 12 13 14 15 ” ) disp ( ”A 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 / / E xam ple 5 . 1 4 . 2 clc 3 disp ( ” H er e , i n s t e a d
4 5 6 7 8 9
o f m in te rm s , m axt er ms a r e s p e c i f i e d . Thus , we h a ve t o c i r c l e m ax te rm s w hi ch a re n ot i n c l u d e d i n t he B oo le a n f u n c t i o n . F i g . 5 . 2 8 sh ows t he i m pl em en t at i on o f B oo le an f u n c t i o n w i th 8 : 1 m u l t i p l e x e r . ” ) disp ( ” ” ) disp ( ” I m p l em e nt a ti o n t a b l e : ” ) D0 D1 D2 D3 D4 D5 D6 D7” ) disp ( ” disp ( ”A’ ’ 0 1 2 3 4 5 6 7 ”) disp ( ”A 8 9 10 11 12 13 14 15 ” ) 0 A’ ’ A’ ’ A A’ ’ A 0 1”) disp ( ”
71
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.15 implement boolean function using 8to1 MUX
1 / / E x am pl e 5 . 1 5 2 clc 3 disp ( ” I n t he g i ve n B oo le an f u n c t i o n t h r e e don ’ ’ t
4 5 6 7 8 9 10 11
c a re c o n d i t i o n s a re a l s o s p e c i f i e d . We know t ha 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 s ho ws t he i mp le me nt at io n o f g i ve n B oo le a n f u n c ti o n u s in g 8 : 1 m u l t i p l e x e r . ” ) disp ( ” ” ) disp ( ” I m p l em e nt a ti o n t a b l e : ” ) D0 D1 D2 D3 D4 D5 D6 D7” ) disp ( ” 0 1 2 3 4 5 6 7 ”) disp ( ”A’ ’ disp ( ”A 8 9 10 11 12 13 14 15 ” ) 1 0 1 1 A A 1 0 ”) disp ( ” disp ( ” ” ) by t a k in g don ’ ’ t c a r e disp ( ” I n t h i s example , c o n d i t i o n s 8 and 14 we h ave e l i m i n a t e d A ’ ’ term and h en ce t he 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 2 3 4
/ / E x am pl e 1 5 . 6 clc disp ( ” disp ( ”D
D’ ’ 0
D” ) 1 ”) 72
5 6 7 8 9 10 11 12 13
14 15 16
17
18
19
2 3”) disp ( ” 0 disp ( ” 0 4 5”) 6 7”) disp ( ” 1 disp ( ”D 8 9 ”) 10 11 ” ) disp ( ” 1 disp ( ”D’ ’ 12 13 ” ) 14 15 ” ) disp ( ” 0 disp ( ” ” ) disp ( ” Here , i mp le me n ta ti on t a b l e
is list ed for least s i g n i f i c a n t b i t i . e . D . The f i r s t co lu mn l i s t a l l m in te rm s w it h D i s c om pl em en ta te d and t h e s e co n d col umn l i s t s a l l t h e m in te rm s w it h D u nc om pl em en te d , a s shown i n f i g . 5 . 3 0 ( a ) . Then a c co r d i n g t o d a ta i n pu t s g i v en t o t he m u l t i p l e x e r mi n te rm s a r e c i r c l e d a p pl 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 m in term 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 pu t 1 , c i r c l e bo th t he m in te rm 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 np u t i s D, c i r c l e t he minterm b e l o ng s t o cloumn D i n t he c o r r es p o n d i ng row . ” ) disp ( ” 4 . I f m u l t i p l e x e r i n pu t i s D’ ’ , c i r c l e t he min term b e l o n g s t o co lum n D’ ’ i n t h e c o r r e s p o n d i n g row . ” ) disp ( ” Th 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 te rm s ca n be w r i tt e n t o g e t B oo le an e x pr e ss i o n a s 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 / / E x am pl e 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 / / E x am pl e 5 . 1 8 2 clc 3 disp ( ” The c a s ca d i n g o f d e m u l t i p l ex e r s
i s s i m i l a r to t he c a s c ad i n g o f d ec o de r . F ig . 5 . 3 3 s ho ws c a s c a d i n g o f two 1 : 4 d e m u l t i p l ex e r s t o f orm 1 : 8 demultiplexer . ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.19 implement full subtractor
1 / / E x am pl e 5 . 1 9 2 clc 3 disp ( ” L e t u s s e e t he t r ut h t a b l e o f ”) 4 disp ( ” A B Bin D Bout ” )
74
f u l l s u b t r ac t o r .
5 6 7 8 9 10 11 12 13 14
disp ( ” 0 0 disp ( ” 0 0 disp ( ” 0 1 disp ( ” 0 1 disp ( ” 1 0 disp ( ” 1 0 disp ( ” 1 1 disp ( ” 1 1 disp ( ” ” ) disp ( ” For f u l l
0 1 0 1 0 1 0 1
0 1 1 0 1 0 0 1
0 ”) 1 ”) 1 ”) 1 ”) 0 ”) 0 ”) 0 ”) 1 ”)
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 ti o n ca n be w r i t t e n a s D = f (A , B , C) = summ ation m ( 1 , 2 , 4 , 7 ) and Bout f u n c ti o n ca n 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 in te rm s a t t he o ut p ut s o by l o g i c a l l y ORing r e q u i r e d m in te rm s we ca n i mp le me nt B oo le an 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 ig . 5 . 3 4 s ho ws t h e i m pl em en t at i on o f f u l l s u b t r a c t o r u s i ng demu ltip lexer . ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.20 construst 1 to 32 DEMUX
1 / / E x ma pl e 5 . 2 0 2 clc 3 disp ( ” The f i g . 5 . 3 7 sh ows t he i mp le me nt at io n o f 1 t o
3 2 d e m u l t i p l e x e r u s i n g two 7 4X154 I Cs . 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 na b l e e i t h e r u p p er 1 t o 16 d e m u l ti p l e x er o r l ow er 1 t o 16 d e m u l t i p l e x er . The d at a i np u t and o th er s e l e c t s i g n a l s a re c o nn e c t e d p a r a l l e l t o b ot h t h e d e m u l t i p l e x e r I Cs . When A4 = 0 , u pp er 75
d e m u l t i p le x e r i s e na bl ed and t he d at a i np u t i s r ou te d t o t he o ut p u t c o r r e s p o n d s t o t h e s t a t u s o f 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 na bl ed and t h e d a t a i np ut i s r ou te d t o t he o ut p u t c o r r e s p o n d s t o t h e s t a t u s o f 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 / / E x am pl e 5 . 2 1 2 clc 3 disp ( ” F ig . 5 . 40 s ho ws 3 t o 8 l i n e
4 5 6 7
8
d ec od er . Here , 3 i n p u t s a r e d e co de d i n t o e i g h t o ut pu ts , e a ch o ut pu t r e p r e s en t on e o f t he m i n te rm s o f t he 3 i n p ut 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 id e t he complement o f t he i n pu ts , and e ac h on e o f t he e i g h t AND g a t e s g e n e r a t e s o ne o f t h e m in te rm s . E n a bl e i np u t i s p ro vi d e d t o a c t i v a t e d ec o de d o ut pu t b as ed on d at a i n p u ts A, B and C . The t a b l e s hows t he t r ut h t a b l e f o r 3 t o 8 d ec od er . ” ) disp ( ” ” ) disp ( ” Truth t a b l e f o r a 3 t o 8 d ec od er ” ) disp ( ” Inputs Outputs”) | Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 disp ( ”EN A B C | ”) X X X | 0 0 0 0 0 0 0 0” disp ( ” 0
) 9 disp ( ” 1 ) 10 disp ( ” 1 ) 11 disp ( ” 1
0
0
0
|
0
0
0
0
0
0
0
1”
0
0
1
|
0
0
0
0
0
0
1
0”
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 / / E x am pl e 5 . 2 2 2 clc 3 disp ( ” The F ig . 5 . 4 5 sh ows t he c o n s t r u c t i o n o f 5 t o
32 d e co d er u s i ng f o u r 74 L S1 38 s 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 ec od er t o d ec od e t he two h i g h e r o r de r i np ut s , D and E . The f o u r o u t pu ts o f t h i s d ec od er a r e u se d t o e na b l e on e o f t h e f o u r 3 t o 8 d e c od e r s . The t h r e e l o w er i n p u t s A , B and C a r e c on ne ct ed i n p a r a l l e l t o f o ur 3 t o 8 d ec o d er s . T h i s means t ha t t h e s ame o u t p u t p in o f e a c h o f t h e f o u r 3 t o 8 d ec o d e r s i s s e l e c t e d b ut o nl y on e i s e na b l e . The r em ai ni ng e n a b le s s i g n a l s o f f o u r 3 t o 8 d e c o d er s I Cs a re c on ne ct ed i n p a r a l l e l t o c o n s t r u c t e na b l e s i g n a l s f o r 5 t o 32 d ec od er . ” )
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 / / E x am pl e 5 . 2 3 2 clc 3 disp ( ” 4 l i n e t o 16 l i n e d e c o d e r u s in g 1 l i n e t o 4 l i n e d ec od er ” ) 4 disp ( ” As s hown i n f i g . 5 . 4 6 f i v e numbers o f 2 : 4
d ec o de r a re r e q u i r e d t o d e s i g n 4 : 16 d ec od er . D e c o d e r 1 i s u se d t o e n a b le o ne o f t he d ec od er 2 , 3 , 4 and 5 . I n pu t s o f f i r s t d ec od er a r e t he A and B MSB i n p u t s o f 4 : 16 d ec o de r . The i n p u t s o f d e co d er a r e c o nn e ct ed t o g e t h e r f o rm in g C and D LSB i n p u ts o f 4 : 16 d e co d er . ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 5.24 implement using 74LS138
1 / / E x am pl e 5 . 2 4 2 clc 3 disp ( ” I n t h i s example , we u se IC 74 LS138 , 3 : 8
d e co d er t o i mp le men t m u l t i p l e o ut pu t f u n c t i o n . The o u tp u ts 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 ) c an be i mp le me nt ed 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 ) c an b e i m pl em e nt ed 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 / / E x am pl e 5 . 2 5 2 clc 3 disp ( ” The t ru t h t a b l e f o r f u l l s u b t r a c t o r i s a s s ho wn b e l o w ” ) 4 disp ( ” ” ) 5 disp ( ” I n p u t s Ou tp uts ” ) 6 disp ( ”A B Bin D Bout ” ) 7 disp ( ” 0 0 0 0 0 ”) 8 disp ( ” 0 0 1 1 1 ”) 9 disp ( ” 0 1 0 1 1 ”) 10 disp ( ” 0 1 1 0 1 ”) 11 disp ( ” 1 0 0 1 0 ”) 12 disp ( ” 1 0 1 0 0 ”) 13 disp ( ” 1 1 0 0 0 ”) 14 disp ( ” 1 1 1 1 1 ”) 15 disp ( ” ” ) 16 disp ( ” I m p le me nt at io n o f f u l l s u b t r a c t o r u s in g 3 : 8 d ec od er 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 / / E x am pl e 5 . 2 6 2 clc
79
3 disp ( ” The t ru t h t a b l e f o r 3− b i t b i n a r y t o g ra y c od e c o n v e r t e r i s a s shown b el ow ” ) 4 disp ( ” ” ) 5 disp ( ”A B C G2 G1 G0” ) 6 disp ( ” 0 0 0 0 0 0”) 7 disp ( ” 0 0 1 0 0 1”) 8 disp ( ” 0 1 0 0 1 1”) 9 disp ( ” 0 1 1 0 1 0”) 10 disp ( ” 1 0 0 1 1 0”) 11 disp ( ” 1 0 1 1 1 1”) 12 disp ( ” 1 1 0 1 0 1”) 13 disp ( ” 1 1 1 1 0 0”) 14 disp ( ” ” ) 15 disp ( ” The f i g . 5 . 5 2 sh ows t he i m pl em e nt a ti o n o f 3−
b i t b in ar y t o g ra y c o d e c o nv e rt e r u s i n g 3 : 8 d ec od er . As o ut pu ts o f 7 4 13 8 a r e a c t i v e lo w we h av e 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 lo w o ut pu t fro m t he d ec o de r f o r c e s o ut pu t ( s ) o f c o n n e c t e d NAND g a t e ( s ) t o b ec om e HIGH , t h u s i m p l em e n ti n g t h e 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 2 3 4 5 6 7 8 9
/ / E x am pl e 5 . 2 7
clc disp ( ” ” ) disp ( ”A1 disp ( ” 0 disp ( ” 0 disp ( ” 0 disp ( ” 0 disp ( ” 0
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 / / E x am pl e 5 . 2 8 2 clc 3 disp ( ” T ru th t a b l e ) 4 disp ( ” Inputs 5 disp ( ”A B Cin 6 disp ( ” 0 0 0 7 disp ( ” 0 0 1 8 disp ( ” 0 1 0 9 disp ( ” 0 1 1 10 disp ( ” 1 0 0 11 disp ( ” 1 0 1 12 disp ( ” 1 1 0 13 disp ( ” 1 1 1
for
f u l l a d de r i s a s shown b el ow . ”
Ou tpu ts ” ) Ca 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 2 3 4 5 6 7 8 9 10 11 12 13 14
/ / E x am pl e 5 . 2 9
clc disp ( ”BCD−to−common anode 7−s eg me nt d e c o d e r ” ) A B C D a b c d e f disp ( ” D i g i t disp ( ” 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 1 disp ( ” 1 disp ( ” 2 0 0 1 0 0 0 1 0 0 1 0 0 1 1 0 0 0 0 1 1 disp ( ” 3 disp ( ” 4 0 1 0 0 1 0 0 0 1 1 0 1 0 1 0 1 0 0 1 0 disp ( ” 5 0 1 1 0 0 1 0 0 0 0 disp ( ” 6 disp ( ” 7 0 1 1 1 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 disp ( ” 8 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 / / E x am pl e 5 . 3 1 2 clc 3 disp ( ” F i g . 5 . 7 5 s ho ws how f o u r 7 4 LS148 c an be
c on n e ct ed t o a c c e p t 32 i n pu t s and p ro du ce a 5− b i t 82
e n c od e d o u tp u t , A0 − A4 . EO’ ’ s i g n a l i s c on n e ct ed t o t he EI ’ ’ i np u t o f t he n ex t l o w er p r i o r i t y e nc od er and EI ’ ’ i np ut o f t he h i g h e s t p r i o r i t y e nc o de r i s g ro un de d . T he r ef or e , a t any t im e o n ly on e e nc o de r i s e n ab l ed . S in ce , t he A2 − A0 o u t pu ts o f a t t he most on e 74 LS148 w i l l be e na bl ed a t a time , t he o ut pu ts o f t he i n d i v i d u a l 7 4 L S1 48 s c an b e ORed t o p r o du c e A2 − A0 . L i k ew i s e , t he i n d i v i d u a l GS ’ ’ o u tp u ts can be co mb ined i n a 4 t o 2 e nc o de r t o p ro du ce A4 a nd A3 . The GS o ut pu t f o r 32− b i t e n c od e r i s p ro du ce db y ORing GS ’ ’ o ut pu ts o f a l l e n c od e r s . ” )
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 / / E xa mp le 6 . 4 2 clc 3 disp ( ”To a n al y ze t he 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 he t ru t h t a b l e f o r i t . ” ) disp ( ”We h av e , 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” ) 0 0 0 disp ( ” down 0 ”) 0 1 1 disp ( ” down 1 ”) 1 0 1 disp ( ” down 1 ”) 1 1 0 disp ( ” down 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 ut d oe s n o t c h a ng e when i np u t i s 0 and i t t o g g l e s when i n p ut 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 he g i v en c i r c u i i s T f l i p − f l o p 84
c o n st r u ct e d u s in 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 / / E xa mp le 7 . 1 2 clc 3 disp ( ” ( i ) A 6− b i t b i n a r y number r e q u i r e s r e g i s t e r w i t h 6 f l i p − f l o p s . ” ) 4 disp ( ” ” ) 5 disp ( ” ( i i ) ( 3 2 ) 1 0 = ( 1 00 0 0 0) 2 . The number o f b i t s
6 7
8 9
r e q u i r e d t o r e p re s e n t 32 i n b in ar y a re s ix , t h e r e f o r e , 6 f l i p − f l o p s a re n e e d e d t o 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 ec im al . ” ) 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 t o r e p re s e n t ( F) 1 6 i n b in ar y a re f o ur , t h e r e f o r e f o u r f l i p − f l o p s a re n e e d e d t o c o n s t r u c t a r e g i s t e r c ap ab le o f s t o r i n g ( F ) 1 6 ” ) disp ( ” ” ) disp ( ” ( i v ) ( 1 0 ) 8 = ( 1 0 00 ) 2 . The number o f b i t s r e q u i r e d t o r e p re s e n t ( 1 0 ) 8 i n b in ar y a re f o ur , t h e r e f o r e , f o u r f l i p − f l o p s a re n e e d e d t o c o n s t r u c t a r e g i s t e r c ap ab le o f s t o r i n g ( 1 0 ) 8 . ” )
86
Chapter 8 Counters
Scilab code Exa 8.1 count after 12 pulse
1 / / E xa mp le 8 . 1 2 clc 3 disp ( ” A f te 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 , . e . 1 2 i n d e c im a l . ” )
Scilab code Exa 8.2 count in binary
1 2 3 4 5
/ / E xa mp le 8 . 2
clc a=dec2bin(144) disp (a , ” d e c i m a l ( 1 4 4 ) =” ) disp ( ” S i n ce c o un te r i s a 5− b i t c o u n t e r , i t r e s e t s a f t e r 2 ˆ5 = 32 c l o c k p u l s e s . ” ) 6 disp ( ” D i v id i ng 14 4 by 32 we g et q u o ti e n t 2 and r e ma i n de r 6 ” ) 7 disp ( ” T h er ef or e , c o un t e r r e s e t s f o u r t im es and t he n
i t c ou nt s r em ai ni ng 16 c l o c k p u l s e s . Thus , t he c ou nt w i l l be b i n a r y ( 1 1 0 0 0 0) , i . e . , 16 i n decimal”) 87
i
Scilab code Exa 8.4 draw logic diagram
1 / / E xa mp le 8 . 4 2 clc 3 disp ( ” When f l i p − f l o p s
a re n e g a t i v e l y t h e Q ou t p u t o f p r e v i o us s t a g e i s t he c l o c k i np u t o f t he n ex t s t a g e . 3− s t a g e a s yn ch ro n ou s c o u nt e r w it h t r i g g e r e d f l i p − f l o p s . ” )
edge t r ig g er e d , c on ne ct ed t o F ig . 8 . 5 s ho ws n e g a t i v e e dg e
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.5 output frequency
1 2 3 4 5
/ / e xa mp le 8 . 5 clc of=50/14 format (5) disp ( o f , ” O utp ut f r e q u e n c y = 5 0 kHz / 1 4 =” )
Scilab code Exa 8.6 maximum operating frequency
1 / / E xa mp le 8 . 6 2 clc 3 disp ( ”We know th a t MOD−32 u s e s f i v e
f l i p − f l o p s . With t pd = 50 ns , t he f m a x f o r r i p p l e c ou nt er ca n be g i v e n a s , ” )
4 fm=(1/(250*10^-9))*10^-6
88
5 disp ( f m , ” f m ax ( r i p p l e ) = ” )
Scilab code Exa 8.8 design 4 bit up down ripple counter
1 / / E xa mp le 8 . 8 2 clc 3 disp ( ” T h e 4− b i t c ou nt er n ee 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 un t er 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 nt e r e x ce p t t h a t 4− b i t c o u n t e r h as o ne more f l i p − f l o p and i t s c l oc k d r i vi n g c i r c u i t i n g . ”) 4 disp ( ” The f i g . 8 . 1 4 sh ows t h e 4− b i t up /down r i p p l e cou nte r . ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.9 design divide by 9 counter
1 / / E xa mp le 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 s hown i n f i g . 8 . 1 6 . ”) 4 disp ( ” ” ) 5 disp ( ” The c i r c u i t d i a gr a m f o r d i v i de −by −9 c o un te 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 / / E x am pl e 8 . 1 0 2 clc 3 disp ( ” S i n ce 12 8 = 1 6 x 8 , a d i vi d e −by −16 c o u n t er
f o l l o we d by a d i vi 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 id e −by −16) , t h e r e f o r e , two IC p ac ka g es 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 gr 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 / / E x am pl e 8 . 1 1 2 clc 3 disp ( ” S i n ce 78 = 13 x 6 , we h ave t o u se 7 4 9 3 a s mod−
a 3 and 7 49 2 a s mod−6 c o u n t e r s . Fo r t h e mod−13 c o u n t e r QD, QC a nd QA o u t p u t s o f 7 4 93 a n s ANDed and u se d t o c l e a r t he c ou nt when t he c ou nt r e a c h es 1 1 0 1 . For t he mod−6 c o un te r , c l o c k i s a p p li e d t o B i n p ut o f 7 4 92 . ” ) 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 / / E x am pl e 8 . 1 2 2 clc 3 disp ( ” The f i g . 8 . 2 0 s ho ws d i vi d ed −by −6 (MOD 6 )
c ou n te r u s in g 7 4 9 3 . As shown i n t he f i g . 8 . 2 0 , t he c l o c k i s a p pl i ed t o i n o u t B o f IC 7 49 3 and t h e o u tp u t c o un t s e q u e n c e i s t a k en f ro m QD, QC and QB . As s oo n a s c ou nt i s 1 1 0 , i . e . QD a nd QC = 1 , t h e i n t e r n a l NAND g a te o ut pu t g o es lo w a nd 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 / / E x am pl e 8 . 1 3 2 clc 3 disp ( ” For a s yn ch ro no us c o u n te r t he t o t a l
d el a y t ha t must be a l lo w e d b et w ee n i n p ut c l o ck p u l s e s i s e qu al 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 he c o u n t e r h as ”)
4 5 6 7
fm=(1/(70*10^-9))*10^-6 format (5) f m a x ( i n MHz ) =” ) disp ( f m , ” disp ( ”We know th a t MOD−16 r i p p l e
c o u n t e r u se 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 = 5 0 ns , t h e f m a x f o r r i p p l e c o u n te r can be g i ve n a s , ” )
8 fma=(1/(4*(50*10^-9)))*10^-6 9 format (3) 10 disp ( f m a , ” f m a x ( r i p p l e ) ( i n MHz) =” )
91
Scilab code Exa 8.14 determine states
1 / / E x am pl e 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 er . Thus i t i s MOD−16 c o u n t e r . H ow ev er , 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 et w ee n 16 and 11 i s 5 . Hence 5 s t e p s must b e s k i p p e d f ro m t h e f u l l m od ul us s e q u e n c e . T h is can be a c hi e v e d by p r e s e t t i n g c o u n t er t o v a lu e 5 . Each t i me when c o u n te 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 fro m 5 u pt o 16 on e a ch f u l l c y c l e . T he re fo re , e ac h f u l l c y c l e o f t he c o u n t e r 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 / / E x am pl e 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 er . Thus i t i s MOD−16 c o u n t e r . H ow ev er , 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 et w ee n 16 and 10 i s 6 . Hence 6 s t e p s must b e s k i p p e d f ro m t h e f u l l m od ul us s e q u e n c e . T h is can be a c hi e v e d by p r e s e t t i n g c o u n t er t o v a lu e 6 . Each t i me when c o u n te 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 fro m 6 u pt o 16 on e a ch f u l l c y c l e . T he re fo re , e ac h f u l l c y c l e o f t he c o u n t e r 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 / / E x am pl e 8 . 1 6 2 clc 3 disp ( ” The f i g 8 . 3 6 s ho ws t he c o n n e c ti o n s f o r 74 LS191
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
t o g et d e s i r e o p e ra t i o n . We ca n d e si g n t he c o m b in a ti o na l c i r c u i t f o r s u ch c o u n t e r fro m t he t r u t h t a b l e sho wn b el o w . ” ) disp ( ” ” ) disp ( ”Q3 Q2 Q1 Q0 Y” ) 0 0 0 0 ”) disp ( ” 0 0 0 1 0 ”) disp ( ” 0 disp ( ” 0 0 1 0 0 ”) 0 1 1 1 ”) disp ( ” 0 disp ( ” 0 1 0 0 1 ”) 1 0 1 1 ”) disp ( ” 0 disp ( ” 0 1 1 0 1 ”) 1 1 1 1 ”) disp ( ” 0 disp ( ” 1 0 0 0 1 ”) 0 0 1 1 ”) disp ( ” 1 disp ( ” 1 0 1 0 1 ”) 0 1 1 1 ”) disp ( ” 1 disp ( ” 1 1 0 0 1 ”) disp ( ” 1 1 0 1 1 ”) 1 1 0 0 ”) disp ( ” 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 ” ) Q1 ’ ’ Q0 ’ ’ Q1 ’ ’ Q0 Q1Q0 Q1Q0 ’ ’ ” ) disp ( ” disp ( ”Q3 ’ ’ Q2 ’ ’ 0 0 1 0 ”) 1 1 1 1”) disp ( ”Q3 ’ ’ Q2 disp ( ”Q3Q2 1 1 0 0 ”) 1 1 1 1”) disp ( ”Q3Q2 ’ ’ disp ( ” ” ) disp ( ” T h e r e f o r e , PL ’ ’ = Y = Q3 ’ ’ Q1Q0 + Q3 ’ ’ Q2 + Q3Q1 ’ ’ + Q3Q2 ’ ’ ” ) disp ( ” A f t er s w i t c h ON, i f t he c o u n t e r o ut pu t i s o t h er th an 1 10 1 t hr ou gh 0 01 1 , t he PL ’ ’ g o es l ow 93
and c ou nt 1 1 01 i s l o a de d i n t he c o u n te r . The c o un t er i s t he n d ec re me nt ed on t he o c c u rr e n c e o f c l o c k p u l s e s . When c o u n t er r e a c h e s 0 0 10 , t h e PL ’ ’ a g a i n g o e s lo w a nd c o un t 1 10 1 i s l oa d e d i n t he c o u n t e r ”)
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 / / E x am pl e 8 . 1 7 2 clc 3 disp ( ” The IC 7 41 91 i s a 4− b i t
b i na r y c ou nt er , t h e r e f o r e f o u t = f CLK / 16 i n up and down c o un t er mode . I f f CLK = 5 00 Hz and f o u t = 5 0 Hz we n ee d mod 1 0 ( 5 0 0 / 5 0) c o u n t er . The f i g . 8 . 3 9 s ho w s t h e mod−10 c o u nt e r u s i ng IC 7 41 91 ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.18 design a counter
1 / / E x am pl e 8 . 1 8 2 clc 3 disp ( ” The f i g s ho ws t he c o n n e ct i o n s f o r 74 LS191 t o
g e t d e s i r e o p e ra t i o n . We can d e si g n t he c o m b in a ti o na l c i r c u i t f o r s u ch c o u n t e r fro m t he t r u t h t a b l e sho wn b el o w . ” ) 94
disp ( ” ” ) disp ( ”Q3 Q2 Q1 Q0 Y” ) 0 0 0 0 ”) disp ( ” 0 disp ( ” 0 0 0 1 0 ”) 0 1 0 0 ”) disp ( ” 0 disp ( ” 0 0 1 1 1 ”) 1 0 0 1 ”) disp ( ” 0 disp ( ” 0 1 0 1 1 ”) 1 1 0 1 ”) disp ( ” 0 disp ( ” 0 1 1 1 1 ”) 0 0 0 1 ”) disp ( ” 1 0 0 1 1 ”) disp ( ” 1 disp ( ” 1 0 1 0 1 ”) 0 1 1 1 ”) disp ( ” 1 disp ( ” 1 1 0 0 1 ”) 1 0 1 1 ”) disp ( ” 1 disp ( ” 1 1 1 0 1 ”) 1 1 1 0 ”) disp ( ” 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 ’ ’ ” ) 0 0 1 0 ”) disp ( ”Q3 ’ ’ Q2 ’ ’ disp ( ”Q3 ’ ’ Q2 1 1 1 1”) disp ( ”Q3Q2 1 1 0 1 ”) 1 1 1 1”) disp ( ”Q3Q2 ’ ’ 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 er s w i t c h ON, i f t he c o u n t e r o ut pu t i 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
o t h er th an 1 11 0 t hr ou gh 0 01 1 , t he PL ’ ’ g o es l ow and c ou nt 1 1 10 i s l o a de d i n t he c o u n te r . The c o un t er i s t he n d ec re me nt ed on t he o c c u rr e n c e o f c l o c k p u l s e s . When c o u n t er r e a c h e s 0 0 10 , t h e PL ’ ’ a g a i n g o e s lo w a nd c o un t 1 11 0 i s l oa d e d i n t he c o u n t e r ”)
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 / / E x am pl e 8 . 1 9 2 clc 3 disp ( ” IC 7 4 1 9 1 i s a 4− b i t b i na r y c o un t er . Thus i t
d i v i d e s t he i n pu t f r e qu e n cy by 1 6 . However , we c a n d e s i g n MOD−N c o u n t er u s i n g IC 7 4 1 9 1 . Fo r MOD− N c ou n t er t he o ut p u t f r e qu e n c y w i l l be f o u t = f i n / N . Thus by c ha ng i ng N we ca n c ha ng e t he o ut pu t f r eq u e nc y . The f i g . 8 . 4 0 s ho ws t he pro gra mma ble f r eq u n cy d i v i d e r u s i ng IC 7 4 1 91 . ” )
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 / / E x am pl e 8 . 2 0 2 clc 3 disp ( ” F i g . 8 . 4 1 s ho ws D i vi d i ng −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 te r . S in ce , a f t e r
p r e s e t a b o v e c o u n t e r g o e s t hr ou gh 2 s t a t e s 1 1 1 0 and 1 11 1 , i t i s a mod−2 c o u n t e r . Thus , a bo ve c i r c u i t i s a d i v i de −by −2 c o u n t er f o r up c ou 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” ) 0 0 0 0 ”) disp ( ” 0 disp ( ” 0 0 0 1 0 ”) 0 1 0 0 ”) disp ( ” 0 disp ( ” 0 0 1 1 0 ”) 1 0 0 0 ”) disp ( ” 0 disp ( ” 0 1 0 1 0 ”) 1 1 0 0 ”) disp ( ” 0 1 1 1 0 ”) disp ( ” 0 disp ( ” 1 0 0 0 0 ”) 0 0 1 0 ”) disp ( ” 1 disp ( ” 1 0 1 0 0 ”) 0 1 1 1 ”) disp ( ” 1 disp ( ” 1 1 0 0 1 ”) 1 0 1 1 ”) disp ( ” 1 disp ( ” 1 1 1 0 1 ”) 1 1 1 1 ”) disp ( ” 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 ”) 0 0 0 0”) disp ( ”Q3 ’ ’ Q2 disp ( ”Q3Q2 1 1 1 1 ”) 0 0 1 0”) disp ( ”Q3Q2 ’ ’ 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 / / E x am pl e 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 er . Thus i t i s MOD−16 c o u n t e r . H ow ev er , 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 we en 16 and 9 i s 7 . Hence 7 s t e p s must b e s k i p p e d f ro m t h e f u l l m od ul us s e q u e n c e . T h is can be a c hi e v e d by p r e s e t t i n g c o u n t er t o v a lu e 7 . Each t i me when c o u n te 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 fro m 7 u pt o 16 on e a ch f u l l c y c l e . T he re fo re , e ac h f u l l c y c l e o f t he c o u n t e r c o n s i s ts o f 9 s t a te s . ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.22 determine MOD number and counter range
1 2 3 4 5 6 7 8 9
/ / E x am pl e 8 . 2 2
clc disp ( ” C l oc k f r e q u e n c y = 2 56 kHz ” ) disp ( ” O utp ut f r e q u e n c y = 2 kHz ” ) format (4) mn=256/2 disp ( m n , ” T h e r e f o r e , Mod n umb er = n =” ) C ou nt er i s MOD−128 c o u n t e r ” ) disp ( ” T h e r e fo r e , disp ( ”Mod−128 c o u n t er c an c ou nt t h e n umb ers f ro m 0 t o 1 2 7 . ”)
Scilab code Exa 8.23 design a divide by 20 counter
1 / / E x am pl e 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 ou nt er IC i s a s shown i n f i g . 8 . 5 0 ” ) disp ( ” ” ) disp ( ”We know t h a t , o n e IC c an wo rk a s mod−10 (BCD) c o u n t er . T h er e fo r e , we n ee d two I Cs . The c o u n t er w i l l go t h r o ug h s t a t e s 0−19 and s ho ul d be r e s e t on s t a t e 2 0 . i . e . ” ) QD QC QB QA QD QC QB QA” ) disp ( ” disp ( ” 0 0 1 0 0 0 0 0 ”) 7490(2) 7 4 9 0 ( 1 ) ”) disp ( ” disp ( ” ” ) disp ( ” The d ia gr am o f d i v i d e −by −20 c o u nt e r u s i ng IC 7 4 90 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 / / E x am pl e 8 . 2 4 2 clc 3 disp ( ” IC 7 49 0 i s a d ec a de c o u n t er . When t wo s uc h I Cs
a r e c as ca de d , i t b ecom es a d i vi d e −by −100 c o u n t e r . To g et a d i v id e −by −96 c ou nt er , t he c o u nt e r i s r e s e t a s s oo n a s i t beco m es 1 0 0 1 0 1 10 . The d i a g ra 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 / / E xam ple 8 . 2 5 . 2 clc 3 disp ( ” IC 7 49 0 i s a d ec a de c o u n t er . Whentwo s uc h I Cs
a r e c as ca de d , i t beco mes a d i vi d e −by −100 c o u n t e r . To g et a d i v i d e −by −93 c ou nt er , t he c o un t er i s r e s e t a s s oo n a s o t beco m es 1 0 0 1 0 0 11 . The d ia gr am 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 / / E x am pl e 8 . 2 6 2 clc 3 disp ( ” IC 7 49 0 i s a d ec a de c o u n t er . When t wo s uc h I Cs
a r e c as ca de d , i t b ecom es a d i vi 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 un t er , t h e c ou n te r i s r e s e t a s s oo n a s o t b ecom es 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 / / E x am pl e 8 . 2 8 2 clc 3 disp ( ” I f t he QD o ut pu t i s
c on ne ct ed t o A i np u t o f 7 4 90 IC a nd , i n p ut c l o c k i s a p p l i e d t o B i n pu t 100
4 5 6 7 8 9 10 11 12 13 14 15
d i v i d e by t en s qu a r e wave i s o b t a i n ed a t o ut pu t QA. ” ) Ou tp uts ” ) disp ( ” C l o c k disp ( ” QA QD QC QB” ) L L L L” ) disp ( ” 0 disp ( ” 1 L L L H” ) L L H L” ) disp ( ” 2 disp ( ” 3 L L H H” ) L H L L” ) disp ( ” 4 disp ( ” 5 H L L L” ) H L L H” ) disp ( ” 6 H L H L” ) disp ( ” 7 disp ( ” 8 H L H H” ) H H L L” ) disp ( ” 9
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.30 sketch output waveforms of counter
1 2 3 4 5 6
/ / e xa mp le 1 0 . 9
7 8 9 10 11
clc ; clear ; close ; c = [0 0]; q = [0 0]; a = [0 0]; b = [0 0]; y1=q; y2=a;
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
// t a k in g t he 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 : 2 5 // making a r r a y s if y 1 ( i ) = = 1 then for o = 1 : 1 0 0 y11(y11p)=1; y11p=y11p+1; end else for o = 1 : 1 0 0 y11(y11p)=0; y11p=y11p+1; end end if y 2 ( i ) = = 1 then for o = 1 : 1 0 0 y21(y22p)=1; y22p=y22p+1; end else for o = 1 : 1 0 0 y21(y22p)=0; y22p=y22p+1; end end if y 3 ( i ) = = 1 then for o = 1 : 1 0 0 y31(y33p)=1; y33p=y33p+1; end else
102
t o draw t h e o ut pu t
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 : 1 0 0 y31(y33p)=0; y33p=y33p+1; end
end if c ( i ) = = 1 then for o = 1 : 1 0 0 c1(cp)=1; cp=cp+1; end else for o = 1 : 1 0 0 c1(cp)=0; cp=cp+1; end end
end z = [ 2 2 ]; subplot ( 4 , 1 , 1 ) ; / / p l o t i n g t he o ut put t i t l e ( ’ T i m in g D i ag r am ’ ) ; plot ( c 1 ) ; plot ( z ) ; y l a b e l ( ’QA’ ) ; subplot ( 4 , 1 , 2 ) ; plot ( y 1 1 ) ; y l a b e l ( ’QB’ ) ; plot ( z ) ; subplot ( 4 , 1 , 3 ) ; plot ( y 2 1 ) ; y l a b e l ( ’QC’ ) ; plot ( z ) ; subplot ( 4 , 1 , 4 ) ; plot ( z ) ; y l a b e l ( ’QD’ ) ; plot ( y 3 1 ) ; disp ( ” The c o u n t er g o e s t h ro u gh s t a t e s 0 00 0 ( D ec im al
103
Figure 8.1: sketch output waveforms of counter 0 ) t o 1 01 1 ( D ec im al 1 1 ) , i . e . , t h ro u gh 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 / / E x am pl e 8 . 3 1 2 clc 3 disp ( ” The f i g . 8 . 6 3 sh ows t he c a sc a de d c o n n ec t i on o f
4− b i t b in ar y c o u n t e r s . L et us s e e t he c i r c u i t o p e r a t i on . The c o un t er IC1 o p e r a t e s a s a c o un t er f o r c o un t io n i n t he 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 pl e C ar ry Output ) g o e s HIGH w hi c h m ak es P a nd T ( E n a bl e ) i n p u t s o f I C2 HIGH f o r o ne c l o c k c y c l e a dv an ci ng i t s o ut pu t b y 1 and making Q o u tp u ts o f IC1 , 0 a t t he n ex t c l o c k c y c l e . A ft er t h i s c l o c k c y c l e P = T = 0 f o r IC2 and IC1 w i l l go on c o un t in g t he p u l s e s . When t he o u tp u ts o f IC1 and IC2 bo th r e ac h t he maximum c ou nt , RC o u t p u t s o f b ot h o f t h e s e I Cs w i l l go HIGH . T hi 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 he n ex t c l o c k c y c l e IC3 c o un t w i l l be i n cr em en t ed and s i m u l t a n eo u s l y IC1 and IC2 w i l l be c l e a r e d . T h is way t he c o u n t i n g w i l l con tin ue . ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.32 design divide by 40000 counter
1 / / E x am pl e 8 . 3 2 2 clc 3 disp ( ” C a s ca d in g f o u r 7 41 61 ( e ac h 4− b i t ) c o u n te r s we
g et 16 ( 4 x 4 ) b i t c ou nt er 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 m od ul us c o u n t e r ”) 5 disp ( ” However , we r e q u i r e d i v i d e −by −4 0 , 00 0 c o u n t e r .
The d i f f e r e n c e b et wee n 6 5 , 53 6 and 4 0 , 00 0 i s 2 5 , 5 36 , wh ich i s t he number o f s t a t e s t h o se must be s k i p pe d f ro m t h e f u l l m od ul us s e q u en c e . T hi s can be a c hi e v e d by p r e s e t t i n g t he c o u n t i n g fro m 2 5 , 53 6 u pt o 6 5 , 53 6 on e ac h f u l c y c l e . T h er ef or e , e ac h f u l l c y c l e o f t he c o u n t e r c o n s i s t s o f 4 0 , 00 0 st at es . ”) 105
Scilab code Exa 8.33 design modulo 11 counter
1 / / E x am pl e 8 . 3 3 2 clc 3 disp ( ” A l th ou g h t h e 7 4 X163 i s
a modulo−16 c ou nt er , i t can be made t o c ou nt i n a modulus l e s s t ha n 16 by u s i ng t he CLR’ ’ o r LD ’ ’ i n pu t t o s h o rt e n t he n or ma l c o u n t in g s e q ue n c e . The f i g . 8 . 6 9 s ho ws c i r c u i t c o n ne c t i o n s f o r modulo −11 c o u n t e r . H er e , l o a d i n p ut 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 ut pu t ) . S i n ce l o ad i n pu t i s a d j u s t e d t o s t a t e 5 , c ou nt er c ou nt s fro m 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 p er c o u n t i n g c y c l e . ” ) 4 disp ( ” ” ) 5 disp ( ”We ca n 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 pu t a s shown i n f i g . 8 . 7 0 . h er e , NAND g a t e i s u s e d t o d e t e ct s t a t e 10 a nd f o r c e t he n ex t s t a t e t o 0 . A 2− i np ut g at 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 ry 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 / / E x am pl e 8 . 3 4 2 clc 3 disp ( ”An e x c e s s −3 d e ci ma l c o u n t e r s ho ul d s t a r t
c o u n t in g f ro m c ou nt 3 ( b i n a ry 0 0 1 1) and c ou n t 106
u pt o c ou nt 12 ( b i na r y 1 10 0 ) . S t a r t i n g c ou nt i s a d ju s te d by l o a di n g 0 0 11 a t l o a d i n pu t s . To r e c y c l e c ou nt f ro m 1 10 0 t o 0 0 11 , Q3 a nd Q2 o u tp ut a re c on ne c te d a s i n p u t s f o r 2− in pu t NAND ga te . Thus , NAND g a t e d e t e c t s s t a t e 1 10 0 and f o r c e s 0 0 11 t o be l o a de d a s t he n ex 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 / / E x am pl e 8 . 3 5 2 clc 3 disp ( ”A b i n a ry c o un t er w it h a mo dulus g r e a t e r t ha n
16 c an be b u i l t by c a s c a d i n g 7 4 X16 3s . When c o u n t e r s a r e c a s ca d e d , CLK , CLR ’ ’ and LD ’ ’ o f a l l t he 74 X163s a r e c on ne ct ed i n p a r a l l e l , s o t h a t a l l o f t hem c o u n t o r a re c l e a r e d o r l oa de d a t t h e same t i me . 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 he n ex t c o u nt e r . The f i g . 8 . 7 3 s ho ws modulo −60 c o u n t er . To h av e a modulo 60 c ou n t we n ee d a t l e a s t 6− b i t c o un t er , t h us two 7 4 X1 63 s a r e c as c ad ed . Co un ter i s d e s ig n e d t o c ou nt fro m 1 96 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 2 55 and s t o p s t he c o un t er 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 he c ou n t er i s r e l o ad e d w i t h 19 6 ( b i na r y 1 10 0 0 10 0 ) and c o un t s u pto 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 et ba ck t o s t a t e 1 96 o nl y i f GO’ ’ i s a s s e r t e d and t he c ou nt er 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 / / E x am pl e 8 . 3 6 2 clc 3 disp ( ”A b i n a ry c o u n t er may be c om bi ned w it h a
d e co de r t o o bt ai n a s e t o f 1−out−o f −M c o d e d s i g n a l s , wh ere on e s i g n a l i s a s s e r t e d i n e a c h c ou nt s t a t e . T hi s i s u s e f u l when c o u n t er 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 es , wh ere a d i f f e r e n t d e v i c e s i s e na bl ed i n e a ch c ou n t er st at e . ”) 4 disp ( ” The f i g . 8 . 7 4 s ho ws how a 7 4X163 c o n ne c te d a s a modulo −8 c o u n t er c an be c om bi ne d w it h a 7 4X138 3−8 d ec od er t o p ro v i d e e i g h t s i g n a l s , e a c h o ne r e p r e s e n t i n g a c o u n t er 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 2 3 4
/ / E x am pl e 8 . 3 7 clc 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 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
0 0
7 disp ( ” 0
0 0
8 disp ( ” 0
0 0
9 disp ( ” 0
0 0
10 disp ( ” 0
1 0
11 disp ( ” 0
1 0
12 disp ( ” 0
1 0
13 disp ( ” 0
1 1
14 disp ( ” 1
0 0
15 disp ( ” 1
0 1
16 disp ( ” 1
0 X
17 disp ( ” 1
0 X
18 disp ( ” 1
1 X
19 disp ( ” 1
1 X
20 disp ( ” 1
1 X
21 disp ( ” 1
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 ” ) For JK D” ) disp ( ” QB’ ’ QA’ ’ QB’ ’QA QBQA disp ( ” disp ( ”QD’ ’ QC’ ’ 0 0 0 0 0 1 disp ( ”QD’ ’ QC
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
X X X disp ( ”QDQC disp ( ”QDQC’ ’ 0 1 X disp ( ”JK D = QA QD + QA QB QC” ) disp ( ” ” ) For JK C” ) disp ( ” disp ( ” QB’ ’ QA’ ’ QB’ ’QA QBQA 0 0 1 disp ( ”QD’ ’ QC’ ’ disp ( ”QD’ ’ QC 0 0 1 X X X disp ( ”QDQC disp ( ”QDQC’ ’ 0 0 X disp ( ”JK C = QA QB” ) disp ( ” ” ) disp ( ” For JK B ” ) QB’ ’ QA’ ’ QB’ ’QA QBQA disp ( ” disp ( ”QD’ ’ QC’ ’ 0 1 1 0 1 1 disp ( ”QD’ ’ QC disp ( ”QDQC X X X 0 0 X disp ( ”QDQC’ ’ disp ( ”JK B = QA QD’ ’ ” ) disp ( ” ” ) disp ( ” For JK A” ) QB’ ’ QA’ ’ QB’ ’QA QBQA disp ( ” disp ( ”QD’ ’ QC’ ’ 1 1 1 disp ( ”QD’ ’ QC 1 1 1 X X X disp ( ”QDQC disp ( ”QDQC’ ’ 1 1 X disp ( ” JK A = 1 ” ) disp ( ” ” ) disp ( ” F ig sh ows t he l o g i c d i ag r a m f o r
X” ) X” )
QBQA’ ’ ” ) 0”) 0”) X” ) X” )
QBQA’ ’ ” ) 0”) 0”) X” ) X” )
QBQA’ ’ ” ) 1”) 1”) X” ) X” )
t he s yn ch ro n ou s d ec ad e c o un t er u s i ng 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 2 3 4
/ / E x am pl e 8 . 3 8 clc disp ( ” E x c i t a t i o n 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 ut s ” ) disp ( ”UP/DOWN’ ’ QC QB QA Q A+1 JK C JK B JK A” ) disp ( ” UD” ) 0 0 0 disp ( ” 0 1 1 1 1”) 0 0 1 disp ( ” 0 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”) 0 0 0 disp ( ” 1 1 0 0 1”) 0 0 1 disp ( ” 1 0 0 1 1”) 0 1 0 disp ( ” 1 1 0 0 1”) 0 1 1 disp ( ” 1 0 1 1 1”) 1 0 0 disp ( ” 1 1 0 0 1”) 1 0 1 disp ( ” 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 disp ( ” 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
1 0
1
1 1
1
1 1”)
0
disp ( ” ” ) disp ( ”K−map S i m p l i f i c a t i o n ” ) For JK C” ) disp ( ” disp ( ” QB’ ’ QA’ ’ QB’ ’QA QBQA QBQA’ ’ ” ) 1 0 0 0”) disp ( ”QD’ ’ QC’ ’ disp ( ”QD’ ’ QC 1 0 0 0”) 0 0 1 0”) disp ( ”QDQC disp ( ”QDQC’ ’ 0 0 1 0”) disp ( ”JK C =UD’ ’ QB’ ’ QB’ ’ + UD QB QA” ) disp ( ” ” ) disp ( ” For JK B ” ) QB’ ’ QA’ ’ QB’ ’QA QBQA QBQA’ ’ ” ) disp ( ” disp ( ”QD’ ’ QC’ ’ 1 0 0 1”) 1 0 0 1”) disp ( ”QD’ ’ QC disp ( ”QDQC 0 1 1 0”) 0 1 1 0”) disp ( ”QDQC’ ’ disp ( ”TB =UD’ ’ QA’ ’ + UD QA” ) disp ( ” ” ) disp ( ” For JK A” ) QB’ ’ QA’ ’ QB’ ’QA QBQA QBQA’ ’ ” ) disp ( ” disp ( ”QD’ ’ QC’ ’ 1 1 1 1”) disp ( ”QD’ ’ QC 1 1 1 1”) 1 1 1 1”) disp ( ”QDQC 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 / / E x am pl e 8 . 3 9
112
0
2 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
clc disp ( ” F o r mod−5 c o u n te r we r e q u i r e 3 f l i p − f l o p s . ” ) disp ( ” E x c i t a t i o n t a b l e ” ) disp ( ” Present State Next S t a t e F l i p −f l o p I n p ut s ” ) disp ( ” QC QB QA Q A+1 Q B+1 Q C+1 TA TB T C” ) disp ( ” 0 0 0 0 0 0 1 0 0 1”) disp ( ” 1 0 0 1 0 1 0 0 1 1”) 0 1 0 0 1 disp ( ” 2 1 0 0 1”) 0 1 1 1 0 disp ( ” 3 0 1 1 1”) 1 0 0 0 0 disp ( ” 4 0 1 0 0”) disp ( ” ” ) disp ( ”K−map S i m p l i f i c a t i o n ” ) QB’ ’ QC’ ’ QB’ ’QC QBQC QBQC’ ’ ” ) disp ( ” disp ( ”QA’ ’ 0 0 1 0 ”) 1 X X X” ) disp ( ”QA disp ( ”T A = QA + QB QC” ) disp ( ” ” ) QB’ ’ QC’ ’ QB’ ’QC QBQC QBQC’ ’ ” ) disp ( ” disp ( ”QA’ ’ 0 1 1 0 ”) 0 X X X” ) disp ( ”QA disp ( ”T B = QC” ) disp ( ” ” ) disp ( ” QB’ ’ QC’ ’ QB’ ’QC QBQC QBQC’ ’ ” ) 1 1 1 1 ”) disp ( ”QA’ ’ disp ( ”QA 0 X X X” ) disp ( ”T C = QA’ ’ ” ) disp ( ” ” )
113
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.40 design MOD 4 down counter
1 2 3 4
/ / E x am pl e 8 . 4 0
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
clc disp ( ” E x c i t a t i o n t a b l e ” ) Next S t a t e disp ( ” P r e s e n t S t a t e f l o p I np ut s ” ) QC QB A+ B+ disp ( ” J B K B” ) 0 0 1 1 disp ( ” 1 X” ) 0 1 0 0 disp ( ” 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 ” ) B’ ’ B” ) disp ( ” disp ( ”A’ ’ 1 0”) X X” ) disp ( ”A disp ( ” J A = B ’ ’ ” ) disp ( ” ” ) disp ( ” For K A” ) disp ( ” B’ ’ B” ) X X” ) disp ( ”A’ ’ 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” ) 1 X” ) disp ( ”A’ ’ disp ( ”A 1 X” ) disp ( ” J B = 1 ” ) disp ( ” ” ) disp ( ” For K B” ) disp ( ” B’ ’ B” ) X 1”) disp ( ”A’ ’ 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 / / E x am pl e 8 . 4 1 2 clc 3 disp ( ”Mod−12 s yn ch ro no u s c o un t er u s i ng D f l i p − f l o p : ”) 4 disp ( ” Le t Number o f f l i p − f l o p r e qu i r e d = n” ) 5 disp ( ” 2ˆ n >= 1 2 ” ) 6 disp ( ” n = 4”) 7 disp ( ” E x c i t a t i o n t a b l e ” ) 8 disp ( ” P r e s e n t S t a t e Next S t a t e ”) 9 disp ( ”QD QC QB QA Q D+1 Q C+1 Q B+1 Q A+1” ) 10 disp ( ” 0 0 0 0 0 0 0 1 ”) 11 disp ( ” 0 0 0 1 0 0 1 0 ”) 12 disp ( ” 0 0 1 0 0 0 1 1 ”) 13 disp ( ” 0 0 1 1 0 1 0 0 ”) 14 disp ( ” 0 1 0 0 0 1 0 1 ”) 15 disp ( ” 0 1 0 1 0 1 1 0 ”) 16 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
1 1 1 1 0 0 0 ”) disp ( ” 0 disp ( ” 1 0 0 0 1 0 0 1 ”) 0 0 1 1 0 1 0 ”) disp ( ” 1 disp ( ” 1 0 1 0 1 0 1 1 ”) 0 1 1 0 0 0 0 ”) disp ( ” 1 disp ( ” ” ) disp ( ”K−map S i m p l i f i c a t i o n ” ) disp ( ” For D A” ) QB’ ’ QA’ ’ QB’ ’QA QBQA QBQA’ ’ ” ) disp ( ” disp ( ”QD’ ’ QC’ ’ 1 0 0 1”) 1 0 0 1”) disp ( ”QD’ ’ QC X X X X” ) disp ( ”QDQC disp ( ”QDQC’ ’ 1 0 0 1”) disp ( ”D A = QA’ ’ ” ) disp ( ” ” ) For D B” ) disp ( ” disp ( ” QB’ ’ QA’ ’ QB’ ’QA QBQA QBQA’ ’ ” ) 0 1 0 1”) disp ( ”QD’ ’ QC’ ’ disp ( ”QD’ ’ QC 0 1 0 1”) X X X X” ) disp ( ”QDQC disp ( ”QDQC’ ’ 0 1 0 1”) disp ( ”D B = QB’ ’ QaA + QA’ ’ QB” ) disp ( ” = QA XOR QB” ) disp ( ” ” ) For D C” ) disp ( ” disp ( ” QB’ ’ QA’ ’ QB’ ’QA QBQA QBQA’ ’ ” ) 0 0 1 0”) disp ( ”QD’ ’ QC’ ’ disp ( ”QD’ ’ QC 1 1 0 1”) X X X X” ) disp ( ”QDQC disp ( ”QDQC’ ’ 0 0 0 0”) disp ( ”D C = QC QB’ ’ + QC QA’ ’ + QD’ ’ QC’ ’ QB QA” ) disp ( ” ” ) For D D” ) disp ( ” disp ( ” QB’ ’ QA’ ’ QB’ ’QA QBQA QBQA’ ’ ” ) 0 0 0 0”) disp ( ”QD’ ’ QC’ ’ 0 0 1 0”) disp ( ”QD’ ’ QC disp ( ”QDQC X X X X” ) 1 1 0 1”) disp ( ”QDQC’ ’ 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 / / E x am pl e 8 . 4 2 2 clc 3 disp ( ” The f i g . 8 . 9 9
s ho ws t he c i r c u i t d i a g ra m f o r a 4− b it , 4− s t a t e r i n g c o un te 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 c on ne ct ed s o t ha t i t n or ma ll y p re fo rm s a l e f t − s h i f t . H ow ev er , 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 eg at ed , t he 7 41 94 s h i f t s l e f t on e ac h c l o c k p u l se . The D SL s e r i a l i n pu t i s c o nn e ct ed t o t he l e f t m o s t o ut pu t ( Q3 : MSB) , s o t he n ex t s t a t e s a r e 0 01 0 , 0 1 00 , 1 0 00 , 0 0 01 , 0 0 10 , . . . . . Thus t h e c o u n t er c o un t er v i s i t s f o u r u ni qu e s t a t e s b e f o r e repe ati ng . ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 8.44 design 4 bit 8 state johnson counter
1 / / E x am pl e 8 . 4 4 2 clc 3 disp ( ” Jo h n s o n c ou n t er
i s b a s i c a l l y a t w i s te d r i n g c ou n te r . The f i g . 8 . 1 0 4 ( a ) s ho ws t he b a s i c c i r c u i t f o r a J oh ns on c o un t er . The t a b l e s ho ws t he s t a t e s o f a 4− b i t J oh ns on 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 oh ns on c o un t er ” ) Q3 Q2 Q1 Q0” ) disp ( ” S t a t e name disp ( ” S1 0 0 0 0”) S2 0 0 0 1”) disp ( ” disp ( ” S3 0 0 1 1”) S4 0 1 1 1”) disp ( ” disp ( ” S5 1 1 1 1”) S6 1 1 1 0”) disp ( ” disp ( ” S7 1 1 0 0”) S8 1 0 0 0”) disp ( ” disp ( ” ” ) disp ( ” T hi s c o un t er ca n be m o d if i ed t o h ave s e l f
c o r r e c t i n g Jo h n s o n c o u n te 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 uc h t h a t c i r c u i t o ad s 0 0 0 1 a s t he n ex t s t a t e wh en e v er t he c u r r e nt 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 / / E x am pl e 8 . 4 5 2 clc 3 disp ( ” J oh ns on c o un t er
w i l l p ro du ce a modulus o f 2 xn where n i s t he number o f s t a g e s ( i . e . f l i p − f l o p s ) i n t he c o un t er . T he re fo r e , Mod 1 0 r e q u i r e s 5 f l i p − f l o p s and Mod 1 6 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 / / E xa mp le 9 . 1 2 clc 3 disp ( ” The d i f f e r e n t i a l
am pl if ie r is
repr esen ted as
shown i n f i g . 9 . 5 . ” ) 4 disp ( ” ( i ) CMRR = 100 ” ) 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
vd=300-240 disp ( v d , ” Vd ( i n uV ) = V1 − V 2 = ” ) vc=(300+240)/2 Vc ( i n uV ) = V1+V2 / 2 =” ) disp ( v c , ” disp ( ”CMRR = Ad / Ac” ) ac=5000/100 disp ( a c , ” T h e r e fo r e , Ac =” ) format (6) vo=((5000*60)+(50*270))*10^-3 disp ( v o , ” T h e r e f o r e , Vo ( i n mV) = Ad∗Vd + Ac∗Vc =” ) disp ( ” ( i i ) CMRR = 10ˆ5 ” ) ac=5000/(10^5) disp ( a c , ” T h e r e f o r e , Ac = A d / CMRR =” ) vo=((5000*60)+(0.05*270))*10^-3 format (9) disp ( v o , ” 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 ut pu t s h ou l d be
o n l y Ad∗Vd w hi ch i s 5 00 0∗60∗10ˆ −6 i . e . 3 00 mV. I t can be s e en t h at h i g h er t he v a lu e o f CMRR, t he o u t p ut i s a lm os t p r o p o r t i o n a l t o t he 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 he 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 2 3 4 5 6 7 8
/ / E xa mp le 9 . 3
clc I b = 60 nA” ) disp ( ” I i O S = 20 nA , disp ( ”Now I iO S = I b 1 − I b 2 = 2 0 ” ) I b = I b 1+I b 2 / 2 = 60 ” ) disp ( ” I b 1 + I b 2 = 12 0 ” ) disp ( ” T he re fo re , disp ( ” T he re fo re , 2∗ I b 1 = 14 0 ” ) I b 1 = 70 nA , I b 2 = 50 nA” ) disp ( ” T he re fo re ,
Scilab code Exa 9.4 design inverting schmitt trigger
1 2 3 4 5 6 7 8 9 10 11 12
/ / E xa mp le 9 . 4
clc V LT = −4 V, S u p p l y = +− 1 5 V ” ) disp ( ”V UT = +4 V , disp ( ”+− V s at = 0 . 9 x [ S up pl y ] = +− 1 3 . 5 V = V o ” ) I B ( max ) = 5 0 0 nA” ) disp ( ” F o r op−amp 7 4 1 , disp ( ” T h e r e f o r e , I 2 = 1 00 I B ( max ) = 5 0 uA” ) r2=(4/(50*10^-6))*10^-3 disp ( r 2 , ” T h e re fo r e , R2 ( i n k−ohm ) = V UT / I 2 =” ) i2=(4/(82*10^3))*10^6 format (6) disp ( i 2 , ” R e c a l c u l a t i n g I 2 , I 2 = V UT / R2 =” ) r1=((13.5-4)/(48.78*10^-6))*10^-3
120
13 format (7) 14 disp ( r 1 , ” T h e r e fo 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
/ / E xa mp le 9 . 5
clc disp ( ”V CC = +15 V” ) vsat=0.9*15 format (5) V s a t ( i n V) = 0 . 9 V CC =” ) disp ( v s a t , ” T h e r e fo r e , disp ( ” R1 = 51 k−ohm , R2 = 1 20 ohm ”) vut=(13.5*120)/((51*10^3)+120) format (8) disp ( v u t , ” V UT ( i n V ) = +V s a t ∗R2 / R1+R2 =” ) vlt=(-13.5*120)/((51*10^3)+120) disp ( v l t , ” 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 / / E xa mp le 9 . 6 2 clc 3 disp ( ” As i np ut
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 er mi na l , t he c i r c u i t i s non−i n v e r t i n g S ch mi tt tr ig ge r . ”) 121
R2 = 1 k−ohm” ) disp ( ” R1 = 1 00 k−ohm , vut=13.5*(1/100) format (6) disp ( v u t , ” 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 ( v l t , ” T h e r e fo r e , V LT ( i n V) = −V s a t ∗ R2/R1 =” ) 4 5 6 7
Scilab code Exa 9.8 time duration
1 2 3 4 5 6 7
/ / E xa mp le 9 . 8
8 9 10 11 12 13 14 15 16 17 18 19 20 21
clc disp ( ”LTP = −1.5 V and H = 2 V” ) disp ( ”Now H = UTP − LTP” ) 2 = UTP − ( − 1 . 5 ) ” ) disp ( ” T h e r e fo r e , disp ( ” T h e r e f o r e , UTP = 0 . 5 V” ) disp ( ” I n t h e f i g . 9 . 4 7 , t h e a n g l e t h e ta ca n be
o b ta i n ed fro m e q ua t i on o f s i n e wave . S i ne wave i s represented as , ”) disp ( ” V i n = V p∗ s i n ( p i+t ha ta ) when p i < omega ∗ t < 2 p i ”) 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 ) ” ) sin ( theta ) = 0.3 ”) disp ( ” T h e r e fo r e , t=asind(0.3) format (6) disp (t , ” T h e r e fo r e , t h e t a ( i n d e g r e e ) =” ) disp ( ” The t im e p e r i od o f s i n e wave i s , ” ) T =1 T( i n ms ) = 1/ f =” ) disp (T , ” disp ( ” At UTP, 0 .5 = V p ∗ s i n ( t h e t a ) ” ) disp ( ” T h e re fo 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 disp (t , ” T h e r e f o r e , t h e t a ( i n d e g r e e ) =” ) 23 disp ( ” The t im e T1 f o r o ut pu t i s from 5 . 73 9 d e g r ee t o ( 18 0 d e g re e + 1 7 . 4 5 d e g re e ) ” ) 24 t 1 = 1 9 7 . 4 5 - 5 . 7 3 9 25 format (7) 26 disp ( t 1 , ” T h e r e fo r e , T1 ( i n d e g r e e ) =” ) 27 T 1 = ( 1 9 1 . 7 1 / 3 6 0 ) 28 disp ( T 1 , ” i . e . T1 ( ms ) =” ) 29 t 2 = 1 - 0 . 5 3 2 5 30 disp ( t 2 , ” and T2 ( i n ms ) = T − T1 =” )
Scilab code Exa 9.9 calculate R1 and R2
1 / / E xa mp le 9 . 9 2 clc 3 disp ( ” Given +V sa t = 12 V , −V s a t = −1 2 V , V H = 6 V” ) 4 disp ( ”We know t ha t h y s t e r e s i s w i d t h i s g i ve 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 fo r e , R2 = 0 . 2 5 R1 + 0 . 2 5 R2” ) 10 disp ( ” T h e re fo r e , 0 . 7 5 R2 = 0 . 2 5 R1” ) 11 r 2 = 0 . 2 5 / 0 . 7 5 12 format (7) 13 disp ( r 2 , ” T h e r e fo r e , R2 / R1 =” ) 14 disp ( ” A ss umi ng R2 = 10 k−ohm” ) 15 r 1 = ( 1 0 0 0 0 / 0 . 3 3 3 3 ) * 1 0 ^ - 3 16 format (3) 17 disp ( r 1 , ” R1 ( i n k−ohm) =” )
Scilab code Exa 9.10 calculate trip point and hysteresis
123
1 / / E x am pl e 9 . 1 0 2 clc 3 disp ( ”From f i g 9 . 4 5 ,
and 4 5 6 7 8 9 10 11 12
13 14 15 16 17 18 19
R1 = 68 k−ohm , V s at = 1 3. 5 V” )
R2 = 1 . 5 k−ohm
vut=(1.5/(1.5+68))*13.5 format (7) disp ( v u t , ”V UT( i n V) = R2/R1+R2 ∗ V s a t = ” ) vlt=(-1.5/(1.5+68))*13.5 disp ( v l t , ” V LT ( i n V ) = −R2/R1+R2 ∗ V s a t = ” ) h=2*0.2913 disp (h , ” T h e r e fo r e , H( i n V) = V UT − V LT =” ) H = ( 2 ∗ R2 / R1+R2) ∗ V s a t ” ) disp ( ”Now disp ( ” F o r minimum H , R2 m us t b e minimum a nd R1 m us t be maximum” ) r2min =((1.5) -(0.05*1.5)) format (6) disp ( r 2 m i n , ” T h e re fo r e , R2 min ( i n k−ohm) = R2 − 5%∗ R2 =” ) r2max=((68)+(0.05*68)) R1 max ( i n k−ohm) = R1 + 5%∗ disp ( r 2 m a x , ” T h e r e fo r e , R1 =” ) hm=((2*1.425)/(71.4+1.425))*13.5 disp ( h m , ” T h e r e fo r e , H min ( i n V) =” )
Scilab code Exa 9.11 design schmitt trigger
1 / / E x am pl e 9 . 1 1 2 clc 3 disp ( ” C h oo s e op−amp LM318 w i t h V s a t a s +− 1 3 . 5 V w i th s up pl y v o l t a g e +− 1 5 V ” ) 4 disp ( ” V UT = + 5 V” ) 5 disp ( ”Now V UT = (R2 / R1+R2) ∗ V s a t ” ) 6 disp ( ” T h e r e f o r e , 5 = ( R2 / R1+R2 ) ∗ 1 3 . 5 ” ) 7 disp ( ” T h e re fo r e , R1 + R2 = 2 . 7 ∗ R2” ) 8 disp ( ” T h er ef or e , R1 = 1 . 7 ∗ R2” )
124
9 10 11 12
disp ( ” Choos e R2 = 10 k−ohm” ) r1=1.7*10 R1 ( i n k−ohm) =” ) disp ( r 1 , ” T h e re fo r e , disp ( ” The d e si g ne 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 2 3 4
/ / E x am pl e 9 . 1 2
clc disp ( ” For t he S ch mi tt t r i g g e r ” ) V LT = −4 V, +−V s a t = +−10 disp ( ”V UT = 2 V, V” ) 5 disp ( ” F or u n e qu a l UTP a nd 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 . ” ) 6 disp ( ” The v o l t a g e V1 d e c i d e s t h e UTP a nd LTP l e v e l s .
7 8 9 10 11 12 13 14 15 16 17 18
A pp ly in g KVL t o t h e o u tp ut 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 c an w r i te , ” ) disp ( ”−IR2 − IR1 − x + V0 = 0 ” ) disp ( ” T h er ef or e , I = V0−x / R1+R2” ) disp ( ” And V1 = IR1 + x ” ) disp ( ” T h e r e fo r e , V1 = ( V0−x/R1+R2) ∗R 1 + x ” ) +V s a t = 10 V, ” ) disp ( ” For disp ( ” V1 = V UT = 2 V , ” ) disp ( ” V 0 = 1 0 V ” ) disp ( ” T h er ef or e , 2 = (10 −x/R1+R2) ∗R1 + x (1) ”) disp ( ” F o r −V s at = −10 V, ” ) disp ( ” V 1 = V L T = −4 V , ” ) disp ( ”V0 = −10 V” ) disp ( ” T h e r e f o r e , (2) ” −4 = (−10−x/R1+R2) ∗R1 + x
) 19 disp ( ” S u b t ra c t i n g e q u a ti o n s ( 2 ) and ( 1 ) , ” ) 20 disp ( ” T he re fo re , 6 = 20 ∗R1 / R1+R2” )
125
21 22 23 24 25 26 27 28 29
R1+R2 = 3 . 3 3 3 ∗ R1” ) disp ( ” T h e r e f o r e , disp ( ” T h e re fo r e , R2 = 2 . 3 3 3 ∗ R1 (3 ) ”) disp ( ” S u b s t i t u t i n g ( 3 ) i n e q u a ti o n ( 1 ) ” ) disp ( ” 2 = ( ( 1 0 − x ) ∗R1 / 3 . 3 33 ∗ R 1 ) + x ” ) 2 . 33 3 ∗ x = −3 . 3 3 3 4 ” ) disp ( ” T h er ef or e , x=-3.3334/2.333 format (7) disp (x , ” T h e re fo r e , x =” ) 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 rc e
’ ’x ’ ’ must be o p p o s i t e t o what i s a ss ume d e a r l i e r a s shown i n f i g . 9 . 5 2 . ” ) 30 disp ( ” Choos e R1 = 1 k−ohm h e n c e R2 = 2 . 3 3 3 k− ohm” ) 31 disp ( ” T h e r e fo r e , R comp = R1 | | R2 = 0 . 7 k−ohm” ) 32 disp ( ”Now a s l on g a s V i n i s l e s s t h a n V UT , t he o ut pu t i s a t +V s at = 1 0 V and when V in > V UT, t he o ut pu t s w i t c h e s from +V sa t t o −V s a t . W hi le a s l on g a s V i n > V LT , t h e o u tp u t i s a t −V s a t = −10 V a nd when V i n < V LT , t he o ut pu 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 2 3 4 5 6 7 8 9
/ / E x am pl e 9 . 1 3
clc disp ( ” ( a ) We know t h a t vut=(86*15)/(86+100) format (5) disp ( v u t , ” V UT ( i n V) vlt=(86*-15)/(86+100) disp ( ” ( b ) We know t h a t disp ( v l t , ” V LT ( i n V)
, ”)
= R1∗+V sa t / R1+R2 =” ) , ”) = R1∗−V sa t / R1+R2 =” ) 126
10 disp ( ” ( c ) We know that , ” ) 11 f 0 = 1 / 0 . 0 2 12 disp ( f 0 , ” 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 / / E x am pl e 9 . 1 7 2 clc 3 disp ( ” The m on os ta bl e m u l t i v i b r a t o r
u s i ng op−amp p r o du c es t h e p u l s e wa ve fo rm . The p u l s e w id th i s g i v e n by , ” ) 4 disp ( ” T = RC∗ l n [ 1+ V D1 / V s a t / 1−be ta ] ” ) 5 disp ( ” wh ere V D1 = 0 . 7 V, +v s a t = +−12 V f o r op− amp 7 4 1 ” ) 6 disp ( ” b e t a = R2 / R1+R2 = 0 . 5 w i th R1 = R2” ) t=1/(2*10^3) format (6) disp (t , ”T ( i n s e c ) = 1 / f ” ) disp ( ” Choos e C = 0 . 1 uF” ) disp ( ” T he re fo re , 5∗10ˆ −4 = R∗0 . 1∗10 ˆ −6∗ l n [ 1 + ( 0 . 7 / 1 2 ) /1 − 0 . 5 ] ” ) 12 disp ( ” T he re fo re , R = 6 . 7 k−ohm” ) 13 disp ( ” C ho os e R1 = R2 = 10 k−ohm” ) 14 disp ( ” The d e si g ne d c i r c u i t i s shown i n f i g . 9 . 6 3 ” ) 7 8 9 10 11
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 9.18 design monostable using IC 555
1 / / E x am pl e 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 id th i s , ” ) disp ( ” W = 10 ms” ) disp ( ” The p u l s e w id th i s g i ve n by , ” ) disp ( ” W = 1 .1 ∗R∗C” ) 10∗10ˆ −3 = 1 . 1 ∗R∗C” ) disp ( ” T h er ef or e , disp ( ” T h e r e f o r e , RC = 9 . 09 0 9∗ 1 0 ˆ −3 ” ) disp ( ” Choos e C = 0 . 1 uF” ) disp ( ” T h er ef or e , R = 9 0 . 90 9 k−ohm ˜ 9 1 k−ohm” ) disp ( ” The d e si g ne 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 / / E x am pl e 9 . 1 9 2 clc 3 disp ( ” F ig . 9 . 79 s ho ws m on os ta bl e c i r c u i t u se d t o d r i v e t he r e l a y . ” ) 4 disp ( ” T h i s r e l a y s ho ul d be e n e r g i z e d f o r 5 s ec o nd t o
5 6 7 8
9 10 11 12 13 14
h o ld h e a t e r ’ ’ON’ ’ f o r 5 s e c o nd s . Thus , T ON f o r m o no s ta b le i s 5 s e c o n ds . ” ) disp ( ”We know t h a t t h e p u l s e w id th i s g i v e n by , ” ) disp ( ” W = 1 . 1 RC” ) 5 = 1 . 1 RC” ) disp ( ” T h e re fo r e , disp ( ”Now , t h e r e a r e two unknowns . I n t h i s c a se , we ha ve t o s e l e c t v a l ue 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 al ue we h a ve t o f i n d t h e v al ue o f r e s i s t a n c e fro m t he f or mu l a . ” ) disp ( ” T he re fo re , I f c a p a c i t o r v al ue i s 10 uF” ) 5 = 1 . 1 ∗R∗1 0 uF ” ) disp ( ” t h e n r=(5/(1.1*10*10^-6))*10^-3 format (7) disp (r , ” T h e re fo 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 ot s ta n d ar d v al ue ,
128
but we c an a d j us t t h i s v a l u e by c o nn e ct i ng v a r i a b l e r e s i s t a n c e i . e . p o t e nt i o m et e r . ” )
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 9.20 draw timer using IC 555
1 / / E x am pl e 9 . 2 0 2 clc 3 disp ( ” The r e qu i re m en t i s
4 5 6 7 8 9 10 11
t h at t he d oo r must be o pen f o r 15 s ec 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 t he n g e t s s hu t d oo r a u t o ma t i c a l l y . T h is r e q u i r e s IC 5 55 i n a m on os ta bl e mode w it h a p u l s e w id th o f 15 sec . ”) disp ( ” T h e re fo r e , W = 15 s e c ” ) disp ( ”Now W = 1 . 1 RC” ) disp ( ” T h e r e f o r e , 1 5 = 1 . 1 RC” ) disp ( ” Choos e C = 10 0 uF” )
r=(15/(1.1*100*10^-6))*10^-3 format (8) disp (r , ” T h e re fo 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 ”) 12 disp ( ” The s up pl y v o l t a g e 10 o r 15 V ha s no e f f e c t on
the o pe ra ti on o f the c i r c u i t or the v al ue s o f 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 2 3 4 5 6 7 8 9 10 11
/ / / E xa mp le 9 . 2 1
clc disp ( ” The f r e qu e n cy o f o ut pu t i s g i ve n by , ” ) f=(1.44/(12*0.01*10^-3))*10^-3 format (3) disp (f , ” f ( i n kHz ) = 1 . 4 4 / ( R A+2∗R B ) ∗C =” ) disp ( ” The du ty c y c l e i s g i ve n by , ” ) d=8/12 format (7) disp (d , ” D = R A+R B / R A+2∗R B =” ) disp ( ” Thus t h e d ut y c y c l e 6 6 . 6 7%” )
Scilab code Exa 9.26 design astable multivibrator
1 2 3 4 5 6 7
/ / E x am pl e 9 . 2 6
8 9 10 11 12 13
14 15 16 17
clc disp ( ” f = 1 kHz ” ) disp ( ”D = 7 5% = 0 . 7 5 ” ) disp ( ”Now f = 1 . 4 4 / ( R A+2∗R B ) ∗C” ) 1 ∗1 0ˆ 3 = 1 . 4 4 / ( R A+2∗R B ) ∗C” ) disp ( ” T he re fo re , disp ( ” T h e r e fo r e , ( R A+2∗R B ) ∗C = 1 . 4 4 ∗1 0 ˆ −3 . . . . ( 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 ) ) ∗1 0 0 ” ) 0 . 7 5 = R A+R B / R A+2∗R B” ) disp ( ” T h e r e f o r e , disp ( ” T h e r e fo r e , R A+2∗R B = ( R A+R B ) / 0 . 7 5 ” ) R A+2∗R B = 1 . 3 3 ∗ ( R A+R B ) ” ) disp ( ” T h e r e fo r e , disp ( ” T h er ef or e , 0 . 66 ∗ R B = 0 . 3 3∗ R A” ) R B = 0 . 5∗ R A disp ( ” T h er ef or e , . . . . ( 2 ) ”) disp ( ” Choos e 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∗1 0 ˆ −6 = 1 . 4 4 ∗1 0 ˆ −3 ” ) R A+2∗R B = 1 4 40 0 disp ( ” T h e r e fo r e , . . . . ( 3 ) ”)
130
18 19 20 21 22 23 24 25 26
disp ( ” S u b s t i t u t i n g ( 2 ) i n ( 3 ) , ” ) disp ( ”R A + 2 ( 0 . 5 ∗ R A ) = 1 4 40 0 ” ) ra=(14400/2)*10^-3 format (4) R A ( i n k−ohm) =” ) disp ( r a , ” T h e re fo r e , rb=0.5*7.2 R B ( i n k−ohm) =” ) disp ( r b , ” T h er ef or e , disp ( ” and C = 0 . 1 uF” ) disp ( ” Hence t he c i r c u i t d i a g ra m i s a s s hown i n f i g . 9 . 1 0 0 ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 9.27 design astable multivibrator
/ / E x am pl e 9 . 2 7
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18
clc disp ( ”T ON = 0 . 6 ms , T = 1 ms” ) d=0.6*100 disp (d , ” T h e r e fo r e , D( i n p e r c e n t a g e ) = t ON / T =” ) disp ( ” Now D = R A+R B / R A+2∗R B = 0 . 6 ” ) R A+R B = 0 . 6 ∗ R A + 1 . 2 ∗ R B” ) disp ( ” T h e r e f o r e , disp ( ” T he re fo re , 0 . 4 ∗ R B = 0 . 2 ∗ R B” ) R B = 2∗R A . . . . ( 1 ) ”) disp ( ” T h er ef or e , disp ( ” f = 1 . 4 4 / ( R A+2∗R B ) ∗C = 1 /T = 1 0 00 ” ) disp ( ” Choos e C = 0 . 1 uF” ) R A+2∗R B = 1 4 40 0 ” ) disp ( ” T h e r e fo r e , disp ( ” U s i n g ( 1 ) , 5∗R A = 1 4 40 0 ” ) ra=(14400/5)*10^-3 format (5) disp ( r a , ” T h e r e f o r e , R A ( i n k−ohm) =” ) rb=2.88*2 disp ( r b , ” R B ( i n k−ohm) =” )
131
19 disp ( ” The c i r c u i t
i s shown i n t he 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 2 3 4 5 6 7 8 9 10 11
/ / E x am pl e 9 . 2 8
12
clc disp ( ” T ON = T OFF = 0 . 5 ms ” ) disp ( ” T h e r e f o r e , T = T ON + T OFF = 1 ms ” ) f = 1/T = 1 kHz ” ) disp ( ” i . e . disp ( ”Now T d = T OFF = 0 . 6 9 ∗ R B∗C” ) C = 0 .1 uF” ) disp ( ” Choos e rb=((0.5*10^-3)/(0.69*0.1*10^-6))*10^-3 format (6) disp ( r b , ” T h er ef or e , R B ( i n k−ohm) =” ) disp ( ”Now du ty c y c l e i s 50% s o R A = R B = 7 . 24 6 k− ohm” ) disp ( ” P r a c t i c a l l y a m od if ie d c i r c u i t i s r e q u i r e d f o r
50% du ty c y c l e wh ere d i od e i s c o nn e ct ed a c r o s s R B and c h a rg i n g t a k es p l a c e t hr ou gh 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 de f or wa rd r e s i s t a n c e . So t o ha ve p e r f e c t s q u a r e wave , R A i s k ep t v a r i a b l e i . e . p o t o f s ay 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 in 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 th LED t o be c on ne ct ed i s , ” ) 13 disp ( ”R = V 0−V LED / I L ED ” ) 14 disp ( ” A s su mi ng V LED = 0 . 7 V” ) 15 16 17 18 19
r=(5-0.7)/(50*10^-3) format (3) disp (r , ” C ur re nt 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 = ( 5 0∗1 0 ˆ −3 ) ˆ 2 ∗ 1 0 0 ” )
132
20 21 22 23
p = ( (5 0* 10 ^ - 3 ) ^ 2) * 1 00 disp (p , ”P( in W) =” ) disp ( ” Both r e s i s t o r s R c a n be o f 1 /4 W” ) 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 f i g . 9 . 1 0 2 ”)
This code can be downloaded from the website wwww.scilab.in
Scilab code Exa 9.32 define resolution
1 2 3 4 5 6
/ / E x am pl e 9 . 3 2
7 8 9 10
clc disp ( ” F o r t h e g i v e n DAC, ” ) disp ( ” n = Number o f b i t s = 8” ) disp ( ” ( i ) R e s o l u t i o n = 2 ˆ n = 2 ˆ8 = 2 56 ” ) disp ( ” i . e . t he o ut pu t v o l t a g e can ha ve 25 6 d i f f e r e n t v a l u e s i n c l u d i n g z e r o . ”) disp ( ” ( i i ) V 0FS = F u ll s c a l e o ut pu t v o l t a g e ” ) = 2 . 5 5 V” ) disp ( ” R e s o lu t i o n = V 0FS / 2ˆ n − 1 = disp ( ” T h e re fo r e , 2 . 5 5 / 2ˆ 8 − 1 = 10mV / 1LSB” ) disp ( ” Thus an i n p u t c ha ng e o f 1LSB c a u s e s t h e o u tp ut t o c h a n g e b y 1 0mV” )
Scilab code Exa 9.33 output voltage
1 2 3 4 5
/ / E x am pl e 9 . 3 3 clc disp ( ” F o r g i v e n DAC, ” ) disp ( ” n = 4” ) V 0FS = 15 V” ) disp ( ” T h e r e fo r e ,
133
6 disp ( ” T h e re fo r e / LSB” ) 7 disp ( ” T h e re fo r e 8 disp ( ”Now D = 9 disp ( ” T h e r e fo r e
,
R e s o lu t i o n = V 0FS / 2ˆ n − 1 = 1 V
, V0 = R e s o l u t io n ∗ D” ) D ec im al o f 0 11 0 = 6 ” ) , V0 = 1V / LSB ∗ 6 = 6 V ” )
Scilab code Exa 9.34 find VoFS
1 2 3 4 5 6 7
/ / E x am pl e 9 . 3 4
clc disp ( ” R e s o l u t i o n = V 0FS / 2ˆ n − 1 ” ) 20 = V 0FS / 2ˆ n − 1 ” ) disp ( ” T h er ef or e , disp ( ” T h e re fo r e , V 0FS = 5 . 1 V” ) disp ( ” D = E q u i v a l en t o f 1 00 00 00 0 = 12 8 ” ) disp ( ” T h e re fo r e , V0 = R e s o l u t io n ∗ D = 2 0 ∗ 1 2 8 = 2.56 V”)
Scilab code Exa 9.35 find out stepsize and analog output
1 2 3 4 5 6 7 8 9
/ / E x am pl e 9 . 3 5
clc disp ( ” Fo r g i v e n DAC, n = 4 , V 0FS = +5 V” ) disp ( ” R e s o l u t i o n = V 0FS / 2ˆ n − 1 = 1 / 3 V / L S B ” ) disp ( ” T h e re fo r e , V0 = R e s o l u t io n ∗ D” ) disp ( ” For D = D ec im al od 1 00 00 = 8 ” ) disp ( ” V0 = 1 /3 ∗ 8 = 2 . 6 6 6 7 V ” ) disp ( ” For D = De ci ma l o f 1 11 1 = 15 ” ) disp ( ” V0 = 1 /3 ∗ 1 5 = 5 V ” )
Scilab code Exa 9.36 find output voltage
134
1 2 3 4 5 6 7 8 9 10 11 12
/ / E x am pl e 9 . 3 6
clc disp ( ” F o r 12− b i t DAC, s t e p s i z e i s 8 mV” ) v = ( 8 * 1 0 ^ - 3 ) * ( ( 2 ^ 1 2 ) - 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 6 V ∗ 1 0 0 = ” ) q=(8*10^-3)*1389 format (7) disp (q , ” The o ut pu t v o l t a g e f o r t he i n p ut 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 2 3 4 5 6 7 8 9
/ / E xam ple 9 . 3 8 .
10 11 12 13 14
clc disp ( ” ( a ) From e q u a t i o n ( 1 ) we h av e , ” ) r=2^8 format (4) disp (r , ” R e s o l u t i o n = 2 ˆ8 =” ) disp ( ” a nd f ro m e q u a t i o n ( 2 ) we h av e , ” ) disp ( ” R e s o l u t i o n = 5 . 1 V/ ( 2 ˆ 8 − 1 ) = 20 mV/LSB” ) disp ( ” T h e re fo r e , we can s ay t h at t o c ha ng e o ut pu t by 1 LSB we h av e t o c h an g e i n p u t by 2 0 mV” ) disp ( ” ( b ) For 1 . 2 8 V a n al og i np ut , d i g i t a l o ut pu t 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 LSB s ) = 1 . 2 8 V / 2 0 mV/ LSB =” ) disp ( ” The b i n a ry e q u i v a l e n t o f 64 i s 0 1 00 0 0 00 ” )
135
Scilab code Exa 9.39 calculate quantizing error
1 2 3 4 5 6
/ / E x am pl e 9 . 3 9
clc disp ( ” From e q u a t i o n ( 3 ) we g e t ” ) qe=(4.095/(4095*2))*10^3 format (4) disp ( q e , ” Q E ( i n mV) = 4 . 0 9 5 / ( 40 96 −1 ) ∗2 =” )
Scilab code Exa 9.40 dual scope ADC
1 2 3 4 5 6 7 8 9 10
/ / E x am pl e 9 . 4 0
clc disp ( ”We know tha t , ” ) disp ( ” t2 = (V1/VR) ∗ t 1 ” ) t2=83.33 format (6) disp ( t 2 , ” ( i ) t 2 ( i n ms ) = ( 1 0 0 / 1 0 0 ) ∗ 8 3 . 3 3 = ” ) disp ( ” ( i i ) V1 = 200 mV” ) t2=83.33*2 disp ( t 2 , ” T h e r e fo 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 2 3 4
/ / E x am pl e 8 . 4 1
5 6 7 8
clc disp ( ” The d i g i t a l o ut pu t i s g i v e n as , ” ) disp ( ” D i g i t a l o u t p u t = ( C ou nt s / S e c o nd ) ∗ t 1 ∗ ( V i / V R ) ” ) disp ( ”Now C lo ck f r e q u e n c y = 12 kHz ” ) i . e . = 12000 co un ts / second ”) disp ( ” d=12000*83.33*(100/100)*10^-3 format (5)
136
9 disp (d , ” T h e re fo r e ,
D i g i t a l o ut pu t ( i n c o un ts ) = 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 2 3 4 5 6 7 8
/ / E xam ple 9 . 4 2 .
clc disp ( ” f = 1 MHz” ) disp ( ” T he re fo re , T = 1 / f = 1 / 1 ∗1 0ˆ 6 = 1 u s ec ” ) disp ( ” n = 8”) tc=1*(8+1) format (2) disp ( t c , ” T h e re fo r e , T C ( i n u s ec ) = T∗ (n+1) =” )
Scilab code Exa 9.43 find maximum frequency of input sine wave
1 2 3 4 5 6
/ / E x am pl e 9 . 4 3
clc disp ( ” The maximum f r e q u e n c y i s g i v e n by , ” ) f=1/(2*%pi*(9*10^-6)*2^8) format (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 / / E x am pl e 1 0 . 1 2 clc 3 disp ( ” Z Z = 7 ohm , R3 = 330 ohm , V 0 = 4 . 7 V , V in = 15 V”) 4 disp ( ” The s p e c i f i e d c h an g e i n V i n i s 10%, ” ) 5 vin=0.1*15 6 format (4) 7 disp ( v i n , ” T h er e fo r e , d e l t a V i n ( i n V) = 1 0% o f V i n =” ) 8 vo=(1.5*7)/330 9 format (8) 10 disp ( v o , ” T h e re fo r e , d e lt a V 0 ( i n V) = d e l t a V i n ∗ Z Z / R3 =” ) 11 l r = 0 . 0 3 1 8 1 * 1 0 0 / 4 . 7 12 format (6) 13 disp ( l r , ” T h e re fo r e , L in e r e g u l a t i o n ( i n p e r ce n t ag e ) = d e l t a V 0 ∗ 1 00 / V 0 =” ) 14 disp ( ” F o r I L ( max ) = 5 0 mA, ” ) 15 d v o = ( 2 0 * 7 * 5 0 * 1 0 ^ - 3 ) / 3 3 0 16 format (8) 17 disp ( d v o , ” T h e r e fo r e , d e l t a V 0 ( i n V) = I L ( max ) ∗ R S ∗
138
Z Z / R3 =” ) 18 l r = 0 . 0 2 1 2 1 * 1 0 0 / 4 . 7 19 format (7) 20 disp ( l r , ” T h e re fo r e ,
L in e r e g u l a t i o n ( i n p r e ce n t ag e ) = d e l t a V 0 ∗ 1 00 / V 0 =” ) 21 disp ( ”Now V R ( o u t ) = V R ( i n ) ∗ Z Z / R3” ) 22 23 24 25 26 27
zz=7/330 format (8) V R ( o u t ) / V R ( i n ) = Z Z / R3 =” ) disp ( z z , ” T h e r e f o r e , r r = 2 0 * log10 ( 0 . 0 2 1 2 1 ) format (6) disp ( r r , ” T h e r e fo r e , RR( i n dB ) = 2 0∗ l o g ( 0 . 0 2 1 2 1 ) = ” )
Scilab code Exa 10.2 design op amp series voltage regulator
1 2 3 4 5 6 7 8 9 10 11 12
/ / E x am pl e 1 0 . 4
clc disp ( ” R 1 = 5 k−ohm , R2 = 10 k−ohm” ) disp ( ” The IC i s 7 80 8 i . e . V r e g = +8 V” ) vt=8*(3) format (3) V ou t ( i n V) = V r eg ∗ [ 1 + R 2 / R 1 ] disp ( v t , ” T h e r e fo r e , =” ) disp ( ”Now R2 = 1 k−ohm then , ” ) vo=8*(1+(1/5)) format (4) disp ( v o , ” V o ut ( i n V) = 8 ∗ [ 1 + 1 / 5 ] = ” ) disp ( ” Thus t he V o ut ca n be v a r ie d fro m 9 . 6 V t o 24 V, by v a ri n g R2 fro m 1 k−ohm t o 10 k−ohm . ” )
Scilab code Exa 10.4 calculate output voltage
139
1 2 3 4 5 6 7 8 9 10 11 12
/ / E x am pl e 1 0 . 4
clc R2 = 10 k−ohm” ) disp ( ” R 1 = 5 k−ohm , disp ( ” The IC i s 7 80 8 i . e . V r e g = +8 V” ) vo=8*3 format (3) V ou t ( i n V) = V r eg ∗ [ 1 + R 2 / R 1 ] disp ( v o , ” T h e r e fo r e , =” ) disp ( ”Now R2 = 1 k−ohm then , ” ) vou=8*(1+(1/5)) format (4) disp ( v o u , ” V o u t ( i n V ) =” ) disp ( ” Thus t he V o ut ca n be v a r ie d fro m 9 . 6 V t o 24 V, by v a ri n g R2 fro m 1 k−ohm t o 10 k−ohm” )
Scilab code Exa 10.7 determine regulated output voltage
1 2 3 4 5 6 7 8 9
/ / E x am pl e 1 0 . 7
clc disp ( ” The r e s i s t a n c e u se d a re , ” ) disp ( ” R1 = 2 20 ohm and R2 = 1 . 5 k−ohm” ) I ADJ = 1 00 uA” ) disp ( ” w h i l e f o r LM 3 1 7 , disp ( ” T h er ef or e , V 0 = 1 .2 5 ∗ [ 1 + R2 /R1 ] + I AD J∗R2” ) vo=(1.25*(1+((1.5*10^3)/220)))+(100*1.5*10^-3) format (5) V 0 ( i n V) =” ) disp ( v o , ” T h e re fo r e ,
Scilab code Exa 10.8 find the range
1 2 3 4
/ / E x am pl e 1 0 . 8 clc disp ( ” F or LM 3 1 7 , t h e c u r r e n t I ADJ = 1 00 uA” ) disp ( ” When R2 i s maximum i . e . R2 = 0 t h e n , ” )
140