0% found this document useful (0 votes)
103 views71 pages

Scilab 3ed PDF

This document provides a summary of the Scilab codes written as a companion to the textbook "Electronic Circuits" by M. H. Tooley. It includes an introduction to the textbook, author, publisher and edition. It then describes the numbering convention used to relate the Scilab codes to examples and equations from the textbook. Finally, it provides a list of over 150 Scilab codes along with a brief description of what each code calculates or determines. The codes cover topics in electrical fundamentals, passive components, DC circuits, alternating voltage/current, semiconductors, power supplies, amplifiers, operational amplifiers, oscillators and radio frequency circuits.

Uploaded by

Emmanuel Thomas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views71 pages

Scilab 3ed PDF

This document provides a summary of the Scilab codes written as a companion to the textbook "Electronic Circuits" by M. H. Tooley. It includes an introduction to the textbook, author, publisher and edition. It then describes the numbering convention used to relate the Scilab codes to examples and equations from the textbook. Finally, it provides a list of over 150 Scilab codes along with a brief description of what each code calculates or determines. The codes cover topics in electrical fundamentals, passive components, DC circuits, alternating voltage/current, semiconductors, power supplies, amplifiers, operational amplifiers, oscillators and radio frequency circuits.

Uploaded by

Emmanuel Thomas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 71

Scilab Textbook Companion for

Electronic Circuits
by M. H. Tooley1

Created by
Karan Bhargava
b.tech
Electronics Engineering
Uttarakhand Technical University
College Teacher
Vatsalya Sharma
Cross-Checked by
Ganesh R

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: Electronic Circuits

Author: M. H. Tooley

Publisher: Elsevier, New Delhi

Edition: 3

Year: 2008

ISBN: 978-81-312-0650-8

1
Scilab numbering policy used in this document and the relation to the
above book.

Exa Example (Solved example)

Eqn Equation (Particular equation of the above book)

AP Appendix to Example(Scilab Code that is an Appednix to a particular


Example of the above book)

For example, Exa 3.51 means solved example 3.51 of this book. Sec 2.3 means
a scilab code whose theory is explained in Section 2.3 of the book.

2
Contents

List of Scilab Codes 4

1 Electrical Fundamentals 9

2 Passive Components 19

3 DC Circuits 32

4 Alternating voltage and current 40

5 Semiconductors 48

6 Power Supplies 52

7 Amplifiers 55

8 Operational Amplifiers 60

9 Oscillators 63

12 The 555 timer 65

13 Radio 67

3
List of Scilab Codes

Exa 1.4 Express angle of 215 degree in radians . . . . . . . . . 9


Exa 1.5 Express angle in degrees . . . . . . . . . . . . . . . . . 9
Exa 1.6 Calculate the current in milliamp . . . . . . . . . . . . 10
Exa 1.7 Express the freq in Mhz of 1495 kHz radio transmitter 10
Exa 1.8 Express the capacitance in microfarad of 27000 pF . . 10
Exa 1.9 Express current in amp . . . . . . . . . . . . . . . . . 11
Exa 1.10 Express the voltage in millivolt using exp notation . . 11
Exa 1.11 Calculate the voltage dropped across 33kohm with 3mA
current . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Exa 1.12 Calculate the charge transferred in 20ms by 45 microamp
current . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Exa 1.13 Calculate the current supplied to the circuit when 1500V
is applied dissipating 300 mW . . . . . . . . . . . . . 12
Exa 1.14 Calculate the current through resistor 12ohm with 6V
battery . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Exa 1.15 Calculate the voltage developed across 56ohm with 100mA
current . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Exa 1.16 Calculate the resistance with 15 volt applied with 1mA
current . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Exa 1.17 Calculate the resistance of 8m length cooper wire . . . 14
Exa 1.18 Calculate the voltage drop between the ends of the 20m
wire carring 5A current . . . . . . . . . . . . . . . . . 14
Exa 1.19 Calculate the power supplied by 3 V battery . . . . . 14
Exa 1.20 Calculate the power dissipated in 100ohm with 4V drop 15
Exa 1.21 Calculate the power dissipated in 100ohm with 4V drop 15
Exa 1.22 Calculate the electric field strength if 2 parallel plates
seperated by 25mm are fed by 600V supply . . . . . . 16

4
Exa 1.23 Calculate the flux density at 50mm from st wire carrying
20A . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Exa 1.24 Calculate the total flux by flux density . . . . . . . . . 16
Exa 1.25 Calculate the relative permitivity of steel at different
given flux density . . . . . . . . . . . . . . . . . . . . 17
Exa 1.26 Calculate the current to establish given flux . . . . . . 17
Exa 2.1 Determine the tolerance of resistor . . . . . . . . . . . 19
Exa 2.2 Nominal current taken from supply and Max and Min
value of supply current . . . . . . . . . . . . . . . . . 19
Exa 2.3 Determine value and type of resistor used for 100mA . 20
Exa 2.4 Determine the value and tolerance of resistor of brown
black red silver . . . . . . . . . . . . . . . . . . . . . . 20
Exa 2.5 Determine the value and tolerance of resistor of red vi-
olet orange gold . . . . . . . . . . . . . . . . . . . . . 21
Exa 2.6 Determine the value and tolerance of resistor of green
blue black gold . . . . . . . . . . . . . . . . . . . . . . 21
Exa 2.7 Determine the value and tolerance of resistor of red
green black brown . . . . . . . . . . . . . . . . . . . . 21
Exa 2.8 Determine the bands coressponding to 2pt kohm of tol-
erance 2 percent . . . . . . . . . . . . . . . . . . . . . 22
Exa 2.9 Determine the bands coressponding to 4R7K . . . . . 22
Exa 2.10 Determine the bands coressponding to 330RG . . . . . 22
Exa 2.11 Determine the bands coressponding to R22M . . . . . 23
Exa 2.12 Determine the effective resistance in Series and Parallel 23
Exa 2.13 Determine the effective resistance of the circuit . . . . 23
Exa 2.14 Determine the resistance required to realize 50 ohm at
2W . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Exa 2.15 Determine the resistance at 80 degree . . . . . . . . . 24
Exa 2.16 Determine the resistance at 90 degree . . . . . . . . . 25
Exa 2.17 Determine the resistor temperature coeff . . . . . . . . 25
Exa 2.18 Determine the current flow . . . . . . . . . . . . . . . 25
Exa 2.19 Determine the charged stored . . . . . . . . . . . . . . 26
Exa 2.20 Determine the potential diff that be applied to 47 uF-
capacitor . . . . . . . . . . . . . . . . . . . . . . . . . 26
Exa 2.21 Determine the required plate area for 1 nF capacitor . 27
Exa 2.22 Determine the value of capacitance . . . . . . . . . . . 27
Exa 2.23 Determine the value of capacitor 103K . . . . . . . . . 27

5
Exa 2.24 Determine the value of tubular capacitor with brown
green brown red brown . . . . . . . . . . . . . . . . . 28
Exa 2.25 Determine the effective capacitance . . . . . . . . . . . 28
Exa 2.26 Determine the series combination of capacitos and their
voltage rating . . . . . . . . . . . . . . . . . . . . . . . 29
Exa 2.27 Determine the voltage induced . . . . . . . . . . . . . 29
Exa 2.28 Determine the current that be applied to an inductor . 29
Exa 2.29 Determine the numbers of turns required . . . . . . . 30
Exa 2.30 Determine the parallel combination for 5mH inductor
rated at 2A . . . . . . . . . . . . . . . . . . . . . . . . 30
Exa 2.31 Determine the effective inductance . . . . . . . . . . . 31
Exa 3.1 Determine the value of current flowing between A B and
value of I3 . . . . . . . . . . . . . . . . . . . . . . . . 32
Exa 3.2 Determine the value of V2 and value of E3 . . . . . . 32
Exa 3.3 Determine the voltage and current in circuit . . . . . . 33
Exa 3.4 Determine the output when no load and loaded by 10kohm 33
Exa 3.5 Determine the value of parallel shunt resistor . . . . . 34
Exa 3.6 Determine the range of resistances that can be measured 34
Exa 3.7 Determine the current flow in 100 ohm load . . . . . . 35
Exa 3.8 Determine the voltage produced . . . . . . . . . . . . 35
Exa 3.9 Determine the voltage produced . . . . . . . . . . . . 36
Exa 3.10 Determine the initial charging current and current that
flow 50ms and 100ms after connecting supply After what
time does capacitor fully charge . . . . . . . . . . . . . 36
Exa 3.11 Determine the time taken by the capacitor to fall below
10V . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Exa 3.12 Determine the capacitor voltage 1 minute later . . . . 37
Exa 3.13 Determine the C R values for sq wave of 1kHz . . . . . 38
Exa 3.14 Determine the C R values for sq wave of 1kHz . . . . . 38
Exa 3.15 Determine the current in the inductor after supply first
connected . . . . . . . . . . . . . . . . . . . . . . . . . 38
Exa 3.16 Determine the inductor voltage 20ms after supply first
connected . . . . . . . . . . . . . . . . . . . . . . . . . 39
Exa 4.1 Determine the instanteous voltage . . . . . . . . . . . 40
Exa 4.2 Determine the time period of 400 Hz waveform . . . . 40
Exa 4.3 Determine the freq of 40 ms waveform . . . . . . . . . 41
Exa 4.4 Determine the peak value of 240V rms . . . . . . . . . 41
Exa 4.5 Determine the rms value of 50mA peak to peak . . . . 41

6
Exa 4.6 Determine the rms current . . . . . . . . . . . . . . . 42
Exa 4.7 Determine the reactance of 1uF at 100Hz and 10kHz . 42
Exa 4.8 Determine the current flow in capacitor . . . . . . . . 43
Exa 4.9 Determine the reactance of 1mH at 100Hz and 10kHz 43
Exa 4.10 Determine the reactance of 1mH at 100Hz and 10kHz 43
Exa 4.11 Determine the impedance of the circuit and current fro
supply . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Exa 4.12 Determine the power factor of choke and currentt from
supply . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Exa 4.13 Determine the value of capacitance required . . . . . . 45
Exa 4.14 Determine the current supplied and voltage developed
across 100 ohm . . . . . . . . . . . . . . . . . . . . . . 45
Exa 4.15 Determine the value of secondry voltage . . . . . . . . 46
Exa 4.16 Determine the number of secondary turns and primary
current . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Exa 5.1 Determine the resistance of diode when forward current
is given and when forward voltage is given . . . . . . . 48
Exa 5.2 Determine the series resistor required . . . . . . . . . 48
Exa 5.3 Determine the Ie emitter current and hfe . . . . . . . 49
Exa 5.4 Determine the Ie emitter current and hfe . . . . . . . 49
Exa 5.5 Determine the Ib base current and hfe . . . . . . . . . 50
Exa 5.6 Determine the hfe required and collector power dissipa-
tion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Exa 5.7 Determine the I base current and change in collector
current . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Exa 5.8 Determine the change in drain current . . . . . . . . . 51
Exa 6.1 Determine the peak voltage that appear across load . 52
Exa 6.2 Determine the amt of ripple at output . . . . . . . . . 52
Exa 6.3 Determine the amt of ripple at output . . . . . . . . . 53
Exa 6.4 Determine the series resistor for operation in conjunc-
tion with 9V . . . . . . . . . . . . . . . . . . . . . . . 53
Exa 6.5 Determine equiv output resistance and regulation of power
supply . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Exa 7.1 Determine voltage gain and current gain and power gain 55
Exa 7.2 Determine voltage gain and upper and lower cutoff freq 55
Exa 7.3 Determine overall voltage gain with negative feedback 56
Exa 7.4 Determine percentage increase in overall voltage gain . 56
Exa 7.5 Determine amount of feedback required . . . . . . . . 57

7
Exa 7.6 Determine output voltage produced by input signal of
10mV . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Exa 7.7 Determine of load resistance required . . . . . . . . . . 57
Exa 7.8 Determine static value of current gain and voltage gain 58
Exa 7.9 Determine quiescent value of collector current and volt-
age and peak to peak output voltage . . . . . . . . . . 58
Exa 8.1 Determine the value of open loop voltage gain . . . . . 60
Exa 8.2 Determine the value of input current . . . . . . . . . . 60
Exa 8.3 Determine the slew rate of device . . . . . . . . . . . . 61
Exa 8.4 Determine the time taken to change level . . . . . . . 61
Exa 8.6 Determine the circuit parameters using opamps . . . . 61
Exa 9.1 Determine the freq of oscillation . . . . . . . . . . . . 63
Exa 9.2 Determine the output freq . . . . . . . . . . . . . . . . 63
Exa 9.3 Determine the value of R3 and R4 . . . . . . . . . . . 64
Exa 12.1 Determine the parameters of timer circuit . . . . . . . 65
Exa 12.2 Determine the parameters of timer circuit that produce
5V . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Exa 12.3 Design of pulse generator . . . . . . . . . . . . . . . . 66
Exa 12.4 Design of 5V square wave generator . . . . . . . . . . 66
Exa 13.1 Determine the frequency of radio signal of wavelength
15m . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Exa 13.2 Determine the frequency of radio signal of 150MHz . . 67
Exa 13.3 Determine the velocity of propagation of radio signal of
30MHz and 8m wavelength . . . . . . . . . . . . . . . 68
Exa 13.4 Determine the two possible BFO freq . . . . . . . . . . 68
Exa 13.5 Determine the range the local oscillator be tuned . . . 68
Exa 13.6 Determine the range the local oscillator be tuned . . . 69
Exa 13.7 Determine the radiated power . . . . . . . . . . . . . . 69
Exa 13.8 Determine the power and radiation efficiency . . . . . 70

8
Chapter 1

Electrical Fundamentals

Scilab code Exa 1.4 Express angle of 215 degree in radians

1 // Exa : 1 . 4
2 clc ;
3 clear ;
4 close ;
5 ang_d =215; // g i v e n
6 ang_r = ang_d * %pi /180;
7 printf ( ” %f d e g r e e a n g l e i s %f r a d i a n s ” , ang_d , ang_r ) ;

Scilab code Exa 1.5 Express angle in degrees

1 // Exa : 1 . 5
2 clc ;
3 clear ;
4 close ;
5 ang_r =2.5; // g i v e n
6 ang_d =2.5*180/ %pi ; // a n g l e i n d e g r e e s
7 printf ( ” %f r a d i a n s a n g l e i s %f d e g r e e s ” , ang_r , ang_d )
;

9
Scilab code Exa 1.6 Calculate the current in milliamp

1 // Exa : 1 . 6
2 clc ;
3 clear ;
4 close ;
5 i_amp =0.075; // g i v e n
6 i_milamp = i_amp *1000; // c u r r e n t i n m i l l i a m p .
7 printf ( ” %f amp c u r r e n t i s %f mA” , i_amp , i_milamp ) ;

Scilab code Exa 1.7 Express the freq in Mhz of 1495 kHz radio transmitter

1 // Exa : 1 . 7
2 clc ;
3 clear ;
4 close ;
5 fq_khz =1495; // g i v e n
6 fq_Mhz = fq_khz /1000;
7 printf ( ” %f kHz f r e q u e n c y i s %f MHz” , fq_khz , fq_Mhz ) ;

Scilab code Exa 1.8 Express the capacitance in microfarad of 27000 pF

1 // Exa : 1 . 8
2 clc ;
3 clear ;
4 close ;
5 c_pF =27000; // g i v e n
6 c_uF = c_pF /1000;
7 printf ( ” %f p i c o f a r a d c a p a c i t a n c e i s %f m i c r o f a r a d ” ,
c_pF , c_uF ) ;

10
Scilab code Exa 1.9 Express current in amp

1 // Exa : 1 . 9
2 clc ;
3 clear ;
4 close ;
5 c_mA =7.25; // g i v e n
6 c_A = c_mA *1000;
7 printf ( ” %f m i l l i a m p e r e c u r r e n t i s %f ampere ” , c_mA ,
c_A ) ;

Scilab code Exa 1.10 Express the voltage in millivolt using exp notation

1 // Exa : 1 . 1 0
2 clc ;
3 clear ;
4 close ;
5 vg_v =3.75*10^ -6; // g i v e n
6 vg_mv = vg_v *1000;
7 printf ( ” %f v o l t v o l t a g e i s %e mV” , vg_v , vg_mv ) ;

Scilab code Exa 1.11 Calculate the voltage dropped across 33kohm with
3mA current

1 // Ex : 1 . 1 1
2 clc ;
3 clear ;
4 close ;
5 r =33000; // i n ohms

11
6 i =0.003; // i n amp
7 v=i*r;
8 printf ( ” V o l t a g e d r o p p e d = %d v o l t s ” ,v ) ;

Scilab code Exa 1.12 Calculate the charge transferred in 20ms by 45 mi-
croamp current

1 // Ex : 1 . 1 2
2 clc ;
3 clear ;
4 close ;
5 t =20*10^ -3; // i n s e c
6 i =45*10^ -6; // i n amp
7 q = i * t *10^9;
8 printf ( ” Charge t r a n s f e r r e d = %f nC” ,q ) ;

Scilab code Exa 1.13 Calculate the current supplied to the circuit when
1500V is applied dissipating 300 mW

1 // Ex : 1 . 1 3
2 clc ;
3 clear ;
4 close ;
5 p =0.3; // i n w a t t s
6 v =1500; // i n v o l t s
7 i =( p / v ) *10^6;
8 printf ( ” C u r r e n t s u p p l i e d = %d microamp ” ,i ) ;

Scilab code Exa 1.14 Calculate the current through resistor 12ohm with
6V battery

12
1 // Ex : 1 . 1 4
2 clc ;
3 clear ;
4 close ;
5 r =12; // i n ohms
6 v =6; // i n v o l t s
7 i =( v / r ) ;
8 printf ( ” C u r r e n t = %f Amp” ,i ) ;

Scilab code Exa 1.15 Calculate the voltage developed across 56ohm with
100mA current

1 // Ex : 1 . 1 5
2 clc ;
3 clear ;
4 close ;
5 r =56; // i n ohms
6 i =0.1; // i n amp
7 v=i*r;
8 printf ( ” V o l t a g e d r o p p e d = %f v o l t s ” ,v ) ;

Scilab code Exa 1.16 Calculate the resistance with 15 volt applied with
1mA current

1 // Ex : 1 . 1 6
2 clc ;
3 clear ;
4 close ;
5 v =15; // i n v o l t s
6 i =0.001; // i n amp
7 r=v/i;
8 printf ( ” R e s i s t a n c e = %d ohms ” ,r ) ;

13
Scilab code Exa 1.17 Calculate the resistance of 8m length cooper wire

1 // Ex : 1 . 1 7
2 clc ;
3 clear ;
4 close ;
5 p =1.724*10^ -8; // i n ohm−m e t e r
6 l =8; // i n m e t e r s
7 a =1*10^ -6; // i n s q . m e t e r
8 r =( p * l ) / a ;
9 printf ( ” R e s i s t a n c e = %f ohms ” ,r ) ;

Scilab code Exa 1.18 Calculate the voltage drop between the ends of the
20m wire carring 5A current

1 // Ex : 1 . 1 8
2 clc ;
3 clear ;
4 close ;
5 p =1.724*10^ -8; // i n ohm−m e t e r
6 l =20; // i n m e t e r s
7 a =1*10^ -6; // i n s q . m e t e r
8 i =5; // i n a m p e r e s
9 r =( p * l ) / a ;
10 v=i*r;
11 printf ( ” V o l t a g e d r o p p e d = %f v o l t s ” ,v ) ;

Scilab code Exa 1.19 Calculate the power supplied by 3 V battery

14
1 // Ex : 1 . 1 9
2 clc ;
3 clear ;
4 close ;
5 v =3; // i n v o l t s
6 i =1.5; // i n a m p e r e s
7 p=v*i;
8 printf ( ” Power s u p p l i e d = %f w a t t s ” ,p ) ;

Scilab code Exa 1.20 Calculate the power dissipated in 100ohm with 4V
drop

1 // Ex : 1 . 2 0
2 clc ;
3 clear ;
4 close ;
5 v =4; // i n v o l t s
6 r =100; // i n ohms
7 p =( v ^2) / r ;
8 printf ( ” Power d i s s i p a t e d = %f w a t t s ” ,p ) ;

Scilab code Exa 1.21 Calculate the power dissipated in 100ohm with 4V
drop

1 // Ex : 1 . 2 1
2 clc ;
3 clear ;
4 close ;
5 i =20*10^ -3; // i n amps
6 r =1000; // i n ohms
7 p =( i ^2) * r ;
8 printf ( ” Power d i s s i p a t e d = %f w a t t s ” ,p ) ;

15
Scilab code Exa 1.22 Calculate the electric field strength if 2 parallel plates
seperated by 25mm are fed by 600V supply

1 // Ex : 1 . 2 2
2 clc ;
3 clear ;
4 close ;
5 v =600; // i n v o l t s
6 d =25*10^ -3; // i n m e t e r s
7 E =( v ) / d ;
8 printf ( ” E l e c t r i c F i e l d S t r e n g t h = %d kV/m” ,E /1000) ;

Scilab code Exa 1.23 Calculate the flux density at 50mm from st wire
carrying 20A

1 // Ex : 1 . 2 3
2 clc ;
3 clear ;
4 close ;
5 u =4* %pi *10^ -7; // i n H/m
6 i =20; // i n amps
7 d =50*10^ -3; // i n m e t e r s
8 B =( u * i ) /(2* %pi * d ) ;
9 printf ( ” Flux D e n s i t y = %e T e s l a ” ,B ) ;

Scilab code Exa 1.24 Calculate the total flux by flux density

1 // Ex : 1 . 2 4
2 clc ;

16
3 clear ;
4 close ;
5 B =(2.5*10^ -3) ; // i n T e s l a
6 a =(20*10^ -4) ; // i n s q . m e t e r
7 flux = B * a ;
8 printf ( ” Flux = %e w e b e r s ” , flux ) ;

Scilab code Exa 1.25 Calculate the relative permitivity of steel at differ-
ent given flux density

1 // Ex : 1 . 2 5
2 clc ;
3 clear ;
4 close ;
5 B1 =0.6; // i n T e s l a
6 u1 = B1 /800;
7 u_r1 = u1 /(4* %pi *10^ -7) ;
8 printf ( ” r e l t i v e p e r m i t i v i t y a t 0 . 6 T = %f ” , u_r1 ) ;
9 B2 =1.6; // i n T e s l a
10 u2 =0.2/4000;
11 u_r2 = u2 /(4* %pi *10^ -7) ;
12 printf ( ” \n r e l t i v e p e r m i t i v i t y a t 1 . 6 T = %f ” , u_r2 ) ;

Scilab code Exa 1.26 Calculate the current to establish given flux

1 // Ex : 1 . 2 6
2 clc ;
3 clear ;
4 close ;
5 flux =0.8*10^ -3;
6 a =(500*10^ -6) ; // i n s q . m e t e r
7 l =0.6; // i n m e t e r
8 N =800;

17
9 B = flux / a ;
10 printf ( ” Flux D e n s i t y = %e T e s l a ” ,B ) ;
11 H =3500; // i n A/m
12 i =( H * l ) / N ;
13 printf ( ” \n C u r r e n t r e q u i r e d = %f amp . s ” ,i ) ;

18
Chapter 2

Passive Components

Scilab code Exa 2.1 Determine the tolerance of resistor

1 // Ex : 2 . 1
2 clc ;
3 clear ;
4 close ;
5 marked =220; // i n ohms
6 measured =207; // i n ohms
7 err = marked - measured ;
8 tol =( err / marked ) *100;
9 printf ( ” T o l e r a n c e = %f %%” , tol ) ;

Scilab code Exa 2.2 Nominal current taken from supply and Max and Min
value of supply current

1 // Ex : 2 . 2
2 clc ;
3 clear ;
4 close ;
5 r =39; // i n ohms

19
6 v =9; // i n v o l t s
7 i =( v / r ) ; // i n Amps
8 printf ( ” C u r r e n t = %d mA” ,i *1000) ;
9 tol =0.1; // i . e , 10%
10 r_min =r -( tol * r ) ;
11 i_max = v / r_min ;
12 r_max = r +( tol * r ) ;
13 i_min = v / r_max ;
14 printf ( ” \n Max . C u r r e n t = %f mA & Min C u r r e n t= %f mA”
, i_max *1000 , i_min *1000) ;

Scilab code Exa 2.3 Determine value and type of resistor used for 100mA

1 // Ex : 2 . 3
2 clc ;
3 clear ;
4 close ;
5 v =28; // i n v o l t s
6 i =0.1; // i n A
7 r=v/i;
8 p=v*i;
9 printf ( ” R e s i s t a n c e V a l u e = %f ohms & Power
d i s s i p a t e d = %f W” ,r , p ) ;

Scilab code Exa 2.4 Determine the value and tolerance of resistor of brown
black red silver

1 // Ex : 2 . 4
2 clc ;
3 clear ;
4 close ;
5 r =10*(10^2) ;
6 printf ( ” R e s i s t o r v a l u e = %d ohm” ,r ) ;

20
7 printf ( ” \ n T o l e r a n c e = 10 %%” ) ;

Scilab code Exa 2.5 Determine the value and tolerance of resistor of red
violet orange gold

1 // Ex : 2 . 5
2 clc ;
3 clear ;
4 close ;
5 r =27*(10^3) ;
6 printf ( ” R e s i s t o r v a l u e = %d ohm” ,r ) ;
7 printf ( ” \ n T o l e r a n c e = 5 %%” ) ;

Scilab code Exa 2.6 Determine the value and tolerance of resistor of green
blue black gold

1 // Ex : 2 . 6
2 clc ;
3 clear ;
4 close ;
5 r =56*(10^0) ;
6 printf ( ” R e s i s t o r v a l u e = %d ohm” ,r ) ;
7 printf ( ” \ n T o l e r a n c e = 5 %%” ) ;

Scilab code Exa 2.7 Determine the value and tolerance of resistor of red
green black brown

1 // Ex : 2 . 7
2 clc ;
3 clear ;

21
4 close ;
5 r =25*(10^0) ;
6 printf ( ” R e s i s t o r v a l u e = %d ohm” ,r ) ;
7 printf ( ” \ n T o l e r a n c e = 20 %%” ) ;

Scilab code Exa 2.8 Determine the bands coressponding to 2pt kohm of
tolerance 2 percent

1 // Ex : 2 . 8
2 clc ;
3 clear ;
4 close ;
5 r =22*(10^3) ;
6 printf ( ” Bands a r e Red , Red , Red , Red ” ) ;

Scilab code Exa 2.9 Determine the bands coressponding to 4R7K

1 // Ex : 2 . 9
2 clc ;
3 clear ;
4 close ;
5 printf ( ” R e s i s t a n c e = 4 . 7 ohm w i t h 10%% t o l e r a n c e ” ) ;

Scilab code Exa 2.10 Determine the bands coressponding to 330RG

1 // Ex : 2 . 1 0
2 clc ;
3 clear ;
4 close ;
5 printf ( ” R e s i s t a n c e = 330 ohms w i t h 2%% t o l e r a n c e ” ) ;

22
Scilab code Exa 2.11 Determine the bands coressponding to R22M

1 // Ex : 2 . 1 1
2 clc ;
3 clear ;
4 close ;
5 printf ( ” R e s i s t a n c e = 0 . 2 2 ohm w i t h 20%% t o l e r a n c e ” ) ;

Scilab code Exa 2.12 Determine the effective resistance in Series and Par-
allel

1 // Ex : 2 . 1 2
2 clc ;
3 clear ;
4 close ;
5 r1 =22; // i n ohms
6 r2 =47; // i n ohms
7 r3 =33; // i n ohms
8 r_ser = r1 + r2 + r3 ;
9 printf ( ” E f f e c t i v e r e s i s t a n c e i n s e r i e s = %d ohms ” ,
r_ser ) ;
10 r_parel =((1/ r1 ) +(1/ r2 ) +(1/ r3 ) ) ^ -1;
11 printf ( ” \n E f f e c t i v e r e s i s t a n c e i n p a r a l l e l = %f
ohms ” , r_parel ) ;

Scilab code Exa 2.13 Determine the effective resistance of the circuit

1 // Ex : 2 . 1 3
2 clc ;

23
3 clear ;
4 close ;
5 r1 =4.7; // i n ohms
6 r2 =47; // i n ohms
7 r3 =12; // i n ohms
8 r4 =27; // i n ohms
9 r5 = r3 + r4 ;
10 r_parel =((1/ r5 ) +(1/ r2 ) ) ^ -1;
11 r_eff = r_parel + r1 ;
12 printf ( ” E f f e c t i v e r e s i s t a n c e = %d ohms ” , r_eff ) ;

Scilab code Exa 2.14 Determine the resistance required to realize 50 ohm
at 2W

1 // Ex : 2 . 1 4
2 clc ;
3 clear ;
4 close ;
5 printf ( ”Two 100 ohm r e s i s t o r o f 1 W” ) ;

Scilab code Exa 2.15 Determine the resistance at 80 degree

1 // Ex : 2 . 1 5
2 clc ;
3 clear ;
4 close ;
5 temp_coeff =0.001; // i n p e r d e g r e e c e n t i g r a d e
6 r_o =1500; // i n ohm
7 t =80; // t e m p e r a t u r e d i f f .
8 r_t = r_o *(1+( temp_coeff ) * t )
9 printf ( ” R e s i s t a n c e a t %d d e g r e e = %d ohms ” ,t , r_t ) ;

24
Scilab code Exa 2.16 Determine the resistance at 90 degree

1 // Ex : 2 . 1 6
2 clc ;
3 clear ;
4 close ;
5 temp_coeff =0.0005; // i n p e r d e g r e e c e n t i g r a d e
6 r_t1 =680; // i n ohm
7 t1 =20; // t e m p e r a t u r e d i f f .
8 t2 =90;
9 r_o = r_t1 /(1+( temp_coeff ) * t1 ) ;
10 r_t2 = r_o *(1+( temp_coeff ) * t2 ) ;
11 printf ( ” R e s i s t a n c e a t %d d e g r e e = %f ohms ” ,t2 , r_t2 ) ;

Scilab code Exa 2.17 Determine the resistor temperature coeff

1 // Ex : 2 . 1 7
2 clc ;
3 clear ;
4 close ;
5 r_o =40; // r e s i s a t 0 d e g r e e
6 r_t =44; // a t 100 d e g r e e
7 t =100; // t e m p e r a t u r e d i f f .
8 temp_coeff =(1/ t ) *(( r_t / r_o ) -1) ;
9 printf ( ” T e m p e r a t u r e C o e f f i c i e n t = %f p e r d e g r e e
c e n t i g r a d e ” , temp_coeff ) ;

Scilab code Exa 2.18 Determine the current flow

25
1 // Ex : 2 . 1 8
2 clc ;
3 clear ;
4 close ;
5 V_1 =50;
6 V_2 =10;
7 dV = V_1 - V_2 ; // i n v o l t s
8 dt =0.1; // i n s e c o n d s
9 C =22*10^ -6;
10 i = C *( dV / dt ) *1000; // i n mA
11 printf ( ” C u r r e n t f l o w = %f m i l l i A m p s ” ,i ) ;

Scilab code Exa 2.19 Determine the charged stored

1 // Ex : 2 . 1 9
2 clc ;
3 clear ;
4 close ;
5 C =10*10^ -6;
6 V =250; // i n v o l t s
7 Q = V * C *1000; // i n m i l l i c o u l o m b
8 printf ( ” Charged s t o r e d =%f mC” ,Q ) ;

Scilab code Exa 2.20 Determine the potential diff that be applied to 47
uFcapacitor

1 // Ex : 2 . 2 0
2 clc ;
3 clear ;
4 close ;
5 C =47*10^ -6; // i n f a r a d s
6 W =4; // e n e r g y i n j o u l e s
7 V = sqrt ( W /(0.5* C ) ) ;

26
8 printf ( ” V o l t a g e t h t be a p p l i e d = %d v o l t s ” ,V ) ;

Scilab code Exa 2.21 Determine the required plate area for 1 nF capacitor

1 // Ex : 2 . 2 1
2 clc ;
3 clear ;
4 close ;
5 E_o =8.85*10^ -12;
6 E_r =5.4;
7 C =1*10^ -9;
8 d =0.1*10^ -3;
9 A =( C * d ) /( E_o * E_r ) *10^4;
10 printf ( ” R e q u i r e d p l a t e a r e a = %f s q . cm” ,A ) ;

Scilab code Exa 2.22 Determine the value of capacitance

1 // Ex : 2 . 2 2
2 clc ;
3 clear ;
4 close ;
5 E_o =8.85*10^ -12;
6 E_r =4.5;
7 n =6; // no . o f p l a t e s
8 d =0.2*10^ -3; // i n m e t e r
9 A =20*10^ -4; // i n s q . m e t e r
10 C ={( E_o * E_r *( n -1) * A ) / d }*10^11;
11 printf ( ” C a p a c i t a n c e = %d pF” ,C ) ;

Scilab code Exa 2.23 Determine the value of capacitor 103K

27
1 // Ex : 2 . 2 3
2 clc ;
3 clear ;
4 close ;
5 printf ( ” C a p a c i t a n c e = 1 0 0 0 0 pF o f 10%%” ) ;

Scilab code Exa 2.24 Determine the value of tubular capacitor with brown
green brown red brown

1 // Ex : 2 . 2 4
2 clc ;
3 clear ;
4 close ;
5 printf ( ” C a p a c i t a n c e = 150 pF o f 2%% t o l e r a n c e a t 100
V” ) ;

Scilab code Exa 2.25 Determine the effective capacitance

1 // Ex : 2 . 2 5
2 clc ;
3 clear ;
4 close ;
5 C1 =2; // i n nF
6 C2 =4; // i n nF
7 C3 =2;
8 C4 =4;
9 C_a = C1 + C2 ;
10 C_b = C_a * C3 /( C_a + C3 ) ;
11 C_eff = C4 + C_b ;
12 printf ( ” C a p a c i t a n c e = %f nF” , C_eff ) ;

28
Scilab code Exa 2.26 Determine the series combination of capacitos and
their voltage rating

1 // Ex : 2 . 2 6
2 clc ;
3 clear ;
4 close ;
5 C =100; // i n uF
6 C_eff = C * C /( C + C ) ;
7 printf ( ”Two c a p a c i t o r s o f %d uF be i n p a r a l l e l u s e d
t o make %d uF c a p a c i t a n c e ” ,C , C_eff ) ;

Scilab code Exa 2.27 Determine the voltage induced

1 // Ex : 2 . 2 7
2 clc ;
3 clear ;
4 close ;
5 L =600*10^ -3; // i n H
6 I1 =6; // i n A
7 I2 =2; // i n A
8 dI = I1 - I2 ;
9 dt =250*10^ -3; // i n s e c .
10 E = - L *( dI / dt ) ;
11 printf ( ” I n d u c e d v o l t a g e = %f v o l t s ” ,E ) ;

Scilab code Exa 2.28 Determine the current that be applied to an induc-
tor

1 // Ex : 2 . 2 8
2 clc ;
3 clear ;
4 close ;

29
5 E =2.5; // e n e r g y i n j o u l e s
6 L =20*10^ -3; // i n h e n r y
7 I = sqrt ( E /(0.5* L ) ) ;
8 printf ( ” C u r r e n t = %f A” ,I ) ;

Scilab code Exa 2.29 Determine the numbers of turns required

1 // Ex : 2 . 2 9
2 clc ;
3 clear ;
4 close ;
5 u_o =12.57*10^ -7;
6 u_r =500;
7 A =15*10^ -4; // a r e a o f c r o s s −s e c t i o n i n s q . m e t e r s
8 l =20*10^ -2; // l e n g t h
9 L =100*10^ -3; // i n h e n r y
10 n = sqrt (( L * l ) /( u_r * u_o * A ) ) ;
11 printf ( ” I n d u c t o r r e q u i r e s %d t u r n s o f w i r e ” ,n ) ;

Scilab code Exa 2.30 Determine the parallel combination for 5mH induc-
tor rated at 2A

1 // Ex : 2 . 3 0
2 clc ;
3 clear ;
4 close ;
5 //L=(L1 ∗ L2 ) / ( L1+L2 )
6 L_eq =5; // i n m i l l i h e n r y
7 printf ( ” I n d u c t o r o f 10 mH w i r e d i n p a r a l l e l would
p r o v i d e %d mH” , L_eq ) ;

30
Scilab code Exa 2.31 Determine the effective inductance

1 // Ex : 2 . 3 1
2 clc ;
3 clear ;
4 close ;
5 L1 =60; // i n mH
6 L2 =60; // i n mH
7 L_a = L1 + L2 ;
8 L3 =120; // i n mH
9 L_b = L_a * L3 /( L_a + L3 ) ;
10 L4 =50; // i n mH
11 L_eq = L4 + L_b ;
12 printf ( ” E q u i v a l e n t I n d u c t a n c e = %d mH” , L_eq ) ;

31
Chapter 3

DC Circuits

Scilab code Exa 3.1 Determine the value of current flowing between A B
and value of I3

1 // Ex : 3 . 1
2 clc ;
3 clear ;
4 close ;
5 i1 =1.5;
6 i2 =2.7; // i n amp . s
7 i5 = i1 + i2 ;
8 i4 =3.3;
9 i3 = i4 + i5 ;
10 printf ( ” C u r r e n t b /w A & B = %f A” , i5 ) ;
11 printf ( ” \n C u r r e n t I 3 = %f A” , i3 ) ;

Scilab code Exa 3.2 Determine the value of V2 and value of E3

1 // Ex : 3 . 2
2 clc ;
3 clear ;

32
4 close ;
5 E1 =6;
6 E2 =3;
7 V2 = E1 - E2 ;
8 V1 =4.5;
9 E3 = V1 - E2 ;
10 printf ( ” V a l u e o f V2 = %f A” , V2 ) ;
11 printf ( ” \n V a l u e o f E3 = %f A” , E3 ) ;

Scilab code Exa 3.3 Determine the voltage and current in circuit

1 // Ex : 3 . 3
2 clc ;
3 clear ;
4 close ;
5 V1 =7.5; // i n v o l t s
6 V2 =4.5;
7 V3 =4.5;
8 r1 =110; // i n ohms
9 r2 =33;
10 r3 =22;
11 i1 = V1 / r1 ;
12 i2 = V2 / r2 ;
13 i3 = V3 / r3 ;
14 printf ( ” C u r r e n t I 1 = %f A” , i1 ) ;
15 printf ( ” \n C u r r e n t I 2 = %f A” , i2 ) ;
16 printf ( ” \n C u r r e n t I 3 = %f A” , i3 ) ;

Scilab code Exa 3.4 Determine the output when no load and loaded by
10kohm

1 // Ex : 3 . 4
2 clc ;

33
3 clear ;
4 close ;
5 V_in =5; // i n v o l t s
6 r1 =4000;
7 r2 =1000;
8 r_p = r1 * r2 /( r1 + r2 ) ;
9 V_out = V_in *( r2 /( r1 + r2 ) ) ;
10 V_out_p = V_in *( r_p /( r_p + r2 ) ) ;
11 printf ( ” o u t p u t v o l t a g e a t no l o a d = %f A” , V_out ) ;
12 printf ( ” \n o u t p u t v o l t a g e when l o a d e d by 10 kohms =
%f A” , V_out_p ) ;

Scilab code Exa 3.5 Determine the value of parallel shunt resistor

1 // Ex : 3 . 5
2 clc ;
3 clear ;
4 close ;
5 I_in =5; // i n mA
6 R_m =100;
7 I_m =1;
8 R_s = R_m * I_m /( I_in -1) ;
9 printf ( ” V a l u e o f p a r a l l e l s h u n t r e s i s t o r = %d A” , R_s
);

Scilab code Exa 3.6 Determine the range of resistances that can be mea-
sured

1 // Ex : 3 . 6
2 clc ;
3 clear ;
4 close ;
5 r1 =100;

34
6 r2 =1000;
7 R_x_1 =( r2 / r1 ) *10000;
8 R_x_2 =( r1 / r2 ) *10;
9 printf ( ” Range e x t e n d s from %d ohms t o %d ohms ” , R_x_2
, R_x_1 ) ;

Scilab code Exa 3.7 Determine the current flow in 100 ohm load

1 // Ex : 3 . 7
2 clc ;
3 clear ;
4 close ;
5 E =10;
6 r1 =500;
7 r2 =600;
8 r3 =500;
9 r4 =400;
10 V_a = E *( r2 /( r1 + r2 ) ) ;
11 V_b = E *( r4 /( r3 + r4 ) ) ;
12 V_oc = V_a - V_b ;
13 r =(( r1 * r2 ) /( r1 + r2 ) ) +(( r3 * r4 ) /( r3 + r4 ) ) ;
14 i =( V_oc /( r +100) ) *1000;
15 printf ( ” C u r r e n t f l o w i n 100 ohm r e s i s t o r = %f mA” ,i
);

Scilab code Exa 3.8 Determine the voltage produced

1 // Ex : 3 . 8
2 clc ;
3 clear ;
4 close ;
5 I_sc =19; // i n uA
6 R =1000;

35
7 R_m =968;
8 V_out = I_sc *( R * R_m /( R + R_m ) ) ;
9 printf ( ” V o l t a g e p r o d u c e d = %d uV” , V_out ) ;

Scilab code Exa 3.9 Determine the voltage produced

1 // Ex : 3 . 9
2 clc ;
3 clear ;
4 close ;
5 c =1*10^ -6; // i n f a r a d s
6 r =3.3*10^6; // i n ohms
7 t =1; // i n s e c .
8 V_s =9; // i n v o l t s
9 V_c = V_s *(1 - %e ^( - t /( r * c ) ) ) ;
10 printf ( ” V o l t a g e p r o d u c e d = %f V” , V_c ) ;

Scilab code Exa 3.10 Determine the initial charging current and current
that flow 50ms and 100ms after connecting supply After what time does
capacitor fully charge

1 // Ex : 3 . 1 0
2 clc ;
3 clear ;
4 close ;
5 c =100*10^ -6; // i n f a r a d s
6 r =1*10^3; // i n ohms
7 t1 =50*10^ -3; // i n s e c .
8 t2 =100*10^ -3; // i n s e c .
9 V_s =350; // i n v o l t s
10 i1 =( V_s /1000) *( %e ^( - t1 /( r * c ) ) ) ;
11 i2 =( V_s /1000) *( %e ^( - t2 /( r * c ) ) ) ;

36
12 printf ( ” C h a r g i n g c u r r e n t a f t e r %f s e c = %f A” ,t1 , i1 )
;
13 printf ( ” \n C h a r g i n g c u r r e n t a f t e r %f s e c = %f A” ,t2 ,
i2 ) ;

Scilab code Exa 3.11 Determine the time taken by the capacitor to fall
below 10V

1 // Ex : 3 . 1 1
2 clc ;
3 clear ;
4 close ;
5 c =10*10^ -6; // i n f a r a d s
6 r =47*10^3; // i n ohms
7 V_s =20; // i n v o l t s
8 V_c =10;
9 t = - c * r * log ( V_c / V_s ) ;
10 printf ( ” t i m e t a k e n = %f s e c . ” ,t ) ;

Scilab code Exa 3.12 Determine the capacitor voltage 1 minute later

1 // Ex : 3 . 1 2
2 clc ;
3 clear ;
4 close ;
5 c =150*10^ -6; // i n f a r a d s
6 r =2*10^6; // i n ohms
7 V_s =150; // i n v o l t s
8 V_c =0.8187* V_s ;
9 printf ( ” C a p a c i t o r v o l t a g e = %f V” , V_c ) ;

37
Scilab code Exa 3.13 Determine the C R values for sq wave of 1kHz

1 // Ex : 3 . 1 3
2 clc ;
3 clear ;
4 close ;
5 r =10*10^3; // i n ohms
6 t =1*10^ -3;
7 c =(0.1* t / r ) *10^9;
8 printf ( ” C a p a c i t o r = %d nF” ,c ) ;

Scilab code Exa 3.14 Determine the C R values for sq wave of 1kHz

1 // Ex : 3 . 1 4
2 clc ;
3 clear ;
4 close ;
5 r =10*10^3; // i n ohms
6 t =1*10^ -3;
7 c =(10* t / r ) *10^6;
8 printf ( ” C a p a c i t o r = %d uF” ,c ) ;

Scilab code Exa 3.15 Determine the current in the inductor after supply
first connected

1 // Ex : 3 . 1 5
2 clc ;
3 clear ;
4 close ;
5 L =6; // i n h e n r y
6 r =24; // i n ohms
7 t =0.1; // i n s e c .
8 V_s =12; // i n v o l t s

38
9 i =( V_s / r ) *(1 - %e ^( - t * r / L ) ) ;
10 printf ( ” c u r r e n t = %f A” ,i ) ;

Scilab code Exa 3.16 Determine the inductor voltage 20ms after supply
first connected

1 // Ex : 3 . 1 6
2 clc ;
3 clear ;
4 close ;
5 V_s =5; // i n v o l t s
6 V_c =0.8647* V_s ;
7 printf ( ” I n d u c t o r v o l t a g e = %f V” , V_c ) ;

39
Chapter 4

Alternating voltage and current

Scilab code Exa 4.1 Determine the instanteous voltage

1 // Ex : 4 . 1
2 clc ;
3 clear ;
4 close ;
5 V_m =20; // i n v o l t s
6 f =50; // i n Hz
7 t1 =2.5*10^ -3;
8 t2 =15*10^ -3;
9 V1 = V_m * sin (2* %pi * f * t1 ) ;
10 V2 = V_m * sin (2* %pi * f * t2 ) ;
11 printf ( ” V o l t a g e a t 2 . 5 ms = %f V” , V1 ) ;
12 printf ( ” \n V o l t a g e a t 15ms = %f V” , V2 ) ;

Scilab code Exa 4.2 Determine the time period of 400 Hz waveform

1 // Ex : 4 . 2
2 clc ;
3 clear ;

40
4 close ;
5 f =400; // i n Hz
6 T =1/ f ;
7 printf ( ” Time p e r i o d o f %d Hz waveform = %f s e c ” ,f , T )
;

Scilab code Exa 4.3 Determine the freq of 40 ms waveform

1 // Ex : 4 . 3
2 clc ;
3 clear ;
4 close ;
5 T =40*10^ -3; // i n Hz
6 f =1/ T ;
7 printf ( ” F r e q u e n c y o f 40 ms waveform = %f Hz” ,f ) ;

Scilab code Exa 4.4 Determine the peak value of 240V rms

1 // Ex : 4 . 4
2 clc ;
3 clear ;
4 close ;
5 V_rms =240; // i n V o l t s
6 V_pk =1.414* V_rms ;
7 printf ( ” Peak v o l t a g e o f %d V RMS v o l t a g e = %f V” ,
V_rms , V_pk ) ;

Scilab code Exa 4.5 Determine the rms value of 50mA peak to peak

1 // Ex : 4 . 5

41
2 clc ;
3 clear ;
4 close ;
5 I_pk =50*10^ -3; // i n Amps
6 I_rms =0.353* I_pk ;
7 printf ( ”RMS c u r r e n t o f 50mA peak c u r r e n t = %f A” ,
I_rms ) ;

Scilab code Exa 4.6 Determine the rms current

1 // Ex : 4 . 6
2 clc ;
3 clear ;
4 close ;
5 V =10; // pk−pk v o l t a g e
6 r =1000; // ohms
7 I_pk = V / r ; // i n Amps
8 I_rms =0.353* I_pk *1000; // m i l l i a m p s
9 printf ( ”RMS c u r r e n t o f 10V peak−peak v o l t a g e = %f mA
” , I_rms ) ;

Scilab code Exa 4.7 Determine the reactance of 1uF at 100Hz and 10kHz

1 // Ex : 4 . 7
2 clc ;
3 clear ;
4 close ;
5 c =1*10^ -6;
6 f1 =100;
7 f2 =10000;
8 X_c1 =1/(2* %pi * f1 * c ) ;
9 X_c2 =1/(2* %pi * f2 * c ) ;
10 printf ( ” R e a c t a n c e a t 100 Hz = %f mA” , X_c1 ) ;

42
11 printf ( ” \n R e a c t a n c e a t 10 kHz = %f mA” , X_c2 ) ;

Scilab code Exa 4.8 Determine the current flow in capacitor

1 // Ex : 4 . 8
2 clc ;
3 clear ;
4 close ;
5 V =240;
6 c =100*10^ -9;
7 f =50;
8 X_c =1/(2* %pi * f * c ) ;
9 I_c = V / X_c ;
10 printf ( ” C u r r e n t f l o w = %f A” , I_c ) ;

Scilab code Exa 4.9 Determine the reactance of 1mH at 100Hz and 10kHz

1 // Ex : 4 . 9
2 clc ;
3 clear ;
4 close ;
5 L =1*10^ -3;
6 f1 =100;
7 f2 =10000;
8 X_L1 =(2* %pi * f1 * L ) ;
9 X_L2 =(2* %pi * f2 * L ) ;
10 printf ( ” R e a c t a n c e a t 100 Hz = %f ohm” , X_L1 ) ;
11 printf ( ” \ n R e a c t a n c e a t 10 kHz = %f ohm” , X_L2 ) ;

Scilab code Exa 4.10 Determine the reactance of 1mH at 100Hz and 10kHz

43
1 // Ex : 4 . 1 0
2 clc ;
3 clear ;
4 close ;
5 L =1*10^ -3;
6 f1 =100;
7 f2 =10000;
8 X_L1 =(2* %pi * f1 * L ) ;
9 X_L2 =(2* %pi * f2 * L ) ;
10 printf ( ” R e a c t a n c e a t 100 Hz = %f ohm” , X_L1 ) ;
11 printf ( ” \ n R e a c t a n c e a t 10 kHz = %f ohm” , X_L2 ) ;

Scilab code Exa 4.11 Determine the impedance of the circuit and current
fro supply

1 // Ex : 4 . 1 1
2 clc ;
3 clear ;
4 close ;
5 C =2*10^ -6;
6 f =400;
7 V =115;
8 X_C =1/(2* %pi * f * C ) ;
9 r =199;
10 z = sqrt ( r ^2+ X_C ^2) ;
11 I_s = V / z ;
12 printf ( ” R e a c t a n c e = %f ohm” , X_C ) ;
13 printf ( ” \n C u r r e n t = %f A” , I_s ) ;

Scilab code Exa 4.12 Determine the power factor of choke and currentt
from supply

1 // Ex : 4 . 1 2

44
2 clc ;
3 clear ;
4 close ;
5 L =150*10^ -3;
6 f =400;
7 V =115;
8 X_L =(2* %pi * f * L ) ;
9 r =250;
10 z = sqrt ( r ^2+ X_L ^2) ;
11 I_s = V / z ;
12 printf ( ” R e a c t a n c e = %f ohm” , X_L ) ;
13 printf ( ” \n C u r r e n t = %f A” , I_s )

Scilab code Exa 4.13 Determine the value of capacitance required

1 // Ex : 4 . 1 3
2 clc ;
3 clear ;
4 close ;
5 L =100*10^ -3;
6 f =400;
7 C =(1/(4* %pi * %pi * f * f * L ) ) *10^6;
8 printf ( ” C a p a c i t a n c e r e q u i r e d = %f uF” ,C ) ;

Scilab code Exa 4.14 Determine the current supplied and voltage devel-
oped across 100 ohm

1 // Ex : 4 . 1 4
2 clc ;
3 clear ;
4 close ;
5 L =20*10^ -3;
6 f =2000;

45
7 V =1.5;
8 r =100;
9 C =10*10^ -9;
10 X_L =(2* %pi * f * L ) ;
11 X_C =1/(2* %pi * f * C ) ;
12 z = sqrt ( r ^2+( X_L - X_C ) ^2) ;
13 i=V/z;
14 v=i*r;
15 printf ( ” C u r r e n t s u p p l i e d = %f mA” ,i ) ;
16 printf ( ” \ n V o l t a g e d e v e l o p e d = %f V” ,v ) ;

Scilab code Exa 4.15 Determine the value of secondry voltage

1 // Ex : 4 . 1 5
2 clc ;
3 clear ;
4 close ;
5 N_s =120;
6 V_p =220;
7 N_p =2000;
8 V_s = N_s * V_p / N_p ;
9 printf ( ” S e c o n d r y v o l t a g e = %f V” , V_s ) ;

Scilab code Exa 4.16 Determine the number of secondary turns and pri-
mary current

1 // Ex : 4 . 1 6
2 clc ;
3 clear ;
4 close ;
5 V_p =200;
6 V_s =10;
7 N_p =1200;

46
8 N_s = N_p * V_s / V_p ;
9 i_s =2.5;
10 i_p = N_s * i_s / N_p ;
11 printf ( ” S e c o n d r y t u r n s = %d ” , N_s ) ;
12 printf ( ” \ n p r i m a r y c u r r e n t = %f A” , i_p ) ;

47
Chapter 5

Semiconductors

Scilab code Exa 5.1 Determine the resistance of diode when forward cur-
rent is given and when forward voltage is given

1 // Ex : 5 . 1
2 clc ;
3 clear ;
4 close ;
5 v1 =0.43; // v o l t s
6 i1 =2.5*10^ -3; // i n Amps .
7 v2 =0.65; // v o l t s
8 i2 =7.4*10^ -3; // i n Amps .
9 r1 = v1 / i1 ;
10 r2 = v2 / i2 ;
11 printf ( ” Diode r e s i s t a n c e f o r 2 . 5A c u r r e n t = %d ohms ”
, r1 ) ;
12 printf ( ” \n Diode r e s i s t a n c e f o r 0 . 6 5V = %f ohms ” , r2 )
;

Scilab code Exa 5.2 Determine the series resistor required

48
1 // Ex : 5 . 2
2 clc ;
3 clear ;
4 close ;
5 i =15*10^ -3;
6 R =(21 -2.2) / i ;
7 v =18.8; // i n v o l t s
8 P = i * v *1000;
9 printf ( ” R e s i s t o r %d ohms o f %d mW” ,R , P ) ;

Scilab code Exa 5.3 Determine the Ie emitter current and hfe

1 // Ex : 5 . 3
2 clc ;
3 clear ;
4 close ;
5 I_c =30; // i n mA
6 I_b =0.6;
7 I_e = I_c + I_b ;
8 hfe = I_c / I_b ;
9 printf ( ” E m i t t e r c u r r e n t = %f ohms & h f e = %d” ,
I_e , hfe ) ;

Scilab code Exa 5.4 Determine the Ie emitter current and hfe

1 // Ex : 5 . 4
2 clc ;
3 clear ;
4 close ;
5 I_c =30; // i n mA
6 I_b =0.6;
7 I_e = I_c + I_b ;
8 hfe = I_c / I_b ;

49
9 printf ( ” E m i t t e r c u r r e n t = %f ohms & h f e = %d” ,
I_e , hfe ) ;

Scilab code Exa 5.5 Determine the Ib base current and hfe

1 // Ex : 5 . 5
2 clc ;
3 clear ;
4 close ;
5 I_e =98; // i n mA
6 I_c =97;
7 I_b = I_e - I_c ;
8 hfe = I_c / I_b ;
9 printf ( ” E m i t t e r c u r r e n t = %d mA & h f e = %d” ,
I_b , hfe ) ;

Scilab code Exa 5.6 Determine the hfe required and collector power dis-
sipation

1 // Ex : 5 . 6
2 clc ;
3 clear ;
4 close ;
5 I_c =1.5; // i n A
6 I_b =50*10^ -3;
7 V_ce =6; // v o l t s
8 hfe = I_c / I_b ;
9 P = I_c * V_ce ;
10 printf ( ” h f e r e q u i r e d = %d” , hfe ) ;
11 printf ( ” \n c o l l e c t o r power d i s s i p a t i o n = %d W” ,P ) ;

50
Scilab code Exa 5.7 Determine the I base current and change in collector
current

1 // Ex : 5 . 7
2 clc ;
3 clear ;
4 close ;
5 hfe =200
6 I_c =10*10^ -3;
7 dI_b = I_c / hfe ;
8 dI_c = hfe * dI_b /100;
9 printf ( ” Base c u r r e n t = %f A ” , dI_b ) ;
10 printf ( ” \ nChange i n c o l l e c t o r c u r r e n t = %f mA” , dI_c )
;

Scilab code Exa 5.8 Determine the change in drain current

1 // Ex : 5 . 8
2 clc ;
3 clear ;
4 close ;
5 dV_gs =0.025;
6 g_fs = -0.5;
7 dI_d = dV_gs * g_fs ; // i n mA
8 I_d1 =50*10^ -3; // i n mA
9 I_d2 = dI_d + I_d1 ;
10 printf ( ” Change i n d r a i n c u r r e n t = %f A” , dI_d ) ;
11 printf ( ” \nNew v a l u e o f d r a i n c u r r e n t = %f A” , I_d2 ) ;

51
Chapter 6

Power Supplies

Scilab code Exa 6.1 Determine the peak voltage that appear across load

1 // Ex : 6 . 1
2 clc ;
3 clear ;
4 close ;
5 V_p =220;
6 V_s = V_p /44;
7 V_pk =1.414* V_s ; // i n v o l t s
8 V_l = V_pk -0.6;
9 printf ( ” Peak v o l t a g e t h a t a p p e a r a c r o s s l o a d = %f V”
, V_l ) ;

Scilab code Exa 6.2 Determine the amt of ripple at output

1 // Ex : 6 . 2
2 clc ;
3 clear ;
4 close ;
5 X_c =3.18;

52
6 R =100;
7 V_rip =1*( X_c / sqrt ( R ^2+ X_c ^2) ) ;
8 printf ( ” R i p p l e v o l t a g e = %f V” , V_rip ) ;

Scilab code Exa 6.3 Determine the amt of ripple at output

1 // Ex : 6 . 3
2 clc ;
3 clear ;
4 close ;
5 f =50;
6 L =10;
7 X_l =2* %pi * f * L ;
8 X_c =3.18;
9 V_rip =1*( X_c / sqrt ( X_l ^2+ X_c ^2) ) ;
10 printf ( ” R i p p l e v o l t a g e = %f V” , V_rip ) ;

Scilab code Exa 6.4 Determine the series resistor for operation in con-
junction with 9V

1 // Ex : 6 . 4
2 clc ;
3 clear ;
4 close ;
5 R_l =400;
6 V_in =9;
7 V_z =5;
8 P_z_max =0.5;
9 R_s_max = R_l *(( V_in / V_z ) -1) ;
10 R_s_min =(( V_z * V_in ) - V_z ^2) / P_z_max ;
11 printf ( ” S u i t a b l e v a l u e o f r e s i s t o r = %d ohm” ,(
R_s_max + R_s_min ) /2) ;

53
Scilab code Exa 6.5 Determine equiv output resistance and regulation of
power supply

1 // Ex : 6 . 5
2 clc ;
3 clear ;
4 close ;
5 dI_i =20;
6 dV_o =0.5;
7 dV_o_reg =0.1;
8 dI_o =2;
9 R_out = dV_o / dI_o ;
10 Regulation =( dV_o_reg / dI_i ) *100;
11 printf ( ” o u t p u t r e s i s . = %f ohm” , R_out ) ;
12 printf ( ” \n r e g u l a t i o n . = %f %%” , Regulation ) ;

54
Chapter 7

Amplifiers

Scilab code Exa 7.1 Determine voltage gain and current gain and power
gain

1 // Ex : 7 . 1
2 clc ;
3 clear ;
4 close ;
5 I_i =4;
6 V_o =2;
7 V_i =50*10^ -3;
8 I_o =200;
9 A_v = V_o / V_i ;
10 A_i = I_o / I_i ;
11 printf ( ” V o l t g a i n = %f ” , A_v ) ;
12 printf ( ” \n C u r r e n t g a i n = %f ” , A_i ) ;
13 printf ( ” \n Power g a i n = %f ” , A_i * A_v ) ;

Scilab code Exa 7.2 Determine voltage gain and upper and lower cutoff
freq

55
1 // Ex : 7 . 2
2 clc ;
3 clear ;
4 close ;
5 A_v_max =35;
6 A_v_cutoff =0.707* A_v_max ;
7 printf ( ” Mid−band V o l t g a i n = %f ” , A_v_cutoff ) ;
8 printf ( ” \n u p p e r f r e q = 590 Hz & l o w e r f r e q = 57 Hz” ) ;

Scilab code Exa 7.3 Determine overall voltage gain with negative feed-
back

1 // Ex : 7 . 3
2 clc ;
3 clear ;
4 close ;
5 A =50;
6 b =0.1;
7 G = A /(1+ b * A ) ;
8 printf ( ” o v e r a l l V o l t g a i n = %f ” ,G ) ;

Scilab code Exa 7.4 Determine percentage increase in overall voltage gain

1 // Ex : 7 . 4
2 clc ;
3 clear ;
4 close ;
5 A =50;
6 A_new = A +0.2* A ;
7 b =0.1;
8 G = A_new /(1+ b * A_new ) ;
9 dG =8.33 - G /8.33;

56
10 printf ( ” p e r c e n t a g e c h a n g e i n o v e r a l l v o l t g a i n = %f
%%” , dG ) ;

Scilab code Exa 7.5 Determine amount of feedback required

1 // Ex : 7 . 5
2 clc ;
3 clear ;
4 close ;
5 A =100;
6 G =20;
7 b =(1/ G ) -(1/ A ) ;
8 printf ( ” amount o f f e e d b a c k r e q u i r e d = %f ” ,b ) ;

Scilab code Exa 7.6 Determine output voltage produced by input signal
of 10mV

1 // Ex : 7 . 6
2 clc ;
3 clear ;
4 close ;
5 h_oe =80*10^ -6;
6 R_l =10000;
7 I_f =320*10^ -6;
8 I_c = I_f *(1/ h_oe ) /((1/ h_oe ) + R_l ) ;
9 V_out = I_c * R_l ;
10 printf ( ” Output v o l t a g e = %f V” , V_out ) ;

Scilab code Exa 7.7 Determine of load resistance required

57
1 // Ex : 7 . 7
2 clc ;
3 clear ;
4 close ;
5 b =200;
6 h_ie =1.5*10^3; // i n ohms
7 h_fe =150;
8 R_l = b * h_ie / h_fe ;
9 printf ( ” Load r e s i s t a n c e = %d ohms ” , R_l ) ;

Scilab code Exa 7.8 Determine static value of current gain and voltage
gain

1 // Ex : 7 . 8
2 clc ;
3 clear ;
4 close ;
5 V =9;
6 V_e =2;
7 R4 =1000;
8 V_b =2.6;
9 R2 =33*10^3;
10 R1 =68000;
11 I_r1 =( V - V_b ) / R1 ;
12 R3 =2.2*10^3;
13 I_b =15.1*10^ -6;
14 I_c =2.0151*10^ -3;
15 V_r3 = I_c * R3 ;
16 V_c =V - V_r3 ;
17 printf ( ” C o l l e c t o r v o l t a g e = %f V” , V_c ) ;

Scilab code Exa 7.9 Determine quiescent value of collector current and
voltage and peak to peak output voltage

58
1 // Ex : 7 . 9
2 clc ;
3 clear ;
4 close ;
5 V_pp =14.8 -3.3;
6 printf ( ” C o l l e c t o r q u i e s c e n t v o l t a g e = 9 . 2 V” ) ;
7 printf ( ” \ n C o l l e c t o r q u i e s c e n t c u r r e n t = 7 . 3mA” ) ;
8 printf ( ” \ nOutput peak−peak v o l t a g e = %f V” , V_pp ) ;

59
Chapter 8

Operational Amplifiers

Scilab code Exa 8.1 Determine the value of open loop voltage gain

1 // Ex : 8 . 1
2 clc ;
3 clear ;
4 close ;
5 V_out =2;
6 V_in =400*10^ -6;
7 A_v = V_out / V_in ;
8 A_v_dB = ceil (20*( log ( A_v ) / log (10) ) ) ;
9 printf ( ” open l o o p v o l t a g e g a i n = %d dB” , A_v_dB ) ;

Scilab code Exa 8.2 Determine the value of input current

1 // Ex : 8 . 2
2 clc ;
3 clear ;
4 close ;
5 V_in =5*10^ -3;
6 R_in =2*10^6;

60
7 I_in = V_in / R_in ;
8 printf ( ” I n p u t c u r r e n t = %e A” , I_in ) ;

Scilab code Exa 8.3 Determine the slew rate of device

1 // Ex : 8 . 3
2 clc ;
3 clear ;
4 close ;
5 V_out =10;
6 t =4;
7 SR = V_out / t ;
8 printf ( ” S l e w r a t e = %f V/ u s ” , SR ) ;

Scilab code Exa 8.4 Determine the time taken to change level

1 // Ex : 8 . 4
2 clc ;
3 clear ;
4 close ;
5 V_out =2;
6 SR =15; // i n V/ u s
7 t = V_out / SR ;
8 printf ( ” Time t a k e n = %f u s ” ,t ) ;

Scilab code Exa 8.6 Determine the circuit parameters using opamps

1 // Ex : 8 . 6
2 clc ;
3 clear ;

61
4 close ;
5 R_in =10000;
6 f1 =250;
7 f2 =15000;
8 C_in =0.159/( f1 * R_in ) ;
9 C_f =0.159/( f2 * R_in ) ;
10 printf ( ” C f = %e F” , C_f ) ;

62
Chapter 9

Oscillators

Scilab code Exa 9.1 Determine the freq of oscillation

1 // Ex : 9 . 1
2 clc ;
3 clear ;
4 close ;
5 C =10*10^ -9;
6 R =10000;
7 f =(1/(2* %pi * sqrt (6) * C * R ) ) ;
8 printf ( ” The f r e q o f o s c i l l a t i o n = %f Hz” ,f ) ;

Scilab code Exa 9.2 Determine the output freq

1 // Ex : 9 . 2
2 clc ;
3 clear ;
4 close ;
5 r1 =1000;
6 r2 =1000;
7 c =100*10^ -9;

63
8 f =(1/(2* %pi * c * r1 ) ) ;
9 printf ( ” The f r e q o f o s c i l l a t i o n a t 1 kohm= %f Hz” ,f )
;
10 R1 =6000;
11 R2 =6000;
12 F =(1/(2* %pi * c * R1 ) ) ;
13 printf ( ” \ nThe f r e q o f o s c i l l a t i o n a t 6 kohm= %f Hz” ,
F);

Scilab code Exa 9.3 Determine the value of R3 and R4

1 // Ex : 9 . 3
2 clc ;
3 clear ;
4 close ;
5 f =1000;
6 t =1/ f ;
7 C =10*10^ -9;
8 R = t /(1.4* C ) ;
9 printf ( ”R= %d kohm” ,R /1000) ;

64
Chapter 12

The 555 timer

Scilab code Exa 12.1 Determine the parameters of timer circuit

1 // Ex : 1 2 . 1
2 clc ;
3 clear ;
4 close ;
5 C =100*10^ -9;
6 t_on =10*10^ -3;
7 R =( t_on /(1.1* C ) ) /1000;
8 printf ( ”R= %f kohm” ,R ) ;

Scilab code Exa 12.2 Determine the parameters of timer circuit that pro-
duce 5V

1 // Ex : 1 2 . 2
2 clc ;
3 clear ;
4 close ;
5 C =100*10^ -6;
6 t_on =60;

65
7 R =( t_on /(1.1* C ) ) /1000;
8 printf ( ”R= %f kohm” ,R ) ;

Scilab code Exa 12.3 Design of pulse generator

1 // Ex : 1 2 . 3
2 clc ;
3 clear ;
4 close ;
5 //R1=R2=R
6 prf =10;
7 C =1*10^ -6;
8 R =0.48/( prf * C ) ;
9 printf ( ”R= %d ohm” ,R ) ;

Scilab code Exa 12.4 Design of 5V square wave generator

1 // Ex : 1 2 . 4
2 clc ;
3 clear ;
4 close ;
5 prf =50;
6 C =100*10^ -9;
7 R =0.72/( prf * C ) ; // i n ohms
8 printf ( ”R= %d kohm” ,R /1000) ;

66
Chapter 13

Radio

Scilab code Exa 13.1 Determine the frequency of radio signal of wave-
length 15m

1 // Ex : 1 3 . 1
2 clc ;
3 clear ;
4 close ;
5 c =3*10^8;
6 wl =15;
7 f = c / wl ;
8 printf ( ” The f r e q u e n c y =%d Hz” ,f ) ;

Scilab code Exa 13.2 Determine the frequency of radio signal of 150MHz

1 // Ex : 1 3 . 2
2 clc ;
3 clear ;
4 close ;
5 c =3*10^8;
6 f =150*10^6;

67
7 wl = c / f ;
8 printf ( ” The w a v e l e n g t h =%d m” , wl ) ;

Scilab code Exa 13.3 Determine the velocity of propagation of radio sig-
nal of 30MHz and 8m wavelength

1 // Ex : 1 3 . 3
2 clc ;
3 clear ;
4 close ;
5 wl =8;
6 f =30*10^6;
7 v = f * wl ;
8 printf ( ” The v e o c i t y o f p r o p a g a t i o n =%d m/ s ” ,v ) ;

Scilab code Exa 13.4 Determine the two possible BFO freq

1 // Ex : 1 3 . 4
2 clc ;
3 clear ;
4 close ;
5 f_rf =162.5; // i n kHz
6 f_af =1.25; // i n kHz
7 f_bfo_max = f_rf + f_af ;
8 f_bfo_min = f_rf - f_af ;
9 printf ( ” The two p o s s i b l e BFO f r e q . =%f kHz and %f
kHz ” , f_bfo_max , f_bfo_min ) ;

Scilab code Exa 13.5 Determine the range the local oscillator be tuned

68
1 // Ex : 1 3 . 5
2 clc ;
3 clear ;
4 close ;
5 f_rf_1 =88; // i n MHz
6 f_rf_2 =108; // i n MHz
7 f_if =10.7; // i n MHz
8 f_lo_1 = f_rf_1 + f_if ;
9 f_lo_2 = f_rf_2 + f_if ;
10 printf ( ” The r a n g e l o c a l
o s c i l l a t o r be t u n e d =%f MHz
& %f MHz” , f_lo_1 , f_lo_2 ) ;

Scilab code Exa 13.6 Determine the range the local oscillator be tuned

1 // Ex : 1 3 . 6
2 clc ;
3 clear ;
4 close ;
5 f_rf_1 =88; // i n MHz
6 f_rf_2 =108; // i n MHz
7 f_if =10.7; // i n MHz
8 f_lo_1 = f_rf_1 + f_if ;
9 f_lo_2 = f_rf_2 + f_if ;
10 printf ( ” The r a n g e l o c a l
o s c i l l a t o r be t u n e d =%f MHz
& %f MHz” , f_lo_1 , f_lo_2 ) ;

Scilab code Exa 13.7 Determine the radiated power

1 // Ex : 1 3 . 7
2 clc ;
3 clear ;
4 close ;
5 r =12; // i n ohms

69
6 i =0.5; // i n amps
7 P_r = i * i * r ; // i n W
8 printf ( ” Power r a d i a t e d = %d W” , P_r ) ;

Scilab code Exa 13.8 Determine the power and radiation efficiency

1 // Ex : 1 3 . 8
2 clc ;
3 clear ;
4 close ;
5 r =2; // i n ohms
6 i =0.5; // i n amps
7 P_r =4; // i n W
8 P_loss = i * i * r ;
9 P_eff =( P_r /( P_r + P_loss ) ) *100;
10 printf ( ” The power l o s s = %f W” , P_loss ) ;
11 printf ( ” \n The power l o s s = %f %%” , P_eff ) ;

70

You might also like