import math
##Example 4.1
b=100.;
Vcc=12.;
Vbe=0.7;
Rc=6.;
Rb=50.;
Vbb=1.2;
##dc solution
Ibq=(Vbb-Vbe)/Rb;
print"%s %.2f %s"%('\nbase current= ',Ibq,' mA\n')
Icq=b*Ibq;
print"%s %.2f %s"%('\ncollector current= ',Icq,' mA\n')
Vceq=Vcc-Icq*Rc;
print"%s %.2f %s"%('\ncollector emitter voltage= ',Vceq,' V\n')
##transistor is forward biased
##ac solution
V_T=0.026;##(V)
##small signal hybrid pi parameters
r_pi=b*V_T/Icq;
print"%s %.2f %s"%('\nsmall signal resistance= ',r_pi,' KOhm\n')
g_m=Icq/V_T;
print"%s %.2f %s"%('\ntransconductance= ',g_m,' mA/V\n')
##Av=Vo/Vs=-(g_m*Rc)*r_pi/(r_pi+Rb)
Av=-(g_m*Rc)*r_pi/(r_pi+Rb);
print"%s %.2f %s"%('\nsmall signal voltage gain=\n',Av,'')
import math
##Example 4.2
V_pi=50.;##(V)
Icq=1.;##(mA)
ro=V_pi/Icq;
print"%s %.2f %s"%('\nsmall signal output resistance= ',ro,' KOhm\n')
Rc=6.;
g_m=38.5;
r_pi=2.6;
Rb=50.;
Av=-(g_m)*(Rc*ro/(Rc+ro))*r_pi/(r_pi+Rb);
print"%s %.2f %s"%('\nsmall signal voltage gain= \n',Av,'')
import math
##Example 4.4
b=100.;
Vbe=0.7;
Va=100.;
V_T=0.026;##(V)
##from dc analysis
Icq=0.95;
Vceq=6.31;
##ac analysis
r_pi=b*V_T/Icq;
print"%s %.2f %s"%('\nsmall signal resistance= ',r_pi,' KOhm\n')
g_m=Icq/V_T;
print"%s %.2f %s"%('\ntransconductance= ',g_m,' mA/V\n')
Rs=0.5;
Rc=6.;
ro=Va/Icq;
print"%s %.2f %s"%('\nro= ',ro,' KOhm\n')
Av=-g_m*(5.9*r_pi/(5.9+r_pi))/((5.9*r_pi/(r_pi+5.9))+Rs)*ro*Rc/(ro+Rc);
print"%s %.2f %s"%('\nsmall signal voltage gain= ',Av,' \n')
Ri=5.9*r_pi/(r_pi+5.9);
print"%s %.2f %s"%('\ninput resistance= ',Ri,' KOhm\n')
Ro=ro*Rc/(ro+Rc);
print"%s %.2f %s"%('\noutput resistance= ',Ro,' KOhm\n')
import math
##Example 4.5
b=100.;
Vbe=0.7;
Rc=2.;
Rs=0.5;
Icq=2.16;
V_T=0.026;##(V)
Vceq=4.8
##ac solution
r_pi=b*V_T/Icq;
print"%s %.2f %s"%('\nsmall signal resistance= ',r_pi,' KOhm\n')
g_m=Icq/V_T;
print"%s %.2f %s"%('\ntransconductance= ',g_m,' mA/V\n')
##since Va=infinity,ro=Va/Icq is also infinity
Re=0.4;
Rib=r_pi+(1.+b)*Re;
print"%s %.2f %s"%('\ninput resistance to the base= ',Rib,' KOhm\n')
##Ri=R1||R2||Rib
Ri=10.*Rib/(10.+Rib);
print"%s %.2f %s"%('\ninput resistance to the amplifier= ',Ri,' KOhm\n')
Av=-(1./(r_pi+(1.+b)*Re))*b*Rc*Ri/(Ri+Rs);
print"%s %.2f %s"%('\nsmall signal voltage gain= \n',Av,'')
##by approximate expression
Av=-Rc/Re;
print"%s %.2f %s"%('\nsmall signal voltage gain= \n',Av,'')
import math
##Example 4.7
Iq=0.5;
b=120.;
Va=80.;
V_T=0.026;##(V)
rc=120.;##small signal collector resistance (KOhm)
##Icq=Iq
Icq=0.5;
g_m=Icq/V_T;
print"%s %.2f %s"%('\ntransconductance= ',g_m,' mA/V\n')
ro=Va/Icq;
print"%s %.2f %s"%('\nsmall signal output resistance= ',ro,' KOhm\n')
Av=-g_m*ro*rc/(ro+rc);
print"%s %.2f %s"%('\nsmall signal voltage gain= ',Av,' \n')
import math
##Example 4.8
b=150.;Veb=0.7;
##dc solution
V2=10.;
V1=-10.;
V_T=0.026;##(V)
Rc=5.;
Rb=50.;
Re=10.;
Ibq=(V2-Veb)/(Rb+(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')
Vecq=V2-V1-Icq*Rc-Ieq*Re;
print"%s %.2f %s"%('\nemitter collector voltage= ',Vecq,' V\n')
##ac solution
r_pi=b*V_T/Icq;
print"%s %.2f %s"%('\nsmall signal resistance= ',r_pi,' KOhm\n')
g_m=Icq/V_T;
print"%s %.2f %s"%('\ntransconductance = ',g_m,'mA/V\n')
##since Va=infinity,ro=Va/Icq is also infinity
import math
##Example 4.9
Ic=0.894;
i_C=2.*Ic;
print"%s %.2f %s"%('\nmaximum possible symmetrical peak to peak ac collector current= ',i_C,' mA\n')
Rc=5.;
Rl=2.;
vo=i_C*Rc*Rl/(Rc+Rl);
print"%s %.2f %s"%('\nmaximum possible symmetrical peak to peak output voltage= ',vo,' V\n')
iC=Ic+i_C*1/2.;
print"%s %.2f %s"%('\nmaximum instantaneous collector current= ',iC,' mA\n')
import math
##Example 4.10
b=100.;
Vbe=0.7;
V_T=0.026;##(V)
Re=2.;
R1=50.;
R2=50.;
Rs=0.5;
Va=80.;
##by dc analysis
Icq=0.793;
Vceq=3.4;
r_pi=b*V_T/Icq;
print"%s %.2f %s"%('\nsmall signal resistance= ',r_pi,' KOhm\n')
g_m=Icq/V_T;
print"%s %.2f %s"%('\ntransconductance= ',g_m,' mA/V\n')
ro=Va/Icq;
print"%s %.2f %s"%('\nsmall signal output resistance= ',ro,' KOhm\n')
Rib=r_pi+(1.+b)*Re*ro/(ro+Re);
print"%s %.2f %s"%('\ninput resistance to the base= ',Rib,' KOhm\n')
##Ri=R1||R2||Rib
x=R1*R2/(R1+R2);
Ri=x*Rib/(x+Rib);
print"%s %.2f %s"%('\nRi= ',Ri,' KOhm\n')
y=ro*Re/(ro+Re);
Av=(1./(r_pi+(1.+b)*y))*(1.+b)*y*Ri/(Ri+Rs);
print"%s %.2f %s"%('\nsmall signal voltage gain= ',Av,' \n')