import math
##Example 7.1
Rs=1000.;
Rp=10000.;
Cs=1.*10**-6;
Cp=3.*10**-12;
Ts=(Rs+Rp)*Cs;
print"%s %.2f %s"%('\ntime constant= ',Ts,' s\n')
f=1/(2.*math.pi*Ts);
print"%s %.2f %s"%('\ncorner frequency= ',f,' Hz\n')
x=20.*math.log10(Rp/(Rp+Rs));
print"%s %.2f %s"%('\nmaximum magnitude = ',x,'dB\n')
Rp=10.;##KOhm
Rs=1.;##Kohm
Cp=3.;##pF
Tp=Cp*Rs*Rp/(Rs+Rp);
print"%s %.2f %s"%('\ntime constant= ',Tp,' ns\n')
Tp=2.73*10**-3;##micro sec
f=1/(2.*math.pi*Tp);
print"%s %.2f %s"%('\ncorner frequency = ',f,'MHz\n')
import math
##Example 7.2
Rs=1000.;
Rp=10000.;
Cs=1*10**-6;
Cp=3*10**-12;
Ts=(Rs+Rp)*Cs;
print"%s %.2f %s"%('\nopen circuit time constant= ',Ts,' s\n')
Rs=1.;##KOhm
Rp=10.;##KOhm
Cp=3.;##pF
Tp=Cp*Rs*Rp/(Rs+Rp);
print"%s %.2f %s"%('\nshort circuit time constant= ',Tp,' ns\n')
fL=1./(2.*math.pi*Ts);
print"%s %.2f %s"%('\ncorner frequency fL= ',fL,' Hz\n')
Tp=2.73*10**-3;##microsec
fH=1/(2.*math.pi*Tp);
print"%s %.2f %s"%('\ncorner frequency fH= ',fH,' MHz\n')
fL=14.5*10**-6;##MHz
fbw=fH-fL;
print"%s %.2f %s"%('\nbandwidth = ',fbw,' MHz\n')
import math
##Example 7.3
R1=51.2;
R2=9.6;
Rc=2.;
Re=.4;
Rsi=.1;
Vt=0.026;
Cc=1.;
Vcc=10.;
Vbe=0.7;
b=100.;
Rb=8.08;
Icq=1.81;
gm=Icq/Vt;
print"%s %.2f %s"%('\ntransconductance= ',gm,' mA/V\n')
r=b*Vt/Icq;
print"%s %.2f %s"%('\ndiffusion resistance= ',r,' KOhm\n')
x=r+(1.+b)*Re;
y=x*R2/(x+R2);
Ri=y*R1/(R1+y);
print"%s %.2f %s"%('\ninput resistance= ',Ri,' KOhm\n')
Ts=(Rsi+Ri)*Cc;
print"%s %.2f %s"%('\ntime constant= ',Ts, 'ms')
Ts=6.87*10**-3;##Sec
fL=1/(2.*math.pi*Ts);
print"%s %.2f %s"%('\ncorner frequency fL= ',fL,' Hz\n')
Rib=r+(1.+b)*Re;
print"%s %.2f %s"%('\nRib= ',Rib,' KOhm\n')
Av=(gm*r*Rc/(Rsi+Ri))*Rb/(Rb+Rib);
print"%s %.2f %s"%('\nsmall signal voltage gain= ',Av,'\n')
import math
##Example 7.4
fL=20.*10**-3;##KHz
Rd=6.7;
Rl=10;
Ts=1./(2.*math.pi*fL);
print"%s %.2f %s"%('\ntime constant= ',Ts,' ms\n')
Cc=Ts/(Rd+Rl);
print"%s %.2f %s"%('\ncoupling capacitance= ',Cc,' microF\n')
import math
##Example 7.5
b=100.;
Vbe=0.7;
Rs=500.;
Rb=100000.;
Re=10000.;
Rl=10000.;
Va=120.;
Ccc2=1*10**-6;
Icq=0.838*0.001;
r=3100.;##small signal parameter
gm=32.2*0.001;
ro=143000.;
x=(r+Rs*Rb/(Rs+Rb))/(1+b);
y=ro*x/(ro+x);
Ro=Re*y/(Re+y);
print"%s %.2f %s"%('\noutput resistance of emitter= ',Ro,' Ohm\n')
Ts=(Ro+Rl)*Ccc2;
print"%s %.2f %s"%('\ntime constant= ',Ts,' s\n')
fL=1/(2.*math.pi*Ts);
print"%s %.2f %s"%('\n3dB frequency= ',fL,' Hz\n')
import math
##Example 7.6
Rs=3.2;
Rd=10.;
Rl=20.;
Cl=10.;
Vtp=-2.;
Kp=0.25;
Idq=0.5;
Vsgq=3.41;
Vsdq=3.41;
gm=2.*Kp*(Vsgq+Vtp);
print"%s %.2f %s"%('\ntransconductance = ',gm,'mA/V\n')
Tp=Cl*Rd*Rl/(Rd+Rl);
print"%s %.2f %s"%('\ntime constant= ',Tp,' ns\n')
Tp=66.7*10**-3;##micro sec
fH=1./(2.*math.pi*Tp);
print"%s %.2f %s"%('\ncorner frequency= ',fH,' MHz\n')
Av=(gm*Rd*Rl/(Rd+Rl))/(1+gm*Rs);
print"%s %.2f %s"%('\nmaximum small signal voltage gain=\n',Av,'')
import math
##Example 7.7
Vbe=0.7;
b=100.;
Re=.5;
Rc=5.;
Rl=10.;
R1=40.;
Cc=10.;
R2=5.7;
Rs=.1;
Vt=0.026;
Icq=0.99;
gm=Icq/Vt;
print"%s %.2f %s"%('\ntransconductance= ',gm,' mA/V\n')
r=b*Vt/Icq;
print"%s %.2f %s"%('\ndiffusion resistance= ',r,' KOhm\n')
Ri=r+(1.+b)*Re;
print"%s %.2f %s"%('\ninput resistance= ',Ri,' KOhm\n')
x=Rc*Rl/(Rc+Rl);
y=R1*R2/(R1+R2);
t=y*Ri/(y+Ri);
Av=gm*r*x*(y/(y+Ri))*(1./(Rs+t));
print"%s %.2f %s"%('\nmaximum small signal voltage gain=\n',Av,'')
Ts=(Rs+t)*Cc;
print"%s %.2f %s"%('\ntime constant=\n',Ts,'ms')
Ts=46.6*0.001;##sec
Cl=15.;
Tp=x*Cl;
print"%s %.2f %s"%('\ntime constant ',Tp,' ns\n')
fL=1/(2.*math.pi*Ts);
print"%s %.2f %s"%('\nlower corner frequency= ',fL,' Hz\n')
Tp=50.*10**-3;##micro sec
fH=1/(2.*math.pi*Tp);
print"%s %.2f %s"%('\nupper corner frequency= ',fH,' MHz\n')
fL=3.4*10**-6;##MHz
fbw=fH-fL;
print"%s %.2f %s"%('\nbandwidth = ',fbw,'MHz\n')
import math
##Example 7.8
Re=4.;
Rc=2.;
Rs=0.5;
Vt=0.026;
Ce=1*10**-3;
V1=5.;
Icq=1.06;
V2=-5.;
b=100.;
Vbe=0.7;
gm=Icq/Vt;
print"%s %.2f %s"%('\ntransconductance = ',gm,'mA/V\n')
r=b*Vt/Icq;
print"%s %.2f %s"%('\ndiffusion resistance= ',r,' KOhm\n')
Ta=Re*Ce;
print"%s %.2f %s"%('\ntime constant Ta= ',Ta,'f s\n')
Tb=(Re*Ce*(Rs+r))/(Rs+r+(1+b)*Re);
print"%s %.2f %s"%('\ntime constant Tb= ',Tb,' s\n')
fA=1/(2.*math.pi*Ta);
print"%s %.2f %s"%('\ncorner frequency = ',fA,'Hz\n')
Tb=2.9*0.01;##msec
fB=1/(2.*math.pi*Tb);
print"%s %.2f %s"%('\ncorner frequency =',fB,'khz')
Av=(gm*r*Rc)/(Rs+r+(1.+b)*Re);
print"%s %.2f %s"%('\nlimiting low frequency horizontal asymptote= \n',Av,'')
Av=gm*r*Rc/(Rs+r);
print"%s %.2f %s"%('\nnlimiting high frequency horizontal asymptote=\n',Av,'')
import math
##Example 7.9
r=2600.;
C1=2.*10**-6;
C2=0.1*10**-6;
fB=1/(2.*math.pi*r*(C1+C2));
print"%s %.2f %s"%('\n3dB frequency= ',fB,' MHz\n')
import math
##Example 7.10
fT=500.;
Ic=1.;
b=100.;
Vt=0.026;
C2=0.3*10**-12;
fB=fT/b;
print"%s %.2f %s"%('\nbandwidth= ',fB,' MHz\n')
gm=Ic/Vt;
print"%s %.2f %s"%('\ntransconductance= ',gm,'mA/V\n')
fT=500000000.;
gm=38.5*0.001;
C1=gm/(fT*2.*math.pi)-C2;
print"%s %.2e %s"%('\ncapacitance = ',C1,'F\n')
import math
##Example 7.12
Kn=0.25;
Vtn=1.;
Cgd=0.04*10**-3;
Cgs=0.2*10**-3;
Vgs=3.;
gm=2.*Kn*(Vgs-Vtn);
print"%s %.2f %s"%('\ntransconductance = ',gm,'mA/V\n')
fT=gm/(2.*math.pi*(Cgd+Cgs));
print"%s %.2f %s"%('\nunity gain bandwidth= ',fT,' MHz\n')
import math
##Example 7.13
gm=1.;
Cgd=0.04;
Rl=10.;
Cgs=0.2;
Cm=Cgd*(1.+gm*Rl);
print"%s %.2f %s"%('\nMiller capacitance= ',Cm,' pF\n')
Cm=0.44*0.001;##nF
Cgs=0.2*0.001;##nF
fT=gm/(2.*math.pi*(Cgs+Cm));
print"%s %.2f %s"%('\ncutoff frequency= ',fT,' MHz\n')
import math
##Example 7.14
V1=5.;
V=-5.;
Rs=0.1;
Rb=40.;
R2=5.72;
Re=0.5;
Rc=5.;
Rl=10.;
b=150.;
Vbe=0.7;
C1=35*10**-3;
C2=4.;
Vt=0.026;
Icq=1.02;
r=b*Vt/Icq;
print"%s %.2f %s"%('\nsmall signal parameter= ',r,' KOhm\n')
gm=Icq/Vt;
print"%s %.2f %s"%('\ntransconductance= ',gm,' mA/V\n')
Cm=C2*(1+gm*Rc*Rl/(Rc+Rl));
print"%s %.2f %s"%('\nMiller capacitance= ',Cm,' pF\n')
Cm=527.*10**-3;
x=Rb*Rs/(Rb+Rs);
y=r*x/(r+x);
fH=1/(2.*math.pi*y*(C1+Cm));
print"%s %.2f %s"%('\nupper corner frequency = ',fH,'MHz\n')
t=Rb*r/(Rb+r);
p=Rc*Rl/(Rc+Rl);
Av=gm*p*t/(t+Rs);
print"%s %.2f %s"%('\nmidband gain= ',Av,'\n')
import math
##Example 7.15
V1=5.;
V=-5.;
Rs=0.1;
R1=40.;
R2=5.72;
Re=0.5;
Rc=5.;
Rl=10.;
b=150.;
Vbe=0.7;
C1=35.;
C2=4.;
Vt=0.026;
Icq=1.02;
gm=39.2;
r=3.82;
x=Re*Rs/(Re+Rs);
t=r/(1.+b);
y=t*x/(t+x);
Tp=y*C1;
print"%s %.2f %s"%('\ntime constant= ',Tp,' ns\n')
Tp=0.679*10**-3;##micro sec
f=1/(2.*math.pi*Tp);
print"%s %.2f %s"%('\nupper frequency = ',f,'MHz\n')
T=C2*Rc*Rl/(Rc+Rl);
print"%s %.2f %s"%('\ntime constant= ',T,' ns\n')
T=13.3*10**-3;##micro sec
f=1/(2.*math.pi*T);
print"%s %.2f %s"%('\nupper frequency= ',f,' MHz\n')
x=Rc*Rl/(Rc+Rl);
y=Re*t/(Re+t);
Av=gm*x*(y/(y+Rs));
print"%s %.2f %s"%('\nmidband voltage gain \n',Av,'')
import math
##Example 7.16
V1=5.;
V=-5.;
Rs=0.1;
R1=42.5;
R2=20.5;
R3=28.3;
Re=5.4;
Rc=5.;
Rl=10.;
b=150.;
Vbe=0.7;
C1=35.;
C2=4.;
Vt=0.026;
Icq=1.02;
gm=39.2;
r=3.820;
Rb=R2*R3/(R2+R3);
x=Rb*r/(Rb+r);
y=Rs*x/(x+Rs);
Tp=y*(C1+2*C2);
print"%s %.2f %s"%('\ntime constant= ',Tp,' ns\n')
Tp=Tp*10**-3;##micro sec
f=1/(2.*math.pi*Tp);
print"%s %.2f %s"%('\n3dB frequency = ',f,'MHz\n')
T=C2*Rc*Rl/(Rc+Rl);
print"%s %.2f %s"%('\ntime constant= ',T,'ns\n')
T=T*0.001;##micro sec
f=1/(2.*math.pi*T);
print"%s %.2f %s"%('\nupper frequency= ',f,' MHz\n')
x=Rc*Rl/(Rc+Rl);
y=Rb*r/(Rb+r);
Av=gm*x*(y/(y+Rs));
print"%s %.2f %s"%('\nmidband voltage gain= ',Av,' \n')
import math
##Example 7.17
V1=5.;
V=-5.;
Rs=0.1;
R1=40;
R2=5.720;
Re=0.5;
Rc=5.;
Rl=10.;
b=150.;
Vbe=0.7;
C1=35.;
C2=4.;
Vt=0.026;
Icq=1.02;
gm=39.2;
r=3.820;
t=r/(1.+b);
t=t*0.001;
f=1/(2.*math.pi*C1*t);
print'%s %.2f %s'%('\nthe zero occurs at this frequency= ',f,' MHz\n')
x=1+gm*Re*Rl/(Re+Rl);
Rb=R1*R2/(R1+R2)
d=x*r;
y=d*Rb/(d+Rb);
t=y*Rs/(y+Rs);
Tp=t*(C2+C1/x);
print'%s %.2f %s'%('\ntime constant= ',Tp,' ns\n')
Tp=Tp*10**-3;##micro sec
f=1/(2.*math.pi*Tp);
print'%s %.2f %s'%('\n3dB frequency= ',f,' MHz\n')