import math
##Example 3.1
##let beta be "b"
b=150.;##common emitter current gain
iB=15*10**-3;##(mA) base current
##assume transistor biased in forward active mode
iC=b*iB;
print"%s %.2f %s"%('\ncollector current= ',iC,' mA\n')
iE=(1.+b)*iB;
print"%s %.2f %s"%('\nemitter current= ',iE,' mA\n')
a=b/(1.+b);
print"%s %.2f %s"%('\ncommon base current gain=',a,'')
import math
#calculate the
##Example 3.2
b=100.;##common emitter current gain
BVcbo=120.;##(V) break down voltage of the B-C junction
n=3.;##empirical constant
BVceo=BVcbo/(b)**(1./n);
print"%s %.2f %s"%('\nbreakdown voltage= ',BVceo,' V\n')
import math
##Example 3.3
Vbb=4.;##(V)
Rb=220.##(KOhm);
Rc=2.;##(KOhm)
Vcc=10.;##(V)
Vbe=0.7;##(V)
b=200.;
##from fig.3.19(b)
Ib=(Vbb-Vbe)/Rb;
print"%s %.2f %s"%('\nbase current= ',Ib,' mA\n')
Ic=b*Ib;
print"%s %.2f %s"%('\ncollector current= ',Ic,' mA\n')
Ie=(1.+b)*Ib;
print"%s %.2f %s"%('\nemitter current= ',Ie,' mA\n')
Vce=Vcc-Ic*Rc;
print"%s %.2f %s"%('\ncollector emitter voltage= ',Vce,' V\n')
import math
##Example 3.4
Vbb=1.5;##(V)
Rb=580.;##(KOhm)
Veb=0.6;##(V)
Vcc=5.;##(V)
b=100.;
##writing Kirchhoff voltage law equation around E-B loop
Ib=(Vcc-Veb-Vbb)/Rb;
print"%s %.2f %s"%('\nbase current= ',Ib,' mA\n')
Ic=b*Ib;
print"%s %.2f %s"%('\ncollector current= ',Ic,' mA\n')
Ie=(1.+b)*Ib;
print"%s %.2f %s"%('\nemitter current=',Ie,' mA\n')
Vec=(1./2.)*Vcc;
print"%s %.2f %s"%('\nce voltage= ',Vec,' V\n')
Rc=(Vcc-Vec)/Ic;
print"%s %.2f %s"%('\ncollector resistance= ',Rc,' KOhm\n')
import math
##Example 3.5
b=100.;
Vbe=0.7;##(V)
Vce=0.2;##(V)
Vbb=8.;##(v)
Rb=220.;##(KOhm)
Ib=(Vbb-Vbe)/Rb
print"%s %.2f %s"%('\nbase current= ',Ib,' mA\n')
##transistor in active region
Ic=b*Ib;
print"%s %.2f %s"%('\ncollector current= ',Ic,' mA\n')
Vcc=10.;##(V)
Rc=4.;##(KOhm)
Vce=Vcc-Ic*Rc;
print"%s %.2f %s"%('\ncollector emitter voltage= ',Vce,' V\n')
##saturation
Vce=0.2;##(V)
Ic=(Vcc-Vce)/Rc;
print"%s %.2f %s"%('\nsaturation collector current= ',Ic,' mA\n')
x=Ic/Ib
##which is <b
Ie=Ic+Ib;
print"%s %.2f %s"%('\nemitter current= ',Ie,' mA\n')
import numpy
import matplotlib
from matplotlib import pyplot
import math
%matplotlib inline
import warnings
warnings.filterwarnings('ignore')
#calculate the
##Example 3.6
Vbe=0.7;
b=75.;
##Q point values::
##using KVL eq around the B-E loop
##Vbb=Ib*Re+Vbe+Ie*Re
##assuming transistor is in forward biased mode we can write Ie=(1+b)*Ib
Vbb=6.;
Rb=25.;##KOhm
Re=0.6;##KOhm
Ib=(Vbb-Vbe)/(Rb+(1.+b)*Re);
print"%s %.2f %s"%('\nbase current= ',Ib,' mA\n')
Ic=b*Ib;
print"%s %.2f %s"%('\ncollector current= ',Ic,' mA\n')
Ie=(1+b)*Ib;
print"%s %.2f %s"%('\nemitter current= ',Ie,' mA\n')
Vcc=12.;
Rc=0.4;
Vce=Vcc-Ic*Rc-Ie*Re;
print"%s %.2f %s"%('\ncollector emitter voltage= ',Vce,' V\n')
##load line::
##using KVL law around C-E loop
##Vce=Vcc-(Ic*(Rc+((1+B)/B)*Re));
Ic=numpy.array([0.12,5.63])
Vce=12.-(Ic)*1
pyplot.plot(Vce,Ic)
pyplot.xlabel("Vce")
pyplot.ylabel("Ic")
pyplot.show()
import math
import numpy
import matplotlib
from matplotlib import pyplot
%matplotlib inline
#calculate the
##Example 3.7
Vbe=0.65;
Vcc=5.;
Rc=0.5;##KOhm
b=100.;
V1=-5.;
Re=1.;##KOhm
## Q-point values :: writing KVL eq around B-E loop
Ie=(-V1-Vbe)/Re;
print"%s %.2f %s"%('\nemitter current= ',Ie,' mA\n')
Ib=(Ie/(1.+b));
print"%s %.2f %s"%('\nbase current= ',Ib,' mA\n')
Ic=(b/(1.+b))*Ie;
print"%s %.2f %s"%('\ncollector current= ',Ic,' mA\n')
Vce=Vcc-Ic*Rc-Ie*Re-V1;
print"%s %.2f %s"%('\ncollector emitter voltage= ',Vce,' V\n')
##load line::
##Vce=Vcc-V1-(Ic*(Rc+((1+B)/B)*Re));
Vce=numpy.array([0,2,3.5,4,6,8,10])
Ic=(10.-Vce)/1.51;
pyplot.plot(Vce,Ic)
pyplot.xlabel("Vce")
pyplot.ylabel("Ic")
pyplot.title("load line")
import math
import numpy
import matplotlib
from matplotlib import pyplot
%matplotlib inline
#calculate the
##Example 3.9
b=100.;
Vbe=0.7;
V1=-5.;
V2=12.;
Rb=10.;
Re=5.;
Rc=5.;
Rl=5.;
##Q point values:: using KVL eq around B-E loop
Ib=-(V1+Vbe)/(Rb+(1.+b)*Re);
print"%s %.2f %s"%('\nbase current= ',Ib,' mA\n')
Ic=b*Ib;
print"%s %.2f %s"%('\ncollector current= ',Ic,' mA\n')
Ie=(1.+b)*Ib;
print"%s %.2f %s"%('\nemitter current= ',Ie,' mA\n')
##at collector node we can write Ic=(V2-Vo)/Rc-Vo/Rl
Vo=(V2/Rc-Ic)*Rc*Rl/(Rc+Rl);
print"%s %.2f %s"%('\noutput voltage= ',Vo,' V\n')
Vce=Vo-Ie*Re-V1;
print"%s %.2f %s"%('\ncollector emitter voltage= ',Vce,' V\n')
##load line::
Rth=Rl*Rc/(Rl+Rc);
print"%s %.2f %s"%('\nThevenin rquivalent resistance= ',Rth,' KOhm\n')
Vth=(Rl/(Rl+Rc))*V2;
print"%s %.2f %s"%('\nThevenin equivalent voltage= ',Vth,' V\n')
##fig.3.36(c) KVL law
##Vce=6-V1-Ic*Rth-Ie*Re;
Vce=numpy.array([0,2,4.7,3.5,4,6,8,10])
Ic=(11.-Vce)/7.5;
pyplot.plot(Vce,Ic)
pyplot.xlabel("Vce")
pyplot.ylabel("Ic")
pyplot.title("load line")
import math
#calculate the
##Example 3.10
Rb=0.24;
Vcc=12.;
Vbe=0.7;
Vce=0.1;
b=75.;
Rc=5.;##Ohm
##for Vt=0 ,transistor is cut off,Ib=Ic=0,Vo=Vcc=12 V,power dissipation is zero
Vt=12.;##(V)
Ib=(Vt-Vbe)/Rb;
print"%s %.2f %s"%('\nbase current= ',Ib,' mA\n')
Ic=(Vcc-Vce)/Rc;
print"%s %.2f %s"%('\ncollector current= ',Ic,'A\n')
Ib=0.0471;##A
x=Ic/Ib
##since Ic/Ib<b transistor is in saturation
##Vo==Vcc;
Vo=0.1;
print"%s %.2f %s"%('\noutput voltage= ',Vo,' V\n')
P=Ic*Vce+Ib*Vbe;
print"%s %.2f %s"%('\npower dissipation= ',P,' W\n')
import math
##Example 3.13
b=100.;
Vcc=12.;
Vbe=0.7;
Icq=1.;##mA
Vceq=6.;
Rc=(Vcc-Vceq)/Icq;
print"%s %.2f %s"%('\ncollector resistance= ',Rc,' KOhms\n')
Ibq=Icq/b;
print"%s %.2f %s"%('\nbase current= ',Ibq,' mA\n')
Rb=(Vcc-Vbe)/Ibq;
print"%s %.2f %s"%('\nbase resistance= ',Rb,' KOhms\n')
import math
##Example 3.14
R1=56.;
R2=12.2;
Rc=2.;
Re=.4;
Vcc=10.;
Vbe=0.7;
b=100.;
##fig.3.53(b)
Rth=R2*R1/(R1+R2);
print"%s %.2f %s"%('\nThevenin rquivalent resistance= ',Rth,' KOhm\n')
Vth=(R2/(R1+R2))*Vcc;
print"%s %.2f %s"%('\nThevenin equivalent voltage= ',Vth,' V\n')
Ibq=(Vth-Vbe)/(Rth+(1.+b)*Re);
print"%s %.2f %s"%('\nbase current= ',Ibq,' mA\n')
Icq=b*Ibq;
print"%s %.2f %s"%('\ncollector current= ',Icq,' mA\n')
Ieq=(1.+b)*Ibq;
print"%s %.2f %s"%('\nemitter current= ',Ieq,' mA\n')
Vceq=Vcc-Icq*Rc-Ieq*Re;
print"%s %.2f %s"%('\ncollector emitter voltage= ',Vceq,' V\n')
b=numpy.array([50,100,150])
for x in range(0,150):
Ibq=(Vth-Vbe)/(Rth+(1.+x)*Re);
print("Ibeq,Iceq,Ieq,Vceq")
print(Ibq)
Icq=x*Ibq;
print(Icq)
Ieq=(1+x)*Ibq;
print(Ieq)
Vceq=Vcc-Icq*Rc-Ieq*Re;
print(Vceq)
print("")
import math
##Example 3.15
Vcc=5.;
Rc=1.;##KOhm
Vbe=0.7;
b=120.;
Vceq=3.;
Re=.510;
Icq=(Vcc-Vceq)/(Rc+Re);
print"%s %.2f %s"%('\ncollector current= ',Icq,' mA\n')
Ibq=Icq/b;
print"%s %.2f %s"%('\nbase current= ',Ibq,' mA\n')
##for bias stable circuit
Rth=0.1*(1.+b)*Re;
print"%s %.2f %s"%('\nThevenin rquivalent resistance= ',Rth,' KOhm\n')
##Ibq=(Vth-Vbe)/(Rth+(1+b)*Re)
Vth=Ibq*(Rth+(1.+b)*Re)+Vbe;
print"%s %.2f %s"%('\nThevenin equivalent voltage= ',Vth,' V\n')
##Vth=(R2/(R1+R2))*Vcc
##let x=(R2/(R1+R2))
x=Vth/Vcc
##Rth=6050=R1*x
R1=6.05/x;
print"%s %.2f %s"%('\nR1= ',R1,'KOhms\n')
R2=x*R1/(1-x);
print"%s %.2f %s"%('\nR2= ',R2,'KOhms\'')
import math
##Example 3.16
R1=10.;
b=50.;
Vbe=0.7;
V1=-5.;
I1=-(V1+Vbe)/R1;
print"%s %.2f %s"%('\nreference current= ',I1,' mA\n')
Iq=I1/(1.+2./b);
print"%s %.2f %s"%('\nbias current= ',Iq,' mA\n')
##Ib=Ib1=Ib2
Ib=Iq/b;
print"%s %.2f %s"%('\nbase current= ',Ib,' mA\n')
import math
#calculate the
##Example 3.17
Vbe=0.7;
Vcc=10.;
V2=5.;
b=100.;
R1=100.;
R2=50.;
Re1=2.;
Rth=R2*R1/(R1+R2);
print"%s %.2f %s"%('\nThevenin rquivalent resistance= ',Rth,' KOhm\n')
Vth=(R2/(R1+R2))*Vcc-V2;
print"%s %.2f %s"%('\nThevenin equivalent voltage= ',Vth,' V\n')
##Vth=Ib1*Rth+Vbe+Ie1*Re1-5 and Ie1=(1+b)*Ib1
Ib1=(Vth+5-Vbe)/(Rth+(1+b)*Re1);
print"%s %.2f %s"%('\nIb1= ',Ib1,' mA\n')
Ic1=b*Ib1;
print"%s %.2f %s"%('\nIc1= ',Ic1,' mA\n')
Ie1=(1.+b)*Ib1;
print"%s %.2f %s"%('\nIe1= ',Ie1,' mA\n')
##summing the currents at the collector of Q1,Ir1+Ib2=Ic1
##(5-Vc1)/Rc1+Ib2=Ic1
##also Ib2=Ie2/(1+b)=(5-(Vc1+0.7))/(1+b)*Re2
Rc1=5.;
Re1=2.;
Re2=2.;
Rc2=1.5;
Vc1=Rc1*(1.+b)*Re2*((5./Rc1)+(4.3/((1.+b)*Re2))-Ic1)/(((1.+b)*Re2)+Rc1);
print"%s %.2f %s"%('\nVc1= ',Vc1,' V\n')
Ir1=(5.-Vc1)/Rc1;
print"%s %.2f %s"%('\nIr1= ',Ir1,' mA\n')
Ve2=Vc1+Vbe;
print"%s %.2f %s"%('\nVe2= ',Ve2,' V\n')
Ie2=(5-Ve2)/Re1;
print"%s %.2f %s"%('\nIe2= ',Ie2,' mA\n')
Ic2=Ie2*b/(1.+b);
print"%s %.2f %s"%('\nIc2= ',Ic2,' mA\n')
Ib2=Ie2/(1.+b);
print"%s %.2f %s"%('\nIb2 ',Ib2,' mA\n')
Ve1=Ie1*Re1-5;
print"%s %.2f %s"%('\nVe1= ',Ve1,' V\n')
Vc2=Ic2*Rc2-5.;
print"%s %.2f %s"%('\nVc2= ',Vc2,' V\n')
Vce1=Vc1-Ve1;
print"%s %.2f %s"%('\nVce1= ',Vce1,'V\n')
Vec2=Ve2-Vc2;
print"%s %.2f %s"%('\nVec2= ',Vec2,' V\n')