Analog Integrated Circuits - J. B. Gupta
Analog Integrated Circuits - J. B. Gupta
Analog Integrated Circuits - J. B. Gupta
Created by
Amit Sexana
B.Tech
Electronics Engineering
Dr. A.P.J. Abdul Kalam Technical University
College Teacher
None
Cross-Checked by
Harpreeth Singh
June 4, 2016
Author: J. B. Gupta
Edition: 4
Year: 2009
ISBN: 978-81-89757-75-5
1
Scilab numbering policy used in this document and the relation to 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
1 Differential Amplifiers 5
5 Waveform Generators 53
7 Active Filters 63
10 Voltage Regulators 78
3
List of Scilab Codes
4
Exa 2.12 Input bias current and input offset current . . . . . . . 29
Exa 2.13 Limiting frequency . . . . . . . . . . . . . . . . . . . . 29
Exa 2.14 Required slew rate . . . . . . . . . . . . . . . . . . . . 30
Exa 3.1 Non inverting amplifier . . . . . . . . . . . . . . . . . 31
Exa 3.2 Minimum and maximum closed loop voltage gains . . 31
Exa 3.3 Voltage gain input resistance output resistance and band-
width . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Exa 3.4 Voltage gain input resistance output resistance and band-
width . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Exa 3.5 Voltage gain input resistance output resistance and band-
width . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Exa 3.6 Voltage gain input resistance output resistance and band-
width . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Exa 3.7 Value of Af RIF Rof ff and VooT . . . . . . . . . . . . 35
Exa 3.8 Voltage gain input resistance and output resistance . . 37
Exa 3.9 Input impedance voltage gain and power gain . . . . . 37
Exa 3.10 Designing of an Inverting op amp circuit . . . . . . . . 38
Exa 3.11 Designing of an Inverting op amp circuit . . . . . . . . 39
Exa 3.14 Gain of the amplifier circuit . . . . . . . . . . . . . . . 39
Exa 3.17 Output voltage . . . . . . . . . . . . . . . . . . . . . . 40
Exa 3.18 Voltage gain output voltage and internal resistance . . 41
Exa 3.19 Gain of the circuit . . . . . . . . . . . . . . . . . . . . 42
Exa 3.20 Voltage gain input resistance output resistance and band-
width . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Exa 4.1 Designing of an adder circuit . . . . . . . . . . . . . . 44
Exa 4.2 Output voltage . . . . . . . . . . . . . . . . . . . . . . 45
Exa 4.3 Summing amplifier . . . . . . . . . . . . . . . . . . . . 45
Exa 4.4 Value of R1 R2 and Rf . . . . . . . . . . . . . . . . . . 46
Exa 4.5 Output voltage . . . . . . . . . . . . . . . . . . . . . . 46
Exa 4.7 Capacitor voltage at the end of pulse . . . . . . . . . . 47
Exa 4.8 Value of R1 and Rf . . . . . . . . . . . . . . . . . . . . 48
Exa 4.9 Output voltage . . . . . . . . . . . . . . . . . . . . . . 48
Exa 4.10 Time duration required for saturation . . . . . . . . . 49
Exa 4.12 Output voltage . . . . . . . . . . . . . . . . . . . . . . 50
Exa 4.13 Differentiator to differentiate an input signal . . . . . 51
Exa 4.15 Instrumentation amplifier . . . . . . . . . . . . . . . . 51
Exa 5.1 Frequency and duty cycle . . . . . . . . . . . . . . . . 53
5
Exa 5.2 Positive and negative pulse width and free running fre-
quency . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Exa 5.3 Required resistor . . . . . . . . . . . . . . . . . . . . . 54
Exa 5.4 Designing of a 555 timer . . . . . . . . . . . . . . . . . 55
Exa 5.5 Designing of a 555 timer . . . . . . . . . . . . . . . . . 56
Exa 5.6 Resonance frequencies . . . . . . . . . . . . . . . . . . 56
Exa 5.7 Power dissipated in the crystal . . . . . . . . . . . . . 57
Exa 5.8 Signal frequency and amplitude of triangular and square
wave . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Exa 5.10 A Wien bridge oscillator . . . . . . . . . . . . . . . . . 59
Exa 5.11 Frequency of oscillation . . . . . . . . . . . . . . . . . 60
Exa 6.1 Free runnting frequency . . . . . . . . . . . . . . . . . 61
Exa 6.2 Frequency of reference oscillator . . . . . . . . . . . . 62
Exa 7.1 Low pass filter . . . . . . . . . . . . . . . . . . . . . . 63
Exa 7.2 Second order low pass filter . . . . . . . . . . . . . . . 64
Exa 7.3 Second order low pass filter . . . . . . . . . . . . . . . 64
Exa 7.4 Flattest band second order active filter . . . . . . . . . 65
Exa 7.5 Flattest passband second order active filter . . . . . . 65
Exa 7.7 Cut off frequency . . . . . . . . . . . . . . . . . . . . . 66
Exa 7.8 Centre frequency and gain . . . . . . . . . . . . . . . . 67
Exa 7.10 Bandpass active filter . . . . . . . . . . . . . . . . . . 68
Exa 7.11 Narror bandpass filter . . . . . . . . . . . . . . . . . . 68
Exa 7.12 Cut off frequencies . . . . . . . . . . . . . . . . . . . . 69
Exa 7.13 Designing of a bandpass filter . . . . . . . . . . . . . . 70
Exa 7.14 A wide band stop filter . . . . . . . . . . . . . . . . . 71
Exa 7.15 A 50 Hz active notch filter . . . . . . . . . . . . . . . 72
Exa 7.16 Phase shift . . . . . . . . . . . . . . . . . . . . . . . . 72
Exa 7.18 Bandpass centre frequency . . . . . . . . . . . . . . . 72
Exa 8.2 Peak value and average value of voltage . . . . . . . . 75
Exa 8.7 DC voltage with proper sign . . . . . . . . . . . . . . 75
Exa 8.9 Output voltage . . . . . . . . . . . . . . . . . . . . . . 76
Exa 8.10 Schmitt trigger . . . . . . . . . . . . . . . . . . . . . . 77
Exa 10.1 Minimum input voltage . . . . . . . . . . . . . . . . . 78
Exa 10.2 Input voltage . . . . . . . . . . . . . . . . . . . . . . . 78
Exa 10.3 Regulated output voltage . . . . . . . . . . . . . . . . 79
Exa 10.4 Minimum and maximum output voltage . . . . . . . . 79
Exa 10.5 Regulated output voltage . . . . . . . . . . . . . . . . 80
Exa 10.6 Duty cycle of the pulses . . . . . . . . . . . . . . . . . 81
6
Chapter 1
Differential Amplifiers
1 // Example 1 . 1
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 VCC = 9; // i n V
8 VEE = -9; // i n V
9 RC = 3.9; // i n k
10 RE = 3.3; // i n k
11 VBE = 0.7; // i n V
12 IE = ( abs ( VEE ) - VBE ) /(2* RE ) ; // e m i t t e r c u r r e n t i n mA
13 IC = IE ; // c o l l e c t o r c u r r e n t i n mA
14 // C o l l e c t o r v o l t a g e ,
15 VC = VCC - IC * RC ; // i n V
16 disp ( VC , ” The c o l l e c t o r v o l t a g e i n v o l t s i s : ” ) ;
17 // E m i t t e r v o l t a g e ,
18 VE = 0 - VBE ; // i n V
19 disp ( VE , ” The e m i t t e r v o l t a g e i n v o l t s i s : ” ) ;
20 // C o l l e c c t o r −e m i t t e r v o l t a g e ,
21 VCE = VC - VE ; // i n V
7
22 disp ( VCE , ” The c o l l e c t o r −e m i t t e r v o l t a g e i n v o l t s i s
: ”);
23
24 // Note : There i s some d i f f e r e n c e b e t w e e n c o d i n g
o u t p u t and t h e a n s w e r o f t h e book b e c a u s e i n t h e
book t h e v a l u e o f IE i s u s e d a s 1 . 2 5mA w h i l e t h e
c a l c u l a t e d v a l u e o f IE i s 1 . 2 5 8
Scilab code Exa 1.2 Quiescent collector current and collector emitter volt-
age
1 // Example 1 . 2
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 VCC = 10; // i n V
8 VEE = -10; // i n V
9 RC = 10; // i n k
10 RE = 9.3; // i n k
11 VBE = 0.7; // i n V
12 IE = ( abs ( VEE ) - VBE ) /(2* RE ) ; // e m i t t e r c u r r e n t i n mA
13 ICQ = IE ; // q u i e s c e n t c o l l e c t o r c u r r e n t i n mA
14 disp ( ICQ , ” The q u i e s c e n t c o l l e c t o r c u r r e n t i n mA” ) ;
15 // Q u i e s c e n t C o l l e c t o r −e m i t t e r v o l t a g e ,
16 VCEQ = VCC + VBE - ICQ * RC ; // i n V
17 disp ( VCEQ , ” The q u i e s c e n t c o l l e c t o r −e m i t t e r v o l t a g e
i n v o l t s i s : ”);
1 // Example 1 . 3
8
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 VCC = 12; // i n V
8 VEE = -12; // i n V
9 RC = 10; // i n k
10 RE = 10; // i n k
11 RB = 20; // i n k
12 VBE = 0.7; // i n V
13 // P a r t ( a )
14 beta_dc = 75;
15 // T a i l c u r r e n t , IT= 2∗ IE= VEE/RE ( i g n o r i n g VBE) ,
hence
16 IT = abs ( VEE ) / RE ; // i n mA
17 IC = IT /2; // c o l l e c t o r c u r r e n t i n mA
18 // o u t p u t v o l t a g e ,
19 Vout1 = VCC - IC * RC ; // i n V
20 IT = ( abs ( VEE ) - VBE ) / RE ; // t a i l c u r r e n t i n mA ( on
c o n s i d e r i n g VBE)
21 IC = IT /2; // c o l l e c t o r c u r r e n t i n mA
22 Vout2 = VCC - IC * RC ; // i n V
23 // T a i l c u r r e n t ,
24 IT = ( abs ( VEE ) - VBE ) /( RE + RB /(2* beta_dc ) ) ; // i n mA
25 IC = IT /2; // c o l l e c t o r c u r r e n t i n mA
26 // o u t p u t v o l t a g e ,
27 Vout3 = VCC - IC * RC ; // i n V
28 disp ( ” P a r t ( a ) : There a r e t h r e e d i f f e r e n t values
o f output v o l t a g e i n v o l t s ”);
29 disp ( Vout1 ) ;
30 disp ( Vout2 ) ;
31 disp ( Vout3 ) ;
32
33 // P a r t ( b )
34 IT = abs ( VEE ) / RE ; // i n mA
35 IC = IT /2; // c o l l e c t o r c u r r e n t i n mA
36 IB = IC /( beta_dc ) ; // b a s e c u r r e n t i n mA
9
37 IB = IB *10^3; // i n A
38 VB = - IB * RB ; // b a s e v o l t a g e i n mV
39 VB = VB *10^ -3; // i n V
40 disp ( ” P a r t ( b ) : ” ) ;
41 disp ( IB , ” The v a l u e o f b a s e c u r r e n t i n A i s : ”);
42 disp ( VB , ” The v a l u e o f b a s e v o l t a g e i n v o l t s i s : ” ) ;
43
44 // P a r t ( c )
45 beta_dc1 = 60;
46 beta_dc2 = 80;
47 IB1 = IC / beta_dc1 ; // b a s e c u r r e n t f o r t r a n s i s t o r Q1 ,
i n mA
48 IB1 = IB1 *10^3; // i n A
49 disp ( ” P a r t ( c ) ” )
50 disp ( IB1 , ” The v a l u e o f b a s e c u r r e n t for transistor
Q1 i n A i s : ”);
51 VB1 = - IB1 * RB ; // i n mV
52 VB1 = VB1 *10^ -3; // i n V
53 disp ( VB1 , ” The v a l u e o f b a s e v o l t a g e for transistor
Q1 i n v o l t s i s : ” ) ;
54 IB2 = IC / beta_dc2 ; // b a s e c u r r e n t f o r t r a n s i s t o r Q2 ,
i n mA
55 IB2 = IB2 *10^3; // i n A
56 disp ( IB2 , ” The v a l u e o f b a s e c u r r e n t for transistor
Q2 i n A i s : ”);
57 VB2 = - IB2 * RB ; // i n mV
58 VB2 = VB2 *10^ -3; // i n V
59 disp ( VB2 , ” The v a l u e o f b a s e v o l t a g e for transistor
Q2 i n v o l t s i s : ” ) ;
60
61 // Note : I n t h e p a r t ( c ) , t h e u n i t o f b a s e c u r r e n t
f o r t r a n s i s t o r Q2 i n t h e book i s wrong i t w i l l be
A
10
1 // Example 1 . 4
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,7) ;
7 RC = 2.2; // i n k
8 RE = 4.7; // i n k
9 RE = RE *10^3; // i n
10 Ri1 = 50; // i n
11 Ri2 = 50; // i n
12 VCC = 10; // i n V
13 VEE = 10; // i n V
14 VBE = 0.7; // i n V
15 beta_dc = 100;
16 beta_ac = 100;
17
18 // P a r t ( a )
19 // Formula Used : ICQ= IE= (VEE−VBE) / ( 2 ∗RE+Ri /
beta dc )
20 ICQ = ( VEE - VBE ) /(2* RE + Ri1 / beta_dc ) ; // q u i e s c e n t
c o l l e c t o r current in A
21 ICQ = ICQ *10^3; // i n mA
22 IE = ICQ ; // i n mA
23 disp ( ” P a r t ( a ) ” )
24 disp ( ICQ , ” The v a l u e o f ICQ i n mA i s : ” ) ;
25 // Q u i e s c e n t c o l l e c t o r −e m i t t e r v o l t a g e ,
26 VCEQ = VCC + VBE - ICQ * RC ; // i n V
27 disp ( VCEQ , ” The v a l u e o f VCEQ i n v o l t s i s : ” ) ;
28
29 // P a r t ( b )
30 re_desh = 26/ IE ; // AC e m i t t e r r e s i s t a n c e i n
31 // Formula Used : Ad= Vout / Vind= RC/ r e d e s h
32 Ad = RC *10^3/ re_desh ; // v o l t a g e g a i n
33 disp ( ” P a r t ( b ) ” )
34 disp ( Ad , ” The v o l t a g e g a i n i s : ” ) ;
35
36 // P a r t ( c )
11
37 Rin1 = 2* beta_ac * re_desh ; // i n p u t r e s i s t a n c e i n
38 Rin1 = Rin1 *10^ -3; // i n k
39 Rin2 = Rin1 ; // i n k
40 disp ( ” P a r t ( c ) ” ) ;
41 disp ( Rin1 , ” The i n p u t r e s i s t a n c e i n k i s : ”);
42
43 // P a r t ( d )
44 Rout1 = RC ; // i n k
45 disp ( ” P a r t ( d ) ” ) ;
46 disp ( Rout1 , ” The o u t p u t r e s i s t a n c e i n k i s : ”);
Scilab code Exa 1.5 Voltage gain input resistance output resistance and
CMRR
1 // Example 1 . 5
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,7) ;
7 VCC = 15; // i n V
8 VEE = 15; // i n V
9 RC = 1; // i n M
10 RE = RC ; // i n M
11 beta_ac = 100;
12 VBE = 0.7; // i n V
13 IE = ( VEE - VBE ) /(2* RE ) ; // e m i t t e r c u r r e n t i n A
14 IC = IE ; // i n c o l l e c t o r c u r r e n t i n A
15 re_desh = 26/ IE ; // a c r e s i s t a n c e o f e a c h e m i t t e r
diode in k
16 Ad = RC *10^3/ re_desh ; // V o l t a g e g a i n
17 disp ( Ad , ” The v o l t a g e g a i n i s : ” ) ;
18 Zin = 2* beta_ac * re_desh ; // i n p u t i m p e d a n c e i n k
19 Zin = Zin *10^ -3; // i n M
20 disp ( Zin , ” The i n p u t i m p e d a n c e i n M i s : ”);
12
21 Zout = RC ; // o u t p u t i m p e d a n c e i n M
22 disp ( Zout , ” The o u t p u t i m p e d a n c e i n M i s : ”);
23 Acm = ( RC *10^3) /(2* RE *10^3+ re_desh ) ; // common−mode
gain
24 CMRR = Ad / Acm ; // common−mode r e j e c t i o n r a t i o
25 disp ( CMRR , ” The common−mode r e j e c t i o n r a t i o i s : ” ) ;
26 // When v i n i s z e r o
27 Vout = VCC - IC * RC ; // i n V
28 disp ( Vout , ”When v i n i s z e r o t h e n t h e t o t a l o u t p u t
v o l t a g e at the q u i e s c e n t v a l u e i n v o l t s i s : ”);
29 // When v i n= 1mV,
30 v_in = 1*10^ -3; // i n V
31 Vout = Ad * v_in ; // i n V
32 disp ( Vout , ”When v i n i s −1mV t h e n t h e a c o u t p u t
v o l t a g e i n v o l t s i s : ”);
33
34 // Note : The v a l u e o f CMRR i n t h e book i s wrong
b e c a u s e t h e c o r r e c t v a l u e o f Acm i s ” 0 . 4 9 9 1 ” and
i n t h e book i t i s t a k e n a s ” 0 . 4 2 2 5 ”
1 // Example 1 . 6
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 VEE = 5; // s u p p l y v o l t a g e i n V
8 RC = 2*10^3; // c o l l e c t o r r e s i s t a n c e i n
9 RE = 4.3; // e m i t t e r r e s i s t a n c e i n k
10 VBE = 0.7; // i n V
11 VT = 26; // i n mV
12 IE = ( VEE - VBE ) /(2* RE ) ; // e m i t t e r c u r r e n t i n mA
13 re_desh = VT / IE ; // dynamic e m i t t e r r e s i s t a n c e i n
13
14 Ad = RC /(2* re_desh ) ; // d i f f e r e n t i a l mode g a i n
15 disp ( Ad , ” The d i f f e r e n t i a l mode g a i n i s : ” ) ;
1 // Example 1 . 7
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 VEE = 5; // s u p p l y v o l t a g e i n V
8 RC = 2*10^3; // c o l l e c t o r r e s i s t a n c e i n
9 RE = 4.3; // e m i t t e r r e s i s t a n c e i n k
10 VBE = 0.7; // i n V
11 VT = 26; // i n mV
12 IE = ( VEE - VBE ) /(2* RE ) ; // e m i t t e r c u r r e n t i n mA
13 re_desh = VT / IE ; // dynamic e m i t t e r r e s i s t a n c e i n
14 Ad = RC /(2* re_desh ) ; // d i f f e r e n t i a l mode g a i n
15 Acm = RC /(2* RE *10^3+ re_desh ) ; // common mode g a i n
16 disp ( Acm , ” The common mode g a i n i s : ” ) ;
17 CMRR = Ad / Acm ; // common mode r e j e c t i o n r a t i o
18 disp ( CMRR , ” The CMRR i s : ” ) ;
1 // Example 1 . 8
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 VEE = 9; // i n V
14
8 VCC = 9; // i n V
9 RC = 47*10^3; // c o l l e c t o r r e s i s t a n c e i n
10 RE = 43*10^3; // e m i t t e r r e s i s t a n c e i n
11 vin1 = 2.5*10^ -3; // i n V
12 Ri1 = 20*10^3; // i n
13 Ri2 = Ri1 ; // i n
14 VBE = 0.7; // i n V
15 VT = 26*10^ -3; // i n V
16 beta1 = 75;
17 beta2 = 75;
18 IE = ( VEE - VBE ) /(2* RE + Ri1 / beta1 ) ; // e m i t t e r c u r r e n t i n
A
19 ICQ = IE ; // q u i e s c e n t c u r r e n t i n A
20 VCEQ = VCC + VBE - ICQ * RC ; // q u i e s c e n t c o l l e c t o r v o l t a g e
in V
21 re_desh = VT / IE ; //AC e m i t t e r r e s i s t a n c e i n
22 Ad = RC / re_desh ; // v o l t a g e g a i n
23 vout = Ad * vin1 ; // o u t p u t v o l t a g e i n V
24 disp ( vout , ” The o u t p u t v o l t a g e i n v o l t s i s : ” ) ;
1 // Example 1 . 9
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,7) ;
7 RC = 2.2; // i n k
8 RE = 4.7; // i n k
9 Ri1 = 50*10^ -3; // i n k
10 Ri2 = 50*10^ -3; // i n k
11 VCC = 10; // i n V
12 VEE = 10; // i n V
13 VBE = 0.7; // i n V
15
14 beta_dc = 100;
15 beta_ac = 100;
16
17 // P a r t ( i )
18 // Formula Used : ICQ= IE= (VEE−VBE) / ( 2 ∗RE+Ri /
beta dc )
19 ICQ = ( VEE - VBE ) /(2* RE + Ri1 / beta_dc ) ; // q u i e s c e n t
c o l l e c t o r c u r r e n t i n mA
20 IE = ICQ ; // i n mA
21 disp ( ” P a r t ( i ) : Dual−i n p u t , u n b a l a n c e d o u t p u t ” )
22 disp ( ICQ , ” The v a l u e o f ICQ i n mA i s : ” ) ;
23 // Q u i e s c e n t c o l l e c t o r −e m i t t e r v o l t a g e ,
24 VCEQ = VCC + VBE - ICQ * RC ; // i n V
25 disp ( VCEQ , ” The v a l u e o f VCEQ i n v o l t s i s : ” ) ;
26 re_desh = 26/ IE ; // AC e m i t t e r r e s i s t a n c e i n
27 Rin1 = 2* beta_ac * re_desh ; // i n p u t r e s i s t a n c e i n
28 Rin1 = Rin1 *10^ -3; // i n k
29 Rin2 = Rin1 ; // i n k
30 disp ( Rin1 , ” The v a l u e o f Rin1 i n k i s : ”);
31 Rout = RC ; // i n k
32 disp ( Rout , ” The v a l u e o f Rout i n k i s : ”);
33 disp ( RC , ” The v a l u e o f RC i n k i s : ”)
34 // Formula Used : Ad= Vout / Vind= RC/ r e d e s h
35 Ad = RC *10^3/( re_desh *2) ; // v o l t a g e g a i n o f d u a l
input , unbalanced output
36 disp ( Ad , ” The v a l u e o f Ad i s : ” ) ;
37
38 // P a r t ( i i )
39 disp ( ” P a r t ( i i ) : S i n g l e −o u t p u t , b a l a n c e d o u t p u t ” ) ;
40 disp ( ICQ , ” The v a l u e o f ICQ i n mA i s : ” ) ;
41 disp ( VCEQ , ” The v a l u e o f VCEQ i n v o l t s i s : ” ) ;
42 disp ( Rin1 , ” The v a l u e o f Rin1 i n k i s : ”);
43 disp ( Rout , ” The v a l u e o f Rout i n k i s : ”);
44 disp ( RC , ” The v a l u e o f RC i n k i s : ”)
45 // Formula Used : Ad= Vout / Vind= RC/ r e d e s h
46 Ad = RC *10^3/( re_desh ) ; // v o l t a g e g a i n o f d u a l i n p u t ,
unbalanced output
47 disp ( Ad , ” The v a l u e o f Ad i s : ” ) ;
16
Scilab code Exa 1.10 Single input unbalanced output
1 // Example 1 . 1 0
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,7) ;
7 VEE = 9; // i n V
8 VCC = 9; // i n V
9 RC = 47*10^3; // c o l l e c t o r r e s i s t a n c e i n
10 RE = 43*10^3; // e m i t t e r r e s i s t a n c e i n
11 vin1 = 2.5*10^ -3; // i n V
12 Ri1 = 20*10^3; // i n
13 Ri2 = Ri1 ; // i n
14 VBE = 0.7; // i n V
15 VT = 26*10^ -3; // i n V
16 beta1 = 75;
17 beta2 = 75;
18 IE = ( VEE - VBE ) /(2* RE + Ri1 / beta1 ) ; // e m i t t e r c u r r e n t i n
A
19 ICQ = IE ; // q u i e s c e n t c u r r e n t i n A
20 VCEQ = VCC + VBE - ICQ * RC ; // q u i e s c e n t c o l l e c t o r v o l t a g e
in V
21 re_desh = VT / IE ; //AC e m i t t e r r e s i s t a n c e i n
22 Ad = RC /(2* re_desh ) ; // v o l t a g e g a i n
23 vout = Ad * vin1 ; // o u t p u t v o l t a g e i n V
24 disp ( vout , ” The o u t p u t v o l t a g e i n v o l t s i s : ” ) ;
Scilab code Exa 1.11 Q point differential voltage gain and output resis-
tance
17
1 // Example 1 . 1 1
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 VEE = 15; // i n V
8 VD1 = 0.7; // i n V
9 VD2 = 0.7; // i n V
10 VBE = 0.7; // i n V
11 Beta = 100;
12 VT = 26; // i n mV
13 R3 = 180; // i n
14 RC = 470; // i n
15 VB3 = - VEE + VD1 + VD2 ; // i n V
16 VE3 = VB3 - VBE ; // v o l t a g e a t e m i t t e r t e r m i n a l o f
t r a n s i s t o r Q3 i n V
17 IE3 = ( VE3 -( - VEE ) ) / R3 ; // e m i t t e r c u r r e n t t h r o u g h
t r a n s i s t o r Q3 i n A
18
19 // P a r t (i)
20 ICQ = IE3 /2; // q u i e s c e n t c u r r e n t i n A
21 ICQ = round ( ICQ *10^3) ; // i n mA
22 IE = ICQ ; // e m i t t e r c u r r e n t i n mA
23 disp ( ICQ , ” ( i ) : Q u i e s c e n t c u r r e n t i n mA i s : ” )
24 VCEQ = VEE + VBE - ICQ *10^ -3* RC ; // q u i e s c e n t c o l l e c t o r −
emitter voltage in V
25 disp ( VCEQ , ” The q u i e s c e n t c o l l e c t o r −e m i t t e r v o l t a g e
in v o l t s i s : ”)
26 re_desh = VT / IE ; //AC e m i t t e r r e s i s t a n c e i n
27
28 // P a r t ( i i )
29 Ad = RC / re_desh ; // d i f f e r e n t i a l v o l t a g e g a i n
30 disp ( Ad , ” ( i i ) : D i f f e r e n t i a l v o l t a g e g a i n i s : ”)
31
32 // P a r t ( i i i )
33 Rin1 = 2* Beta * re_desh ; // i n
34 Rin1 = Rin1 *10^ -3; // i n k
18
35 disp ( Rin1 , ” ( i i i ) : The i n p u t r e s i s t a n c e i n k is :
”)
Scilab code Exa 1.12 Voltage gain input resistance and operation point
1 // Example 1 . 1 2
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 VEE = 10; // i n V
8 VCC =10; // i n V
9 VD1 = 0.715; // i n V
10 Vz = 6.2 // i n V
11 VBE = VD1 ; // i n V
12 Izt = 41; // i n mA
13 R3 = 2.7; // i n k
14 RC = 4.7; // i n k
15 VT = 26; // i n mV
16 beta_ac = 100;
17 beta_dc = 100;
18 VB3 = - VEE + Vz + VD1 ; // v o l t a g e a t t h e b a s e o f t r a n s i s t o r
Q3 i n V
19 VE3 = VB3 - VBE ; // v o l t a g e a t t h e e m i t t e r o f t r a n s i s t o r
Q3 i n V
20 IE3 = ( VE3 -( - VEE ) ) / R3 ; // e m i t t e r c u r r e n t t h r o u g h
t r a n s i s t o r Q3 i n mA
21 ICQ = IE3 /2; // q u i e s c e n t c u r r e n t i n mA
22 VCEQ = VCC + VBE - ICQ * RC ; // i n V
23 disp ( ” P a r t ( a ) : The Q−p o i n t v a l u e s : ” ) ;
24 disp ( ICQ , ” The v a l u e o f ICQ i n mA i s : ” ) ;
25 disp ( VCEQ , ” The v a l u e o f VCEQ i n v o l t s i s : ” )
26 re_desh = VT / ICQ ; // dynamic e m i t t e r r e s i s t a n c e i n
27 Ad = RC *10^3/ re_desh ; // v o l t a g e g a i n
19
28 disp ( Ad , ” P a r t ( b ) : The v o l t a g e g a i n i s : ” )
29 Rin = 2* beta_ac * re_desh ; // d i f f e r e n t i a l i n p u t
r e s i s t a n c e in
30 Rin = Rin *10^ -3; // i n k
31 disp ( Rin , ” P a r t ( c ) : The d i f f e r e n t i a l i n p u t
r e s i s t a n c e in k i s : ”)
1 // Example 1 . 1 3
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 VCC = 12; // i n V
8 VBE = 0.7; // i n V
9 R1 = 25; // i n k
10 // I= I REF= (VCC−VBE) /R1
11 I = ( VCC - VBE ) / R1 ; // m i r r o r e d c u r r e n t i n mA
12 disp (I , ” The m i r r o r e d c u r r e n t i n mA i s : ” ) ;
1 // Example 1 . 1 4
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 VCC = 10; // i n V
8 VBE = 0.7; // i n V
9 R1 = 15; // i n k
20
10 Beta = 100;
11 I_REF = ( VCC - VBE ) / R1 ; // r e f e r e n c e c u r r e n t i n mA
12 disp ( I_REF , ” The r e f e r e n c e c u r r e n t i n mA i s : ” )
13 Iout = I_REF * Beta /( Beta +2) ; // o u t p u t c u r r e n t i n mA
14 disp ( Iout , ” The o u t p u t c u r r e n t i n mA i s : ” )
1 // Example 1 . 1 5
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,5) ;
7 VCC = 15; // i n V
8 VBE = 0.7; // i n V
9 R1 = 2.2; // i n k
10 Beta = 220;
11 I_REF = ( VCC - VBE ) / R1 ; // r e f e r e n c e c u r r e n t i n mA
12 // Formula : I= IC= I REF ∗ ( Beta / ( Beta +2) )
13 IC = I_REF * Beta /( Beta +2) ; // i n mA
14 disp ( IC , ” The v a l u e o f c u r r e n t i n mA i s : ” )
1 // Example 1 . 1 6
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 Vz = 1.8; // i n V
8 VBE = 0.7; // i n V
21
9 RE = 1; // i n k
10 Beta = 180;
11 VB = Vz - VBE ; // i n V
12 IE = VB / RE ; // e m i t t e r c u r r e n t i n mA
13 // Formula : I= IC= IE ∗ ( Beta / ( Beta +1) )
14 IC = IE * Beta /( Beta +1) ; // i n mA
15 disp ( IC , ” The v a l u e o f c u r r e n t i n mA i s : ” )
1 // Example 1 . 1 7
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,7) ;
7 VCC = 9; // i n V
8 R1 = 12; // i n k
9 VBE = 0.7; // i n V
10 Beta = 100;
11 I_REF = ( VCC -2* VBE ) / R1 ; // r e f e r e n c e c u r r e n t i n mA
12 disp ( I_REF , ” The r e f e r e n c e c u r r e n t i n mA i s : ” )
13 Iout = I_REF /(1+2/( Beta *(1+ Beta ) ) ) ; // o u t p u t c u r r e n t
i n mA
14 disp ( Iout , ” The o u t p u t c u r r e n t i n mA i s : ” )
15 IC2 = Iout ; // c o l l e c t o r c u r r e n t i n mA
16 disp ( IC2 , ” The c o l l e c t o r c u r r e n t i n mA i s : ” )
17 // IB3= I REF−IC1= I REF−IC2 ( s i n c e IC1= IC2 )
18 IB3 = I_REF - IC2 ; // b a s e c u r r e n t o f t r a n s i s t o r Q3 i n mA
19 IB3 = IB3 *10^3; // i n A
20 disp ( IB3 , ” The b a s e c u r r e n t o f t r a n s i s t o r Q3 i n A
i s : ”)
21 IB3 = 0.1; // i n A
22 IE3 = (1+ Beta ) * IB3 ; // e m i t t e r c u r r e n t o f t r a n s i s t o r
Q3 i n A
22
23 disp ( IE3 , ” The e m i t t e r c u r r e n t o f t r a n s i s t o r Q3 i n
A i s : ”)
24 IB1 = IE3 /2; // b a s e c u r r e n t i n A
25 IB2 = IB1 ; // i n A
26 disp ( IB1 , ” The b a s e c u r r e n t i n A i s : ”)
1 // Example 1 . 1 8
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,5) ;
7 VEE = 10; // i n V
8 VBE = 0.715; // i n V
9 beta_ac = 100;
10 beta_dc = 100;
11 R = 5.6; // i n k
12 I_REF = ( VEE - VBE ) / R ; // i n mA
13 IC1 = I_REF * beta_ac /(2+ beta_ac ) ; // i n mA
14 // IC1= IC2= IC3 ( by symmetry )
15 IC2 = IC1 ; // i n mA
16 IC3 = IC2 ; // i n mA
17 I_RC = IC1 + IC2 + IC3 ; // c u r r e n t t h r o u g h RC i n mA
18 disp ( I_RC , ” The c u r r e n t t h r o u g h RC i n mA i s : ” ) ;
1 // Example 1 . 1 9
2 clc ;
3 clear ;
4 close ;
23
5 // Given d a t a
6 format ( ’ v ’ ,8) ;
7 VCC = 5; // i n V
8 VBE = 0.7; // i n V
9 VEE = -5; // i n V
10 VT = 26; // i n mV
11 R = 18.6; // i n k
12 Beta = 100;
13 I2 = ( VCC - VBE - VEE ) / R ; // i n mA
14 IC3 = I2 ; // i n mA ( due t o c u r r e n t m i r r o r a c t i o n )
15 IE = IC3 /2; // e m i t t e r c u r r e n t o f t r a n s i s t o r Q1 and Q2
16 re_desh = VT / IE ; //AC e m i t t e r r e s i s t a n c e o f t r a n s i s t o r
in
17 Rin1 = 2* Beta * re_desh ; // i n
18 Rin1 = Rin1 *10^ -3; // i n k
19 disp ( Rin1 , ” The d i f f e r e n t i a l i n p u t r e s i s t a n c e i n k
i s : ”)
1 // Example 1 . 2 0
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 VCC = 18; // i n V
8 R1 = 4.7; // i n k
9 R2 = 5.6; // i n k
10 R3 = 6.8; // i n k
11 RE = 1.1; // i n k
12 VBE = 0.7; // i n V
13 VT = 26; // i n mV
14 RC = 1.8*10^3; // i n
15 IE1 = ( VCC * R1 /( R1 + R2 + R3 ) - VBE ) / RE ; // i n mA
24
16 re_desh = VT / IE1 ; // dynamic r e s i s t a n c e o f e a c h
t r a n s i s t o r in
17 Av = - RC / re_desh ; // v o l t a g e g a i n o f t h e c a s c o d e
amplifier
18 disp ( Av , ” The v o l t a g e g a i n o f t h e c a s c o d e a m p l i f i e r
i s : ”)
25
Chapter 2
1 // Example 2 . 2
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 // P a r t ( i )
8 Vin1 = 5; // i n V
9 Vin1 = Vin1 *10^ -6; // i n V
10 Vin2 = -7; // i n V
11 Vin2 = Vin2 *10^ -6; // i n V
12 Av = 2*10^5; // u n i t l e s s
13 Rin = 2; // i n M
14 Vout = ( Vin1 - Vin2 ) * Av ; // i n V
15 disp ( Vout , ” The o u t p u t v o l t a g e in v o l t s i s : ”)
26
Scilab code Exa 2.4 Input resistance
1 // Example 2 . 4
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,5) ;
7 Rs = 2; // i n k
8 RL = 5; // i n k
9 A = 10^5; // u n i t l e s s
10 Rin = 100; // i n k
11 Rout = 50; // i n
12 Vout = 10; // i n V
13 // For Vout = 10 V, V1= V2 = Vout
14 V1 = Vout ; // i n V
15 V2 = V1 ; // i n V
16 // From e q u a t i o n V1= Vs∗ Rin / ( Rin+Rs )
17 Vs = V1 *( Rin + Rs ) / Rin ; // i n V
18 Vout_by_Vs = Vout / Vs ; // v a l u e o f Vout / Vs
19 disp ( Vs , ” The v a l u e o f Vs i n v o l t s i s : ” ) ;
20 disp ( Vout_by_Vs , ” The v a l u e o f Vout / Vs i s : ” ) ;
21 disp ( Rin , ” The i n p u t r e s i s t a n c e o f t h e c i r c u i t i n k
i s : ”);
1 // Example 2 . 6
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,5) ;
7 Ad = 100; // d i f f e r e n t i a l mode g a i n
8 Acm = 0.01; // common mode g a i n
27
9 CMRR = Ad / Acm ;
10 CMRR_desh = 20* log10 ( CMRR ) ; // CMRR i n dB
11 disp ( CMRR_desh , ”CMRR i n dB i s : ” ) ;
1 // Example 2 . 7
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,5) ;
7 Ad = 10^5; // d i f f e r e n t i a l mode g a i n
8 CMRR = 10^5;
9 // Common−mode g a i n ,
10 Acm = Ad / CMRR ;
11 disp ( Acm , ” The common−mode g a i n i s : ” ) ;
1 // Example 2 . 8
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 V1 = 10; // i n mV
8 V2 = 9; // i n mV
9 Ad = 60; // d i f f e r e n t i a l v o l t a g e g a i n i n dB
10 Ad = 10^( Ad /20) ;
11 CMRR = 80; // i n dB
12 CMRR = 10^( CMRR /20) ;
13 Vd = V1 - V2 ; // d i f f e r e n c e s i g n a l i n mV
28
14 Vcm = ( V1 + V2 ) /2; // common−mode s i g n a l i n mV
15 // Output v o l t a g e ,
16 Vout = Ad * Vd *(1+1/ CMRR * Vcm / Vd ) ; // i n mV
17 AdVd = Ad * Vd ; // i n mV
18 // E r r o r v o l t a g e
19 Verror = Vout - AdVd ; // i n mV
20 Per_error = Verror / Vout *100; // p e r c e n t a g e e r r o r
21 disp ( Verror , ” The e r r o r v o l t a g e i n mV i s : ” )
22 disp ( Per_error , ” The p e r c e n t a g e e r r o r i n t h e o u t p u t
v o l t a g e i s : ”)
1 // Example 2 . 9
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,9) ;
7 V1 = 745; // i n V
8 V2 = 740; // i n V
9 Ad = 5*10^5; // d i f f e r e n t i a l v o l t a g e g a i n
10 CMRR = 80; // i n dB
11 CMRR = 10^( CMRR /20) ;
12 Vd = V1 - V2 ; // d i f f e r e n c e s i g n a l i n V
13 Vcm = ( V1 + V2 ) /2; // common−mode s i g n a l i n V
14 // Output v o l t a g e ,
15 Vout = Ad * Vd *(1+1/ CMRR * Vcm / Vd ) ; // i n V
16 AdVd = Ad * Vd ; // i n V
17 // E r r o r v o l t a g e
18 Verror = Vout - AdVd ; // i n V
19 Vout = Vout *10^ -6; // i n V
20 Verror = Verror *10^ -6; // i n V
21 Per_error = Verror / Vout *100; // p e r c e n t a g e e r r o r
22 disp ( Vout , ” The o u t p u t v o l t a g e i n v o l t s i s : ” )
29
23 disp ( Per_error , ” The p e r c e n t a g e e r r o r i n t h e o u t p u t
v o l t a g e i s : ”)
1 // Example 2 . 1 0
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,9) ;
7 Vd = 25; // d i f f e r e n t i a l i n p u t v o l t a g e i n V
8 Vd = Vd *10^ -6; // i n V
9 A = 200000; // open l o o p g a i n
10 // Output v o l t a g e ,
11 Vout = A * Vd ; // i n V
12 disp ( ” The o u t p u t v o l t a g e i s : ” + string ( Vout ) + ”V”
)
1 // Example 2 . 1 1
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,9) ;
7 dVout = 20; // c h a n g e i n o u t p u t v o l t a g e i n V
8 dt = 4; // c h a n g e i n t i m e i n s
9 SR = dVout / dt ; // s l e w r a t e i n V/ s
10 disp ( SR , ” The s l e w r a t e i n V/ s i s : ” )
30
Scilab code Exa 2.12 Input bias current and input offset current
1 // Example 2 . 1 2
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,9) ;
7 IB1 = 10; // i n A
8 IB2 = 7.5; // i n A
9 // I n p u t b i a s c u r r e n t ,
10 I_in_bias = ( IB1 + IB2 ) /2; // i n A
11 // I n p u t o f f s e t c u r r e n t ,
12 I_in_offset = IB1 - IB2 ; // i n A
13 disp ( I_in_bias , ” The i n p u t b i a s c u r r e n t i n A is : ”
)
14 disp ( I_in_offset , ” The i n p u t o f f s e t c u r r e n t i n A is
: ”)
1 // Example 2 . 1 3
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 SR = 6; // s l e w r a t e i n V/ s
8 SR = 6*10^6; // i n V/ s
9
10 // P a r t ( i ) For Vmax= 1V
11 Vmax = 1; // i n V
31
12 fmax = SR /(2* %pi * Vmax ) ; // l i m i t i n g f r e q u e n c y i n Hz
13 fmax = fmax *10^ -6; // i n MHz
14 disp ( fmax , ” P a r t ( i ) : The l i m i t i n g f r e q u e n c y f o r
maximum v o l t a g e o f 1V i n MHz i s : ” ) ;
15
16 // P a r t ( i i ) For Vmax= 10V
17 Vmax = 10; // i n V
18 fmax = SR /(2* %pi * Vmax ) ; // l i m i t i n g f r e q u e n c y i n Hz
19 fmax = fmax *10^ -3; // i n kHz
20 disp ( fmax , ” P a r t ( i i ) : The l i m i t i n g f r e q u e n c y f o r
maximum v o l t a g e o f 10V i n kHz i s : ” ) ;
1 // Example 2 . 1 4
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 Vpp = 3; // o u t p u t v o l t a g e i n V
8 del_t = 4; // i n s
9 del_V = 90* Vpp /100 -10* Vpp /100; // i n V
10 // R e q u i r e d s l e w r a t e ,
11 SR = del_V / del_t ; // i n V/ s
12 disp ( SR , ” The r e q u i r e d s l e w r a t e i n V/ s i s : ”);
32
Chapter 3
1 // Example 3 . 1
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 Af = 10; // v o l t a g e g a i n
8 R1 = 3; // i n
9 Rf = ( Af -1) * R1 ; // From Af= 1+Rf /R1
10 disp ( R1 , ” The v a l u e o f R1 i n i s : ”);
11 disp ( Rf , ” The v a l u e o f Rf i n i s : ”);
Scilab code Exa 3.2 Minimum and maximum closed loop voltage gains
1 // Example 3 . 2
2 clc ;
33
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 R1 = 2; // i n k
8 Rf_min = 0;
9 Rf_max = 100; // i n k
10 // Formula Used : Af= 1+Rf /R1
11 Af_max = 1+ Rf_max / R1 ; // maximum c l o s e d loop voltage
gain
12 Af_min = 1+ Rf_min / R1 ; // minimum c l o s e d l o o p v o l t a g e
gain
13 disp ( Af_max , ” The maximum c l o s e d l o o p v o l t a g e g a i n i s
: ”);
14 disp ( Af_min , ” The minimum c l o s e d l o o p v o l t a g e g a i n i s
: ”);
Scilab code Exa 3.3 Voltage gain input resistance output resistance and
bandwidth
1 // Example 3 . 3
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 R1 = 100; // i n
8 Rf = 100*10^3; // i n
9 A = 2*10^5; // u n i t l e s s
10 Rin = 2*10^6; // i n
11 Rout = 75; // i n
12 f0 = 5; // i n Hz
13 B = R1 /( R1 + Rf ) ; // f e e d b a c k f r a c t i o n
14 AB = A * B ; // f e e d b a c k f a c t o r
15 Af = 1+ Rf / R1 ; // v o l t a g e g a i n
34
16 Rin_f = Rin *(1+ AB ) ; // i n p u t r e s i s t a n c e i n
17 Rout_f = Rout /(1+ AB ) ; // o u t p u t r e s i s t a n c e i n
18 f_f = f0 *(1+ AB ) ; // bandwidth i n Hz
19 Rin_f = Rin_f *10^ -6; // i n M
20 disp ( Af , ” The v o l t a g e g a i n i s : ” ) ;
21 disp ( Rin_f , ” The i n p u t r e s i s t a n c e i n M i s : ”);
22 disp ( Rout_f , ” The o u t p u t r e s i s t a n c e i n i s : ”)
23 disp ( f_f , ” The bandwidth i n Hz i s : ” ) ;
Scilab code Exa 3.4 Voltage gain input resistance output resistance and
bandwidth
1 // Example 3 . 4
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,9) ;
7 Rin = 2*10^6; // i n
8 Rout = 75; // i n
9 f0 = 5; // i n Hz
10 A = 2*10^5; // u n i t l e s s
11 B =1; // f o r v o l t a g e f o l l o w e r
12 Rf = 0;
13 Af = 1; // v o l t a g e g a i n ( s i n c e Rf =0)
14 Rin_f = A * Rin ; // i n p u t r e s i s t a n c e i n
15 Rin_f = Rin_f *10^ -9; // i n G
16 Rout_f = Rout / A ; // o u t p u t r e s i s t a n c e i n
17 f_f = f0 * A ; // bandwidth i n Hz
18 f_f = f_f *10^ -6; // i n MHz
19 disp ( Af , ” The v o l t a g e g a i n i s : ” ) ;
20 disp ( Rin_f , ” The i n p u t r e s i s t a n c e i n G i s : ”);
21 disp ( Rout_f , ” The o u t p u t r e s i s t a n c e i n i s : ”)
22 disp ( f_f , ” The bandwidth i n MHz i s : ” ) ;
35
Scilab code Exa 3.5 Voltage gain input resistance output resistance and
bandwidth
1 // Example 3 . 5
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,8) ;
7 Rin = 2*10^6; // i n
8 Rout = 75; // i n
9 f0 = 5; // i n Hz
10 R1 = 330; // i n
11 Rf = 3.3*10^3; // i n
12 A = 2*10^5; // u n i t l e s s
13 B = R1 /( R1 + Rf ) ; // f e e d b a c k f r a c t i o n
14 AB = A * B ; // f e e d b a c k f a c t o r
15 Af = - Rf / R1 ; // c o l s e d −l o o p v o l t a g e g a i n
16 Rin_f = R1 ; // i n p u t r e s i s t a n c e w i t h f e e d b a c k i n
17 Rout_f = Rout /(1+ AB ) ; // o u t p u t r e s i s t a n c e w i t h
feedback in
18 f_f = f0 *(1+ AB ) ; // c l o s e d −l o o p bandwidth i n Hz
19 f_f = f_f *10^ -3; // i n kHz
20 disp ( Af , ” The c l o s e d −l o o p v o l t a g e g a i n i s : ” ) ;
21 disp ( Rin_f , ” The i n p u t r e s i s t a n c e i n i s : ”);
22 disp ( Rout_f , ” The o u t p u t r e s i s t a n c e i n i s : ”);
23 disp ( f_f , ” The bandwidth i n kHz i s : ” ) ;
Scilab code Exa 3.6 Voltage gain input resistance output resistance and
bandwidth
1 // Example 3 . 6
36
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,8) ;
7 Rin = 2*10^6; // i n
8 Rout = 75; // i n
9 f0 = 5; // i n Hz
10 A = 2*10^5; // u n i t l e s s
11 B = 1/2; // f e e d b a c k f r a c t i o n ( s i n c e R1=Rf )
12 Af = -1; // v o l t a g e g a i n
13 R1 = 330; // i n ( assume )
14 Rin_f = R1 ; // i n p u t r e s i s t a n c e w i t h f e e d b a c k i n
15 Rout_f = Rout /( A /2) ; // o u t p u t r e s i s t a n c e i n
16 f_f = A /2* f0 ; // i n Hz
17 f_f = f_f *10^ -6; // i n MHz
18 disp ( Af , ” The c l o s e d −l o o p v o l t a g e g a i n i s : ” ) ;
19 disp ( Rin_f , ” The i n p u t r e s i s t a n c e i n i s : ”);
20 disp ( Rout_f , ” The o u t p u t r e s i s t a n c e i n i s : ”);
21 disp ( f_f , ” The bandwidth i n kHz i s : ” ) ;
1 // Example 3 . 7
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,8) ;
7 Rin = 2*10^6; // i n
8 Rout = 75; // i n
9 f0 = 5; // i n Hz
10 A = 200000; // u n i t l e s s
11 VCC = 15; // i n V
12 VEE = -15; // i n V
37
13 Vout_swing = 13; // i n V
14 // P a r t ( i ) : Non−i n v e r t i n g A m p l i f i e r
15 R1 = 1*10^3; // i n
16 Rf = 10*10^3; // i n
17 B = R1 /( R1 + Rf ) ; // f e e d b a c k f r a c t i o n
18 AB = A * B ; // f e e d b a c k f a c t o r
19 Af = 1+ Rf / R1 ; // v o l t a g e g a i n
20 Rin_f = Rin *(1+ AB ) ; // i n p u t r e s i s t a n c e i n
21 Rin_f = Rin_f *10^ -9; // i n G
22 Rout_f = Rout /(1+ AB ) ; // o u t p u t r e s i s t a n c e i n
23 f_f = f0 *(1+ AB ) ; // bandwidth i n Hz
24 f_f = f_f *10^ -3; // i n kHz
25 VooT = Vout_swing /(1+ AB ) ; // i n V
26 VooT = VooT *10^3; // i n mV
27 disp ( ” P a r t ( i ) : Non−i n v e r t i n g A m p l i f i e r :− ” ) ;
28 disp ( Af , ” The c l o s e d −l o o p v o l t a g e g a i n i s : ” ) ;
29 disp ( Rin_f , ” The i n p u t r e s i s t a n c e i n G i s : ”);
30 disp ( Rout_f , ” The o u t p u t r e s i s t a n c e i n i s : ”);
31 disp ( f_f , ” The bandwidth i n kHz i s : ” ) ;
32 disp ( ” The o u t p u t o f f s e t v o l t a g e w i t h f e e d b a c k i s :
” + string ( VooT ) + ” mV” )
33
34 // P a r t ( i i ) : I n v e r t i n g A m p l i f i e r
35 R1 = 470; // i n
36 Rf = 4.7*10^3; // i n
37 B = R1 /( R1 + Rf ) ; // f e e d b a c k f r a c t i o n
38 AB = A * B ; // f e e d b a c k f a c t o r
39 Af = - Rf / R1 ; // v o l t a g e g a i n
40 Rin_f = R1 ; // i n p u t r e s i s t a n c e i n
41 Rout_f = Rout /(1+ AB ) ; // o u t p u t r e s i s t a n c e i n
42 f_f = f0 *(1+ AB ) ; // bandwidth i n Hz
43 f_f = f_f *10^ -3; // i n kHz
44 VooT = Vout_swing /(1+ AB ) ; // i n V
45 VooT = VooT *10^3; // i n mV
46 disp ( ” P a r t ( i i ) : I n v e r t i n g A m p l i f i e r :− ” ) ;
47 disp ( Af , ” The c l o s e d −l o o p v o l t a g e g a i n i s : ” ) ;
48 disp ( Rin_f , ” The i n p u t r e s i s t a n c e i n G i s : ”);
49 disp ( Rout_f , ” The o u t p u t r e s i s t a n c e i n i s : ”);
38
50 disp ( f_f , ” The bandwidth i n kHz i s : ” ) ;
51 disp ( ” The o u t p u t o f f s e t v o l t a g e w i t h f e e d b a c k i s :
” + string ( VooT ) + ” mV” )
Scilab code Exa 3.8 Voltage gain input resistance and output resistance
1 // Example 3 . 8
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,8) ;
7 Rf = 500*10^3; // i n
8 R1 = 5*10^3; // i n
9 Vin = 0.1; // i n p u t v o l t a g e i n V
10 Af = - Rf / R1 ; // v o l t a g e g a i n
11 Rin = R1 ; // i n p u t r e s i s t a n c e i n
12 Rin = Rin *10^ -3; // i n k
13 Rout = 0; // i n
14 Vout = Af * Vin ; // o u t p u t v o l t a g e i n V
15 I_in = Vin / R1 ; // i n p u t c u r r e n t i n A
16 I_in = I_in *10^3; // i n mA
17 disp ( Af , ” The a m p l i f i e r c i r c u i t v o l t a g e g a i n i s : ” ) ;
18 disp ( Rin , ” The a m p l i f i e r c i r c u i t i n p u t r e s i s t a n c e i n
k i s : ”);
19 disp ( Rout , ” The a m p l i f i e r c i r c u i t o u t p u t r e s i s t a n c e
in i s : ”);
20 disp ( Vout , ” The o u t p u t v o l t a g e i n v o l t s i s : ” ) ;
21 disp ( I_in , ” The i n p u t c u r r e n t i n mA i s : ” ) ;
Scilab code Exa 3.9 Input impedance voltage gain and power gain
1 // Example 3 . 9
39
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,8) ;
7 Rf = 1*10^6; // i n
8 Rin = 1*10^6; // i n
9 Vout_by_Vin = - Rf / Rin ; // ( s i n c e Vout= −Rf / Rin ∗ Vin )
10 Av = Vout_by_Vin ; // v o l t a g e g a i n
11 disp ( Av , ” The v o l t a g e g a i n i s : ” ) ;
12 // I i n = I o u t ( As i t i s a u n i t y g a i n i n v e r t e r )
13 Ain = 1; // i n p u t i m p e d a n c e ( s i n c e I i n = I o u t )
14 disp ( Ain , ” The i n p u t i m p e d a n c e i s : ” ) ;
15 Ap = abs ( Av * Ain ) ; // power g a i n
16 disp ( Ap , ” The power g a i n i s : ” ) ;
1 // Example 3 . 1 0
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,4) ;
7 Av = -30; // v o l t a g e g a i n
8 Rf = 1*10^6; // i n
9 // S i n c e , Av= Vo/ Vi=−Rf /R1 , s o
10 R1 = - Rf / Av ; // i n
11 R1 = R1 *10^ -3; // i n k
12 Rf = Rf *10^ -6; // i n M
13 disp ( Rf , ” The v a l u e o f Rf i n M i s : ”)
14 disp ( R1 , ” The v a l u e o f R1 i n k i s : ”);
40
Scilab code Exa 3.11 Designing of an Inverting op amp circuit
1 // Example 3 . 1 1
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 Av = -8; // v o l t a g e g a i n
8 Vi = 1; // i n p u t v o l t a g e i n V
9 I1 = 15; //maximum c u r r e n t i n A
10 I1 = I1 *10^ -6; // i n A
11 R1 = Vi / I1 ; // i n
12 R1 = R1 *10^ -3; // i n k
13 disp ( R1 , ” The v a l u e o f R1 i n k i s : ”);
14 disp ( ” The s t a n d a r d v a l u e o f R1 i s 68 k ” ) ;
15 R1 = 68; // i n k
16 Rf = - Av * R1 ; // i n k
17 disp ( Rf , ” The v a l u e o f Rf i n k i s : ”);
18
19 // Note : The c a l c u l a t e d v a l u e o f Rf i n t h e book i s
wrong [ −( −8) ∗68 i s n o t e q u a l t o 3 8 4 ] , i t w i l l be
544 k
1 // Example 3 . 1 4
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 Rf = 20*10^3; // i n
8 R1 = 10*10^3; // i n
9
41
10 // P a r t ( i ) When s w i t c h S i s o f f ,
11 Aoff_non_inv = 1+ Rf / R1 ; // non−i n v e r t i n g a m p l i f i e r
c i r c u i t gain
12 Aoff_inv = - Rf / R1 ; // i n v e r t i n g a m p l i f i e r g a i n
13 Aoff = Aoff_non_inv + Aoff_inv ; // a m p l i f i e r c i r c u i t
gain
14 disp ( Aoff , ” P a r t ( i ) : When s w i t c h S i s o f f , t h e
g a i n o f the a m p l i f i e r c i r c u i t i s : ”);
15
16 // P a r t ( i i ) When s w i t c h S i s on ,
17 Aon = - Rf / R1 ; // a m p l i f i e r c i r c u i t g a i n
18 disp ( Aon , ” P a r t ( i i ) : When s w i t c h S i s on , the gain
of the amplifer c i r c u i t i s : ”);
1 // Example 3 . 1 7
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 R1 = 1*10^3; // i n
8 R2 = 1*10^3; // i n
9 Rf = 10*10^3; // i n
10 R3 = 10*10^3; // i n
11 Vd = 5; // i n mV
12 Vcm = 2; // i n mV
13 CMRR_dB = 90; // i n dB
14 CMRR = 10^( CMRR_dB /20) ;
15 Ad = Rf / R1 ; // d i f f e r e n t i a l v o l t a g e g a i n
16 // P a r t ( i )
17 Vout = Ad * Vd ; // o u t p u t v o l t a g e i n mV
18 disp ( Vout , ” P a r t ( i ) : The o u t p u t v o l t a g e i n mV i s :
”);
42
19 // P a r t ( i i )
20 Acm = Ad / CMRR ; // common mode g a i n
21 AcmVcm = Acm * Vcm ; // m a g n i t u d e o f t h e i n d u c e d 60 Hz
n o i s e a t t h e o u t p u t i n mV
22 AcmVcm = AcmVcm *10^3; // i n V
23 disp ( AcmVcm , ” The m a g n i t u d e o f t h e i n d u c e d 60 Hz n o i s e
at the output in V i s : ”)
Scilab code Exa 3.18 Voltage gain output voltage and internal resistance
1 // Example 3 . 1 8
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 R1 = 540; // i n
8 R3 = 540; // i n
9 R2 = 5.4*10^3; // i n
10 Rf = 5.4*10^3; // i n
11 Vin1 = -2.5; // i n V
12 Vin2 = -3.5; // i n V
13 Rin = 2*10^6; // i n p u t i m p e d a n c e i n
14 A = 2*10^5; // open l o o p v o l t a g e g a i n
15 Ad = (1+ Rf / R1 ) ; // v o l t a g e g a i n
16 disp ( Ad , ” The v o l t a g e g a i n i s : ” ) ;
17 Vout = Ad *( Vin1 - Vin2 ) ; // o u t p u t v o l t a g e in V
18 disp ( Vout , ” The o u t p u t v o l t a g e i n v o l t s i s : ”);
19 Rin_f1 = Rin *(1+ A * R1 /( R1 + Rf ) ) ; // i n
20 Rin_f2 = Rin *(1+ A * R2 /( R1 + Rf ) ) ; // i n
21 format ( ’ e ’ ,10) ;
22 disp ( Rin_f1 , ” The v a l u e o f R i n f 1 i n i s : ”)
23 disp ( Rin_f2 , ” The v a l u e o f R i n f 2 i n i s : ”)
43
Scilab code Exa 3.19 Gain of the circuit
1 // Example 3 . 1 9
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,4) ;
7 Vin = 100*10^ -3; // i n V
8 Vout = 4.25; // i n V
9 R1 = 100; // i n
10 // Formula Used : Vout= (1+2∗ Rf / Rf ) ∗ Vin
11 Rf = ( Vout / Vin -1) * R1 /2; // i n
12 Rf = Rf *10^ -3; // i n k
13 disp ( R1 , ” The v a l u e o f R1 i n i s : ”)
14 disp ( Rf , ” The v a l u e o f Rf i n k i s : ”)
15 disp ( ” ( S t a n d a r d v a l u e o f Rf i s 2 . 2 k ) ” )
Scilab code Exa 3.20 Voltage gain input resistance output resistance and
bandwidth
1 // Example 3 . 2 0
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,9) ;
7 R1 = 3.3; // i n k
8 R2 = 3.3; // i n k
9 R3 = 1.2; // i n k
10 R4 = 1.2; // i n k
11 Rf = 3.9; // i n k
44
12 R5 = 3.9; // i n k
13 Rp = 2.5; // i n k
14 A = 2*10^5; // u n i t l e s s
15 f0 = 5; // i n Hz
16 Rin = 2*10^6; // i n
17 Rout = 75; // i n
18 Ad = -(1+2* R1 / Rp ) * Rf / R3 ; // v o l t a g e g a i n
19 disp ( Ad , ” The v o l t a g e g a i n i s : ” ) ;
20 Rinf = Rin *(1+ A *( R1 + Rp ) /(2* R1 + Rp ) ) ; // i n p u t resistance
in
21 Rinf = Rinf *10^ -9; // i n G
22 disp ( Rinf , ” The i n p u t r e s i s t a n c e i n G is : ”);
23 Routf = Rout /(1+ A / Ad ) ; // o u t p u t r e s i s t a n c e in
24 disp ( Routf , ” The o u t p u t r e s i s t a n c e i n is : ”);
25 f_f = A * f0 / abs ( Ad ) ; // bandwidth i n Hz
26 f_f = f_f *10^ -3; // i n kHz
27 disp ( f_f , ” The bandwidth i n kHz i s : ” ) ;
45
Chapter 4
Linear Applications of Op
Amps
1 // Example 4 . 1
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 Vout = ’ −(V1+10∗V2+100∗V3 ) ’ ; // g i v e n e x p r e s s i o n
8 Rf = 100; // i n k
9 // Vout= −Rf ∗ ( V1/R1+V2/R2+V3/R3 )= −(Rf /R1∗V1+Rf /R2∗
V2+Rf /R3∗V3 ) (i)
10 // Compare e q u a t i o n ( i ) w i t h g i v e n expression
11 R1 = Rf /1; // i n k
12 R2 = Rf /10; // i n k
13 R3 = Rf /100; // i n k
14 disp ( Rf , ” The v a l u e o f Rf i n k is : ”);
15 disp ( R1 , ” The v a l u e o f R1 i n k is : ”);
16 disp ( R2 , ” The v a l u e o f R2 i n k is : ”);
17 disp ( R3 , ” The v a l u e o f R3 i n k is : ”);
46
Scilab code Exa 4.2 Output voltage
1 // Example 4 . 2
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 Rf = 12; // i n k
8 R1 = 12; // i n k
9 R2 = 2; // i n k
10 R3 = 3; // i n k
11 V1 = 9; // i n V
12 V2 = -3; // i n V
13 V3 = -1; // i n V
14 Vout = - Rf *( V1 / R1 + V2 / R2 + V3 / R3 ) ; // o u t p u t v o l t a g e i n V
15 disp ( Vout , ” The o u t p u t v o l t a g e i n v o l t s i s : ” ) ;
1 // Example 4 . 3
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 Vout = ’ (−V1+2∗V2−3∗V3 ) ’ ; // g i v e n e x p r e s s i o n
8 Rf = 6; // i n k
9 // Vout= −(Rf /R1∗V1+Rf /R2∗V2+Rf /R3∗V3 ) (i)
10 // Compare e q u a t i o n ( i ) w i t h g i v e n e x p r e s s i o n
11 R1 = Rf /1; // i n k
12 R2 = Rf /2; // i n k
47
13 R3 = Rf /3; // i n k
14 disp ( Rf , ” The v a l u e of Rf in k is : ”);
15 disp ( R1 , ” The v a l u e of R1 in k is : ”);
16 disp ( R2 , ” The v a l u e of R2 in k is : ”);
17 disp ( R3 , ” The v a l u e of R3 in k is : ”);
1 // Example 4 . 4
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 Vout = ’ ( −2∗V1+3∗V2+4∗V3 ) ’ ; // g i v e n e x p r e s s i o n
8 R3 = 10; // i n k
9 // Vout= −(Rf /R1∗V1+Rf /R2∗V2+Rf /R3∗V3 ) (i)
10 // Compare e q u a t i o n ( i ) w i t h g i v e n e x p r e s s i o n
11 Rf = 4* R3 ; // i n k
12 R2 = Rf /3; // i n k
13 R1 = Rf /2; // i n k
14 disp ( Rf , ” The v a l u e o f Rf i n k i s : ”);
15 disp ( R2 , ” The v a l u e o f R2 i n k i s : ”);
16 disp ( R1 , ” The v a l u e o f R1 i n k i s : ”);
1 // Example 4 . 5
2 clc ;
3 clear ;
4 close ;
5 format ( ’ v ’ ,6) ;
6 // Given d a t a
48
7 V1 = 2; // i n V
8 V2 = -1; // i n V
9 R =100; // i n ( assumed )
10 Vs1 = V1 *( R /2) /( R + R /2) ; // i n V
11 Rf = 2* R ; // i n
12 Vo_1 = Vs1 *(1+ Rf / R ) ; // i n V
13 Vs2 = V2 *( R /2) /( R + R /2) ; // i n V
14 Vo_2 = Vs2 *(1+ Rf / R ) ; // i n V
15 Vout = Vo_1 + Vo_2 ; // o u t p u t v o l t a g e i n V
16 disp ( Vout , ” The o u t p u t v o l t a g e i n v o l t s i s : ” ) ;
1 // Example 4 . 7
2 clc ;
3 clear ;
4 close ;
5 format ( ’ v ’ ,6) ;
6 // Given d a t a
7 Vin = 10; // i n V
8 R = 2.2; // i n k
9 R = R *10^3; // i n k
10 Ad = 10^5; // d i f f e r e n t i a l v o l t a g e g a i n
11 C =1; // i n F
12 C = C *10^ -6; // i n F
13 T = 1; // i n ms
14 T = T *10^ -3; // i n s
15 I = Vin / R ; // i n mA
16 V = I * T / C ; // o u t p u t v o l t a g e a t t h e end o f p u l s e i n mV
17 V = V *10^ -3; // i n V
18 disp (V , ” The o u t p u t v o l t a g e a t t h e end o f t h e p u l s e
in v o l t s i s : ”)
19 RC_desh = R * C * Ad ; // c l o s e d −l o o p t i m e c o n s t a n t i n s e c .
20 disp ( RC_desh , ” The c l o s e d −l o o p t i m e c o n s t a n t i n
seconds : ”)
49
Scilab code Exa 4.8 Value of R1 and Rf
1 // Example 4 . 8
2 clc ;
3 clear ;
4 close ;
5 format ( ’ v ’ ,6) ;
6 // Given d a t a
7 A_dB = 20; // peak g a i n i n dB
8 A = 10^( A_dB /20) ; // peak g a i n
9 omega = 10000; // i n r a d / s e c o n d
10 C = 0.01; // i n F
11 C = C *10^ -6; // i n F
12 Rf = 10; // i n k
13 // Vout /V1= Rf /R1= A
14 R1 = Rf / A ; // i n k
15 disp ( Rf , ” The v a l u e o f Rf i n k i s : ”);
16 disp ( R1 , ” The v a l u e o f R1 i n k i s : ”);
1 // Example 4 . 9
2 clc ;
3 clear ;
4 close ;
5 format ( ’ v ’ ,6) ;
6 // Given d a t a
7 R = 40; // i n k
8 R = R *10^3; // i n
9 C = 0.2; // i n F
10 C = C *10^ -6; // i n F
50
11 Vin = 5; // i n V
12 V1 = 3; // i n V
13 t = 50; // i n ms
14 Vout = 3; // i n V
15 t =[0:0.1:50];
16 vout = -1/( R * C ) * integrate ( ’ ( Vin−V1 ) ’ , ’ t ’ ,0 , t ) *10^ -3+
Vout ; // i n V
17 plot (t , vout ) ;
18 title ( ” S k e t c h o f o u t p u t v o l t a g e ” ) ;
19 xlabel ( ” Time i n m i l l i s e c o n d s ” ) ;
20 ylabel ( ” Output v o l t a g e i n v o l t s ” )
21 disp ( ” P l o t f o r o u t p u t v o l t a g e shown i n f i g u r e ” ) ;
1 // Example 4 . 1 0
2 clc ;
3 clear ;
4 close ;
5 format ( ’ v ’ ,6) ;
6 // Given d a t a
7 R = 500; // i n k
8 R = R *10^3; // i n
9 C = 10; // i n F
10 C = C *10^ -6; // i n F
11 vout = 12; // i n V
12 v = -0.5; // i n V
13 vout_by_t = -1/( R * C ) * integrate ( ’−t ’ , ’ t ’ ,0 ,1) ; // i n V/
sec
14 // Time r e q u i r e d f o r s a t u r a t i o n o f o u t p u t v o l t a g e
15 t = vout / vout_by_t ; // i n s e c
16 disp (t , ” The t i m e d u r a t i o n r e q u i r e d f o r s a t u r a t i o n o f
output v o l t a g e in seconds i s : ”)
51
Scilab code Exa 4.12 Output voltage
1 // Example 4 . 1 2
2 clc ;
3 clear ;
4 close ;
5 format ( ’ v ’ ,7) ;
6 // Given d a t a
7 fa = 1; // i n kHz
8 fa = fa *10^3; // i n Hz
9 Vp = 1.5; // i n V
10 f = 200; // i n Hz
11 C = 0.1*10^ -6; // i n F
12 t = poly (0 , ’ t ’ ) ;
13 R = 1/(2* %pi * fa * C ) ; // i n
14 R = 1.5; // i n k ( standard value )
15 fb = 20* fa ; // i n Hz
16 R_desh = 1/(2* %pi * fb * C ) ; // i n
17 R_desh = 82; // i n ( standard value ) , so
18 R_OM = R ; // i n k
19 // Vin= Vp∗ s i n ( omega ∗ t )= Vp∗ s i n ( 2 ∗ %pi ∗ f ) ∗ t
20 disp ( ” The i n p u t v o t a g e : Vin = ” + string ( Vp ) + ” s i n
( 4 0 0 ∗ %pi ∗ t ) ” )
21 RC = R *10^3* C ; // i n F
22 V = - RC * Vp *400* %pi ;
23 // Vout= −RC∗ dVin / d t= −RC∗Vp∗ 4 0 0 ∗ %pi ∗ c o s ( 4 0 0 ∗ %pi ∗ t )
24 disp ( ” The o u t p u t v o l t a g e : Vout = ” + string ( V ) + ” c o s
( 4 0 0 ∗ %pi ∗ t ) ” )
25 x =[0:0.1:5* %pi /2];
26 plot ( V * cos ( x ) )
27 title ( ” o u t p u t Waveform ” ) ;
28 xlabel ( ”−−−− Time −−−−>” ) ;
29 ylabel ( ”−−−− o u t p u t v o l t a g e −−−−>” ) ;
30 disp ( ” o u t p u t Waveform i s shown i n f i g u r e . ” )
52
Scilab code Exa 4.13 Differentiator to differentiate an input signal
1 // Example 4 . 1 3
2 clc ;
3 clear ;
4 close ;
5 format ( ’ v ’ ,6) ;
6 // Given d a t a
7 Vp = 1; // i n V
8 f = 1000; // i n Hz
9 R = 1.5*10^3; // i n
10 C = 0.1*10^ -6; // i n F
11 // Vin= Vp∗ s i n ( omega ∗ t )= Vp∗ s i n ( 2 ∗ %pi ∗ f ) ∗ t
12 disp ( ” The i n p u t v o t a g e : Vin = s i n ( 2 0 0 0 ∗ %pi ∗ t ) ” )
13 RC = R * C ; // i n F
14 V = - RC *2000* %pi ;
15 // Vout= −RC∗ dVin / d t= −RC∗Vp∗ 2 0 0 0 ∗ %pi ∗ c o s ( 2 0 0 0 ∗ %pi ∗ t )
16 disp ( ” The o u t p u t v o l t a g e : Vout = ” + string ( V ) + ” c o s
( 2 0 0 0 ∗ %pi ∗ t ) ” )
17 x =[0:0.1:4* %pi ];
18 plot ( -1.88* cos ( x ) )
19 title ( ” Output Waveform ” ) ;
20 xlabel ( ”−−−− Time −−−−>” ) ;
21 ylabel ( ”−−−− o u t p u t v o l t a g e −−−−>” ) ;
22 disp ( ” Waveform i s shown i n f i g u r e . ” )
1 // Example 4 . 1 5
2 clc ;
3 clear ;
4 close ;
53
5 format ( ’ v ’ ,6) ;
6 // Given d a t a
7 R1 = 50; // i n k
8 R3 =15; // i n k
9 R4 = R3 ; // i n k
10 // For minimum d i f f e r e n t i a l v o l t a g e g a i n ,
11 Ad_min = 5; // and
12 Ad = Ad_min ;
13 // From Ad= 1+2∗R2/R1
14 R2 = ( Ad -1) * R1 /2; // i n k
15 // For maximum d i f f e r e n t i a l v o l t a g e g a i n ,
16 Ad_max = 200; // and
17 Ad = Ad_max ;
18 // From Ad= 1+2∗R2/R1
19 R1_min = round (2* R2 /( Ad -1) ) ; // i n k
20 disp ( ” The v a l u e o f R1 : ” + string ( R1_min ) + ” k − ”+
string ( R1 ) + ” k ” )
21 disp ( R2 , ” The v a l u e o f R2 i n k i s : ”)
22 disp ( R3 , ” The v a l u e o f R3 and R4 i n k i s : ”)
54
Chapter 5
Waveform Generators
1 // Example 5 . 1
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 C = 0.01; // i n F
8 C = C *10^ -6; // i n F
9 R_A = 2; // i n k
10 R_A = R_A *10^3; // i n
11 R_B = 100; // i n k
12 R_B = R_B *10^3; // i n
13 T_HIGH = 0.693*( R_A + R_B ) * C ; // c h a r g i n g p e r i o d i n
second
14 T_LOW = 0.693* R_B * C ; // d i s c h a r g i n g p e r i o d i n s e c o n d
15 T = T_HIGH + T_LOW ; // o v e r a l l p e r i o d o f o s c i l l a t i o n s i n
second
16 f = 1/ T ; // f r e q u e n c y o f o s c i l l a t i o n s i n Hz
17 D = T_HIGH / T *100; // duty c y c l e i n %
18 disp (f , ” The f r e q u e n c y o f o s c i l l a t i o n s i n Hz i s : ” )
19 disp (D , ” Duty c y c l e i n % i s : ” )
55
Scilab code Exa 5.2 Positive and negative pulse width and free running
frequency
1 // Example 5 . 2
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 C = 1; // i n F
8 C = C *10^ -6; // i n F
9 R_A = 4.7; // i n k
10 R_A = R_A *10^3; // i n
11 R_B = 1; // i n k
12 R_B = R_B *10^3; // i n
13 T_on = 0.693*( R_A + R_B ) * C ; // p o s i t i v e p u l s e w i d t h i n
second
14 T_on = T_on *10^3; // i n ms
15 T_off = 0.693* R_B * C ; // p u l s e w i d t h i n s e c o n d
16 T_off = T_off *10^3; // i n ms
17 f = 1.4/(( R_A +2* R_B ) * C ) ; // f r e e r u n n i n g f r e q u e n c y i n
Hz
18 D = round (( R_A + R_B ) /( R_A +2* R_B ) *100) ; // i n %
19 disp ( T_on , ” The p o s i t i v e p u l s e w i d t h i n ms” )
20 disp ( T_off , ” The n e g a t i v e p u l s e w i d t h i n ms” )
21 disp (f , ” The f r e q u e n c y o f o s c i l l a t i o n s i n Hz i s : ” )
22 disp (D , ” Duty c y c l e i n % i s : ” )
1 // Example 5 . 3
56
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 C = 0.01; // i n F
8 C = C *10^ -6; // i n F
9 f = 1; // i n kHz
10 f = f *10^3; // i n Hz
11 // For 50% duty c y c l e , Ton= T o f f = T/2 and R A= R B
12 // From e q u a t i o n , f= 1 . 4 4 / ( ( R A+R B ) ∗C)= 1 . 4 4 / ( 2 ∗ R A
∗C)
13 R_A = 1.44/(2* f * C ) ; // i n
14 R_A = R_A *10^ -3; // i n k
15 R_B = R_A ; // i n k
16 disp ( R_A , ” The v a l u e o f R A and R B i n k : ”)
17 disp ( ” ( S t a n d a r d v a l u e 68 k ) ” )
1 // Example 5 . 4
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,5) ;
7 f = 700; // i n Hz
8 C = 0.01; // i n F ( assumed )
9 C = C *10^ -6; // i n F
10 // For 50% duty c y c l e , Ton= T o f f = T/2 and R A= R B
11 // From e q u a t i o n , f= 1 . 4 4 / ( ( R A+R B ) ∗C)= 1 . 4 4 / ( 2 ∗ R A
∗C)
12 R_A = 1.44/(2* f * C ) ; // i n
13 R_A = R_A *10^ -3; // i n k
14 R_B = R_A ; // i n k
57
15 C = C *10^6; // i n F
16 disp ( R_A , ” The v a l u e o f R A and R B i n k : ”)
17 disp ( ” ( S t a n d a r d v a l u e 100 k ) ” )
18 disp (C , ” The v a l u e o f C i n F i s : ”)
1 // Example 5 . 5
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,5) ;
7 f = 800; // i n Hz
8 C = 0.01; // i n F ( assumed )
9 C = C *10^ -6; // i n F
10 D = 60; // i n duty c y c l e i n %
11 // D= ( R A+R B ) / ( R A+2∗R B ) ∗100= 60 o r
12 // R B= 2∗R A
13 R_A = 1.44/( f *5* C ) ; // i n ( From f = 1 . 4 4 / ( ( R A+2∗R B
) ∗C) )
14 R_A = R_A *10^ -3; // i n k
15 R_B = 2* R_A ; // i n k
16 C = C *10^6; // i n F
17 disp ( R_A , ” The v a l u e o f R A i n k i s : ”);
18 disp ( R_B , ” The v a l u e o f R B i n k i s : ”);
19 disp (C , ” The v a l u e o f C i n F i s : ”)
1 // Example 5 . 6
2 clc ;
3 clear ;
58
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,5) ;
7 Rs = 5*10^3; // s e r i e s r e s i s t a n c e i n
8 Ls = 0.8; // s e r i e d i n d u c t a n c e i n H
9 Cs = 0.08*10^ -12; // s e r i e s c a p a c i t a n c e i n F
10 Cp = 1.0*10^ -12; // p a r a l l e l c a p a c i t a n c e i n F
11 fs = 1/(2* %pi * sqrt ( Ls * Cs ) ) ; // s e r i e s r e s o n a n t
f r e q u e n c y i n Hz
12 fs = fs *10^ -3; // i n kHz
13 fp = 1/(2* %pi ) * sqrt ((1+ Cs / Cp ) /( Ls * Cs ) ) ; // p a r a l l e l
r e s o n a n t f r e q u e n c y i n Hz
14 fp = fp *10^ -3; // i n kHz
15 disp ( fs , ” The s e r i e s r e s o n a n t f r e q u e n c y i n kHz i s : ”
)
16 disp ( fp , ” The p a r a l l e l r e s o n a n t f r e q u e n c y i n kHz i s :
”)
1 // Example 5 . 7
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 C1 = 1000*10^ -12; // i n F
8 C2 = 100*10^ -12; // i n F
9 f = 1*10^6; // i n Hz
10 R1 = 1*10^6; // i n ( assume )
11 R2 = 10*10^3; // i n ( assume )
12 Rs = 800; // i n
13 VDD = 5; // i n V
14 C_T = C1 * C2 /( C1 + C2 ) ; // t o t a l c a p a c i t a n c e i n F
15 // At r e s o n a n c e , X L= X CT o r 2∗ %pi ∗ f ∗L= 1 / ( 2 ∗ %pi ∗ f ∗
59
C T ) , So
16 L = 1/((2* %pi * f ) ^2* C_T ) ; // i n H
17 L = L *10^3; // i n mH
18 disp (L , ” The v a l u e o f i n d u c t a n c e i n mH i s : ” )
19 i_p = VDD /( R1 + R2 + Rs ) ; // c u r r e n t t h r o u g h c r y s t a l i n A
20 // Power d i s s i p a t e d i n t h e c r y s t a l ,
21 P_D = (0.707* i_p ) ^2* Rs ; // i n W
22 P_D = P_D *10^9; // i n nW
23 disp ( P_D , ” The power d i s s i p a t e d i n t h e c r y s t a l i n nW
i s : ”)
Scilab code Exa 5.8 Signal frequency and amplitude of triangular and square
wave
1 // Example 5 . 8
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 R = 12*10^3; // i n
8 R1 = 120*10^3; // i n
9 Rf = 1*10^6; // i n
10 C = 0.1*10^ -6; // i n F
11 Vsupply = 12; // i n V
12 Vsat = 10; // i n V
13 // P a r t ( i ) : S i g n a l f r e q u e n c y ,
14 f = Rf /(4* R1 * R * C ) ; // i n Hz
15 f = f *10^ -3; // i n kHz
16 disp ( ” P a r t ( i ) : The s i g n a l f r e q u e n c y : ” + string ( f ) +
” kHz ” )
17 // P a r t ( i i ) : A m p l i t u d e o f t r i a n g u l a r wave ,
18 Vpp = 2* R1 / Rf * Vsat ; // Vp−p
19 disp ( ” P a r t ( i i ) : A m p l i t u d e o f t h e t r i a n g u l a r wave
i s : ” + string ( Vpp ) + ” Vp−p ” )
60
20 // A m p l i t u d e o f s q u a r e wave ,
21 Vpp = Vsat -( - Vsat ) ; //Vp−p
22 disp ( ” A m p l i t u d e o f t h e s q u a r e wave i s : ” + string ( Vpp
) + ” Vp−p ” )
1 // Example 5 . 1 0
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 I_Bmax = 500; // i n nA
8 I_Bmax = I_Bmax *10^ -9; // i n A
9 VCC = 10; // i n V
10 f = 10*10^3; // i n Hz
11 I1 = 500*10^ -6; // c u r r e n t t h r o u g h R1 i n A ( assume )
12 Vout = ( VCC -1) ; // o u t p u t v o l t a g e i n V
13 // Rf+R1= Vout / I 1 and Rf= 2∗R1 , s o
14 R1 = Vout /(3* I1 ) ; // i n
15 R1 = R1 *10^ -3; // i n k
16 disp ( ” The v a l u e o f R1 i s : ” + string ( R1 ) + ” k (
standard v a l u e 5 . 6 k ) ”);
17 R1 = 5.6; // i n k ( standard value )
18 Rf = 2* R1 ; // i n k
19 disp ( ” The v a l u e o f Rf i s : ” + string ( Rf ) + ” k (
s t a n d a r d v a l u e 12 k ) ” ) ;
20 R = R1 ; // i n k
21 R = R *10^3; // i n
22 C = 1/(2* %pi * f * R ) ; // i n F
23 C = C *10^12; // i n pF
24 disp ( ” The v a l u e o f C i s : ” + string ( C ) + ” pF” ) ;
61
Scilab code Exa 5.11 Frequency of oscillation
1 // Example 5 . 1 1
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 R = 1*10^3; // i n
8 C = 4.7*10^ -6; // i n F
9 omega = 1/( R * C ) ; // r a d i a n s / s e c o n d
10 f = omega /(2* %pi ) ; // i n Hz
11 disp (f , ” The f r e q u e n c y o f o s c i l l a t i o n i n Hz i s : ” )
62
Chapter 6
1 // Example 6 . 1
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 R1 = 15*10^3; // i n
8 C1 = 0.01*10^ -6; // i n F
9 C2 = 10*10^ -6; // i n F
10 R2 = 3.6*10^3; // i n
11 Vpos = 12; // i n V
12 Vneg = -12; // i n V
13 f_out = 1.2/(4* R1 * C1 ) ; // f r e e r u n n i n g f r e q u e n c y i n Hz
14 f_out = f_out *10^ -3; // i n kHz
15 disp ( ” The f r e e r u n n i n g f r e q u e n c y i s : ” + string ( f_out
) + ” kHz ” ) ;
16 f_L = 8* f_out /( Vpos -( Vneg ) ) ; // Lock−r a n g e i n kHz
17 disp ( ” Lock−r a n g e o f t h e c i r c u i t i s : ” + string ( f_L
) + ” kHz ” ) ;
63
18 f_L = f_L *10^3; // i n Hz
19 f_C = sqrt ( f_L /(2* %pi * R2 * C2 ) ) ; // Hz
20 disp ( ” Capture −r a n g e o f t h e c i r c u i t i s : ” + string (
f_C ) + ” Hz” ) ;
1 // Example 6 . 2
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,12) ;
7 f_out_max = 200; // i n kHz
8 f_lowest = 1; // i n Hz
9 // F r e q u e n c y o f r e f e r e n c e o s c i l l a t o r ,
10 f_ref_os = 2.2* f_out_max ; // i n kHz
11 disp ( ” The f r e q u e n c y o f r e f e r e n c e o s c i l l a t o r i s : ”+
string ( f_ref_os ) + ” kHz ” )
12 // Formula u s e d : f l o w e s t = f r e f o s /2ˆ n
13 n = round ( log ( f_ref_os *10^3/ f_lowest ) / log (2) ) ; //
number o f b i t s r e q u i r e d
14 disp ( ” The number o f b i t s r e q u i r e d i s : ” + string ( n ) )
64
Chapter 7
Active Filters
1 // Example 7 . 1
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 f_H = 2*10^3; // cut − o f f f r e q u e n c y i n Hz
8 C = 0.01*10^ -6; // i n F
9 passband_gain = 2.5;
10 R = 1/(2* %pi * f_H * C ) ; // i n
11 R = 8.2; // i n k ( standard value )
12 // 1+Rf /R1= p a s s b a n d g a i n o r Rf s h o u l d be e q u a l t o
1 . 5 ∗ R1 s i n c e Rf | | R1= R
13 R1 = passband_gain /1.5* R ; // i n k
14 disp ( ” The v a l u e o f R1 i s : ” + string ( R1 ) + ” k ” ) ;
15 disp ( ” ( S t a n d a r d v a l u e 15 k ) ” ) ;
16 Rf = floor (1.5* R1 ) ; // i n k
17 disp ( ” The v a l u e o f Rf i s : ” + string ( Rf ) + ” k ” ) ;
65
Scilab code Exa 7.2 Second order low pass filter
1 // Example 7 . 2
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 f_H = 2*10^3; // cut − o f f f r e q u e n c y i n Hz
8 C = 0.033*10^ -6; // i n F
9 R = 1/(2* %pi * f_H * C ) ; // i n
10 // 2∗R= Rf ∗R1 / ( Rf+R1 )= 0 . 5 8 6 ∗ R1 ˆ 2 / ( 1 . 5 8 6 ∗ R1 ) since
Rf= 0 . 5 8 6 ∗ R1
11 R1 = 2* R *1.586/0.586; // i n
12 R1 = round ( R1 *10^ -3) ; // i n k
13 disp ( ” The v a l u e o f R1 i s : ” + string ( R1 ) + ” k ”);
14 disp ( ” ( The v a l u e o f R1 may be t a k e n o f 15 k ) ”);
15 R1 = 15; // i n k
16 Rf = R1 *0.586; // i n k
17 // Rf= f l o o r ( 1 . 5 ∗ R1 ) ; / / i n k
18 disp ( ” The v a l u e o f Rf i s : ” + string ( Rf ) + ” k ”);
19 disp ( ” ( The v a l u e o f Rf may be t a k e n a s a p o t o f 10
k ) ”);
1 // Example 7 . 3
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,7) ;
7 f_H = 1*10^3; // cut − o f f f r e q u e n c y i n Hz
8 C = 0.0047*10^ -6; // i n F
9 R = 1/(2* %pi * f_H * C ) ; // i n
66
10 R = ( R *10^ -3) ; // i n k
11 R1 = 30; // i n k ( assume )
12 Rf = 0.586* R1 ; // i n k
13 C = C *10^6; // i n F
14 disp ( ” The v a l u e o f R’ ’ = R= ” + string ( R ) + ” k (
s t a n d a r d v a l u e 33 k ) ” ) ;
15 disp ( ” The v a l u e o f C’ ’ = C= ” + string ( C ) + ” F ”);
16 disp ( ” The v a l u e o f R1= ” + string ( R1 ) + ” k ”);
17 disp ( ” The v a l u e o f Rf= ” + string ( Rf ) + ” k ( standard
v a l u e 20 k pot ) ”);
Scilab code Exa 7.4 Flattest band second order active filter
1 // Example 7 . 4
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,5) ;
7 fc = 1*10^3; // i n Hz
8 alpha = 1.414;
9 C = 0.1*10^ -6; // i n F ( assume )
10 C_desh = C * alpha ^2/4; // i n F
11 C_desh = C_desh *10^6; // i n F
12 disp ( ” The v a l u e o f C ’ ’ i s : ” + string ( C_desh ) + ” F ”)
;
13 C_desh = C_desh *10^ -6; // i n F
14 R_desh = 1/(2* %pi * fc * sqrt ( C * C_desh ) ) ; // i n
15 R_desh = R_desh *10^ -3; // i n k
16 disp ( ” The v a l u e o f R ’ ’ i s : ” + string ( R_desh ) + ” k (
standard value 2 . 2 k ) ”)
Scilab code Exa 7.5 Flattest passband second order active filter
67
1 // Example 7 . 5
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,5) ;
7 alpha = 1.414; // p a s s b a n d
8 C = 0.01*10^ -6; // i n F ( assume )
9 fc = 1*10^3; // i n Hz
10 dc_gain = 6;
11 R = 1/(2* %pi * C * fc ) ; // i n
12 R = R *10^ -3; // i n k
13 disp ( ” The v a l u e o f R i s : ” + string ( R ) + ” k (
s t a n d a r d v a l u e 15 k ) ” ) ;
14 R = 15; // i n k
15 Af = 3 - alpha ; // and Af= 1+Rf /R1 o r
16 // Rf= ( Af −1) ∗R1 (i)
17 // 2∗R= Rf | | R1 , h e n c e from ( i )
18 R1 = 2* R * Af /( Af -1) ; // i n k
19 disp ( ” The v a l u e o f R1 i s : ” + string ( R1 ) + ” k (
s t a n d a r d v a l u e 82 k ) ” ) ;
20 R1 = 82; // i n k
21 Rf = ( Af -1) * R1 ; // i n k
22 disp ( ” The v a l u e o f Rf i s : ” + string ( Rf ) + ” k (
s t a n d a r d v a l u e 47 k ) ” ) ;
23 Aamp = dc_gain / Af ;
24 disp ( ” The v a l u e o f Aamp i s : ” + string ( Aamp ) ) ;
1 // Example 7 . 7
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
68
6 format ( ’ v ’ ,6) ;
7 R = 2.1*10^3; // i n k
8 C = 0.05*10^ -6; // i n F
9 R1 = 20*10^3; // i n
10 Rf = 60*10^3; // i n
11 // Low cut − o f f f r e q u e n c y ,
12 f_L = 1/(2* %pi * R * C ) ; // i n Hz
13 f_L = f_L *10^ -3; // i n kHz
14 disp ( f_L , ” The cut − o f f f r e q u e n c y i n kHz i s : ” )
1 // Example 7 . 8
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 R1 = 2*10^3; // i n
8 R2 = 2/3*10^3; // i n
9 R3 = 200*10^3; // i n
10 C = 0.1*10^ -6; // i n F
11 Af = R3 /(2* R1 ) ; // g a i n
12 disp ( Af , ” The v a l u e o f Af i s : ” )
13 // R1= Q/ ( 2 ∗ %pi ∗ f C ∗C∗ Af ) (i)
14 // R2= Q/ ( 2 ∗ %pi ∗ f C ∗C∗ ( 2 ∗Qˆ2−Af ) ) ( ii )
15 // R3= Q/ ( %pi ∗ f C ∗C) (
iii )
16 Q = sqrt (( R3 /(2* R2 ) + Af ) /2) ; // from ( i i ) and ( i i i )
17 disp (Q , ” The v a l u e o f Q i s : ” ) ;
18 f_C = Q /( R3 * %pi * C ) ; // i n Hz ( from ( i i i ) )
19 disp ( f_C , ” The v a l u e o f f C i n Hz i s : ” ) ;
20 omega_0 = 2* %pi * f_C ; // i n r a d i a n s / s e c o n d
21 disp ( omega_0 , ” The v a l u e o f omega 0 i n r a d i a n s /
seconds i s : ”)
69
Scilab code Exa 7.10 Bandpass active filter
1 // Example 7 . 1 0
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 f_L = 2*10^3; // i n Hz
8 f_H = 2.5*10^3; // i n Hz
9 Af = -5;
10 f_C = sqrt ( f_L * f_H ) ; // c e n t r e f r e q u e n c y i n Hz
11 del_f = f_H - f_L ; // bandwidth i n Hz
12 Q = f_C / del_f ; // s e l e c t i v i t y
13 // Assume C1= C2= C= 0 . 0 1 F
14 C = 0.01*10^ -6; // i n F
15 R3 = 1/( %pi * del_f * C ) ; // i n
16 R3 = R3 *10^ -3; // i n k
17 disp ( ” The v a l u e o f R3 i s : ” + string ( R3 ) + ” k (
s t a n d a r d v a l u e 64 k ) ” ) ;
18 R3 = 64; // i n k
19 R3 = R3 *10^3; // i n
20 R1 = - R3 /(2* Af ) ; // i n
21 R2 = R1 /(4* %pi ^2* f_C ^2* R1 * R3 * C ^2 -.1)
22 R1 = R1 *10^ -3; // i n k
23 C = C *10^6; // i n F
24 disp ( ” The v a l u e o f R1 i s : ” + string ( R1 ) + ” k ”);
25 disp ( ” The v a l u e o f R2 i s : ” + string ( R2 ) + ” k (
s t a n d a r d v a l u e 800 ) ” ) ;
26 disp ( ” The v a l u e o f C i s : ” + string ( C ) + ” F ”);
70
1 // Example 7 . 1 1
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 f_C = 1*10^3; // c e n t r e f r e q u e n c y i n Hz
8 f_C_desh = 2*10^3; // new c e n t r e f r e q u e n c y i n Hz
9 Q = 5; // s e l e c t i v i t y
10 Af = -8;
11 C = 0.01*10^ -6; // i n F ( assume )
12 R3 = Q /( %pi * f_C * C ) ; // i n
13 R3 = R3 *10^ -3; // i n k
14 disp ( ” The v a l u e o f R3 i s : ” + string ( R3 ) + ” k (160
k ( approx ) ) ”);
15 R1 = round ( - R3 /(2* Af ) ) ; // i n k
16 disp ( ” The v a l u e o f R1 i s : ” + string ( R1 ) + ” k ” ) ;
17 R2 = R1 *10^3/(4* %pi ^2* f_C ^2* R1 *10^3* R3 *10^3* C ^2 -1) ; //
in
18 R2 = R2 *10^ -3; // i n k
19 disp ( ” The v a l u e o f R2 i s : ” + string ( R2 ) + ” k (2 k
( approx ) ) ”);
20 R2 = 2; // i n k ( approx )
21 R2_desh = R2 *( f_C / f_C_desh ) ^2; // i n k
22 R2_desh = R2_desh *10^3; // i n
23 disp ( ” The v a l u e o f R2 ’ ’ i s : ” + string ( R2_desh ) + ” ”
)
1 // Example 7 . 1 2
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
71
6 format ( ’ v ’ ,6) ;
7 R = 10*10^3; // i n
8 C1 = 0.1*10^ -6; // i n F
9 C2 = 0.0025*10^ -6; // i n F
10 f_H = 1/(2* %pi * R * C2 ) ; // h i g h e r cut − o f f f r e q u e n c y i n Hz
11 f_H = f_H *10^ -3; // i n kHz
12 f_L = 1/(2* %pi * R * C1 ) ; // l o w e r cut − o f f f r e q u e n c y i n Hz
13 BW = f_H - f_L *10^ -3; // bandwidth i n kHz
14 disp ( f_H , ” The h i g h e r cut − o f f f r e q u e n c y i n kHz i s : ”
)
15 disp ( f_L , ” The l o w e r cut − o f f f r e q u e n c y i n Hz i s : ” )
16 disp ( BW , ” The bandwidth i n kHz i s : ” )
1 // Example 7 . 1 3
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,5) ;
7 f_L = 200; // i n Hz
8 f_H = 1*10^3; // i n Hz
9 alpha =4; // p a s s b a n d g a i n
10 C_desh = 0.01*10^ -6; // i n F ( assume )
11 R_desh = 1/(2* %pi * f_H * C_desh ) ; // i n
12 R_desh = R_desh *10^ -3; // i n k
13 disp ( ” The v a l u e o f R ’ ’ i s : ” + string ( R_desh ) + ” k (
Approx . 20 k ) ” )
14 R_desh = 20; // i n k ( standard value )
15 // F i r s t Order High−P a s s F i l t e r
16 C = 0.05*10^ -6; // i n F ( assume )
17 R = 1/(2* %pi * f_L * C ) ; // i n
18 R = R *10^ -3; // i n k
19 R1 = 10; // i n k
72
20 Rf = R1 ; // i n k
21 C_desh = C_desh *10^6; // i n F
22 C = C *10^6; // i n F
23 disp ( ” The v a l u e o f R i s : ” + string ( R ) + ” k ( Approx .
20 k ) ” )
24 R = 20; // i n k ( standard value )
25 disp ( ” The v a l u e o f R1 and Rf i s : ” + string ( R1 ) + ” k
”)
26 disp ( ” The v a l u e o f C ’ ’ i s : ” + string ( C_desh ) + ” F ”)
27 disp ( ” The v a l u e o f C i s : ” + string ( C ) + ” F ”)
1 // Example 7 . 1 4
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,5) ;
7 f_H = 200; // i n Hz
8 f_L = 2*10^3; // i n Hz
9 C = 0.05*10^ -6; // i n F
10 // For low−p a s s f i l t e r ,
11 R_desh = 1/(2* %pi * f_H * C ) ; // i n
12 R_desh = R_desh *10^ -3; // i n k
13 disp ( ” The v a l u e o f R ’ ’ i s : ” + string ( R_desh ) + ” k (
Approx . 20 k ) ” )
14 // For h i g h −p a s s f i l t e r ,
15 R = 1/(2* %pi * f_L * C ) ; // i n
16 R = R *10^ -3; // i n k
17 disp ( ” The v a l u e o f R i s : ” + string ( R ) + ” k ( Approx
. 2 k ) ”)
73
Scilab code Exa 7.15 A 50 Hz active notch filter
1 // Example 7 . 1 5
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,5) ;
7 C = 0.068*10^ -6; // i n F
8 f_N = 50; // i n Hz
9 R = 1/(2* %pi * f_N * C ) ; // i n
10 R = R *10^ -3; // i n k
11 disp ( ” The v a l u e o f R i s : ” + string ( R ) + ” k ( Approx
. 50 k ) ” )
1 // Example 7 . 1 6
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,5) ;
7 R = 15*10^3; // i n
8 C = 0.01*10^ -6; // i n F
9 f = 2*10^3; // i n Hz
10 PhaseShift = -2* atand (2* %pi * f * R * C ) ; // i n
11 disp ( ” The p h a s e s h i f t i s : ” + string ( PhaseShift ) + ”
i . e . ” + string ( abs ( PhaseShift ) ) + ” ( l a g g i n g ) ”)
1 // Example 7 . 1 8
74
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 R_A = 2.2*10^3; // i n
8 R_B = 1.2*10^3; // i n
9 Rf = 4.7*10^3; // i n
10 C = 0.01*10^ -6; // i n F
11 k_lp = 1.238;
12 k_hp = 1/ k_lp ;
13 // P a r t ( i )
14 alpha = 3* R_B /( R_A + R_B ) ;
15 disp ( alpha , ” P a r t ( i ) : The v a l u e o f a l p h a i s : ” ) ;
16 disp ( ” Given f i l t e r i s 1 db peak Chebyshev ” ) ;
17
18 // P a r t ( i i )
19 f_0 = 1/(2* %pi * Rf * C ) ; // c r i t i c a l f r e q u e n c y i n Hz
20 f_0 = f_0 *10^ -3; // i n kHz
21 f_low_pass = f_0 * k_lp ; // i n kHz
22 disp ( f_low_pass , ” P a r t ( i i ) : The low−p a s s f r e q u e n c y
i n kHz i s : ” )
23 f_high_pass = f_0 * k_hp ; // i n kHz
24 disp ( f_high_pass , ” The h i g h −p a s s f r e q u e n c y i n kHz i s
: ”)
25
26 // P a r t ( i i i )
27 fc = f_0 ; // b a n d p a s s c e n t r e f r e q u e n c y i n kHz
28 disp ( fc , ” P a r t ( i i i ) : The b a n d p a s s c e n t r e f r e q u e n c y
i n kHz i s : ” )
29
30 // P a r t ( i v )
31 // Formula u s e d : d e l t a f = f c /Q= f c / ( 1 / a l p h a )
32 delta_f = fc /(1/ alpha ) ; // i n kHz
33 disp ( delta_f , ” P a r t ( i v ) : The b a n d p a s s w i d t h i n kHz
i s : ”)
34
35 // P a r t ( v )
75
36 A0 = 1/ alpha ; // b a n d p a s s g a i n a t c e n t r e f r e q u e n c y
37 disp ( A0 , ” P a r t ( v ) : The b a n d p a s s g a i n a t c e n t r e
frequency i s : ”)
76
Chapter 8
Scilab code Exa 8.2 Peak value and average value of voltage
1 // Example 8 . 2
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,5) ;
7 R1 = 5; // i n k
8 R2 = 10; // i n k
9 V_peak = R1 * R2 /( R1 + R2 ) ; // i n V
10 Vav = V_peak / %pi ; // i n V
11 disp ( ” Peak v a l u e o f V1 i s : ” + string ( V_peak ) + ” V” )
12 disp ( ” A v e r a g e v a l u e o f Vo i s : ” + string ( Vav ) + ” V” )
1 // Example 8 . 7
2 clc ;
3 clear ;
77
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 t = 0;
8 Vc = 0; // i n v o l t s
9 Vo = 5; // i n v o l t s
10 R = 10; // i n 2 ( assume )
11 RC = 1; // ( assume )
12 R3 = 2* R ; // i n
13 R2 = 3* R ; // i n
14 // From e q u a t i o n : T= 2∗ Rf ∗C∗ l o g [1+2∗ R3/R2 ]
15 T = 2* RC * log (1+2* R3 / R2 ) ;
16 Vc_t = 2; // i n v o l t s
17 t = T /2;
18 // V o l t a g e a c r o s s c a p a c i t o r ,
19 // V c t= Vco ∗[1 −%eˆ(− t /ReqC ) ]= 1 / 5 ∗ (VR+4∗Vo ) ∗[1 −%e
ˆ(− t /4∗RC/ 5 ) ]
20 VR = Vc_t *5/[1 - %e ^( - t /(4* RC /5) ) ] -4* Vo ;
21 disp ( ” The v a l u e o f VR i s : ” + string ( VR ) + ” v o l t s ” )
1 // Example 8 . 9
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,7) ;
7 // P a r t ( c )
8 R1 = 150; // i n
9 R2 = 68*10^3; // i n
10 Vin = 50*10^ -3; // i n V
11 Vsat = 14; // i n V
12 Vpositive = Vsat *( R1 /( R1 + R2 ) ) ; // i n V
13 V_UT = Vpositive ; // i n V
78
14 V_LT = Vpositive ; // i n V
15 disp ( V_UT , ” The v a l u e o f V UT i n v o l t s i s : ” )
16 disp ( V_LT , ” The v a l u e o f V LT i n v o l t s i s : ” )
1 // Example 8 . 1 0
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,9) ;
7 V_UT = 5; // i n V
8 V_LT = -5; // i n V
9 // H y s t e r e s i s v o l t a g e ,
10 Vhy = V_UT - V_LT ; // i n V
11 disp ( Vhy , ” The h y s t e r e s i s v o l t a g e in v o l t s i s : ”)
79
Chapter 10
Voltage Regulators
1 // Example 1 0 . 1
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 Idc = 300; // i n mA
8 C = 200; // i n F
9 Vmax = 24; // i n V
10 Vrms = 2.4* Idc / C ; // i n V
11 Vr_peak = sqrt (3) * Vrms ; // i n V
12 Vdc = Vmax - Vr_peak ; // i n V
13 disp ( Vdc , ” The minimum i n p u t v o l t a g e i n v o l t s i s : ” )
1 // Example 1 0 . 2
2 clc ;
80
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 VR = 12; // i n V
8 IL = 0.5; // i n A
9 RL = 25; // i n
10 // R e s i s t a n c r e q u i r e d ,
11 R = VR / IL ; // i n
12 VL = IL * RL ; // i n V
13 Vout = VR + VL ; // o u t p u t v o l t a g e i n V
14 Vin = Vout +2; // i n p u t v o l t a g e i n V
15 disp ( Vin , ” The i n p u t v o l t a g e i n v o l t s i s : ” )
1 // Example 1 0 . 3
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 R1 = 240; // i n
8 R2 = 1.2*10^3; // i n
9 // R e g u l a t e d o u t p u t v o l t a g e i n t h e c i r c u i t ,
10 Vout = 1.25*(1+ R2 / R1 ) ; // i n V
11 disp ( Vout , ” The r e g u l a t e d o u t p u t v o l t a g e i n v o l t s is
: ”);
1 // Example 1 0 . 4
2 clc ;
81
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 V_REG = 15; // i n V
8 I_Q = 10*10^ -3; // i n A
9 R1 = 40; // i n
10 // When p o t e n t i o m e t e r R2=0 ( minimum )
11 R2 = 0; // i n
12 Vout = (1+ R2 / R1 ) * V_REG + I_Q * R2 ;
13 disp ( Vout , ” The minimum o u t p u t v o l t a g e i n volts is :
”);
14 // When p o t e n t i o m e t e r R2=200 ( maximum )
15 R2 = 200; // i n
16 Vout = (1+ R2 / R1 ) * V_REG + I_Q * R2 ;
17 disp ( Vout , ” The minimum o u t p u t v o l t a g e i n v o l t s is :
”);
1 // Example 1 0 . 5
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 V_REF = 1.25; // i n V
8 R1 = 2.5*10^3; // i n
9 R2 = 1*10^3; // i n
10 I = V_REF / R2 ; // i n A
11 // The o u t p u t v o l t a g e ,
12 Vout = I *( R1 + R2 ) ; // i n V
13 disp ( Vout , ” The r e g u l a t e d o u t p u t v o l t a g e i n v o l t s i s
: ”)
82
Scilab code Exa 10.6 Duty cycle of the pulses
1 // Example 1 0 . 6
2 clc ;
3 clear ;
4 close ;
5 // Given d a t a
6 format ( ’ v ’ ,6) ;
7 V_REF = 1.25; // i n V
8 R1 = 3*10^3; // i n
9 R2 = 1*10^3; // i n
10 Vin = 20; // i n V
11 Vout = V_REF *( R1 + R2 ) / R2 ; // o u t p u t v o l t a g e i n v o l t s
12 // Duty c y c l e ,
13 D = Vout / Vin *100; // i n %
14 disp ( ” The duty c y c l e i s ” + string ( D ) + ” %” )
83