# minimum base current to work transistor in saturation region
import math
#Variable declaration
vcc=12.0 # V
rl=4.0 # Ohm
alfa=0.98
#Calculations
ic=vcc/rl
B=alfa/(1-alfa)
ibmin=ic/B
#Result
print("Ic(saturation)= %d mA\nBeta = %.0f \nIb(min) = %.1f micro A"%(ic,B,ibmin*1000))
# maximum allowable value of RB for transistor in cut off
import math
#Variable declaration
t1=75.0
t2=25.0
icbo=2.0 # at T1=25
vbe=0.1
vbb=5
#Calculations
icbo2=icbo*2**((t1-t2)/10)
Rb=(vbb-vbe)/icbo2
#Result
print("Icbo at 75°C = %.0f micro A\nRb = %.1f K-Ohm"%(icbo2,Rb*1000))
# temperature increase before transistor comes of cut off
import math
#Variable declaration
vbb=-1.0 # V
Rb=50.0 # K-Ohm
vbe=-0.1
#Calculations
Icbo=(vbe-vbb)/Rb
t=math.log(Icbo*1000/2)*10/(math.log(2))
#Result
print("Icbo = %.0f micro A"%(Icbo*1000))
print("Delta_T = %d°C \nHence, T = %d°C"%(math.ceil(t),math.ceil(t)+25))
# calculation of ib ic and vbc for transistor AF 114
import math
#Variable declaration
vce = - 0.07 # V
vbe = - 0.21 # V
vcc=-9.0
rc=1.0 # K-Ohm
rb=30.0 # K-Ohm
#Calculations
ic=(vcc-vce)/rc
ib=(vcc-vbe)/rb
vbc=vbe-vce
#Result
print("Ic = %.2f mA\nIB = %.3f mA\nVbc = %.2f V"%(ic,ib,vbc))
# calculation of resistance in CE configuration
import math
#Variable declaration
alfa=0.98
Ie=-2.0 # in mA IE is negative because it is NPN transistor
Ic=-alfa*Ie
Ib=(1-alfa)*(-Ie)
vbe=0.6 # V
vcc=12.0 # V
re=100.0 # ohm
r2= 20000.0 # ohm
r1=3.3 # k-Ohm
#Calculations
vbn=vbe-(Ie*re*10**-3)
Ir2=vbn*10**3/r2
Ir1=Ir2+Ib
vr1=vcc-((Ir1+Ic)*r1)-vbn
R1=vr1/Ir1
#Result
print("Ic = %.2f mA\nIb = %.0f micro A\nV_BN =%.1f V"%(Ic,Ib*1000,vbn))
print("IR1 = %.0f micro A\nIR2 = %.0f micro A\nIrc = %.2f mA"%(Ir1*1000,Ir2*1000,Ir1+Ic))
print("R1 = %d K-Ohm"%(math.ceil(R1)))
# Barrier Potential
import math
#Variable declaration
eps=12/(36*math.pi*10**11) # F/cm
mup=500.0 # cm^2/V-Sec
#Calculations
Vb=(2.54/1000)**2/(2*eps*mup)
#Result
print("VB = %.1f*10^3*W^2/rho_B"%(Vb/1000))
# Av Ai and Ap of transistor in CB configuration
import math
#Variable declaration
alfa=0.96
Rl=5000.0
x=80.0
#Calculations
Av=alfa*Rl/x
pg=Av*alfa
#Result
print("Power Gain = %.1f"%pg)
# Av Ai and Ap of Transistor in CE configuration
import math
#Variable declaration
alfa = 0.96
B=alfa/(1-alfa)
x=80.0
Rl=75000.0 # ohm
#Calculations
Av=B*Rl/x
Ap=Av*B
#Result
print("power gain = %.0f"%Ap)
# Junction voltages for open collector transistor
import math
#Variable declaration
ico=2.0 # micro A
ieo=1.6 # micro A
alfa = 0.98
ie=2.0 # micro A
T=301.6
#Calculations
vt=T/11600.0
ve=vt*math.log(1+(ie/ieo))
vc=vt*math.log(1+(alfa*ie/ico))
#Result
print("Ve = %.4f V"%ve)
print("Vc = %.4f V\nV_CE = %.4f V"%(vc,vc-ve))
# variation in Vi corresponding to variation in Vo
import math
#Variable declaration
rs=200.0 # Ohm
vz=100.0 # V
rz=20.0 # Ohm
il=50.0 # mA
iz=0.01 # mA
ilmax=100.0 # mA
#calculations
izmin=0.1*ilmax
vl=vz+iz*rz
v1=vl+((il/1000)+iz)*rs
vldash=vl+1
izdash=(vldash-100)/rz
it=(il/1000)+izdash
vt=vldash+(rs*it)
#Result
print("V_L = %.1f V"%vl)
print("V1 = %.1fV"%v1)
print("Increase in Iz = %.2f mA"%izdash)
print("Total Current = %.1f A\nTotal Voltage = %.1f V\nchange in V1 =%.0fV"%(it,vt,vt-v1))
print("\nA change of 11 V in V, on the input side produces a change of")
print("1V on the output side due to zener diode action")
# Design of bias circuit for zero drain current drift
import math
#Variable declaration
vp=-3.0 # V
idss=1.75 # mA
rd=5.0 # K-Ohm
gmo=1.8 # mA/V
#Calculations
#(a)
id=idss*(1-(vgs/vp))**2
#(b)
vgs=vp-0.63 # V
#(c)
rs=-vgs/0.08
#(d)
gm=gmo*(vgs-vp)/vp
Av=gm*rd
#Rezult
print("(a)Id for zero drift current\nId = %.2f mA"%id)
print("\n(b)\nVgs = %.2f V\n\n(c)\nRs = %d K-Ohm\n\n(d)\ngm = %.3f mA/V\nAv = %.2f"%(vgs,rs,gm,Av))
# pinch off voltage
import math
#Variable declaration
a=2*10**-4 # cm
rho = 10.0 # Ohm-cm
#Calculations
eps=12.0/(36*math.pi*10**11)
mup = 500.0 #cm^2/V-sec
ena=1/(rho*mup)
vp= (ena*a**2)/(2*eps)
#Result
print("Vp = %.2f V"%vp)
print("Same as problem 4.15 in the same chapter")
# pinch off voltage and channel half width
import math
#Variable declaration
a=3*10**-4 # cm
nd=10**15 # electrons/cm^3
e=1.6*10**-19 # C
#Calculations
eps=12.0/(36*math.pi*10**11)
vp=e*nd*a**2/(2*eps)
b=a*(1-(1.0/2)**(1.0/2))
#Result
print("(a)\nVp = %.1f V"%vp)
print("\n(b)Vgs=Vp/2\nb = %.2f * 10^-4 cm"%(b*10**4))
# design of self bias circuit
import math
#Variable declaration
vdd=30.0 # v
rl=4.7 # k-ohm
vd=20.0 # v
#Calculations
id=(vdd-vd)/rl
del_id=1/rl
delv=vdd-vd
deli=2.5
rs=delv/(deli)
#Result
print("Id = %.1f mA"%id)
print("\nfor Vd to be constant, it should be within ±1V.")
print("Delta_Id = ± %.1f mA\nId(min) = %.3f mA\nId(max) = %.3f mA"%(del_id,id-del_id,id+del_id))
print("Rs = %d K-Ohm"%rs)
# Voltage gain and output impedance of common source amplifier
import math
#Variable declaration
rd=100*10**3 # Ohm
gm=3000*10**-6
rl=10000.0 # Ohm
f=10**6 # Hz
c=3*10**-12 # F
r0= 9.09 # K-Ohm
#Calculations
Av=(-gm*rd*rl)/(rd+rl)
xc=1/(2*math.pi*f*c)
z0 = (r0*xc)/math.sqrt(r0**2 + (xc/1000)**2)
#Result
print("(a)\nAv = %.1f"%Av)
print("\n(b)\nXc = %d K-Ohm"%(xc/1000))
print("Z0 = %.2f K-Ohm"%(z0/1000))
# calculation of Vgs Id and Vds
import math
#Variable declaration
idss=5*10**-3 # mA
vp = -5.0 # V
rs =5000.0 # Ohm
rl=2.0 # k-ohm
vdd=10.0
#Calculations
#Vgs^2+11Vgs+25=0 fro equation of Id and Vgs
vgs=(-11+math.sqrt(121-100))/2
id=idss*(1-(vgs/vp))**2
x=id*rl*1000
y=id*rs
vds =vdd-x-y
#Result
print("Vgs = %.2fV\nId = %.2f mA\nVds = %.1f V\nThe FET must be conducting."%(vgs,id*1000,vds))
print("\nIf VGS = -7.8V, the FET in cut off. Therefore Vp = -5V.")
print("Therefore VGS is chosen as -3.2V")