You are on page 1of 92

Scilab Textbook Companion for

Op-Amps And Linear Integrated Circuits


by R. A. Gayakwad1
Created by
Amar Ds
BE
Instrumentation Engineering
Sri Jayachamarajendra College Of Engineering
College Teacher
Rathnnakara S
Cross-Checked by
TechPassion
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: Op-Amps And Linear Integrated Circuits
Author: R. A. Gayakwad
Publisher: PHI Learning Pvt. Ltd., New Delhi
Edition: 4
Year: 2004
ISBN: 978-81-203-2058-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.

Contents
List of Scilab Codes

1 Introduction to Operational Amplifier

2 Interpretation of Data Sheets and Characteristics of an Opamp


3 An Opamp with Negative Feedback

14

4 The Practical Opamp

21

5 Frequency Response of an Opamp

37

6 General Linear Applications

40

7 Active Filters and Oscillators

53

8 Comparators and Converters

74

9 Specialized IC Applications

80

11

List of Scilab Codes


Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa

1.1.a
1.1.b
1.1.c
2.1.a
2.1.b
2.2.a
2.2.b
3.1
3.2
3.3
3.4
3.5.a
3.5.b
3.6.a
3.6.b
4.1
4.2
4.3
4.4.a
4.4.b
4.5.a
4.5.b
4.6
4.7
4.8.a
4.8.b
4.9.a
4.9.b

Collector current and dc voltage . . . . . . . . . . .


Voltage gain of the opamp . . . . . . . . . . . . . . .
Input resistance of the opamp . . . . . . . . . . . . .
Output voltage for Openloop differential amplifier .
Output voltage for openloop differential amplifier . .
Output voltage for inverting amplifier . . . . . . . .
Output voltage for inverting amplifier . . . . . . . .
Parameters Of voltageseries feedback amplifier . . .
Parameters Of voltageseries feedback amplifier . . .
Parameters of Voltageshunt feedback amplifier . . .
Output voltage of voltage shunt feedback amplifier .
Gain input resistance of the amplifier . . . . . . . .
Output voltage of an Opamp . . . . . . . . . . . . .
Voltage gain and input resistance of the Opamp . . .
Output voltage of the Opamp . . . . . . . . . . . . .
Design of Compensating Network . . . . . . . . . . .
Max Output offset voltage . . . . . . . . . . . . . . .
Design of input offset voltage compensating network
Max Output offset voltage . . . . . . . . . . . . . . .
Effect of input bias current . . . . . . . . . . . . . .
Max Output offset voltage . . . . . . . . . . . . . . .
Effect of input bias current . . . . . . . . . . . . . .
Max Output offset voltage . . . . . . . . . . . . . . .
Total Output offset voltage . . . . . . . . . . . . . .
Error voltage and output voltage . . . . . . . . . . .
Error voltage and output voltage . . . . . . . . . . .
Error voltage and output voltage . . . . . . . . . . .
Output waveform . . . . . . . . . . . . . . . . . . .
4

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

7
9
9
11
12
12
13
14
15
16
17
18
18
19
20
21
22
22
23
24
24
25
25
26
27
28
29
30

Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa

4.10.a
4.10.b
4.11.a
4.11.b
4.12
4.13
4.14.a
4.14.b
5.1
5.2
5.3
6.1
6.2.a
6.2.b
6.3
6.4
6.5
6.6
6.7
6.8
6.9
6.10
6.11
6.12.a
6.12.b
6.13
6.14
6.15
6.16.a
6.16.b
7.1
7.2
7.3
7.4.a
7.4.b
7.5.a
7.5.b
7.6.a

Error voltage and output voltage . . . . . . . . . .


Error voltage and output voltage . . . . . . . . . .
Output offset voltage . . . . . . . . . . . . . . . .
Output offset voltage . . . . . . . . . . . . . . . .
Output ripple voltage . . . . . . . . . . . . . . . .
Change in output offset voltage . . . . . . . . . . .
Output voltage . . . . . . . . . . . . . . . . . . . .
Output common mode voltage . . . . . . . . . . .
Maximum gain . . . . . . . . . . . . . . . . . . . .
Gain equation and break frequencies . . . . . . . .
Stability of voltage follower . . . . . . . . . . . . .
Bandwidth of the amplifier . . . . . . . . . . . . .
Bandwidth of the amplifier . . . . . . . . . . . . .
Max output voltage swing . . . . . . . . . . . . . .
Components of peak amplifier . . . . . . . . . . . .
Output voltage . . . . . . . . . . . . . . . . . . . .
Output voltage . . . . . . . . . . . . . . . . . . . .
Output voltage . . . . . . . . . . . . . . . . . . . .
Output voltage . . . . . . . . . . . . . . . . . . . .
Change in resistance in straingage . . . . . . . . .
Gain of the amplifier . . . . . . . . . . . . . . . . .
Range of input voltage . . . . . . . . . . . . . . . .
Current and voltage drop . . . . . . . . . . . . . .
Load current . . . . . . . . . . . . . . . . . . . . .
Output voltage . . . . . . . . . . . . . . . . . . . .
Range of output voltage . . . . . . . . . . . . . . .
Change in output voltage . . . . . . . . . . . . . .
Output voltage of an integrator . . . . . . . . . . .
Design of differentiator . . . . . . . . . . . . . . .
Output waveform of differentiator . . . . . . . . .
Design of low pass filter . . . . . . . . . . . . . . .
Design of low pass filter . . . . . . . . . . . . . . .
Frequency response of low pass filter . . . . . . . .
Design of second order low pass filter . . . . . . . .
Frequency response of second order highpass filter
Design of highpass filter . . . . . . . . . . . . . . .
Frequency response of highpass filter . . . . . . . .
Determination of low cutoff frequency . . . . . . .
5

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

30
31
32
33
34
34
35
35
37
38
38
40
41
42
42
43
44
44
45
46
46
47
47
48
48
49
49
50
51
52
53
54
54
56
57
58
59
61

Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa
Exa

7.6.b
7.7.a
7.7.b
7.7.c
7.8.a
7.8.b
7.9
7.10
7.11
7.12
7.13
7.14
7.15
7.16
7.17.a
7.17.b
8.1
8.2
8.3
8.4
8.5
9.1
9.2
9.3
9.4
9.5
9.6
9.7
9.8
9.9
9.10
9.11
9.12
9.13

Frequency response of second order highpass filter


Design of wide bandpass filter . . . . . . . . . . . .
Frequency response of bandpass filter . . . . . . .
Calculation of quality factor . . . . . . . . . . . . .
Design of narrow bandpass filter . . . . . . . . . .
Design of narrow bandpass filter . . . . . . . . . .
Design of wide bandreject filter . . . . . . . . . . .
Design of notch filter . . . . . . . . . . . . . . . . .
Phase angle . . . . . . . . . . . . . . . . . . . . . .
Design of phase shift oscillator . . . . . . . . . . .
Design of wein bridge oscillator . . . . . . . . . . .
Design of quadrature oscillator . . . . . . . . . . .
Design of squarewave oscillator . . . . . . . . . . .
Design of triangular wave generator . . . . . . . .
Nominal frequency . . . . . . . . . . . . . . . . . .
Modulation in output frequency . . . . . . . . . .
Threshold voltage . . . . . . . . . . . . . . . . . .
Output voltage swing . . . . . . . . . . . . . . . .
Output frequencies . . . . . . . . . . . . . . . . . .
Output voltage . . . . . . . . . . . . . . . . . . . .
Output voltage . . . . . . . . . . . . . . . . . . . .
Second order inverting butterworth lowpass filter .
Second order inverting butterworth bandpass filter
Design of notch filter . . . . . . . . . . . . . . . . .
Second order butterworth lowpass filter . . . . . .
Value of capacitor . . . . . . . . . . . . . . . . . .
Value of resistor . . . . . . . . . . . . . . . . . . .
Value of tc td and f0 . . . . . . . . . . . . . . . . .
Freq of free running ramp generator . . . . . . . .
Value of fout fl fc . . . . . . . . . . . . . . . . . . .
Design of current source . . . . . . . . . . . . . . .
Design of voltage regulator . . . . . . . . . . . . .
Design of stepdown switching regulator . . . . . .
Design of stepdown switching regulator . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

61
63
64
65
66
67
67
68
68
69
70
70
71
71
72
73
74
75
76
78
78
80
81
82
83
83
84
84
85
86
86
87
88
90

Chapter 1
Introduction to Operational
Amplifier

Scilab code Exa 1.1.a Collector current and dc voltage


1 // C h a p t e r 1
2 // Page . No4 ,
3 // E x a m p l e 1 1 a , F i g u r e . No1.2
4 // C o l l e c t o r c u r r e n t and dc v o l t a g e
5 // Given :
6 clear ; clc ;
7 Vcc =6; Vbe5 =0.7; Vee =6; Vbe3 =6.7; Vbe6 =0.7; Vbe7 =0.7; //
8
9
10
11
12
13
14
15
16
17

Voltage in v o l t s
Rc1 =6.7*10^3; // R e s i s t a n c e i n ohms
Ic1 = rand () ;
Vc1 = Vcc - Rc1 * Ic1 ;
Ve4 = Vc1 - Vbe5 ;
I4 =( Ve4 + Vee ) /(9.1*10^3+5.5*10^3) ;
Vb3 =5.5*10^3* I4 - Vee ;
Ve3 = Vb3 - Vbe3 ;
Ie3 =( Ve3 + Vbe3 ) /3.3*10^3;
Ic1 =1.08*10^ -3/2.765; // S i n c e I e 3 =2 I c 1 ,
s u b s t i t u t i n g i n a b o v e e q u a t i o n and s i m p l i f y i n g
printf ( \n C o l l e c t o r c u r r e n t I c 1 i s = %. 5 f A \n , Ic1
7

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

) // R e s u l t
Vc1 = Vcc - Rc1 * Ic1 ;
printf ( \n V o l t a g e Vc1 i s = %. 2 f V \n , Vc1 ) //
Result
Ve4 = Vc1 - Vbe5 ;
printf ( \n V o l t a g e Ve4 i s = %. 2 f V \n , Ve4 ) //
Result
Ie4 =( Ve4 + Vee ) /(29.2*10^3) ;
printf ( \n C u r r e n t I e 4 i s = %. 6 f A \n , Ie4 ) //
Result
Ic5 = Ie4 ;
printf ( \n C u r r e n t I c 5 i s = %. 6 f A \n , Ic5 ) //
Result
Vc5 = Vcc -3.8*10^3* Ic5 ;
printf ( \n V o l t a g e Vc5 i s = %. 2 f V \n , Vc5 ) //
Result
Ve6 = Vc5 - Vbe6 ;
printf ( \n V o l t a g e Ve6 i s = %. 2 f V \n , Ve6 ) //
Result
Ie6 =( Ve6 + Vee ) /(15*10^3) ;
printf ( \n C u r r e n t I e 6 i s = %. 6 f A \n , Ie6 ) //
Result
Ve7 = Ve6 + Vbe7 ;
printf ( \n V o l t a g e Ve7 i s = %. 2 f V \n , Ve7 ) //
Result
I1 =( Vcc - Ve7 ) /400;
printf ( \n C u r r e n t I 1 i s = %. 6 f A \n , I1 ) // R e s u l t
Ie8 = I1 ;
printf ( \n C u r r e n t I e 8 i s = %. 6 f A \n , Ie8 ) //
Result
Ve8 = - Vee +2*10^3* Ie8 ;
printf ( \n V o l t a g e Ve8 a t t h e o u t p u t t e r m i n a l i s = %
. 2 f V \n , Ve8 ) // R e s u l t

Scilab code Exa 1.1.b Voltage gain of the opamp


1 // C h a p t e r 1
2 // Page . No4 ,
3 // E x a m p l e 1 1 b , F i g u r e . No1.2
4 // V o l t a g e g a i n o f t h e opamp
5 // Given :
6 clear ; clc ;
7 Ie1 =0.39*10^ -3; Ie4 =0.298*10^ -3; Ie6 =0.678*10^ -3; //
8
9
10
11
12
13
14
15
16
17

18
19
20

21
22

C u r r e n t i n amps
Rc1 =6.7*10^3; Rc5 =3.8*10^3; // R e s i s t a n c e i n ohms
beta_ac =150;
re1 =(25*10^ -3) / Ie1 ;
re2 = re1 ;
re4 =(25*10^ -3) / Ie4 ;
re5 = re4 ;
re6 =(25*10^ -3) / Ie6 ;
k =( Rc1 *2* beta_ac * re4 ) /( Rc1 +2* beta_ac * re4 ) ;
Ad1 = k / re1 ;
printf ( \n V o l t a g e g a i n o f t h e d u a l i n p u t , b a l a n c e d
o u t p u t d i f f e r e n t i a l a m p l i f i e r i s = %. 2 f \n , Ad1 )
// R e s u l t
k1 =( Rc5 * beta_ac *( re6 +15*10^3) ) /( Rc5 + beta_ac *( re6
+15*10^3) ) ;
Ad2 = k1 /(2* re5 ) ;
printf ( \n V o l t a g e g a i n o f t h e d u a l i n p u t , u n b a l a n c e d
o u t p u t d i f f e r e n t i a l a m p l i f i e r i s = %. 1 f \n , Ad2
) // R e s u l t
Ad =82.55*22.6; // U s i n g Ad=Ad1Ad2
printf ( \n O v e r a l l g a i n o f t h e opamp i s = %. 2 f \n
, Ad ) // R e s u l t

Scilab code Exa 1.1.c Input resistance of the opamp


9

1 // C h a p t e r 1
2 // Page . No4 ,
3 // E x a m p l e 1 1 c , F i g u r e . No1.2
4 // I n p u t r e s i s t a n c e o f t h e opamp
5 // Given :
6 clear ; clc ;
7 beta_ac =150;
8 re1 =64.1; // R e s i s t a n c e i n ohms
9 Ri =2* beta_ac * re1 ;
10 printf ( \n I n p u t r e s i s t a n c e Ri i s = %. 1 f ohm \n , Ri )

// R e s u l t

10

Chapter 2
Interpretation of Data Sheets
and Characteristics of an
Opamp

Scilab code Exa 2.1.a Output voltage for Openloop differential amplifier
1
2
3
4
5
6
7
8
9
10

// C h a p t e r 2
// Page . No45 , F i g u r e . No2.9
// E x a m p l e 2 1 a
// Output v o l t a g e f o r openl o o p d i f f e r e n t i a l
amplifier
// Given :
clear ; clc ;
vin1 =5*10^ -6; vin2 = -7*10^ -6; // Both i n p u t v o l t a g e s
are in volts
A =200000; // V o l t a g e g a i n
vo = A *( vin1 - vin2 ) ; // Output v o l t a g e i n v o l t s
printf ( \n Output v o l t a g e i s vo = %. 1 f V dc \n , vo )
// R e s u l t

11

Scilab code Exa 2.1.b Output voltage for openloop differential amplifier
1
2
3
4
5
6
7
8
9
10

// C h a p t e r 2
// Page . No45 , F i g u r e . No2.9
// EXAMPLE 2 1 b
// Output v o l t a g e f o r openl o o p d i f f e r e n t i a l
amplifier
// Given :
clear ; clc ;
vin1 =10*10^ -3; vin2 =20*10^ -3; // Both i n p u t v o l t a g e s
are in volts
A =200000; // V o l t a g e g a i n
vo = A *( vin1 - vin2 ) ; // Output v o l t a g e i n v o l t s
printf ( \n Output v o l t a g e i s vo = %. f V rms \n , vo )
// R e s u l t

Scilab code Exa 2.2.a Output voltage for inverting amplifier


1 // C h a p t e r 2
2 // Page . No46 , F i g u r e . No 2.10
3 // E x a m p l e 2 2 a
4 // Output v o l t a g e f o r i n v e r t i n g a m p l i f i e r
5 // Given :
6 clear ; clc ;
7 vin =20*10^ -3;
// I n p u t v o l t a g e i n v o l t s
8 A =200000; // V o l t a g e g a i n
9 vo = -( A * vin ) ; // Output v o l t a g e i n v o l t s

12

10

printf ( \n Output v o l t a g e i s vo = %. f V \n , vo ) //
Result

Scilab code Exa 2.2.b Output voltage for inverting amplifier


1 // C h a p t e r 2
2 // Page . No46 , F i g u r e . No 2.10
3 // E x a m p l e 2 2 b
4 // Output v o l t a g e f o r i n v e r t i n g a m p l i f i e r
5 // Given :
6 clear ; clc ;
7 vin = -50*10^ -6;
// I n p u t v o l t a g e i n v o l t s
8 A =200000; // V o l t a g e g a i n
9 vo = -( A * vin ) ; // Output v o l t a g e i n v o l t s
10 printf ( \n Output v o l t a g e i s vo = %. f V \n , vo ) //

Result

13

Chapter 3
An Opamp with Negative
Feedback

Scilab code Exa 3.1 Parameters Of voltageseries feedback amplifier


// C h a p t e r 3
// Page . No75 , F i g u r e . No3.2
// E x a m p l e 3 1
// P a r a m e t e r s o f v o l t a g e s e r i e s f e e d b a c k a m p l i f i e r
// Given
clear ; clc ;
R1 =1000; Rf =10000;
A =200000; // Openl o o p v o l t a g e g a i n
Ri =2*10^6; // I n p u t r e s i s t a n c e w i t h o u t f e e d b a c k
Ro =75; // Output r e s i s t a n c e w i t h o u t f e e d b a c k
fo =5; // Break f r e q u e n c y o f an Opamp
Vsat =13; // S a t u r a t i o n v o l t a g e
B = R1 /( R1 + Rf ) ; // Gain o f t h e f e e d b a c k c i r c u i t
Af = A /(1+ A * B ) ; // C l o s e d l o o p v o l t a g e g a i n
printf ( \n C l o s e d l o o p v o l t a g e g a i n i s Af = %. 2 f \n
, Af ) // R e s u l t
16 RiF = Ri *(1+ A * B ) ; // 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
17 printf ( \n 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 s RiF = %
. 2 f ohms \n , RiF ) // R e s u l t

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

14

18 RoF = Ro /(1+ A * B ) ; // Output r e s i s t a n c e w i t h f e e d b a c k


19 printf ( \n Output r e s i s t a n c e w i t h f e e d b a c k i s RoF =
20
21
22
23

%f ohms \n , RoF ) // R e s u l t
fF = fo *(1+ A * B ) ; // Bandwidth w i t h f e e d b a c k
printf ( \n Bandwidth w i t h f e e d b a c k i s vo = %. 1 f Hz \
n , fF ) // R e s u l t
VooT = Vsat /(1+ A * B ) ; // T o t a l o u t p u t o f f s e t v o l t a g e
with feedback
printf ( \n T o t a l 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 VooT = %f V \n , VooT ) // R e s u l t

Scilab code Exa 3.2 Parameters Of voltageseries feedback amplifier


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

// C h a p t e r 3
// Page . No83 , F i g u r e . No3.7
// E x a m p l e 3 2
// P a r a m e t e r s o f v o l t a g e s e r i e s f e e d b a c k a m p l i f i e r
// Given
clear ; clc ;
R1 =1000; Rf =10000;
A =200000; // Openl o o p v o l t a g e g a i n
Ri =2*10^6; // I n p u t r e s i s t a n c e w i t h o u t f e e d b a c k
Ro =75; // Output r e s i s t a n c e w i t h o u t f e e d b a c k
fo =5; // Break f r e q u e n c y o f an Opamp
Vsat =13; // S a t u r a t i o n v o l t a g e
B =1; // Gain o f t h e f e e d b a c k c i r c u i t and i t i s e q u a l
to 1 f o r voltage f o l l o w e r
Af = A /(1+ A * B ) ; // C l o s e d l o o p v o l t a g e g a i n
printf ( \n C l o s e d l o o p v o l t a g e g a i n i s Af = %. f \n ,
Af ) // R e s u l t
RiF = Ri *(1+ A * B ) ; // 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
printf ( \n 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 s RiF = %
. 1 f ohms \n , RiF ) // R e s u l t
15

18 RoF = Ro /(1+ A * B ) ; // Output r e s i s t a n c e w i t h f e e d b a c k


19 printf ( \n Output r e s i s t a n c e w i t h f e e d b a c k i s RoF =
20
21
22
23

%f ohms \n , RoF ) // R e s u l t
fF = fo *(1+ A * B ) ; // Bandwidth w i t h f e e d b a c k
printf ( \n Bandwidth w i t h f e e d b a c k i s vo = %. 1 f Hz \
n , fF ) // R e s u l t
VooT = Vsat /(1+ A * B ) ; // T o t a l o u t p u t o f f s e t v o l t a g e
with feedback
printf ( \n T o t a l 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 VooT = %f V \n , VooT ) // R e s u l t

Scilab code Exa 3.3 Parameters of Voltageshunt feedback amplifier


// C h a p t e r 3
// Page . No86 , F i g u r e . No3.8
// E x a m p l e 3 3
// P a r a m e t e r s o f v o l t a g e s h u n t f e e d b a c k a m p l i f i e r
// Given
clear ; clc ;
R1 =470; Rf =4.7*10^3;
A =200000; // Openl o o p v o l t a g e g a i n
Ri =2*10^6; // I n p u t r e s i s t a n c e w i t h o u t f e e d b a c k
Ro =75; // Output r e s i s t a n c e w i t h o u t f e e d b a c k
fo =5; // Break f r e q u e n c y o f an Opamp
Vsat =13; // S a t u r a t i o n v o l t a g e
K = Rf /( R1 + Rf ) ; // V o l t a g e a t t e n u a t i o n f a c t o r
B = R1 /( R1 + Rf ) ; // Gain o f t h e f e e d b a c k c i r c u i t
Af = -( A * K ) /(1+ A * B ) ; // C l o s e d l o o p v o l t a g e g a i n
printf ( \n C l o s e d l o o p v o l t a g e g a i n i s Af = %. f \n ,
Af ) // R e s u l t
17 X = Rf /(1+ A ) ;
18 RiF = R1 +( X * Ri ) /( X + Ri ) ; // I n p u t r e s i s t a n c e w i t h
feedback

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

16

19
20
21
22
23
24
25

printf ( \n 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 s RiF = %
. 1 f ohms \n , RiF ) // R e s u l t
RoF = Ro /(1+ A * B ) ; // Output r e s i s t a n c e w i t h f e e d b a c k
printf ( \n Output r e s i s t a n c e w i t h f e e d b a c k i s RoF =
%f ohms \n , RoF ) // R e s u l t
fF = fo *(1+ A * B ) / K ; // Bandwidth w i t h f e e d b a c k
printf ( \n Bandwidth w i t h f e e d b a c k i s vo = %. 2 f Hz \
n , fF ) // R e s u l t
VooT = Vsat /(1+ A * B ) ; // T o t a l o u t p u t o f f s e t v o l t a g e
with feedback
printf ( \n T o t a l 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 VooT = %f V \n , VooT ) // R e s u l t

Scilab code Exa 3.4 Output voltage of voltage shunt feedback amplifier
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

//
//
//
//

Chapter3
Page . No86 , F i g u r e . No3.8
Example 3 4
Output v o l t a g e o f v o l t a g e s h u n t f e e d b a c k
amplifier
// Given
clear ; clc ;
R1 =470; Rf =4.7*10^3;
A =200000; // Openl o o p v o l t a g e g a i n
vin =1; // I n p u t v o l t a g e i n v o l t s
K = Rf /( R1 + Rf ) ; // V o l t a g e a t t e n u a t i o n f a c t o r
B = R1 /( R1 + Rf ) ; // Gain o f t h e f e e d b a c k c i r c u i t
Af = -( A * K ) /(1+ A * B ) ; // C l o s e d l o o p v o l t a g e g a i n
vo = Af * vin ; // Output v o l t a g e
printf ( \n Output v o l t a g e i s vo = %. f V \n , vo ) //
Result
t =0:0.1:2* %pi ;
vo = -10* sin ( t ) ;
17

17
18
19
20

plot (t , vo ) ;
title ( Output V o l t a g e ) ;
xlabel ( t ) ;
ylabel ( Vo ) ;

Scilab code Exa 3.5.a Gain input resistance of the amplifier


1 // C h a p t e r 3
2 // Page . No96 , F i g u r e . No 3.14
3 // E x a m p l e 3 5 a
4 // Gain I n p u t r e s i s t a n c e o f t h e a m p l i f i e r
5 // Given
6 clear ; clc ;
7 R1 =1000; R2 =1000;
8 Rf =10*10^3; R3 =10*10^3;
9 AD = - Rf / R1 ; // V o l t a g e g a i n
10 printf ( \n V o l t a g e g a i n i s AD = %. f \n , AD ) //

Result
RiFx = R1 ; // I n p u t r e s i s t a n c e o f i n v e r t i n g a m p l i f i e r
printf ( \n I n p u t r e s i s t a n c e o f i n v e r t i n g a m p l i f i e r
i s RiFx = %. f ohms \n , RiFx ) // R e s u l t
13 RiFy = R2 + R3 ; // I n p u t r e s i s t a n c e o f noni n v e r t i n g
amplifier
14 printf ( \n I n p u t r e s i s t a n c e o f noni n v e r t i n g
a m p l i f i e r i s RiFy = %. f ohms \n , RiFy ) // R e s u l t
11
12

Scilab code Exa 3.5.b Output voltage of an Opamp


1

// C h a p t e r 3
18

2
3
4
5
6
7
8
9
10
11
12

// Page . No96 , F i g u r e . No 3.14


// E x a m p l e 3 5 b
// Output v o l t a g e o f an Opamp
// Given
clear ; clc ;
vx =2.7; vy =3; // Both i n p u t v o l t a g e s a r e i n v o l t s
Rf =10*10^3; R1 =1000; // Both a r e i n ohms
AD = - Rf / R1 ; // V o l t a g e g a i n
vxy = vx - vy ;
vo = AD * vxy ; // Output v o l t a g e
printf ( \n Output v o l t a g e i s vo = %. f V \n , vo ) //
Result

Scilab code Exa 3.6.a Voltage gain and input resistance of the Opamp
1 // C h a p t e r 3
2 // Page . No99 , F i g u r e . No 3.16
3 // E x a m p l e 3 6 a
4 // V o l t a g e g a i n and i n p u t r e s i s t a n c e o f Opamp
5 // Given
6 clear ; clc ;
7 R1 =680; R3 =680; // Both a r e i n ohms
8 RF =6800; R2 =6800; // Both a r e i n ohms
9 Ri =2*10^6; // Openl o o p i n p u t r e s i s t a n c e o f t h e op
10
11
12
13
14
15

amp
vx = -1.5; vy = -2; // Both a r e i n v o l t s
A =200000; // Openl o o p Gain
AD =1+ RF / R1 ; // V o l t a g e g a i n
printf ( \n V o l t a g e g a i n i s AD = %. f \n , AD ) //
Result
B = R2 /( R2 + R3 ) ;
RiFy = Ri *(1+ A * B ) ; // I n p u t r e s i s t a n c e o f f i r s t s t a g e
amplifier
19

printf ( \n I n p u t r e s i s t a n c e o f f i r s t s t a g e a m p l i f i e r
i s RiFy = %. 1 f ohms \n , RiFy ) // R e s u l t
17 B = R1 /( R1 + RF ) ;
18 RiFx = Ri *(1+ A * B ) ; // I n p u t r e s i s t a n c e o f s e c o n d s t a g e
amplifier
19 printf ( \n I n p u t r e s i s t a n c e o f s e c o n d s t a g e
a m p l i f i e r i s RiFx = %. 1 f ohms \n , RiFx ) // R e s u l t
16

Scilab code Exa 3.6.b Output voltage of the Opamp


1
2
3
4
5
6
7
8
9
10
11
12

// C h a p t e r 3
// Page . No99 , F i g u r e . No 3.16
// E x a m p l e 3 6 b
// Output v o l t a g e o f t h e Opamp
// Given
clear ; clc ;
R1 =680; RF =6800 // Both a r e i n ohms
vx = -1.5; vy = -2; // Both i n p u t v o l t a g e s a r e i n v o l t s
AD =1+ RF / R1 ; // V o l t a g e g a i n
vxy = vx - vy ;
vo = AD * vxy ; // Output v o l t a g e
printf ( \n Output v o l t a g e i s vo = %. 1 f V \n , vo ) //
Result

20

Chapter 4
The Practical Opamp

Scilab code Exa 4.1 Design of Compensating Network


// C h a p t e r 4
// Page . No114
// E x a m p l e 4 1
// D e s i g n o f C o m p e n s a t in g Network
// Given
clear ; clc ;
V =10 // S u p p l y v o l t a g e
Vio =10*10^ -3; // I n p u t o f f s e t v o l t a g e
Rc =10; // Assumption
Rb =( V / Vio ) * Rc ;
printf ( \n R e s i s t a n c e Rb i s = %. f ohms \n , Rb ) //
Result
12 Ra = Rb /2.5; // S i n c e Rb>Rmax , l e t u s c h o o s e Rb=10Rmax
where Rmax=Ra/4
13 printf ( \n R e s i s t a n c e Ra i s = %. f ohms \n , Ra ) //
Result
1
2
3
4
5
6
7
8
9
10
11

21

This code can be downloaded from the website wwww.scilab.in

Scilab code Exa 4.2 Max Output offset voltage


1 // C h a p t e r 4
2 // Page . No121 , F i g u r e . No 4.13
3 // E x a m p l e 4 2
4 // Max Output o f f s e t v o l t a g e
5 // Given
6 clear ; clc ;
7 R1 =1*10^3; Rf =10*10^3;
8 Vio =10*10^ -3; // I n p u t o f f s e t v o l t a g e
9 Aoo =1+ Rf / R1 ; // To f i n d max v a l u e o f Voo , we r e d u c e

input voltage vin to zero .


10 Voo = Aoo * Vio ; // Max o u t p u t o f f s e t v o l t a g e
11 printf ( \n Max o u t p u t o f f s e t v o l t a g e i s = %. 3 f V dc

\n , Voo ) // R e s u l t

Scilab code Exa 4.3 Design of input offset voltage compensating network
Chapter4
Page . No121 , F i g u r e . No 4.14
Example 4 3
D e s i g n o f i n p u t o f f s e t v o l t a g e c o m p e n s a t i n g
network
5 // Given
6 clear ; clc ;

1
2
3
4

//
//
//
//

22

7 R1 =1*10^3; Rf =10*10^3; Rc =10;


8 Af =1+ Rf /( R1 + Rc ) ; // C l o s e d l o o p g a i n o f non

inverting amplifier
9 printf ( \n C l o s e d l o o p g a i n o f noni n v e r t i n g
a m p l i f i e r i s = %. 1 f \n , Af ) // R e s u l t

This code can be downloaded from the website wwww.scilab.in

Scilab code Exa 4.4.a Max Output offset voltage


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

// C h a p t e r 4
// Page . No127 , F i g u r e . No 4.19
// E x a m p l e 4 4 a
// Max Output o f f s e t v o l t a g e
// Given
clear ; clc ;
R1 =470; Rf =47*10^3;
Vio =6*10^ -3;
Ib =500*10^ -9;
Vs =15;
// Max o u t p u t o f f s e t v o l t a g e due t o i n p u t o f f s e t
v o l t a g e , Vio i s :
Voo =(1+ Rf / R1 ) * Vio ; // Max o u t p u t o f f s e t v o l t a g e
printf ( \n Max o u t p u t o f f s e t v o l t a g e i s = %. 3 f V dc
\n , Voo ) // R e s u l t
// Max o u t p u t o f f s e t v o l t a g e due t o i n p u t o f f s e t
voltage , Ib i s :
VoIb = Rf * Ib ; // Max o u t p u t o f f s e t v o l t a g e
printf ( \n Max o u t p u t o f f s e t v o l t a g e due t o i n p u t
o f f s e t c u r r e n t , I b i s = %. 6 f V dc \n , VoIb ) //
Result

23

Scilab code Exa 4.4.b Effect of input bias current


1 // C h a p t e r 4
2 // Page . No127 , F i g u r e . No 4.19
3 // E x a m p l e 4 4 b
4 // E f f e c t o f i n p u t b i a s c u r r e n t
5 // Given
6 clear ; clc ;
7 R1 =470; Rf =47*10^3;
8 ROM = R1 * Rf /( R1 + Rf ) ; // P a r a l l e l c o m b i n a t i o n o f R1 and

Rf
9 printf ( \n P a r a l l e l c o m b i n a t i o n o f R1 and Rf , i . e ROM
i s = %. 1 f ohm \n , ROM ) // A p p r o x i m a t e l y t h e
v a l u e i s 47 ohm

Scilab code Exa 4.5.a Max Output offset voltage


1
2
3
4
5
6
7
8
9
10

// C h a p t e r 4
// Page . No127 , F i g u r e . No 4.19
// E x a m p l e 4 5 a
// Max Output o f f s e t v o l t a g e
// Given
clear ; clc ;
R1 =1*10^3; Rf =100*10^3;
Vio =6*10^ -3;
Ib =500*10^ -9;
Vs =15;

24

11
12
13

14
15
16

// Max o u t p u t o f f s e t v o l t a g e due t o i n p u t o f f s e t
v o l t a g e , Vio i s :
Voo =(1+ Rf / R1 ) * Vio ; // Max o u t p u t o f f s e t v o l t a g e
printf ( \n Max o u t p u t o f f s e t v o l t a g e due t o i n p u t
o f f s e t v o l t a g e , Vio i s = %. 4 f V dc \n , Voo ) //
Result
// Max o u t p u t o f f s e t v o l t a g e due t o i n p u t o f f s e t
voltage , Ib i s :
VoIb = Rf * Ib ; // Max o u t p u t o f f s e t v o l t a g e
printf ( \n Max o u t p u t o f f s e t v o l t a g e due t o i n p u t
o f f s e t c u r r e n t , I b i s = %. 4 f V dc \n , VoIb ) //
Result

Scilab code Exa 4.5.b Effect of input bias current


1 // C h a p t e r 4
2 // Page . No127 , F i g u r e . No 4.19
3 // E x a m p l e 4 4 b
4 // E f f e c t o f i n p u t b i a s c u r r e n t
5 // Given
6 clear ; clc ;
7 R1 =1*10^3; Rf =100*10^3;
8 ROM = R1 * Rf /( R1 + Rf ) ; // P a r a l l e l c o m b i n a t i o n o f R1 and
9

Rf
printf ( \n P a r a l l e l c o m b i n a t i o n o f R1 and Rf , i . e ROM
i s = %. f ohm \n , ROM )

Scilab code Exa 4.6 Max Output offset voltage

25

1 // C h a p t e r 4
2 // Page . No130 , F i g u r e . No 4.21
3 // E x a m p l e 4 6
4 // Max Output o f f s e t v o l t a g e
5 // Given
6 clear ; clc ;
7 Iio =200*10^ -9; // I n p u t o f f s e t c u r r e n t
8 Rf =100*10^3;
9 VoIio = Rf * Iio ; // Max o u t p u t o f f s e t v o l t a g e
10 printf ( \n Max o u t p u t o f f s e t v o l t a g e due t o i n p u t

o f f s e t c u r r e n t , I b i s = %. 4 f V dc \n , VoIio ) //
Result

Scilab code Exa 4.7 Total Output offset voltage


// C h a p t e r 4
// Page . No132 , F i g u r e . No 4 . 2 2 ( a )
// E x a m p l e 4 7
// T o t a l Output o f f s e t v o l t a g e
// Given
clear ; clc ;
R1 =1*10^3; Rf =10*10^3;
Vio =7.5*10^ -3; // Max i n p u t o f f s e t v o l t a g e
Iio =50*10^ -9; // Max i n p u t o f f s e t c u r r e n t
Ib =250*10^ -9; // Max i n p u t b i a s c u r r e n t
// For f i g u r e 4 . 2 2 ( a )
VooT =(1+ Rf / R1 ) * Vio +( Rf * Ib ) ; // S i n c e t h e c u r r e n t
g e n e r a t e d o u t p u t o f f s e t v o l t a g e i s due t o i n p u t
b i a s c u r r e n t Ib
13 printf ( \n Max t o t a l o u t p u t o f f s e t v o l t a g e due t o
i n p u t o f f s e t c u r r e n t , I b i s = %. 4 f V \n , VooT ) //
Result

1
2
3
4
5
6
7
8
9
10
11
12

14

26

// For f i g u r e 4 . 2 2 ( b )
VooT =(1+ Rf / R1 ) * Vio +( Rf * Iio ) ; // S i n c e t h e c u r r e n t
g e n e r a t e d o u t p u t o f f s e t v o l t a g e i s due t o i n p u t
o f f s e t c u r r e n t Ib
17 printf ( \n Max t o t a l o u t p u t o f f s e t v o l t a g e due t o
i n p u t o f f s e t c u r r e n t , I b i s = %. 4 f V \n , VooT ) //
Result
15
16

Scilab code Exa 4.8.a Error voltage and output voltage


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

// C h a p t e r 4
// Page . No136 , F i g u r e . No 4.24
// E x a m p l e 4 8 a
// E r r o r v o l t a g e and o u t p u t v o l t a g e
// Given
clear ; clc ;
delta_Vio =(30*10^ -6) ; // Change i n i n p u t o f f s e t
voltage
delta_T =1; // U n i t c h a n g e i n t e m p e r a t u r e
delta_Iio =(300*10^ -12) ; // Change i n i n p u t o f f s e t
current
Vs =15;
R1 =1*10^3; Rf =100*10^3; Rl =10*10^3;
Vin =1*10^ -3; // I n p u t v o l t a g e
k =25; // A m p l i f i e r i s n u l l e d a t 25 deg
T =35 - k ; // Change i n t e m p e r a t u r e
Ev =(1+ Rf / R1 ) *( delta_Vio / delta_T ) * T + Rf *( delta_Iio /
delta_T ) * T ; // E r r o r v o l t a g e
printf ( \n E r r o r v o l t a g e i s = %. 4 f V \n , Ev ) //
Result
Vo = -( Rf / R1 ) * Vin + Ev ; // Output v o l t a g e
printf ( \n Output v o l t a g e i s = %. 4 f V \n , Vo ) //
Result
27

19 // (OR)
20 Vo = -( Rf / R1 ) * Vin - Ev ; // Output v o l t a g e
21 printf ( \n Output v o l t a g e i s = %. 4 f V \n , Vo ) //

Result

Scilab code Exa 4.8.b Error voltage and output voltage


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

// C h a p t e r 4
// Page . No136 , F i g u r e . No 4.24
// E x a m p l e 4 8 b
// E r r o r v o l t a g e and o u t p u t v o l t a g e
// Given
clear ; clc ;
delta_Vio =(30*10^ -6) ; // Change i n i n p u t o f f s e t
voltage
delta_T =1; // U n i t c h a n g e i n t e m p e r a t u r e
delta_Iio =(300*10^ -12) ; // Change i n i n p u t o f f s e t
current
Vs =15;
R1 =1*10^3; Rf =100*10^3; Rl =10*10^3;
Vin =10*10^ -3; // I n p u t v o l t a g e
k =25; // A m p l i f i e r i s n u l l e d a t 25 deg
T =35 - k ; // Change i n t e m p e r a t u r e
Ev =(1+ Rf / R1 ) *( delta_Vio / delta_T ) * T + Rf *( delta_Iio /
delta_T ) * T ; // E r r o r v o l t a g e
printf ( \n E r r o r v o l t a g e i s = %. 4 f V \n , Ev ) //
Result
Vo = -( Rf / R1 ) * Vin + Ev ; // Output v o l t a g e
printf ( \n Output v o l t a g e i s = %. 4 f V \n , Vo ) //
Result
// (OR)
Vo = -( Rf / R1 ) * Vin - Ev ; // Output v o l t a g e
printf ( \n Output v o l t a g e i s = %. 4 f V \n , Vo ) //
28

Result

Scilab code Exa 4.9.a Error voltage and output voltage


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

// C h a p t e r 4
// Page . No136 , F i g u r e . No 4.24
// E x a m p l e 4 9 a
// E r r o r v o l t a g e and o u t p u t v o l t a g e
// Given
clear ; clc ;
delta_Vio =(30*10^ -6) ; // Change i n i n p u t o f f s e t
voltage
delta_T =1; // U n i t c h a n g e i n t e m p e r a t u r e
delta_Iio =(300*10^ -12) ; // Change i n i n p u t o f f s e t
current
Vs =15;
R1 =1*10^3; Rf =100*10^3; Rl =10*10^3;
Vin =10*10^ -3; // I n p u t v o l t a g e
k =25; // A m p l i f i e r i s n u l l e d a t 25 deg
T =55 - k ; // Change i n t e m p e r a t u r e
Ev =(1+ Rf / R1 ) *( delta_Vio / delta_T ) * T + Rf *( delta_Iio /
delta_T ) * T ; // E r r o r v o l t a g e
printf ( \n E r r o r v o l t a g e i s = %. 4 f V dc \n , Ev ) //
Result
Vo = -( Rf / R1 ) * Vin + Ev ; // Output v o l t a g e
printf ( \n Output v o l t a g e i s = %. 4 f V \n , Vo ) //
Result
// (OR)
Vo = -( Rf / R1 ) * Vin - Ev ; // Output v o l t a g e
printf ( \n Output v o l t a g e i s = %. 4 f V \n , Vo ) //
Result

29

Scilab code Exa 4.9.b Output waveform


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

// C h a p t e r 4
// Page . No136 , F i g u r e . No 4.24
// E x a m p l e 4 9 b
// Output waveform
// Given
clear ; clc ;
t =0:0.1:2* %pi ;
y = -1000* sin ( t ) +91.8;
a = gca () ;
a . x_label . text = Time ;
a . y_label . text = V o l t a g e ;
a . title . text = Output waveform ;
plot2d (t , y ) ;
t1 =0:0.1:2* %pi ;
y1 =91.8*( t1 >=0) ;
b = gca () ;
b . line_style =3;
plot2d ( t1 , y1 ) ;

Scilab code Exa 4.10.a Error voltage and output voltage


1
2
3
4
5
6

// C h a p t e r 4
// Page . No141 , F i g u r e . No 4.26
// E x a m p l e 4 1 0 a
// E r r o r v o l t a g e and o u t p u t v o l t a g e
// Given
clear ; clc ;

30

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

delta_Vio =(30*10^ -6) ; // Change i n i n p u t o f f s e t


voltage
delta_T =1; // U n i t c h a n g e i n t e m p e r a t u r e
delta_Iio =(300*10^ -12) ; // Change i n i n p u t o f f s e t
current
Vs =15;
R1 =1*10^3; Rf =100*10^3;
Vin =1*10^ -3; // I n p u t v o l t a g e
k =25; // A m p l i f i e r i s n u l l e d a t 25 deg
T =35 - k ; // Change i n t e m p e r a t u r e
Ev =(1+ Rf / R1 ) *( delta_Vio / delta_T ) * T + Rf *( delta_Iio /
delta_T ) * T ; // E r r o r v o l t a g e
printf ( \n E r r o r v o l t a g e i s = %. 4 f V dc \n , Ev ) //
Result
Vo =(1+ Rf / R1 ) * Vin + Ev ; // Output v o l t a g e
printf ( \n Output v o l t a g e i s = %. 4 f V \n , Vo ) //
Result
// (OR)
Vo =(1+ Rf / R1 ) * Vin - Ev ; // Output v o l t a g e
printf ( \n Output v o l t a g e i s = %. 4 f V \n , Vo ) //
Result

Scilab code Exa 4.10.b Error voltage and output voltage


// C h a p t e r 4
// Page . No141 , F i g u r e . No 4.26
// E x a m p l e 4 1 0 b
// E r r o r v o l t a g e and o u t p u t v o l t a g e
// Given
clear ; clc ;
delta_Vio =(30*10^ -6) ; // Change i n i n p u t o f f s e t
voltage
8 delta_T =1; // U n i t c h a n g e i n t e m p e r a t u r e

1
2
3
4
5
6
7

31

9
10
11
12
13
14
15
16
17
18
19
20
21

delta_Iio =(300*10^ -12) ; // Change i n i n p u t o f f s e t


current
Vs =15;
R1 =1*10^3; Rf =100*10^3; Rl =10*10^3;
Vin =10*10^ -3; // I n p u t v o l t a g e
k =25; // A m p l i f i e r i s n u l l e d a t 25 deg
T =35 - k ; // Change i n t e m p e r a t u r e
Ev =(1+ Rf / R1 ) *( delta_Vio / delta_T ) * T + Rf *( delta_Iio /
delta_T ) * T ; // E r r o r v o l t a g e
printf ( \n E r r o r v o l t a g e i s = %. 4 f V dc \n , Ev ) //
Result
Vo =(1+ Rf / R1 ) * Vin + Ev ; // Output v o l t a g e
printf ( \n Output v o l t a g e i s = %. 4 f V dc \n , Vo ) //
Result
// (OR)
Vo =(1+ Rf / R1 ) * Vin - Ev ; // Output v o l t a g e
printf ( \n Output v o l t a g e i s = %. 4 f V dc \n , Vo ) //
Result

Scilab code Exa 4.11.a Output offset voltage


1
2
3
4
5
6
7
8
9
10
11

// C h a p t e r 4
// Page . No141 , F i g u r e . No 4.28
// E x a m p l e 4 1 1 a
// Output o f f s e t v o l t a g e
// Given
clear ; clc ;
delta_Vio =15.85*10^ -6; // Change i n i n p u t o f f s e t
voltage
delta_V =1; // U n i t c h a n g e i n s u p p l y v o l t a g e
V =2; // Change i n s u p p l y v o l t a g e
R1 =1*10^3; Rf =100*10^3;
delta_Voo =(1+ Rf / R1 ) *( delta_Vio / delta_V ) * V ; // Change
32

in output o f f s e t v o l t a g e
12 printf ( \n Change i n o u t p u t o f f s e t v o l t a g e i s = %. 4 f
V \n , delta_Voo ) // R e s u l t

Scilab code Exa 4.11.b Output offset voltage


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

// C h a p t e r 4
// Page . No141 , F i g u r e . No 4.28
// E x a m p l e 4 1 1 b
// Output o f f s e t v o l t a g e
// Given
clear ; clc ;
delta_Vio =15.85*10^ -6; // Change i n i n p u t o f f s e t
voltage
delta_V =1; // U n i t c h a n g e i n s u p p l y v o l t a g e
V =2; // Change i n s u p p l y v o l t a g e
Vin =10*10^ -3;
R1 =1*10^3; Rf =100*10^3;
delta_Voo =(1+ Rf / R1 ) *( delta_Vio / delta_V ) * V ; // Output
offs et voltage
Vo =( - Rf / R1 ) * Vin + delta_Voo ; // T o t a l o u t p u t o f f s e t
voltage
printf ( \n T o t a l o u t p u t o f f s e t v o l t a g e i s = %. 4 f V \
n , Vo ) // R e s u l t
// (OR)
Vo =( - Rf / R1 ) * Vin - delta_Voo ; // T o t a l o u t p u t o f f s e t
voltage
printf ( \n T o t a l o u t p u t o f f s e t v o l t a g e i s = %. 4 f V \
n , Vo ) // R e s u l t

33

Scilab code Exa 4.12 Output ripple voltage


1
2
3
4
5
6
7
8
9
10
11
12

// C h a p t e r 4
// Page . No141 , F i g u r e . No 4 . 2 8 ( b )
// E x a m p l e 4 1 2
// Output r i p p l e v o l t a g e
// Given
clear ; clc ;
delta_Vio =15.85*10^ -6; // Change i n i n p u t o f f s e t
voltage
delta_V =1; // U n i t c h a n g e i n s u p p l y v o l t a g e
V =10*10^ -3; // Change i n s u p p l y v o l t a g e
R1 =1*10^3; Rf =100*10^3;
delta_Voo =(1+ Rf / R1 ) *( delta_Vio / delta_V ) * V ; // Change
in output o f f s e t v o l t a g e
printf ( \n Change i n o u t p u t o f f s e t v o l t a g e i s = %. 6 f
V \n , delta_Voo ) // R e s u l t

Scilab code Exa 4.13 Change in output offset voltage


1
2
3
4
5
6
7
8

// C h a p t e r 4
// Page . No136 , F i g u r e . No 4.24
// E x a m p l e 4 1 3
// Change i n o u t p u t o f f s e t v o l t a g e
// Given
clear ; clc ;
delta_Vio =5*10^ -6; // Change i n i n p u t o f f s e t v o l t a g e
delta_t =1; // U n i t c h a n g e i n t i m e
34

9 delta_Iio =2*10^ -9; // Change i n i n p u t o f f s e t c u r r e n t


10 t =4; // Time e l a p s e d ( w e e k s )
11 R1 =1*10^3; Rf =100*10^3; Rl =10*10^3;
12 delta_Voot =(1+ Rf / R1 ) *( delta_Vio / delta_t ) * t + Rf *(

delta_Iio / delta_t ) * t ; // Change i n o u t p u t o f f s e t


voltage
13 printf ( \n Change i n o u t p u t o f f s e t v o l t a g e i s = %. 4 f
V \n , delta_Voot ) // R e s u l t

Scilab code Exa 4.14.a Output voltage


1
2
3
4
5
6
7
8
9
10
11
12

// C h a p t e r 4
// Page . No153 , F i g u r e . No 4.32
// E x a m p l e 4 1 4 a
// Output v o l t a g e
// Given
clear ; clc ;
R1 =1*10^3; R2 =1*10^3; Rf =10*10^3; R3 =10*10^3;
vd =5*10^ -3; // D i f f e r e n t i a l v o l t a g e
vcm =2*10^ -3; // Commonmode v o l t a g e
Ad = Rf / R1 ; // C l o s e d l o o p d i f f e r e n t i a l g a i n
vo = Ad * vd ; // Output v o l t a g e
printf ( \n Output v o l t a g e i s = %. 3 f V \n , vo ) //
Result

Scilab code Exa 4.14.b Output common mode voltage


1
2

// C h a p t e r 4
// Page . No153 , F i g u r e . No 4.32
35

// E x a m p l e 4 1 4 b
// Output commonmode v o l t a g e
// Given
clear ; clc ;
R1 =1*10^3; R2 =1*10^3; Rf =10*10^3; R3 =10*10^3;
vd =5*10^ -3; // D i f f e r e n t i a l v o l t a g e
vcm =2*10^ -3; // Commonmode v o l t a g e
Ad = Rf / R1 ; // C l o s e d l o o p d i f f e r e n t i a l g a i n
CMRRdb =90
CMRR =10^(90/20) ; // U s i n g CMRRdb=20 l o g 1 0 (CMRR) , t o
c o n v e r t t h e CMRR( dB ) v a l u e i n t o i t s e q u u i v a l e n t
numerical value
13 printf ( \n CMRR i s = %. 2 f \n , CMRR ) // R e s u l t
14 vocm =( Ad * vcm ) / CMRR ; // Output commonmode v o l t a g e
15 printf ( \n Output commonmode v o l t a g e i s = %. 8 f V \n
, vocm ) // R e s u l t
3
4
5
6
7
8
9
10
11
12

36

Chapter 5
Frequency Response of an
Opamp

Scilab code Exa 5.1 Maximum gain


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

// C h a p t e r 5
// Page . No171 , F i g u r e . No5.4
// E x a m p l e 5 1
// Maximum g a i n
// Given
clear ; clc ;
fo =5; // Break f r e q o f t h e opamp i n Hz
s = %s ;
A =200000; // Gain o f t h e opamp a t 0 Hz
H = syslin ( c ,( A * fo *2* %pi ) /(( fo *2* %pi ) + s ) ) ;
fmin =1;
fmax =100000;
bode (H , fmin , fmax ) ;
Aol =40;
printf ( \n Maximum g a i n i s = %. f dB \n , Aol ) ; //
From t h e g r a p h

37

Scilab code Exa 5.2 Gain equation and break frequencies


1 // C h a p t e r 5
2 // Page . No172 , F i g u r e . No5.5
3 // E x a m p l e 5 2
4 // Gain e q u a t i o n and b r e a k f r e q u e n c i e s
5 // Given :
6 clear ; clc ;
7 phase = -157.5; // Phase s h i f t a t a b o u t 3 MHz
8 f =3*10^6;
9 disp ( Gain e q u a t i o n i s Aol ( f )=A/ ( ( 1 + ( f / f o 1 ) j ) (1+( f

10
11
12
13
14

/ f o 2 ) j ) ) , where f o 1 f i r s t b r e a k f r e q u e n c y and f o 2
s e c o n d b r e a k f r e q u e n c y ) // From t h e f i g u r e
fo1 =6;
printf ( \n F i r s t b r e a k f r e q u e n c y f o 1 i s = %. f Hz \n
, fo1 ) // From t h e g r a p h
k = - atand ( f / fo1 ) - phase ;
fo2 = f / tand ( k ) ;
printf ( \n S e c o n d b r e a k f r e q u e n c y f o 2 i s = %. 1 f Hz \
n , fo2 ) // R e s u l t

Scilab code Exa 5.3 Stability of voltage follower


1
2
3
4
5

// C h a p t e r 5
// Page . No83 , F i g u r e . No3.7
// E x a m p l e 5 3
// S t a b i l i t y o f v o l t a g e f o l l o w e r
// Given
38

6
7
8
9
10
11
12
13
14
15

clear ; clc ;
fo =5; // Break f r e q o f t h e opamp i n Hz
s = %s ;
A =200000; // Gain o f t h e opamp a t 0 Hz
H = syslin ( c ,( A * fo *2* %pi ) /(( fo *2* %pi ) + s ) ) ;
fmin =10;
fmax =1000000;
bode (H , fmin , fmax ) ;
Aol =0;
printf ( \n Magnitude a t which v o l t a g e f o l l o w e r i s
s t a b l e i s = %. f dB \n , Aol ) ; // From t h e g r a p h

39

Chapter 6
General Linear Applications

Scilab code Exa 6.1 Bandwidth of the amplifier


1 // C h a p t e r 6
2 // Page . No193 , F i g u r e . No 6 . 3 ( a )
3 // E x a m p l e 6 1
4 // Bandwidth o f t h e a m p l i f i e r
5 // Given
6 clear ; clc ;
7 R1 =100; Rf =1*10^3; Rin =50; Rl =10*10^3;
8 Ci =0.1*10^ -6; // C a p a c i t a n c e b /w 2 s t a g e s
9
10
11
12
13
14
15
16
17
18

being

coupled
RiF = R1 ; // a c i n p u t r e s i s t a n c e o f t h e s e c o n d s t a g e
Ro = Rin ; // a c o u t p u t r e s i s t a n c e o f t h e 1 s t s t a g e
UGB =10^6; // U n i t y g a i n bandwidth
fl =1/(2* %pi * Ci *( RiF + Ro ) ) ; // Lowf r e q c u t o f f
printf ( \n Lowf r e q c u t o f f i s = %. 1 f Hz \n , fl ) //
Result
K = Rf /( R1 + Rf ) ;
Af = - Rf / R1 ; // c l o s e d l o o p v o l t a g e g a i n
fh = UGB * K / abs ( Af ) ; // Highf r e q c u t o f f
printf ( \n Highf r e q c u t o f f i s = %. 1 f Hz \n , fh ) //
Result
BW = fh - fl ; // Bandwidth
40

19

printf ( \n Bandwidth i s = %. 1 f Hz \n , BW ) // R e s u l t

Scilab code Exa 6.2.a Bandwidth of the amplifier


1 // C h a p t e r 6
2 // Page . No193 , F i g u r e . No 6 . 4 ( c )
3 // E x a m p l e 6 2 a
4 // Bandwidth o f t h e a m p l i f i e r
5 // Given
6 clear ; clc ;
7 R1 =100*10^3; R2 =100*10^3; R3 =100*10^3; Rf =1*10^6; Rin
8
9
10
11
12
13
14
15
16
17
18
19
20

=50;
Ci =0.1*10^ -6; // C a p a c i t a n c e b /w 2 s t a g e s b e i n g
coupled
Ro = Rin ; // a c o u t p u t r e s i s t a n c e o f t h e 1 s t s t a g e
Vcc =15;
UGB =10^6; // U n i t y g a i n bandwidth
Rif = R2 * R3 /( R2 + R3 ) ; // s i n c e Ri (1+AB)>>R2 o r R3
fl =1/(2* %pi * Ci *( Rif + Ro ) ) ; // lowf r e q c u t o f f
printf ( \n Lowf r e q c u t o f f i s = %. 1 f Hz \n , fl ) //
Result
K = Rf /( R1 + Rf ) ;
Af = - Rf / R1 ; // c l o s e d l o o p v o l t a g e g a i n
fh = UGB * K / abs ( Af ) ; // Highf r e q c u t o f f
printf ( \n Highf r e q c u t o f f i s = %. 1 f Hz \n , fh ) //
Result
BW = fh - fl ; // Bandwidth
printf ( \n Bandwidth i s = %. 1 f Hz \n , BW ) // R e s u l t

41

Scilab code Exa 6.2.b Max output voltage swing


1 // C h a p t e r 6
2 // Page . No193 , F i g u r e . No 6 . 4 ( c )
3 // E x a m p l e 6 2 b
4 // Max o u t p u t v o l t a g e s w i n g
5 // Given
6 clear ; clc ;
7 R1 =100*10^3; R2 =100*10^3; R3 =100*10^3; Rf =1*10^6; Rin
8
9
10
11
12

=50;
Ci =0.1*10^ -6; // C a p a c i t a n c e b /w 2 s t a g e s b e i n g
coupled
Ro = Rin ; // a c o u t p u t r e s i s t a n c e o f t h e 1 s t s t a g e
UGB =10^6; // U n i t y g a i n bandwidth
Vcc =15;
printf ( \n The i d e a l maximum o u t p u t v o l t a g e s w i n g i s
= %. f V pp \n , Vcc )

Scilab code Exa 6.3 Components of peak amplifier


// C h a p t e r 6
// Page . No193 , F i g u r e . No 6 . 5 ( a )
// E x a m p l e 6 3
// Components o f peak a m p l i f i e r
// Given
clear ; clc ;
fp =16*10^3; // Peak f r e q u e n c y
Af =10; // Gain a t peak f r e q u e n c y
C =0.01*10^ -6; // Assume
L =1/(((2* %pi * fp ) ^2) *10^ -8) ; // S i m p l i f y i n g f p =1/(2
p i s q r t ( LC) )
11 printf ( \n I n d u c t a n c e i s = %. 4 f H \n ,L )
12 L =10*10^ -3; // Approximate

1
2
3
4
5
6
7
8
9
10

42

13 R =30; // Assume t h e v a l u e o f

internal resistance of

the inductor
14 Xl =2* %pi * fp * L ; // I n d u c t i v e r e a c t a n c e
15 Qcoil = Xl / R ; // F i g u r e o f m e r i t o f t h e c o i l
16 printf ( \n F i g u r e o f m e r i t o f t h e c o i l i s = %. 1 f \n
17
18
19
20
21

, Qcoil )
Rp =( Qcoil ) ^2* R ; // P a r a l l e l r e s i s t a n c e o f t h e t a n k
circuit
printf ( \n P a r a l l e l r e s i s t a n c e o f t h e t a n k c i r c u i t
i s = %. 1 f ohm \n , Rp )
R1 =100; // Assume t h e v a l u e o f i n t e r n a l r e s i s r a n c e
of the c o i l
Rf = - Rp /(1 -( Rp /( Af * R1 ) ) ) ; // S i m p l i f y i n g Af=( Rf | | Rp ) /
R1
printf ( \n F eedback r e s i s t a n c e i s = %. 1 f ohm \n , Rf )

Scilab code Exa 6.4 Output voltage


1 // C h a p t e r 6
2 // Page . No200 , F i g u r e . No6.6
3 // E x a m p l e 6 4
4 // Output v o l t a g e
5 // Given
6 clear ; clc ;
7 Va =1; Vb =2; Vc =3; // I n p u t v o l t a g e s i n v o l t s
8 Ra =3*10^3; Rb =3*10^3; Rc =3*10^3; Rf =1*10^3;
9 Vo = -(( Rf / Ra ) * Va +( Rf / Rb ) * Vb +( Rf / Rc ) * Vc ) ; // Output

voltage
10 printf ( \n Output v o l t a g e i s = %. f V \n , Vo )

43

Scilab code Exa 6.5 Output voltage


1 // C h a p t e r 6
2 // Page . No203 , F i g u r e . No6.7
3 // E x a m p l e 6 5
4 // Output v o l t a g e
5 // Given
6 clear ; clc ;
7 Va =2; Vb = -3; Vc =4; // I n p u t v o l t a g e s i n v o l t s
8 R1 =1*10^3; Rf =2*10^3;
9 V1 =( Va + Vb + Vc ) /3; // V o l t a g e a t noni n v e r t i n g

terminal
10 printf ( \n V o l t a g e a t noni n v e r t i n g t e r m i n a l i s = %.
f V \n , V1 )
11 Vo =(1+ Rf / R1 ) * V1 ; // Output v o l t a g e
12 printf ( \n Output v o l t a g e i s = %. f V \n , Vo )

Scilab code Exa 6.6 Output voltage


1 // C h a p t e r 6
2 // Page . No205 , F i g u r e . No6.9
3 // E x a m p l e 6 6
4 // Output v o l t a g e
5 // Given
6 clear ; clc ;
7 Va =2; Vb =3; Vc =4; Vd =5; // I n p u t v o l t a g e s
8 R =1*10^3;
9 Vo = - Va - Vb + Vc + Vd ; // Output v o l t a g e

44

in volts

10

printf ( \n Output v o l t a g e i s = %. f V \n , Vo )

Scilab code Exa 6.7 Output voltage


1 // C h a p t e r 6
2 // Page . No209 , F i g u r e . No 6.12
3 // E x a m p l e 6 7
4 // Output v o l t a g e
5 // Given
6 clear ; clc ;
7 R1 =1*10^3; Rf =4.7*10^3; Ra =100*10^3; Rb =100*10^3; Rc

=100*10^3;
8 Vdc =5;
9 Rt =100*10^3; // R e s i s t a n c e o f a t h e r m i s t o r
10 temp_coeff =1*10^3;
11
12 // Output v o l t a g e a t 0 d e g r e e
13 delta_R = - temp_coeff *(0 -25) ; // Change i n r e s i s t a n c e
14 R = Ra ; // Ra=Rb=Rc=R
15 Vo =(( Rf * delta_R ) /( R1 *4* R ) ) * Vdc ;
16 printf ( \n Output v o l t a g e a t 0 d e g r e e i s = %. 2 f V \n

, Vo )
17
18
19

// Output v o l t a g e a t 100 d e g r e e
delta_R = - temp_coeff *(100 -25) ; // Change i n
resistance
20 Vo =(( Rf * delta_R ) /( R1 *4* R ) ) * Vdc ;
21 printf ( \n Output v o l t a g e a t 100 d e g r e e i s = %. 2 f V
\n , Vo )

45

Scilab code Exa 6.8 Change in resistance in straingage


1 // C h a p t e r 6
2 // Page . No209 , F i g u r e . No 6.12
3 // E x a m p l e 6 7
4 // Change i n r e s i s t a n c e i n s t r a i n g a g e
5 // Given
6 clear ; clc ;
7 A = -100; // Gain o f t h e d i f f e r e n t i a l i n s t r u m e n t a t i o n

amplifier
8 Ra =100; Rb =100; Rc =100;
9 Vdc =10; Vo =1;
10 R = Ra ; // Ra=Rb=Rc=R
11 delta_R =( Vo * R ) /( Vdc * abs ( A ) ) ; // Change i n r e s i s t a n c e
12 printf ( \n Change i n r e s i s t a n c e i s = %. 1 f ohm \n ,

delta_R )

Scilab code Exa 6.9 Gain of the amplifier


1 // C h a p t e r 6
2 // Page . No216 , F i g u r e . No 6 . 1 4 ( a )
3 // E x a m p l e 6 9
4 // Gain o f t h e a m p l i f i e r
5 // Given
6 clear ; clc ;
7 Vo =3.7; Vin =100*10^ -3;
8 R1 =100; // Assume
9 Rf =0.5*(( Vo * R1 ) / Vin -1) ; // Fee dback r e s i s r a n c e

46

10 printf ( \n F eedback r e s i s r a n c e i s = %. 1 f ohm \n , Rf )


11 A =(1+2* Rf / R1 ) ; // Gain o f t h e d i f f e r e n t i a l a m p l i f i e r
12 printf ( \n Gain o f t h e d i f f e r e n t i a l a m p l i f i e r i s = %

. 1 f \n ,A )

Scilab code Exa 6.10 Range of input voltage


1 // C h a p t e r 6
2 // Page . No220 , F i g u r e . No 6.17
3 // E x a m p l e 6 1 0
4 // Range o f i n p u t v o l t a g e
5 // Given
6 clear ; clc ;
7 R1min =1*10^3; R1max =6.8*10^3;
8 io =1*10^ -3; // Meter c u r r e n t f o r
9
10
11
12

rectification
vin_min =1.1* R1min * io ; //
printf ( \n Minimum i n p u t
vin_min )
vin_max =1.1* R1max * io ; //
printf ( \n Maximum i n p u t
vin_max )

f u l l wave

Minimum i n p u t v o l t a g e
v o l t a g e i s = %. 1 f V \n ,
Maximum i n p u t v o l t a g e
v o l t a g e i s = %. 2 f V \n ,

Scilab code Exa 6.11 Current and voltage drop


1
2
3
4

//
//
//
//

Chapter6
Page . No222 , F i g u r e . No 6.18
Example 6 11
C u r r e n t and v o l t a g e d r o p
47

5
6
7
8
9
10
11
12

// Given
clear ; clc ;
Vin =0.5; Vo =1.2;
R1 =100;
Io = Vin / R1 ; // C u r r e n t t h r o u g h d i o d e
printf ( \n C u r r e n t t h r o u g h d i o d e i s = %. 4 f A \n , Io )
Vd = Vo - Vin ; // V o l t a g e d r o p a c r o s s d i o d e
printf ( \n V o l t a g e d r o p a c r o s s d i o d e i s = %. 1 f V \n
, Vd )

Scilab code Exa 6.12.a Load current


1 // C h a p t e r 6
2 // Page . No222 , F i g u r e . No 6.19
3 // E x a m p l e 6 1 2 a
4 // Load c u r r e n t
5 // Given
6 clear ; clc ;
7 Vin =5; V1 =1;
8 R =10*10^3;
9 Il = Vin / R ; // Load c u r r e n t
10 printf ( \n Load c u r r e n t i s = %. 5 f A \n , Il )

Scilab code Exa 6.12.b Output voltage


1
2
3
4

//
//
//
//

Chapter6
Page . No222 , F i g u r e . No 6.19
Example 6 12 b
Output v o l t a g e
48

5 // Given
6 clear ; clc ;
7 Vin =5; V1 =1;
8 R =10*10^3;
9 Vo =2* V1 ; // Output v o l t a g e
10 printf ( \n Output v o l t a g e i s = %. f V \n , Vo )

Scilab code Exa 6.13 Range of output voltage


1 // C h a p t e r 6
2 // Page . No222 , F i g u r e . No 6.20
3 // E x a m p l e 6 1 3
4 // Range o f o u t p u t v o l t a g e
5 // Given
6 clear ; clc ;
7 R1 =1*10^3; Rf =2.7*10^3;
8 Vref =2;
9 Io =0; // S i n c e a l l t h e b i n a r y i n p u t s D0 t o D7 a r e
10
11
12
13
14

logic zero
Vo_min = Io * Rf ; // Minimum o u t p u t v o l t a g e
printf ( \n Minimum o u t p u t v o l t a g e i s = %. f V \n ,
Vo_min )
Io =( Vref / R1 )
*( 1/ 2+ 1/ 4+ 1/8 +1 /1 6+ 1/ 32+ 1/ 64 +1 /1 28+ 1/ 25 6) ;
Vo_max = Io * Rf ; // Maximum o u t p u t v o l t a g e
printf ( \n Maximum o u t p u t v o l t a g e i s = %. 2 f V \n ,
Vo_max )

Scilab code Exa 6.14 Change in output voltage


49

1 // C h a p t e r 6
2 // Page . No228 , F i g u r e . No 6.21
3 // E x a m p l e 6 1 4
4 // Change i n o u t p u t v o l t a g e
5 // Given
6 clear ; clc ;
7 Rf =3*10^3;
8 Vdc =5;
9 Rt =100*10^3; // R e s i s t a n c e a t d a r k n e s s
10 Vomin = -( Vdc / Rt ) * Rf ; // Min o u t p u t v o l t a g e a t
11
12
13
14

darkness
printf ( \n Min o u t p u t v o l t a g e a t d a r k n e s s i s = %. 2 f
V \n , Vomin )
Rt =1.5*10^3; // R e s i s t a n c e a t I l l u m i n a t i o n
Vomax = -( Vdc / Rt ) * Rf ; // Max o u t p u t v o l t a g e a t
Illumination
printf ( \n Max o u t p u t v o l t a g e a t I l l u m i n a t i o n i s = %
. f V \n , Vomax )

Scilab code Exa 6.15 Output voltage of an integrator


1
2
3
4
5
6
7
8
9
10
11
12

// C h a p t e r 6
// Page . No230 , F i g u r e . No 6.23
// E x a m p l e 6 1 5
// Output v o l t a g e o f an i n t e g r a t o r
// Given
clear ; clc ;
Vin =2; // I n p u t v o l t a g e i n v o l t
Vo0 =0;
Vo1 = - integrate ( 2 , t ,0 ,1) ;
disp ( Vo1 )
Vo2 = - integrate ( 2 , t ,1 ,2) + Vo1 ;
disp ( Vo2 )
50

13
14
15
16
17
18
19
20
21
22

Vo3 = - integrate ( 2 , t ,2 ,3) + Vo2 ;


disp ( Vo3 )
Vo4 = - integrate ( 2 , t ,3 ,4) + Vo3 ;
disp ( Vo4 )
Vo =[ Vo0 Vo1 Vo2 Vo3 Vo4 ];
t =[0 1 2 3 4];
plot (t , Vo ) ;
title ( Output V o l t a g e ) ;
xlabel ( t ) ;
ylabel ( Vo ) ;

Scilab code Exa 6.16.a Design of differentiator


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

// C h a p t e r 6
// Page . No238
// E x a m p l e 6 1 6 a
// D e s i g n o f d i f f e r e n t i a t o r
// Given
clear ; clc ;
C1 =0.1*10^ -6; // Assume
fa =1*10^3; // Freq a t which g a i n i s 0 dB
Rf =1/(2* %pi * fa * C1 ) ; // U s i n g f a =1/(2 %pi Rf C1 )
printf ( \n F eedback r e s i s t a n c e i s = %. 1 f ohm \n , Rf )
Rf =1.5*10^3; // A p p r o x i m a t i o n
fb =20*10^3; // Gain l i m i t i n g f r e q
R1 =1/(2* %pi * fb * C1 ) ;
printf ( \n R e s i s t a n c e , R1 i s = %. 1 f ohm \n , R1 )
R1 =82; // A p p r o x i m a t i o n
Cf = R1 * C1 / Rf ;
printf ( \n C a p a c i t a n c e , Cf i s = %. 1 0 f f a r a d \n , Cf )
Cf =0.005*10^ -6; // A p p r o x i m a t i o n

51

Scilab code Exa 6.16.b Output waveform of differentiator


1 // C h a p t e r 6
2 // Page . No238
3 // E x a m p l e 6 1 6 b
4 // Output waveform o f d i f f e r e n t i a t o r
5 // Given
6 clear ; clc ;
7 step =0.01;
8 t =0: step :2* %pi ;
9 dy = diff ( sin ( t ) ) / step ; // a p p r o x i m a t e d i f f e r e n t i a t i o n
10
11
12
13
14

of sine function
Vo = -1.5*10^3*0.1*10^ -6*2* %pi *10^3* dy ;
plot ( Vo ) ;
title ( Output V o l t a g e ) ;
xlabel ( t ) ;
ylabel ( Vo ) ;

52

Chapter 7
Active Filters and Oscillators

Scilab code Exa 7.1 Design of low pass filter


1 // C h a p t e r 7
2 // Page . No256
3 // E x a m p l e 7 1
4 // D e s i g n o f low p a s s f i l t e r
5 // Given
6 clear ; clc ;
7 fh =1*10^3; // Cut o f f f r e q u e n c y
8 C =0.01*10^ -6; // Assumption
9 R =1/(2* %pi * fh * C ) ;
10 printf ( \n R e s i s t a n c e R i s = %. 1 f ohm \n ,R ) //
11
12
13
14
15

Result
printf ( \n Use 20 kohm POT a s R \n )
R1 =10*10^3; // Assumption
printf ( \n R e s i s t a n c e R1 i s = %. 1 f ohm \n , R1 )
Rf = R1 ; // S i c e p a s s b a n d g a i n i s 2 , R1 and Rf must be
equal
printf ( \n R e s i s t a n c e Rf i s = %. 1 f ohm \n , Rf )

53

This code can be downloaded from the website wwww.scilab.in

Scilab code Exa 7.2 Design of low pass filter


1
2
3
4
5
6
7
8
9
10
11
12

// C h a p t e r 7
// Page . No256
// E x a m p l e 7 2
// D e s i g n o f low p a s s f i l t e r
// Given
clear ; clc ;
fc0 =1*10^3; // O r i g i n a l cut o f f f r e q u e n c y
fc1 =1.6*10^3; // New cut o f f f r e q u e n c y
R =15.9*10^3; // O r i g i n a l r e s i s t a n c e v a l u e
k = fc0 / fc1 ;
Rnew = R * k ;
printf ( \n New R e s i s t a n c e Rnew i s = %. 1 f ohm \n ,
Rnew ) // R e s u l t

Scilab code Exa 7.3 Frequency response of low pass filter


1 // C h a p t e r 7
2 // Page . No257
3 // E x a m p l e 7 3
4 // F r e q u e n c y r e s p o n s e o f low p a s s f i l t e r
5 // Given
6 clear ; clc ;
7 Af =2; // Passband g a i n o f t h e f i l t e r

54

8 fh =1000; // Cut o f f f r e q u e n c y
9 f1 =10; // I n p u t f r e q i n Hz
10 av1 = Af / sqrt (1+( f1 / fh ) ^2) ;
11 printf ( \n Gain m a g n i t u d e av1 a t f 1
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

av1 ) // R e s u l t
f2 =100; // Freq i n Hz
av2 = Af / sqrt (1+( f2 / fh ) ^2) ;
printf ( \n Gain m a g n i t u d e
av2 ) // R e s u l t
f3 =200; // Freq i n Hz
av3 = Af / sqrt (1+( f3 / fh ) ^2) ;
printf ( \n Gain m a g n i t u d e
av3 ) // R e s u l t
f4 =700; // Freq i n Hz
av4 = Af / sqrt (1+( f4 / fh ) ^2) ;
printf ( \n Gain m a g n i t u d e
av4 ) // R e s u l t
f5 =1000; // Freq i n Hz
av5 = Af / sqrt (1+( f5 / fh ) ^2) ;
printf ( \n Gain m a g n i t u d e
av5 ) // R e s u l t
f6 =3000; // Freq i n Hz
av6 = Af / sqrt (1+( f6 / fh ) ^2) ;
printf ( \n Gain m a g n i t u d e
av6 ) // R e s u l t
f7 =7000; // Freq i n Hz
av7 = Af / sqrt (1+( f7 / fh ) ^2) ;
printf ( \n Gain m a g n i t u d e
av7 ) // R e s u l t
f8 =10000; // Freq i n Hz
av8 = Af / sqrt (1+( f8 / fh ) ^2) ;
printf ( \n Gain m a g n i t u d e
av8 ) // R e s u l t
f9 =30000; // Freq i n Hz
av9 = Af / sqrt (1+( f9 / fh ) ^2) ;
printf ( \n Gain m a g n i t u d e
av9 ) // R e s u l t
f10 =100000; // Freq i n Hz

i s = %. 2 f \n ,

av2 a t f 2 i s = %. 2 f \n ,

av3 a t f 3 i s = %. 2 f \n ,

av4 a t f 4 i s = %. 2 f \n ,

av5 a t f 5 i s = %. 2 f \n ,

av6 a t f 6 i s = %. 2 f \n ,

av7 a t f 7 i s = %. 2 f \n ,

av8 a t f 8 i s = %. 2 f \n ,

av9 a t f 9 i s = %. 2 f \n ,

55

37
38
39
40
41
42
43
44

av10 = Af / sqrt (1+( f10 / fh ) ^2) ;


printf ( \n Gain m a g n i t u d e av10 a t f 1 0 i s = %. 2 f \n ,
av10 ) // R e s u l t
x =[ f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 ];
y =[ av1 av2 av3 av4 av5 av6 av7 av8 av9 av10 ];
gainplot (x , y ) ;
title ( F r e q u e n c y R e s p o n s e ) ;
xlabel ( F r e q u e n c y ( Hz ) ) ;
ylabel ( V o l t a g e g a i n ( dB ) ) ;

Scilab code Exa 7.4.a Design of second order low pass filter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

// C h a p t e r 7
// Page . No256
// E x a m p l e 7 4 a
// D e s i g n o f s e c o n d o r d e r low p a s s f i l t e r
// Given
clear ; clc ;
fh =1*10^3; // Cut o f f f r e q u e n c y
C2 =0.0047*10^ -6; // Assumption
C3 = C2 ;
R2 =1/(2* %pi * fh * C2 ) ;
printf ( \n R e s i s t a n c e R2 i s = %. 1 f ohm \n , R2 ) //
Result
R2 =33*10^3; // A p p r o x i m a t i o n
R3 = R2 ;
printf ( \n R e s i s t a n c e R3 i s = %. 1 f ohm \n , R3 ) //
Result
R1 =27*10^3; // Assumption
Rf =0.586* R1 ;
printf ( \n R e s i s t a n c e Rf i s = %. 1 f ohm \n , Rf ) //
Result
printf ( \n Use 20 kohm POT a s Rf \n )
56

Scilab code Exa 7.4.b Frequency response of second order highpass filter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

//
//
//
//

Chapter7
Page . No260
Example 7 4 b
Frequency r e s p o n s e o f second order highpass
filter
// Given
clear ; clc ;
Af =1.586; // Passband g a i n o f t h e f i l t e r
fh =1000; // Cut o f f f r e q u e n c y
f1 =10; // I n p u t f r e q i n Hz
av1 = Af / sqrt (1+( f1 / fh ) ^4) ;
printf ( \n Gain m a g n i t u d e av1 a t f 1 i s = %. 2 f \n ,
av1 ) // R e s u l t
f2 =100; // Freq i n Hz
av2 = Af / sqrt (1+( f2 / fh ) ^4) ;
printf ( \n Gain m a g n i t u d e av2 a t f 2 i s = %. 2 f \n ,
av2 ) // R e s u l t
f3 =200; // Freq i n Hz
av3 = Af / sqrt (1+( f3 / fh ) ^4) ;
printf ( \n Gain m a g n i t u d e av3 a t f 3 i s = %. 2 f \n ,
av3 ) // R e s u l t
f4 =700; // Freq i n Hz
av4 = Af / sqrt (1+( f4 / fh ) ^4) ;
printf ( \n Gain m a g n i t u d e av4 a t f 4 i s = %. 2 f \n ,
av4 ) // R e s u l t
f5 =1000; // Freq i n Hz
av5 = Af / sqrt (1+( f5 / fh ) ^4) ;
printf ( \n Gain m a g n i t u d e av5 a t f 5 i s = %. 2 f \n ,
av5 ) // R e s u l t
f6 =3000; // Freq i n Hz
57

25 av6 = Af / sqrt (1+( f6 / fh ) ^4) ;


26 printf ( \n Gain m a g n i t u d e av6 a t f 6
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

i s = %. 2 f \n ,
av6 ) // R e s u l t
f7 =7000; // Freq i n Hz
av7 = Af / sqrt (1+( f7 / fh ) ^4) ;
printf ( \n Gain m a g n i t u d e av7 a t f 7 i s = %. 2 f \n ,
av7 ) // R e s u l t
f8 =10000; // Freq i n Hz
av8 = Af / sqrt (1+( f8 / fh ) ^4) ;
printf ( \n Gain m a g n i t u d e av8 a t f 8 i s = %. 2 f \n ,
av8 ) // R e s u l t
f9 =30000; // Freq i n Hz
av9 = Af / sqrt (1+( f9 / fh ) ^4) ;
printf ( \n Gain m a g n i t u d e av9 a t f 9 i s = %. 5 f \n ,
av9 ) // R e s u l t
f10 =100000; // Freq i n Hz
av10 = Af / sqrt (1+( f10 / fh ) ^4) ;
printf ( \n Gain m a g n i t u d e av10 a t f 1 0 i s = %. 6 f \n ,
av10 ) // R e s u l t
x =[ f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 ];
y =[ av1 av2 av3 av4 av5 av6 av7 av8 av9 av10 ];
gainplot (x , y ) ;
title ( F r e q u e n c y R e s p o n s e ) ;
xlabel ( F r e q u e n c y ( Hz ) ) ;
ylabel ( V o l t a g e g a i n ( dB ) ) ;

Scilab code Exa 7.5.a Design of highpass filter


1
2
3
4
5

//
//
//
//
//

Chapter7
Page . No263
Example 7 5 a
Design of highpass f i l t e r
Given
58

6
7
8
9
10
11
12
13
14
15
16

clear ; clc ;
fh =1*10^3; // Cut o f f f r e q u e n c y
Af =2; // Passband g a i n o f t h e f i l t e r
C =0.01*10^ -6; // Assumption
R =1/(2* %pi * fh * C ) ;
printf ( \n R e s i s t a n c e R i s = %. 1 f ohm \n ,R ) //
Result
printf ( \n Use 20 kohm POT a s R \n )
R1 =10*10^3; // Assumption
printf ( \n R e s i s t a n c e R1 i s = %. 1 f ohm \n , R1 )
Rf = R1 ; // S i c e p a s s b a n d g a i n i s 2 , R1 and Rf must be
equal
printf ( \n R e s i s t a n c e Rf i s = %. 1 f ohm \n , Rf )

Scilab code Exa 7.5.b Frequency response of highpass filter


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

// C h a p t e r 7
// Page . No263
// E x a m p l e 7 5 b
// F r e q u e n c y r e s p o n s e o f h i g h p a s s f i l t e r
// Given
clear ; clc ;
Af =2; // Passband g a i n o f t h e f i l t e r
fl =1000; // Cut o f f f r e q u e n c y
f1 =100; // I n p u t f r e q i n Hz
av1 =( Af *( f1 / fl ) ) / sqrt (1+( f1 / fl ) ^2) ;
printf ( \n Gain m a g n i t u d e av1 a t f 1 i s = %. 2 f \n ,
av1 ) // R e s u l t
f2 =200; // Freq i n Hz
av2 =( Af *( f2 / fl ) ) / sqrt (1+( f2 / fl ) ^2) ;
printf ( \n Gain m a g n i t u d e av2 a t f 2 i s = %. 2 f \n ,
av2 ) // R e s u l t
f3 =400; // Freq i n Hz
59

16 av3 =( Af *( f3 / fl ) ) / sqrt (1+( f3 / fl ) ^2) ;


17 printf ( \n Gain m a g n i t u d e av3 a t f 3 i s = %. 2 f \n ,
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

av3 ) // R e s u l t
f4 =700; // Freq i n Hz
av4 =( Af *( f4 / fl ) ) / sqrt (1+( f4 / fl ) ^2) ;
printf ( \n Gain m a g n i t u d e av4 a t f 4 i s = %. 2 f \n ,
av4 ) // R e s u l t
f5 =1000; // Freq i n Hz
av5 =( Af *( f5 / fl ) ) / sqrt (1+( f5 / fl ) ^2) ;
printf ( \n Gain m a g n i t u d e av5 a t f 5 i s = %. 2 f \n ,
av5 ) // R e s u l t
f6 =3000; // Freq i n Hz
av6 =( Af *( f6 / fl ) ) / sqrt (1+( f6 / fl ) ^2) ;
printf ( \n Gain m a g n i t u d e av6 a t f 6 i s = %. 2 f \n ,
av6 ) // R e s u l t
f7 =7000; // Freq i n Hz
av7 =( Af *( f7 / fl ) ) / sqrt (1+( f7 / fl ) ^2) ;
printf ( \n Gain m a g n i t u d e av7 a t f 7 i s = %. 2 f \n ,
av7 ) // R e s u l t
f8 =10000; // Freq i n Hz
av8 =( Af *( f8 / fl ) ) / sqrt (1+( f8 / fl ) ^2) ;
printf ( \n Gain m a g n i t u d e av8 a t f 8 i s = %. 2 f \n ,
av8 ) // R e s u l t
f9 =30000; // Freq i n Hz
av9 =( Af *( f9 / fl ) ) / sqrt (1+( f9 / fl ) ^2) ;
printf ( \n Gain m a g n i t u d e av9 a t f 9 i s = %. 2 f \n ,
av9 ) // R e s u l t
f10 =100000; // Freq i n Hz
av10 =( Af *( f10 / fl ) ) / sqrt (1+( f10 / fl ) ^2) ;
printf ( \n Gain m a g n i t u d e av10 a t f 1 0 i s = %. 2 f \n ,
av10 ) // R e s u l t
x =[ f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 ];
y =[ av1 av2 av3 av4 av5 av6 av7 av8 av9 av10 ];
gainplot (x , y ) ;
title ( F r e q u e n c y R e s p o n s e ) ;
xlabel ( F r e q u e n c y ( Hz ) ) ;
ylabel ( V o l t a g e g a i n ( dB ) ) ;

60

Scilab code Exa 7.6.a Determination of low cutoff frequency


1
2
3
4
5
6
7
8
9
10
11
12

// C h a p t e r 7
// Page . No264
// E x a m p l e 7 6
// D e t e r m i n a t i o n o f low c u t o f f f r e q u e n c y
// Given
clear ; clc ;
R2 =33*10^3;
R3 = R2 ;
C2 =0.0047*10^ -6;
C3 = C2 ;
fl =1/(2* %pi * sqrt ( R2 * R3 * C2 * C3 ) ) ;
printf ( \n Low c u t o f f f r e q f l i s = %. 1 f Hz \n , fl )
// R e s u l t

Scilab code Exa 7.6.b Frequency response of second order highpass filter
1
2
3
4
5
6
7
8
9

//
//
//
//

Chapter7
Page . No264
Example 7 6 b
Frequency r e s p o n s e o f second order highpass
filter
// Given
clear ; clc ;
Af =1.586; // Passband g a i n o f t h e f i l t e r
fl =1000; // Cut o f f f r e q u e n c y
f1 =100; // I n p u t f r e q i n Hz
61

10 av1 = Af / sqrt (1+( fl / f1 ) ^4) ;


11 printf ( \n Gain m a g n i t u d e av1 a t f 1

%. 5 f \n ,

12
13
14

%. 4 f \n ,

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

is =
av1 ) // R e s u l t
f2 =200; // Freq i n Hz
av2 = Af / sqrt (1+( fl / f2 ) ^4) ;
printf ( \n Gain m a g n i t u d e av2 a t f 2 i s =
av2 ) // R e s u l t
f3 =700; // Freq i n Hz
av3 = Af / sqrt (1+( fl / f3 ) ^4) ;
printf ( \n Gain m a g n i t u d e av3 a t f 3 i s =
av3 ) // R e s u l t
f4 =1000; // Freq i n Hz
av4 = Af / sqrt (1+( fl / f4 ) ^4) ;
printf ( \n Gain m a g n i t u d e av4 a t f 4 i s =
av4 ) // R e s u l t
f5 =3000; // Freq i n Hz
av5 = Af / sqrt (1+( fl / f5 ) ^4) ;
printf ( \n Gain m a g n i t u d e av5 a t f 5 i s =
av5 ) // R e s u l t
f6 =7000; // Freq i n Hz
av6 = Af / sqrt (1+( fl / f6 ) ^4) ;
printf ( \n Gain m a g n i t u d e av6 a t f 6 i s =
av6 ) // R e s u l t
f7 =10000; // Freq i n Hz
av7 = Af / sqrt (1+( fl / f7 ) ^4) ;
printf ( \n Gain m a g n i t u d e av7 a t f 7 i s =
av7 ) // R e s u l t
f8 =30000; // Freq i n Hz
av8 = Af / sqrt (1+( fl / f8 ) ^4) ;
printf ( \n Gain m a g n i t u d e av8 a t f 8 i s =
av8 ) // R e s u l t
f9 =100000; // Freq i n Hz
av9 = Af / sqrt (1+( fl / f9 ) ^4) ;
printf ( \n Gain m a g n i t u d e av9 a t f 9 i s =
av9 ) // R e s u l t
x =[ f1 f2 f3 f4 f5 f6 f7 f8 f9 ];
y =[ av1 av2 av3 av4 av5 av6 av7 av8 av9 ];
gainplot (x , y ) ;
62

%. 4 f \n ,

%. 4 f \n ,

%. 4 f \n ,

%. 4 f \n ,

%. 4 f \n ,

%. 4 f \n ,

%. 4 f \n ,

39
40
41

title ( F r e q u e n c y R e s p o n s e ) ;
xlabel ( F r e q u e n c y ( Hz ) ) ;
ylabel ( V o l t a g e g a i n ( dB ) ) ;

Scilab code Exa 7.7.a Design of wide bandpass filter


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

// C h a p t e r 7
// Page . No270
// E x a m p l e 7 7 a
// D e s i g n o f w i d e b a n d p a s s f i l t e r
// Given
clear ; clc ;
fl =200; // Low c u t o f f f r e q i n Hz
fh =1*10^3; // High c u t o f f f r e q i n Hz
C1 =0.01*10^ -6; // Assumption
R1 =1/(2* %pi * fh * C1 ) ;
printf ( \n R e s i s t a n c e R1 i s = %. 1 f ohm \n , R1 ) //
Result
C =0.05*10^ -6;
R =1/(2* %pi * fl * C ) ;
printf ( \n R e s i s t a n c e R i s = %. 1 f ohm \n , R ) //
Result
printf ( \n Bandpass Gain Af i s = 4 \n ) // S i n c e
g a i n o f h i g h p a s s and l o w p a s s i s s e t t o 2
R1 =10*10^3; // Assumption
printf ( \n R e s i s t a n c e R1 i s = %. 1 f ohm \n , R1 )
Rf = R1 ; // S i c e p a s s b a n d g a i n i s 2 , R1 and Rf must be
equal
printf ( \n R e s i s t a n c e Rf i s = %. 1 f ohm \n , Rf )

63

Scilab code Exa 7.7.b Frequency response of bandpass filter


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

// C h a p t e r 7
// Page . No270
// E x a m p l e 7 7 b
// F r e q u e n c y r e s p o n s e o f b a n d p a s s f i l t e r
// Given
clear ; clc ;
Aft =4; // Passband g a i n o f t h e f i l t e r
fl =200; // Lower Cut o f f f r e q u e n c y
fh =1000; // H i g h e r Cut o f f f r e q u e n c y
f1 =10; // I n p u t f r e q i n Hz
av1 =( Aft *( f1 / fl ) ) / sqrt ((1+( f1 / fl ) ^2) *(1+( f1 / fh ) ^2) ) ;
printf ( \n Gain m a g n i t u d e av1 a t f 1 i s = %. 4 f \n ,
av1 ) // R e s u l t
f2 =30; // Freq i n Hz
av2 =( Aft *( f2 / fl ) ) / sqrt ((1+( f2 / fl ) ^2) *(1+( f2 / fh ) ^2) ) ;
printf ( \n Gain m a g n i t u d e av2 a t f 2 i s = %. 4 f \n ,
av2 ) // R e s u l t
f3 =100; // Freq i n Hz
av3 =( Aft *( f3 / fl ) ) / sqrt ((1+( f3 / fl ) ^2) *(1+( f3 / fh ) ^2) ) ;
printf ( \n Gain m a g n i t u d e av3 a t f 3 i s = %. 4 f \n ,
av3 ) // R e s u l t
f4 =200; // Freq i n Hz
av4 =( Aft *( f4 / fl ) ) / sqrt ((1+( f4 / fl ) ^2) *(1+( f4 / fh ) ^2) ) ;
printf ( \n Gain m a g n i t u d e av4 a t f 4 i s = %. 4 f \n ,
av4 ) // R e s u l t
f5 =447.2; // Freq i n Hz
av5 =( Aft *( f5 / fl ) ) / sqrt ((1+( f5 / fl ) ^2) *(1+( f5 / fh ) ^2) ) ;
printf ( \n Gain m a g n i t u d e av5 a t f 5 i s = %. 4 f \n ,
av5 ) // R e s u l t
f6 =700; // Freq i n Hz
64

26 av6 =( Aft *( f6 / fl ) ) / sqrt ((1+( f6 / fl ) ^2) *(1+( f6 / fh ) ^2) ) ;


27 printf ( \n Gain m a g n i t u d e av6 a t f 6 i s = %. 4 f \n ,
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

av6 ) // R e s u l t
f7 =1000; // Freq i n Hz
av7 =( Aft *( f7 / fl ) ) / sqrt ((1+( f7 / fl ) ^2) *(1+( f7 / fh ) ^2) ) ;
printf ( \n Gain m a g n i t u d e av7 a t f 7 i s = %. 4 f \n ,
av7 ) // R e s u l t
f8 =2000; // Freq i n Hz
av8 =( Aft *( f8 / fl ) ) / sqrt ((1+( f8 / fl ) ^2) *(1+( f8 / fh ) ^2) ) ;
printf ( \n Gain m a g n i t u d e av8 a t f 8 i s = %. 4 f \n ,
av8 ) // R e s u l t
f9 =7000; // Freq i n Hz
av9 =( Aft *( f9 / fl ) ) / sqrt ((1+( f9 / fl ) ^2) *(1+( f9 / fh ) ^2) ) ;
printf ( \n Gain m a g n i t u d e av9 a t f 9 i s = %. 4 f \n ,
av9 ) // R e s u l t
f10 =10000; // Freq i n Hz
av10 =( Aft *( f10 / fl ) ) / sqrt ((1+( f10 / fl ) ^2) *(1+( f10 / fh )
^2) ) ;
printf ( \n Gain m a g n i t u d e av10 a t f 1 0 i s = %. 4 f \n ,
av10 ) // R e s u l t
x =[ f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 ];
y =[ av1 av2 av3 av4 av5 av6 av7 av8 av9 av10 ];
gainplot (x , y ) ;
title ( F r e q u e n c y R e s p o n s e ) ;
xlabel ( F r e q u e n c y ( Hz ) ) ;
ylabel ( V o l t a g e g a i n ( dB ) ) ;

Scilab code Exa 7.7.c Calculation of quality factor


1
2
3
4

//
//
//
//

Chapter7
Page . No270
Example 7 7 c
Calculation of quality factor
65

5 // Given
6 clear ; clc ;
7 fh =1*10^3; // H i g h e r cut o f f f r e q u e n c y
8 fl =200; // Lower cut o f f f r e q u e n c y
9 fc = sqrt ( fl * fh ) ; // C e n t e r f r e q u e n c y
10 printf ( \n C e n t e r f r e q u e n c y f c i s = %. 1 f Hz \n , fc )

// R e s u l t
11 Q = fc /( fh - fl ) ; // Q u a l i t y f a c t o r
12 printf ( \n Q u a l i t y f a c t o r Q i s = %. 2 f

\n ,Q ) //

Result

Scilab code Exa 7.8.a Design of narrow bandpass filter


// C h a p t e r 7
// Page . No272
// E x a m p l e 7 8 a
// D e s i g n o f n a r r o w b a n d p a s s f i l t e r
// Given
clear ; clc ;
fc =1*10^3; // C e n t e r f r e q u e n c y
Q =3; // Q u a l i t y f a c t o r
Af =10; // Passband g a i n
C1 =0.01*10^ -6; // Assumption
C2 = C1 ;
R1 = Q /(2* %pi * fc * C1 * Af ) ;
R2 = Q /(2* %pi * fc * C1 *(2* Q ^2 - Af ) ) ;
R3 = Q /( %pi * fc * C1 ) ;
printf ( \n R e s i s t a n c e R1 i s = %. 1 f ohm \n , R1 ) //
Result
16 printf ( \n R e s i s t a n c e R2 i s = %. 1 f ohm \n , R2 ) //
Result
17 printf ( \n R e s i s t a n c e R3 i s = %. 1 f ohm \n , R3 ) //
Result

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

66

Scilab code Exa 7.8.b Design of narrow bandpass filter


1 // C h a p t e r 7
2 // Page . No272
3 // E x a m p l e 7 8 a
4 // D e s i g n o f n a r r o w b a n d p a s s f i l t e r
5 // Given
6 clear ; clc ;
7 fc0 =1*10^3; // O r i g i n a l c e n t e r f r e q u e n c y
8 fc1 =1.5*10^3; // New c e n t e r f r e q u e n c y
9 R2 =5.97*10^3; // O r i g i n a l r e s i s t a n c e
10 R2new = R2 *( fc0 / fc1 ) ^2;
11 printf ( \n R e s i s t a n c e R1 i s = %. 1 f ohm \n , R2new )

// R e s u l t

Scilab code Exa 7.9 Design of wide bandreject filter


1
2
3
4
5
6
7
8
9
10

// C h a p t e r 7
// Page . No274
// E x a m p l e 7 9
// D e s i g n o f w i d e b a n d r e j e c t f i l t e r
// Given
clear ; clc ;
fh =200; // Low c u t o f f f r e q i n Hz
fl =1*10^3; // High c u t o f f f r e q i n Hz
C2 =0.01*10^ -6; // Assumption
R2 =1/(2* %pi * fl * C2 ) ;
67

11
12
13
14
15
16
17
18
19

printf ( \n R e s i s t a n c e R2 o f h i g h p a s s s e c t i o n i s = %
. 1 f ohm \n , R2 ) // R e s u l t
C =0.05*10^ -6;
R =1/(2* %pi * fh * C ) ;
printf ( \n R e s i s t a n c e R o f l o w p a s s s e c t i o n i s = %. 1 f
ohm \n , R ) // R e s u l t
printf ( \n Bandpass Gain Af i s = 4 \n ) // S i n c e
g a i n o f h i g h p a s s and l o w p a s s i s s e t t o 2
R1 =10*10^3; // Assumption
printf ( \n R e s i s t a n c e R1 i s = %. 1 f ohm \n , R1 )
Rf = R1 ; // S i n c e p a s s b a n d g a i n i s 2 , R1 and Rf must be
equal
printf ( \n R e s i s t a n c e Rf i s = %. 1 f ohm \n , Rf )

Scilab code Exa 7.10 Design of notch filter


1 // C h a p t e r 7
2 // Page . No277
3 // E x a m p l e 7 1 0
4 // D e s i g n o f n o t c h f i l t e r
5 // Given
6 clear ; clc ;
7 fn =60; // Notcho u t f r e q u e n c y i n Hz
8 C =0.068*10^ -6; // Assumption
9 R =1/(2* %pi * fn * C ) ;
10 printf ( \n R e s i s t a n c e R i s = %. 1 f ohm \n ,R ) //

Result

Scilab code Exa 7.11 Phase angle


68

1
2
3
4
5
6
7
8
9
10
11

// C h a p t e r 7
// Page . No279
// E x a m p l e 7 1 1
// Phase a n g l e
// Given
clear ; clc ;
f =1*10^3; // I n p u t f r e q u e n c y i n Hz
C =0.01*10^ -6;
R =15.9*10^3;
phi = -2* atand (2* %pi * f * C * R ) ; // Phase a n g l e
printf ( \n Phase a n g l e p h i i s = %. f deg \n , phi ) //
Result

Scilab code Exa 7.12 Design of phase shift oscillator


1 // C h a p t e r 7
2 // Page . No282
3 // E x a m p l e 7 1
4 // D e s i g n o f p h a s e s h i f t o s c i l l a t o r
5 // Given
6 clear ; clc ;
7 fo =200; // F r e q u e n c y o f o s c i l l a t i o n
8 C =0.1*10^ -6; // Assumption
9 R =0.065/( fo * C ) ;
10 printf ( \n R e s i s t a n c e R i s = %. 1 f ohm \n ,R ) //
11
12
13
14
15

Result
printf ( \n Use R e s i s t a n c e R a s 3 . 3 kohm \n )
R =3.3*10^3;
R1 =10* R ; // To p r e v e n t l o a d i n g o f a m p l i f i e r
Rf =29* R1 ;
printf ( \n R e s i s t a n c e Rf i s = %. 1 f ohm \n , Rf ) //
Result

69

Scilab code Exa 7.13 Design of wein bridge oscillator


1 // C h a p t e r 7
2 // Page . No282
3 // E x a m p l e 7 1 3
4 // D e s i g n o f w e i n b r i d g e o s c i l l a t o r
5 // Given
6 clear ; clc ;
7 fo =965; // F r e q u e n c y o f o s c i l l a t i o n
8 C =0.05*10^ -6; // Assumption
9 R =0.159/( fo * C ) ;
10 printf ( \n R e s i s t a n c e R i s = %. 1 f ohm \n ,R ) //

Result
11 R1 =12*10^3; // Assumption
12 Rf =2* R1 ;
13 printf ( \n R e s i s t a n c e Rf i s = %. 1 f ohm \n , Rf ) //

Result

Scilab code Exa 7.14 Design of quadrature oscillator


1 // C h a p t e r 7
2 // Page . No285
3 // E x a m p l e 7 1 4
4 // D e s i g n o f q u a d r a t u r e o s c i l l a t o r
5 // Given
6 clear ; clc ;
7 fo =159; // F r e q u e n c y o f o s c i l l a t i o n
8 C =0.01*10^ -6; // Assumption

70

9 R =0.159/( fo * C ) ;
10 printf ( \n R e s i s t a n c e

v a l u e s R1 , R2 , R3 i s = %. 1 f ohm
\n ,R ) // R1=R2=R3=R
11 printf ( \n C a p a c i t a n c e v a l u e s C1 , C2 , C3 i s = %. 8 f
f a r a d \n ,C ) // C1=C2=C3=C

Scilab code Exa 7.15 Design of squarewave oscillator


// C h a p t e r 7
// Page . No287
// E x a m p l e 7 1 5
// D e s i g n o f s q u a r e w a v e o s c i l l a t o r
// Given
clear ; clc ;
fo =1*10^3;; // F r e q u e n c y o f o s c i l l a t i o n
R1 =10*10^3; // Assumption
C =0.05*10^ -6; // Assumption
R2 =1.16* R1 ;
printf ( \n R e s i s t a n c e R2 i s = %. 1 f ohm \n , R2 ) //
Result
12 R =1/(2* fo * C ) ;
13 printf ( \n R e s i s t a n c e R i s = %. 1 f ohm \n ,R ) //
Result

1
2
3
4
5
6
7
8
9
10
11

Scilab code Exa 7.16 Design of triangular wave generator


1
2
3

// C h a p t e r 7
// Page . No291
// E x a m p l e 7 1 6
71

4
5
6
7
8
9
10
11
12
13
14
15
16

// D e s i g n o f t r i a n g u l a r wave g e n e r a t o r
// Given
clear ; clc ;
fo =2*10^3; // F r e q u e n c y o f o s c i l l a t i o n
vo =7; // Output v o l t a g e
Vsat =14; // S a t u r a t i o n v o l t a g e f o r opamp 1 4 5 8
R3 =40*10^3; // Assumption
R2 =( vo * R3 ) /(2* Vsat ) ;
printf ( \n R e s i s t a n c e R2 i s = %. 1 f ohm \n , R2 ) //
Result
k = R3 /(4* fo * R2 ) ; // U s i n g f o=R3 / ( 4 R1C1R2 ) , k=R1C1 ;
C1 =0.05*10^ -6; // Assumption
R1 = k / C1 ;
printf ( \n R e s i s t a n c e R1 i s = %. 1 f ohm \n , R1 ) //
Result

Scilab code Exa 7.17.a Nominal frequency


// C h a p t e r 7
// Page . No296
// E x a m p l e 7 1 7 a
// Nominal f r e q u e n c y
// Given
clear ; clc ;
R2 =1.5*10^3;
R1 =10*10^3;
R3 =10*10^3;
C1 =0.001*10^ -6;
V =12; // S u p p l y v o l t a g e
Vc = R3 * V /( R2 + R3 ) ; // U s i n g v o l t a g e d i v i d e r r u l e
printf ( \n T e r m i n a l v o l t a g e Vc i s = %. 2 f V \n , Vc )
// R e s u l t
14 fo =2*( V - Vc ) /( V * R1 * C1 ) ;
1
2
3
4
5
6
7
8
9
10
11
12
13

72

15

printf ( \n Approximate Nominal f r e q f o i s = %. 1 f Hz


\n , fo ) // R e s u l t

Scilab code Exa 7.17.b Modulation in output frequency


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

// C h a p t e r 7
// Page . No296
// E x a m p l e 7 1 7 b
// M o d u l a t i o n i n o u t p u t f r e q u e n c y
// Given
clear ; clc ;
R2 =1.5*10^3;
R1 =10*10^3;
R3 =10*10^3;
C1 =0.001*10^ -6;
V =12; // S u p p l y v o l t a g e
Vc1 =9.5;
Vc2 =11.5;
fo1 =2*( V - Vc1 ) /( V * R1 * C1 ) ;
printf ( \n Approximate Nominal f r e q f o 1 i s = %. 1 f Hz
\n , fo1 ) // R e s u l t
fo2 =2*( V - Vc2 ) /( V * R1 * C1 ) ;
printf ( \n Approximate Nominal f r e q f o 2 i s = %. 1 f Hz
\n , fo2 ) // R e s u l t
delta_fo = fo1 - fo2 ; // Change i n o u t p u t f r e q
printf ( \n Change i n o u t p u t f r e q d e l t a f o i s = %. 1 f
Hz \n , delta_fo ) // R e s u l t

73

Chapter 8
Comparators and Converters

Scilab code Exa 8.1 Threshold voltage


1 // C h a p t e r 8
2 // Page . No320 , F i g u r e . No 8 . 4 ( a )
3 // E x a m p l e 8 1
4 // T h r e s h o l d v o l t a g e
5 // Given
6 clear ; clc ;
7 R1 =100; R2 =56*10^3;
8 vin =1; // I n p u t v o l t a g e i n v o l t
9 pos_Vsat =14; // P o s i t i v e s a t u r a t i o n v o l t a g e i n v o l t
10 neg_Vsat = -14; // N e g a t i v e s a t u r a t i o n v o l t a g e i n v o l t
11 Vut =( R1 /( R1 + R2 ) ) *( pos_Vsat ) ; // Upper t h r e s h o l d
12
13
14
15
16
17

voltage
printf ( \n Upper t h r e s h o l d v o l t a g e i s = %. 4 f V \n ,
Vut ) // R e s u l t
Vlt =( R1 /( R1 + R2 ) ) *( neg_Vsat ) ; // Lower t h r e s h o l d
voltage
printf ( \n Lower t h r e s h o l d v o l t a g e i s = %. 4 f V \n ,
Vlt ) // R e s u l t
t =0:0.1:2* %pi ;
vut =0.5* sin ( t ) ;
subplot (2 ,1 ,1) ;
74

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

plot (t , vut ) ;
title ( I n p u t V o l t a g e ) ;
xlabel ( t ) ;
ylabel ( Vin ) ;
c =0;
for i =0:0.1:2* %pi
c = c +1;
end
for i =1: c ;
if vut ( i ) >0.025
v ( i ) = -14;
else if vut ( i ) < -0.025
v ( i ) =14;
end
end
end
subplot (2 ,1 ,2) ;
plot (t , v ) ;
title ( Output Waveform ) ;
xlabel ( t ) ;
ylabel ( Vo ) ;

Scilab code Exa 8.2 Output voltage swing


1 // C h a p t e r 8
2 // Page . No326 , F i g u r e . No 8 . 7 ( a )
3 // E x a m p l e 8 2
4 // Output v o l t a g e s w i n g
5 // Given
6 clear ; clc ;
7 vin =5*10^ -3;
8 R =100;
9 Vd1 = -0.7; // Output v o l t a g e d u r i n g

75

positive half

10
11

12

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

c y c l e of the input
Vd2 =5.1; // Output v o l t a g e d u r i n g n e g a t i v e h a l f
c y c l e of the input
printf ( \n Output v o l t a g e d u r i n g p o s i t i v e h a l f c y c l e
o f t h e i n p u t i s = %. 1 f V \n , Vd1 ) // S i n c e z e n e r
diode i s forward biased
printf ( \n Output v o l t a g e d u r i n g n e g a t i v e h a l f c y c l e
o f t h e i n p u t i s = %. 1 f V \n , Vd2 ) // S i n c e z e n e r
d i o d e i s r e v e r s e b i a s e d
t =0:0.1:2* %pi ;
vut =0.5* sin ( t ) ;
subplot (2 ,1 ,1) ;
plot (t , vut ) ;
title ( I n p u t V o l t a g e ) ;
xlabel ( t ) ;
ylabel ( Vin ) ;
c =1;
for t =0:0.1:2* %pi
if t < %pi
v ( c ) = -0.7;
else
v ( c ) =5.1;
end
c = c +1;
subplot (2 ,1 ,2) ;
plot ( v ) ;
end
title ( Output Waveform ) ;
xlabel ( t ) ;
ylabel ( Vo ) ;

Scilab code Exa 8.3 Output frequencies

76

1 // C h a p t e r 8
2 // Page . No320 , F i g u r e . No 8.12
3 // E x a m p l e 8 3
4 // Output f r e q u e n c i e s
5 // Given
6 clear ; clc ;
7 Vin =2; // I n p u t v o l t a g e
8 Fo1 =2*10^3; // Output f r e q Fo when Vin=2V
9 Fo2 =1*10^3; // Output f r e q Fo /2 when Vin=2V
10 printf ( \n Output f r e q Fo i s = %. f Hz \n , Fo1 ) //
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

Result
printf ( \n Output f r e q Fo /2 i s = %. f Hz \n , Fo2 ) //
Result
count =1;
for i =1:50;
// f o r 5 c y c l e s
if count <4;
v ( i ) =5;
else
v ( i ) =0;
end
if count <10
count = count +1;
else
count =1;
end
end
subplot (2 ,1 ,1) ;
plot ( v ) ;
title ( Output Waveform ) ;
xlabel ( t ( m i c r o s e c ) ) ;
ylabel ( P u l s e f r e q o u t p u t , Fo (V) ) ;
for i =1:50;
// f o r 5 c y c l e s
if count <10;
v ( i ) =5;
else
v ( i ) =0;
end
if count <20
77

37
count = count +1;
38 else
39
count =1;
40 end
41 end
42 subplot (2 ,1 ,2) ;
43 plot ( v ) ;
44 title ( Output Waveform ) ;
45 xlabel ( t ( m i c r o s e c ) ) ;
46 ylabel ( P u l s e f r e q o u t p u t , Fo / 2 (V) ) ;

Scilab code Exa 8.4 Output voltage


1 // C h a p t e r 8
2 // Page . No335 , F i g u r e . No 8 . 1 4 ( a )
3 // E x a m p l e 8 4
4 // Output v o l t a g e
5 // Given
6 clear ; clc ;
7 Vo =2.8; // At Finmax o f 10 kHz
8 Vo1 = Vo /10; // Output v o l t a g e a t Fin=1kHz
9 printf ( \n Output v o l t a g e i s = %. 2 f V \n , Vo1 ) //

Result

Scilab code Exa 8.5 Output voltage


1
2
3

// C h a p t e r 8
// Page . No335 , F i g u r e . No 8 . 2 5 ( a )
// E x a m p l e 8 5
78

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

// Output v o l t a g e
// Given
clear ; clc ;
vin =100*10^ -3;
t =0:0.1:2* %pi ;
i =1;
for t =0:0.1:2* %pi ;
if t <= %pi
v ( i ) = vin * sin ( t ) ;
else
v ( i ) =0;
end
i = i +1;
end
t =0:0.1:2* %pi ;
plot (t , v )

79

Chapter 9
Specialized IC Applications

Scilab code Exa 9.1 Second order inverting butterworth lowpass filter
1 // C h a p t e r 9
2 // Page . No387
3 // E x a m p l e 9 1
4 // S e c o n d o r d e r i n v e r t i n g b u t t e r w o r t h l o w p a s s f i l t e r
5 // Given
6 clear ; clc ;
7 dc_gain =5;
8 f1 =2*10^3; // C u t o f f f r e q i n Hz
9 Q =10; // F i g u r e o f m e r i t
10 R2 =(316*10^3) /10; // R e s i s t a n c e R2
11 printf ( \n R e s i s t a n c e R2 i s = %. 1 f ohm \n , R2 ) //
12
13
14
15
16
17
18

Result
R3 =(100*10^3) /((3.16* Q ) -1) ;
printf ( \n R e s i s t a n c e R3 i s
Result
printf ( \n R e s i s t a n c e R1 i s
R4 =(5.03*10^7) / f1 ;
printf ( \n R e s i s t a n c e R4 i s
Result
R5 = R4 ;
printf ( \n R e s i s t a n c e R5 i s
80

= %. 1 f ohm \n , R3 ) //
Open \n ) // R e s u l t
= %. 1 f ohm \n , R4 ) //

= %. 1 f ohm \n , R5 ) //

19
20
21
22
23

Result
R6 =1.8*10^3; // Assumption
R7 = dc_gain * R6 ;
printf ( \n R e s i s t a n c e R7 i s = %. 1 f ohm \n , R7 ) //
R e s u l t and i t s a p o t e n t i o m e t e r
R8 =( R6 * R7 ) /( R6 + R7 ) ;
printf ( \n R e s i s t a n c e R8 i s = %. 3 f ohm \n , R8 ) //
Result

Scilab code Exa 9.2 Second order inverting butterworth bandpass filter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

//
//
//
//

Chapter9
Page . No388
Example 9 2
Second o r d e r i n v e r t i n g b u t t e r w o r t h bandpass
filter
// Given
clear ; clc ;
f1 =5*10^3; // C e n t e r f r e q i n Hz
Q =10; // F i g u r e o f m e r i t
R2 =100*10^3; // C o n s t a n t f o r bandp a s s f i l t e r
printf ( \n R e s i s t a n c e R2 i s = %. 1 f ohm \n , R2 ) //
Result
R3 =(100*10^3) /((3.48* Q ) -1) ;
printf ( \n R e s i s t a n c e R3 i s = %. 1 f ohm \n , R3 ) //
Result
printf ( \n R e s i s t a n c e R1 i s Open \n ) // R e s u l t
R4 =(5.03*10^7) / f1 ;
printf ( \n R e s i s t a n c e R4 i s = %. 1 f ohm \n , R4 ) //
A p p r o x i m a t e l y 10 kohm
R5 = R4 ;
printf ( \n R e s i s t a n c e R5 i s = %. 1 f ohm \n , R5 ) //
A p p r o x i m a t e l y 10 kohm and i t s a p o t e n t i o m e t e r
81

Scilab code Exa 9.3 Design of notch filter


1 // C h a p t e r 9
2 // Page . No390
3 // E x a m p l e 9 3
4 // D e s i g n o f n o t c h f i l t e r
5 // Given
6 clear ; clc ;
7 f1 =5*10^3; // n o t c h f r e q i n Hz
8 Q =10; // F i g u r e o f m e r i t
9 R2 =100*10^3; // C o n s t a n t f o r bandp a s s f i l t e r
10 printf ( \n R e s i s t a n c e R2 i s = %. 1 f ohm \n , R2 ) //

Result
11 R3 =(100*10^3) /((3.48* Q ) -1) ;
12 printf ( \n R e s i s t a n c e R3 i s = %. 1 f ohm \n , R3 ) //
13
14
15
16
17
18
19
20
21
22
23

Result
printf ( \n R e s i s t a n c e R1 i s
R4 =(5.03*10^7) / f1 ;
printf ( \n R e s i s t a n c e R4 i s
A p p r o x i m a t e l y 10 kohm
R5 = R4 ;
printf ( \n R e s i s t a n c e R5 i s
A p p r o x i m a t e l y 10 kohm and
R6 =10*10^3; // Assumption
printf ( \n R e s i s t a n c e R6 i s
Result
R7 = R6 ;
printf ( \n R e s i s t a n c e R7 i s
Result
R8 = R6 ;
printf ( \n R e s i s t a n c e R8 i s
Result
82

Open \n ) // R e s u l t
= %. 1 f ohm \n , R4 ) //

= %. 1 f ohm \n , R5 ) //
i t s a potentiometer
= %. 1 f ohm \n , R6 ) //

= %. 1 f ohm \n , R7 ) //

= %. 1 f ohm \n , R8 ) //

24 R9 =( R6 * R7 * R8 ) /( R6 * R7 + R6 * R8 + R7 * R8 ) ; // S i n c e R6 | | R7 | |
25

R8
printf ( \n R e s i s t a n c e R9 i s = %. 1 f ohm \n , R9 ) //
Result

Scilab code Exa 9.4 Second order butterworth lowpass filter


1 // C h a p t e r 9
2 // Page . No398
3 // E x a m p l e 9 4
4 // S e c o n d o r d e r b u t t e r w o r t h l o w p a s s f i l t e r
5 // Given
6 clear ; clc ;
7 f1 =500; // Cut o f f f r e q i n Hz
8 Holp = -2; // Passband g a i n
9 R1 =10*10^3; // Assumption
10 R2 = - R1 * Holp ; // U s i n g Holp=R2/R1 ;
11 printf ( \n R e s i s t a n c e R2 i s = %. 1 f ohm \n , R2 ) //

Result
12 Q =0.707; // F i g u r e o f m e r i t Q i s f i x e d f o r s e c o n d
o r d e r b u t t e r w o r t h lowp a s s f i l t e r
13 R3 = Q * R2 ; // U s i n g Q=R3/R2
14 printf ( \n R e s i s t a n c e R3 i s = %. 1 f ohm \n , R3 ) //
A p p r o x i m a t e l y 15 kohm

Scilab code Exa 9.5 Value of capacitor


1
2

// C h a p t e r 9
// Page . No402 , F i g u r e . No 9 . 1 6 ( a )
83

3 // E x a m p l e 9 5
4 // V a l u e o f c a p a c i t o r
5 // Given
6 clear ; clc ;
7 Ra =10*10^3; // R e s i s t a n c e i n ohm
8 tp =10*10^ -3; // Output p u l s e w i d t h
9 C = tp /(1.1* Ra ) ;
10 printf ( \n C a p a c i t a n c e C i s = %. 9 f f a r a d \n ,C ) //

A p p r o x i m a t e l y 1uF

Scilab code Exa 9.6 Value of resistor


1
2
3
4
5
6
7
8
9
10
11

// C h a p t e r 9
// Page . No402 , F i g u r e . No 9 . 1 6 ( a )
// E x a m p l e 9 6
// V a l u e o f r e s i s t o r
// Given
clear ; clc ;
f =2*10^3; // Freq o f i n p u t t r i g g e r s i g n a l i n Hz
C =0.01*10^ -6;
tp =1.2/ f ;
Ra = tp /(1.1* C ) ;
printf ( \n R e s i s t a n c e Ra i s = %. 1 f ohm \n , Ra ) //
Result

Scilab code Exa 9.7 Value of tc td and f0


1
2

// C h a p t e r 9
// Page . No402 , F i g u r e . No 9 . 2 1 ( a )
84

3
4
5
6
7
8
9
10
11
12
13
14
15
16

// E x a m p l e 9 7
// V a l u e o f t c , t d and f 0
// Given
clear ; clc ;
Ra =2.2*10^3; // R e s i s t a n c e i n ohm
Rb =3.9*10^3; // R e s i s t a n c e i n ohm
C =0.1*10^ -6; // c a p a c i t a n c e i n f a r a d
tc =0.69*( Ra + Rb ) * C ; // C h a r g i n g t i m e o f t h e c a p a c i t o r
printf ( \n C h a r g i n g t i m e o f t h e c a p a c i t o r i s = %. 6 f
s e c \n , tc ) // R e s u l t
td =0.69* Rb * C ; // D i s c h a r g i n g t i m e o f t h e c a p a c i t o r
printf ( \n D i s c h a r g i n g t i m e o f t h e c a p a c i t o r i s = %
. 6 f s e c \n , td ) // R e s u l t
T = tc + td ;
fo =1/ T // Freq o f o s c i l l a t i o n
printf ( \n Freq o f o s c i l l a t i o n i s = %. 1 f Hz \n , fo )
// R e s u l t

Scilab code Exa 9.8 Freq of free running ramp generator


1
2
3
4
5
6
7
8
9
10
11
12
13

// C h a p t e r 9
// Page . No412 , F i g u r e . No 9 . 2 4 ( a )
// E x a m p l e 9 8
// Freq o f f r e e r u n n i n g ramp g e n e r a t o r
// Given
clear ; clc ;
R =10*10^3; // R e s i s t a n c e i n ohm
Vcc =5 // S u p p l y v o l t a g e i n v o l t
Vbe =0.7 // Base t o e m i t t e r v o l t a g e i n v o l t
C =0.05*10^ -6; // C a p a c i t a n c e i n f a r a d
Ic =( Vcc - Vbe ) / R ; // C o l l e c t o r c u r r e n t i n ampere
fo =(3* Ic ) /( Vcc * C ) ;
printf ( \n Freq o f f r e e r u n n i n g ramp g e n e r a t o r i s =
85

%. 1 f Hz \n , fo ) // R e s u l t

Scilab code Exa 9.9 Value of fout fl fc


1 // C h a p t e r 9
2 // Page . No423 , F i g u r e . No 9 . 3 3 ( a )
3 // E x a m p l e 9 9
4 // V a l u e o f f o u t , f l , f c
5 // Given
6 clear ; clc ;
7 R1 =12*10^3; // R e s i s t a n c e i n ohm
8 V_plus =10 // S u p p l y v o l t a g e i n v o l t
9 V_minus = -10 // S u p p l y v o l t a g e i n v o l t
10 C1 =0.01*10^ -6; // C a p a c i t a n c e i n f a r a d
11 C2 =10*10^ -6; // C a p a c i t a n c e i n f a r a d
12 fout =1.2/(4* R1 * C1 ) ;
13 printf ( \n F r e e r u n n i n g f r e q u e n c y o f VCO i s = %. 1 f

Hz \n , fout ) // R e s u l t
14 V = V_plus - V_minus ;
15 fl =(8* fout ) / V ;
16 printf ( \n Lock r a n g e f r e q u e n c y o f VCO i s = %. 1 f Hz

\n , fl ) // R e s u l t
17 fc = sqrt ( fl /(2* %pi *3.6*10^3* C2 ) ) ;
18 printf ( \n C a p t u r e r a n g e f r e q u e n c y o f VCO i s = %. 2 f
Hz \n , fc ) // R e s u l t

Scilab code Exa 9.10 Design of current source


1

// C h a p t e r 9
86

2
3
4
5
6
7
8
9
10
11

12
13
14
15
16
17

// Page . No440
// E x a m p l e 9 1 0
// D e s i g n o f c u r r e n t s o u r c e
// Given
clear ; clc ;
Vr =5; // V o l t a g e i n v o l t
Il =0.25; // Load c u r r e n t i n ampere
Rl =48; // Load r e s i s t a n c e i n ohm
dropout_volt =2; // C o n s t a n t f o r IC7805C
R = Vr / Il ; // Approximate r e s u l t s i c e I q i s n e g l i g i b l e
i n t h e eq . I l =(Vr / I l )+I q where I q i s q u i e s c e n t
current
printf ( \n R e s i s t a n c e R i s = %. f ohm \n ,R ) //
Result
Vl = Rl * Il ;
Vo = Vr + Vl ;
printf ( \n Output v o l t a g e Vo i s = %. f V \n , Vo ) //
Result
Vin = Vo + dropout_volt ;
printf ( \n Min i n p u t v o l t a g e Vin i s = %. f V \n , Vin )
// R e s u l t

Scilab code Exa 9.11 Design of voltage regulator


1
2
3
4
5
6
7
8
9

// C h a p t e r 9
// Page . No444
// E x a m p l e 9 1 1
// D e s i g n o f v o l t a g e r e g u l a t o r
// Given
clear ; clc ;
Vo_min =5; // Min o u t p u t v o l t a g e i n v o l t
Vo_max =12; // Max o u t p u t v o l t a g e i n v o l t
Vref =1.25; // R e f e r e n c e v o l t a g e i n v o l t
87

10 Iadj =100*10^ -6; // A d j u s t m e n t p i n c u r r e n t i n ampere


11 R1 =240; // Assumption
12 R2_min = R1 *( Vo_min - Vref ) /( Vref + Iadj * R1 ) ; // U s i n g
13
14
15
16

17
18

Vo min=V r e f (1+R2/R1 )+I a d j R2


printf ( \n R e s i s t a n c e R2 min i s = %. 1 f ohm \n ,
R2_min ) // R e s u l t
R2_max = R1 *( Vo_max - Vref ) /( Vref + Iadj * R1 ) ; // U s i n g
Vo max=V r e f (1+R2/R1 )+I a d j R2
printf ( \n R e s i s t a n c e R2 max i s = %. 1 f ohm \n ,
R2_max ) // R e s u l t
printf ( \n T h e r e f o r e r e s i s t a n c e s h o u l d be v a r i e d
from R2 min t o R2 max v a l u e s . To do t h i s we t a k e
R2 a s 3kohm p o t e n t i o m e t e r \n )
C2 =1*10^ -6; // Added t o t h e c i r c u i t t o i m p r o v e
transient response
C3 =1*10^ -6; // Added t o t h e c i r c u i t t o o b t a i n h i g h
ripple rejection ratios

Scilab code Exa 9.12 Design of stepdown switching regulator


1 // C h a p t e r 9
2 // Page . No453
3 // E x a m p l e 9 1 2
4 // D e s i g n o f s t e p d o wn s w i t c h i n g r e g u l a t o r
5 // Given
6 clear ; clc ;
7 Iomax =500*10^ -3; // Max o u t p u t c u r r e n t i n ampere
8 Vo =5; // Output v o l t a g e i n v o l t
9 Vd =1.25; // V o l t a g e d r o p a c r o s s t h e power d i o d e i n

volt
10 Vin =12; // I n p u t v o l t a g e i n v o l t
11 Vs =1.1; // Output s a t u r a t i o n v o l t a g e i n v o l t
12 Vripple =50*10^ -3; // Output r i p p l e v o l t a g e i n v o l t
88

13 Vref =1.245; // R e f e r e n c e v o l t a g e i n v o l t
14 Vr2 =1.2; // V o l t a g e a c r o s s r e s i s t a n c e R2 i n v o l t
15 Ipk =2* Iomax ; // S e n s e c u r r e n t i n ampere
16 printf ( \n S e n s e c u r r e n t , I p k i s = %. f A \n , Ipk ) //
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

Result
Rsc =0.33/ Ipk ; // S e n s e r e s i s t a n c e i n ohm
printf ( \n S e n s e r e s i s t a n c e , Rsc i s = %. 2 f ohm \n ,
Rsc ) // R e s u l t
K =( Vo + Vd ) /( Vin - Vs - Vo ) ; // K= t o n / t o f f
printf ( \n C o n s t a n t K = %. 2 f \n ,K ) // R e s u l t
printf ( \n i . e , t o n i s K t i m e s o f t o f f \n )
f =20*10^3; // Assuming o p e r a t i n g f r e q i n Hz
T =1/ f ;
toff = T /2.06; // U s i n g t o n+ t o f f =T and s u b s t i t u t i n g
f o r ton
printf ( \n OFF t i m e p e r i o d , t o f f i s = %. 8 f s e c \n ,
toff ) // R e s u l t
ton =1.06* toff ;
printf ( \n ON t i m e p e r i o d , t o n i s = %. 8 f s e c \n , ton )
// R e s u l t
Ct =45*10^ -5* toff ; // O s c i l l a t o r t i m i n g c a p a c i t a n c e
in farad
printf ( \n O s c i l l a t o r t i m i n g c a p a c i t a n c e , Ct i s = %
. 1 0 f F \n , Ct ) // R e s u l t
L =(( Vo + Vd ) / Ipk ) * toff ; // I n d u c t a n c e i n h e n r y
printf ( \n I n d u c t a n c e , L i s = %. 8 f H \n ,L ) // R e s u l t
Co = Ipk *(( ton + toff ) /(8* Vripple ) ) ; // Output
capacitance in farad
printf ( \n Output c a p a c i t a n c e , Co i s = %. 7 f F \n , Co )
// R e s u l t
I2 =0.1*10^ -3; // Assuming t h e c u r r e n t t h r o u g h R2
R2 = Vref / I2 ; // R e s i s t a n c e R2 i n ohm
printf ( \n R e s i s t a n c e R2 i s = %. 1 f ohm \n , R2 ) //
Result
R2 =12*10^3; // Taking a p p r o x i m a t e v a l u e
R1 =( R2 *( Vo - Vr2 ) ) / Vr2 ; // U s i n g Vr2=(R1Vo ) /R1+R2 ,
voltage divider rule
printf ( \n R e s i s t a n c e R1 i s = %. 1 f ohm \n , R1 ) //
89

Result
40 efficiency =(( Vin - Vs + Vd ) / Vin ) *( Vo /( Vo + Vd ) ) *100;
41 printf ( \n e f f i c i e n c y i s = %. 1 f \n , efficiency ) //
Result

Scilab code Exa 9.13 Design of stepdown switching regulator


1 // C h a p t e r 9
2 // Page . No458
3 // E x a m p l e 9 1 3
4 // D e s i g n o f s t e p d o wn s w i t c h i n g r e g u l a t o r
5 // Given
6 clear ; clc ;
7 Iomax =3; // Max o u t p u t c u r r e n t i n ampere
8 Vo =5; // Output v o l t a g e i n v o l t
9 Vd =1.25; // V o l t a g e d r o p a c r o s s t h e power d i o d e i n
10
11
12
13
14
15
16
17
18
19
20
21
22
23

volt
Vin =12; // I n p u t v o l t a g e i n v o l t
Vs =1.1; // Output s a t u r a t i o n v o l t a g e i n v o l t
Vripple =50*10^ -3; // Output r i p p l e v o l t a g e i n v o l t
Vref =1.245; // R e f e r e n c e v o l t a g e i n v o l t
Vr2 =1.2; // V o l t a g e a c r o s s r e s i s t a n c e R2 i n v o l t
Ipk =2* Iomax ; // S e n s e c u r r e n t i n ampere
printf ( \n S e n s e c u r r e n t , I p k i s = %. f A \n , Ipk ) //
Result
Rsc =0.33/ Ipk ; // S e n s e r e s i s t a n c e i n ohm
printf ( \n S e n s e r e s i s t a n c e , Rsc i s = %. 3 f ohm \n ,
Rsc ) // R e s u l t
K =( Vo + Vd ) /( Vin - Vs - Vo ) ; // K= t o n / t o f f
printf ( \n C o n s t a n t K = %. 2 f \n ,K ) // R e s u l t
printf ( \n i . e , t o n i s K t i m e s o f t o f f \n )
f =20*10^3; // Assuming o p e r a t i n g f r e q i n Hz
T =1/ f ;
90

24
25
26
27
28
29
30
31
32
33

toff = T /2.06; // U s i n g t o n+ t o f f =T and s u b s t i t u t i n g


f o r ton
printf ( \n OFF t i m e p e r i o d , t o f f i s = %. 8 f s e c \n ,
toff ) // R e s u l t
ton =1.06* toff ;
printf ( \n ON t i m e p e r i o d , t o n i s = %. 8 f s e c \n , ton )
// R e s u l t
Ct =45*10^ -5* toff ; // O s c i l l a t o r t i m i n g c a p a c i t a n c e
in farad
printf ( \n O s c i l l a t o r t i m i n g c a p a c i t a n c e , Ct i s = %
. 1 0 f F \n , Ct ) // R e s u l t
L =(( Vo + Vd ) / Ipk ) * toff ; // I n d u c t a n c e i n h e n r y
printf ( \n I n d u c t a n c e , L i s = %. 8 f H \n ,L ) // R e s u l t
Co = Ipk *(( ton + toff ) /(8* Vripple ) ) ; // Output
capacitance in farad
printf ( \n Output c a p a c i t a n c e , Co i s = %. 7 f F \n , Co )
// R e s u l t

91

You might also like