import math
##Example 10.1
Vbe=0.6;##(V)
b=100.;
V1=5.;
Io=200.;##micro A
Iref=Io*(1.+2./b);
print"%s %.2f %s"%('\nreference current= ',Iref,' microA\n')
Iref=Iref*0.001;##mA
R1=(V1-Vbe)/Iref;
print"%s %.2f %s"%('\nR1= ',R1,' KOhm\n')
import math
##Example 10.2
V1=5.;
V2=-5.;
R1=9.3;
b=50.;
Vbe=0.7;
Va=80.;
Iref=(V1-Vbe-V2)/R1;
print"%s %.2f %s"%('\nreference current = ',Iref,'mA\n')
Io=Iref/(1.+2./b);
print"%s %.2f %s"%('\noutput current= ',Io,'mA\n')
ro=Va/Io;
print"%s %.2f %s"%('\nsmall signal output resistance= ',ro,' KOhm\n')
##dIo=dVce2/ro
Vce2=0.7;
dIo=(V1-Vce2)/ro;
print"%s %.2f %s"%('\nchange in load current= ',dIo,' mA\n')
x=dIo/Io;
x=x*100.;
print"%s %.2f %s"%('\npercent change in output current= ',x,' \n')
import math
##Example 10.4
Iref=1.;
Io=12.*10**-3;
V1=5.;
V2=-5.;
Vt=0.026;
Vbe=0.7;
R1=(V1-Vbe-V2)/Iref;
print"%s %.2f %s"%('\nResistance R1 = ',R1,'KOhm\n')
Re=(Vt/Io)*math.log(Iref/Io);
print"%s %.2f %s"%('\nResistance Re = ',Re,'KOhm\n')
Vbe=Io*Re;
print"%s %.2f %s"%('\ndifference between two B-E voltages= ',Vbe,' V\n')
import math
##Example 10.5
V1=5.;
V2=-5.;
R1=9.3;
Re=9.580;
Vt=0.026;
b=100.;
Vbe=0.7;
Va=80.;
Io=12.;
ro2=Va/Io;
print"%s %.2f %s"%('\nsmall signal collector resistance= ',ro2,' MOhm\n')
Io=12.*0.001;##mA
gm2=Io/Vt;
print"%s %.2f %s"%('\ntransconductance= ',gm2,' mA/V\n')
r=b*Vt/Io;
print"%s %.2f %s"%('\nResistance= ',r,' KOhm\n')
Ro=ro2*(1.+gm2*Re*r/(Re+r));
print"%s %.2f %s"%('\noutput resistance= ',Ro,' MOhm\n')
dVc2=4.;
dIo=dVc2/Ro;
print"%s %.2f %s"%('\nchange in load current= ',dIo,' microA\n')
Io=12.;##micro A
x=dIo/Io;
x=x*100.;
print"%s %.2f %s"%('\npercent change in output current =\n',x,'')
import math
##Example 10.6
V1=5.;
V2=-5.;
Vbe=0.6;
Veb=0.6;
Iq2=400.*10**-3;##mA
Iref=200.*10**-3;##mA
Iq1=Iref;
Iq3=Iq1;
Iq4=600.*10**-6;
R1=(V1-Veb-Vbe-V2)/Iref;
print"%s %.2f %s"%('\nResistance R1= ',R1,' KOhm\n')
import math
##Example 10.7
##uox*Cox/2=x
x=20.*10**-6;##A/V^2
Vtn=1.;
V1=5.;
V2=0.;
Iref=0.25*10**-3;
Io=0.1*10**-3;
Vgs2=1.85;
##let y=W/L
y2=Io/(x*(Vgs2-Vtn)**2);
print"%s %.2f %s"%('\nwidth per length 2= ',y2,'\n')
y1=Iref/(x*(Vgs2-Vtn)**2);
print"%s %.2f %s"%('\nwidth per length 1= ',y1,'\n')
Vgs1=Vgs2;
Vgs3=V1-V2-Vgs1;
print"%s %.2f %s"%('\nVgs3= ',Vgs3,' V\n')
y3=Iref/(x*(Vgs3-Vtn)**2);
print"%s %.2f %s"%('\nwidth per length 3= ',y3,'\n')
import math
##Example 10.8
Iref=100.;
Io=Iref;
##lambda=y
y=0.01;
gm=0.5*10**3;
ro=1./(y*Iref);
print"%s %.2f %s"%('\noutput resistance= ',ro,' MOhm\n')
ro2=1.;
ro4=1.;
Ro=ro4+ro2*(1.+gm*ro4);
print"%s %.2f %s"%('\noutput resistance of cascode circuit= ',Ro,' MOhm\n')
import math
##Example 10.9
Idss1=2.;
Idss2=1.;
Vp1=-1.5;
Vp2=Vp1;
##lambda=y
y1=0.05;
y2=y1;
V2=-5.;
Vds=1.5;
Vsmin=Vds+V2;
print"%s %.2f %s"%('\nminimum value of Vs= ',Vsmin,' V\n')
Io=Idss2*(1.+y1*Vds);
print"%s %.2f %s"%('\noutput current= ',Io,' mA\n')
Vgs1=(1.-math.sqrt(Io/Idss1))*Vp1;
print"%s %.2f %s"%('\ngate to source voltage of Q1= ',Vgs1,' V\n')
V1=Vgs1+Vsmin;
print"%s %.2f %s"%('\nV1= ',V1,' V\n')
import math
##Example 10.10
Vt=0.026;
Van=120.;
Vap=80.;
Av=-(1./Vt)/(1./Van+1./Vap);
print"%s %.2f %s"%('\nsmall signal open circuit voltage gain=\n',Av,'')
import math
##Example 10.11
Van=120.;
Vap=80.;
Vt=0.026;
Ico=0.001;
##Rl=infinity
Av=-(1./Vt)/(1./Van+1./Vap);
print"%s %.2f %s"%('\nsmall signal open circuit voltage gain=\n',Av,'')
Rl=100.;
Av1=-(1./Vt)/(1./Van+1./Vap+1./Rl);
print"%s %.2f %s"%('\nsmall signal open circuit voltage gain=',Av1,'')
Rl=10.;
Av2=-(1./Vt)/(1./Van+1./Vap+1./Rl);
print"%s %.2f %s"%('\nsmall signal open circuit voltage gain=\n',Av2,'')
import math
##Example 10.12
##lambda=y
yn=0.01;
yp=0.01;
Vtn=1.;
Kn=1.;
Iref=0.5;
gm=2.*math.sqrt(Kn*Iref);
print"%s %.2f %s"%('\ntransconductance = ',gm,'mA/V\n')
go=yn*Iref;
print"%s %.2f %s"%('\nsmall signal transistor conductance= ',go,' mA/V\n')
go2=go;
##for Rl=infinity
Av=-gm/(go+go2);
print"%s %.2f %s"%('\nvoltage gain= ',Av,' \n')
Rl=100.;##Kohm
gl=0.01;
Av=-gm/(go+gl+go2);
print"%s %.2f %s"%('\nvoltage gain= \n',Av,'')