#Calculate max current and check will the capacitor act as short for given frequency
#given
import math
C=100.*10.**-6.;#Farad
Rs=1.*10.**3.;#ohm
Rl=4.*10.**3.;#ohm
Vs=1.;#V
Imax=Vs/(Rs+Rl);
fc=1./(2.*math.pi*(Rs+Rl)*C) #critical frequency
fh=10.*fc; #Border frequency
print '%s %.f %s' %("Maximum current is =",Imax*10**6,"uA\n");
print '%s %.2f %s' %("fh =",fh,"Hz\n");
print '%s %.2f %s %s' %("As long as source frequency is greater than",fh,"Hz","the coupling capacitor acts like an ac short for 20Hz to 20kHz")
#In book Imax is 200mA but there is misprinting of 'm' in mA it should be uA
#Check whether the capacitor is an effective bypass for the signal currents of lowest frequency 20 Hz
#given
import math
C=100.*10.**-6.;#Farad
Rs=1.*10.**3.;#ohm
Rl=4.*10.**3.;#ohm
f=20.;#Hz #lowest frequency
Xc=1./(2.*math.pi*f*C) #reactance of capacitor at 20Hz
Rth=Rs*Rl/(Rs+Rl); #Thevenins equivalent resistance
print '%s %.1f %s %.f %s ' %("Xc < Rth/10 is satisfied",Xc,"ohm",Rth/10,"ohm\n");
print '%s' %("The capacitor of 100uF will work as a good bypass for frequencies greater than 20 Hz ")
#Calculate the value of capacitor required
#given
import math
Rs1=20.*10.**3.;#ohm
Rs2=30.*10.**3.;#ohm
Rl1=40.*10.**3.;#ohm
Rl2=80.*10.**3.;#ohm
Rl3=80.*10.**3.;#ohm
Rth=Rs1*Rs2/(Rs1+Rs2); #Thevenins equivalent resistance
Rl_=Rl2*Rl3/(Rl2+Rl3);
Rl=Rl1*Rl_/(Rl1+Rl_); #Equivalent load
f=50.;#Hz #lowest frequency
R=Rth+Rl;
C=10./(2.*math.pi*f*R)
print '%s %.f %s' %("The required value of coupling capacitor is =",C*10**6,"uF");
#Calculate voltage and current gain and input and output resistance
def prll(r1,r2):
z=r1*r2/(r1+r2)#
return z
#given
#DC analysis
Vcc=12.;#V
Rb=200.*10.**3.;#ohm
Rc=1.*10.**3.;#ohm
B=100.;# beta
Ib=Vcc/Rb;
Ic=B*Ib;
Icsat=Vcc/Rc;
Vce=Vcc-Ic*Rc;
print '%s %.2f %s %.2f %s' %("The Q point of DC analysis=",Vce,"V",Ic*1000,"mA");
#AC analysis
Rl=1.*10.**3.;#ohm
hfe=B;
hie=2.*10.**3.;#ohm
hoe_1=40.*10.**3.;#ohm # 1/hoe
Rac=prll(Rc,Rl);
Av=-hfe*Rac/hie;
print '%s %.2f %s' %("\nThe voltage gain =",Av,"\n");
#Siince (1/hoe) > Rac therefore entire current will flows through Rac
Io=-100.*Ib;
Ac=Io/Ib;
print '%s %.2f %s' %("The current gain =",Ac,"\n");
Ri=prll(Rb,hie);
Ro=prll(Rl,prll(Rc,hoe_1));
print '%s %.f %s' %("The input resistance =",Ri/1000,"kohm\n");
print '%s %.1f %s' %("The output resistance =",Ro/1000,"kohm");
#In book the voltage gain is 25 due to skipping of '-' in printing
#Solve previous example using hybrid pie model
#soltion
#given
def prll(r1,r2):
z=r1*r2/(r1+r2)#
return z
Vcc=12.##V
Rb=200.*10.**3.##ohm
Rc=1.*10.**3.##ohm
Rl=1.*10.**3.##ohm
B=100.## beta
hie=2.*10.**3.##ohm
hoe_1=40.*10.**3.##ohm # 1/hoe
Ib=Vcc/Rb#
Ic=B*Ib#
Rac=prll(Rc,Rl)#
gm=Ic/(25.*10.**-3.)#
rpi=B/gm#
ri=hie#
rb=ri-rpi#
ro=hoe_1#
Vpi=rpi/(rpi+rb)#
Vo=-gm*Vpi*Rac# #output voltage
Av=Vo#
print '%s %.2f' %("The voltage gain",Av)#
#In book voltage gain is -24.96 due to appraoximation
#Determine the value of output voltage
#given
Vcc=12.;#V
Rb=150.*10.**3.;#ohm
Rc=5.*10.**3.;#ohm
B=200.;# beta
hie=2.*10.**3.;#ohm
ro=60.*10.**3.;#ohm # 1/hoe
Vi=1.*10.**-3.;#V
Ib=Vcc/Rb;
Ic=B*Ib;
Icsat=Vcc/Rc;
# Icsat < Ic therefore transistor is in saturation mode and outpuut voltage wil be zero
Vo=0;
print '%s %.f %s' %("The output voltage=",Vo,"V");
#Calculate voltage gain and input resistance
# Function definition is here
#given
def prll(r1,r2):
z=r1*r2/(r1+r2);
return z
R1=75.*10.**3.;#ohm
R2=7.5*10.**3.;#ohm
Rc=4.7*10.**3.;#ohm
Re=1.2*10.**3.;#ohm
Rl=12.*10.**3.;#ohm
B=150.;
ri=2.*10.**3.;#ohm
Vcc=15.;#V
Vb=Vcc*R2/(R1+R2);
Ve=Vb; #since Vbe=0
Ie=Ve/Re;
Ic=Ie;
Icsat=Vcc/(Rc+Re);
# Ic < Icsat therefore transistor is in active mode
Vce=Vcc-Ic*(Rc+Re);
print '%s %.2f %s %.2f %s' %("The Q point of DC analysis=",Vce,"V",Ic*1000,"mA");
Rac=prll(Rc,Rl);
Av=-B*Rac/ri;
print '%s %.1f %s' %("\nThe voltage gain =",Av,"\n");
Ri_=prll(ri,R2);
print '%s %.2f %s' %("The input resistance=",Ri_/1000,"kohm\n");
#Calculate the value of gm at different values of Vgs
#given
Idss=8.*10.**-3.;#A
Vp=4;#V
#At Vgs= -0.5 V
Vgs= -0.5;#V
gmo=2.*Idss/(abs(Vp));
gm=gmo*(1.-(Vgs/(-Vp)));
print '%s %.f %s' %("gmo =",gmo*1000,"mS\n");
print '%s %.1f %s' %("gm (At Vgs = -0.5V) =",gm*1000,"mS\n");
#At Vgs= -1.5 V
Vgs= -1.5;#V
gmo=2.*Idss/(abs(Vp));
gm=gmo*(1.-(Vgs/(-Vp)));
print '%s %.1f %s' %("gm (At Vgs = -1.5V) =",gm*1000,"mS\n");
#At Vgs= -2.5 V
Vgs= -2.5;#V
gmo=2.*Idss/(abs(Vp));
gm=gmo*(1.-(Vgs/(-Vp)));
print '%s %.1f %s' %("gm (At Vgs = -2.5V) =",gm*1000,"mS\n");
#Find the output signal voltage of the amplifier
#given
import math
Rd=12.*10.**3.;#ohm
Rg=1.*10.**6.;#ohm
Rs=1.*10.**3.;#ohm
Cs=25.*10.**-6.;#F
u=80.; #amplification factor
rd=200.*10.**3.;#ohm
Vi=0.1;#V
f=1.*10.**3.;#Hz #input frequency
Xcs=1./(2.*math.pi*f*Cs);
#This is much smaller than Rs therefore it is bypassed
gm=u/rd;
Av=gm*(rd*Rd/(rd+Rd));
Vo=Av*Vi;
print '%s %.3f %s' %("The output voltage is =",Vo,"V");
#Determine the small signal voltage gain and input and output resistance
#given
Rd=2.*10.**3.;#ohm
rd=100.*10.**3.;#ohm
Rg=1.*10.**6.;#ohm
gm=2.*10.**-3.;#S
Av=-gm*(rd*Rd/(rd+Rd));
Ri=Rg;
Ro=rd*Rd/(rd+Rd);
print '%s %.f %s %.f %s %s %.f %s' %("The small signal voltage gain =",Av,"\ninput resistance=",Ri/10**6,"Mohm","\noutput resistance =",Ro/1000,"kohm");
#Determine the small signal voltage gain and input and output resistance
#given
R1=500.*10.**3.;#ohm
R2=50.*10.**3.;#ohm
Rd=5.*10.**3.;#ohm
Rs=100.;#ohm
Rl=5.*10.**3.;#ohm
gm=1.5*10.**-3.;#S
rd=200.*10.**3.;#ohm
Rg=R1*R2/(R1+R2);
Rac=Rd*Rl/(Rd+Rl);
Av=-gm*Rac;
Ri=Rg;
Ro=(rd*Rac/(rd+Rac));
print '%s %.2f %s %.2f %s %s %.1f %s' %("The small signal voltage gain =",Av,"\nInput resistance =",Ri/1000,"kohm","\nOutput resistance =",Ro/1000,"kohm");
#Calculate the voltage gain of the FET
#given
Idss=8.*10.**-3.##A
Vp=4.##V
rd=25.*10.**3.##ohm
Rd=2.2*10.**3.##ohm #by the help of figure
Vgs=-1.8##V
gmo=2.*Idss/(abs(Vp))#
gm=gmo*(1.-(Vgs/(-Vp)))#
Av=-gm*(rd*Rd/(rd+Rd))#
print '%s %.2f' %("The voltage gain of the FET =",Av)#