#Ex 1.1
import math
VDD=1.8;#V
IREF=50;#micro A
IO=IREF;#micro A
L=0.5;#micro m
W=5;#micro m
Vt=0.5;#V
Kn_dash=250;#micro A/V**2
VGS=math.sqrt(IO/(1/2.0*Kn_dash*(W/L)))+Vt;#V
print VGS," is the Value of VGS(V) "
R=(VDD-VGS)/(IREF*10**-6);#ohm
print R/1000," is the Value of R(kohm) "
VDS2=VGS-Vt;#V
VO=VDS2;#V
print VO," is the Lowest value of VO(V) "
#Ex 1.3
VDD=1.8;#V
Vt=0.6;#V
mpCox=100;#a A/V**2
IREF=80;#micro A
VOmax=1.6;#V
VSG=VDD-VOmax+Vt;#V
VGS=-VSG;#V
VS=VDD;#V
VG=VGS+VS;#V
R=VG/(IREF*10**-6);#ohm
ID=IREF;#micro A
WbyL=2*ID*10**-6/(mpCox*10**-6)/(VGS+Vt)**2;#unitless
print VGS,"= Value of VGS(V) "
print VG,"= Value of VG(V) "
print R/1000,"= Value of R(kohm) "
print WbyL,"= W/L ratio "
#Ex 1.4
Beta=80;#unitless
print "IREF=IC1+IC1/Beta+IO/Beta)"
print "IO/IREF=m implies IC1=IO/m as IC1=IREF"
print "IREF=IO*(1/m+1/m/Beta+1/Beta)"
print "IO/IREF=m/(1+1/Beta+m/Beta)"
print "IO/IREF=m*(1-5/100)"#for large Beta
m=(1/(1-5.0/100)-1)*Beta-1;#Current transfer ratio
print round(m,2)," is Largest current transfer ratio "
#Ex 1.7
Beta=80;#untless
print "g8=IC1+IC1/Beta+IO/Beta"
print "IO/IREF=m implies IC1=IO/m as IC1=IREF"
print "IREF=IO*(1/m+1/m/Beta+1/Beta"
print "IO/IREF=m/(1+1/Beta+m/Beta"
print "IO/IREF=m*(1-5/100)"#for large Beta
m=(1/(1-5.0/100)-1)*Beta-1;#Current transfer ratio
print round(m,2),"Largest current transfer ratio "
#Ex 1.9
Beta=20.0;#unitless
IObyIREF=1/(1+2/Beta);#Current gain
print round(IObyIREF,2)," is Current gain "
#Ex 1.10
IREF=2;#mA
IO=IREF;#mA
VA2=90.0;#V
Vo1=1.0;#V
Vo2=10.0;#V
ro2=VA2/IO;#kohm
delVO=Vo2-Vo1;#V
delIO=delVO/ro2;#mA
Change=delIO/IO*100;#%
print Change," % is Change in Io "
#Ex 1.11
import math
VBE3=0.7;#V
VBE1=0.7;#V
IREF1=100.0;#micro A
IC1=IREF1;#micro A
IREF2=1.0;#mA
IC2=IREF2;#mA
Beta=200.0;#unitless
#IC2/IC1=(IS*exp(VBE2/VT))/(IS*exp(VBE1/VT))
VT=26.0;#mV
deltaVBE=VT*10**-3*math.log(IC2/IC1);#V(deltaVBE=VBE2-VBE1)
deltaVx=2*deltaVBE;#V
IO=IREF1/(1+2.0/(Beta**2+Beta));#micro A
delIO=IC1-IO;#micro A
Change=delIO/IO*100;#%
print round(Change,4)," % is Change in Io"
#Ex 1.12
Iout=8;#micro A
VBE=0.7;#V
VCC=20.0;#V
Beta=80.0;#unitless
IREF=Iout*(1+2/Beta);#micro A
print IREF," is Reference current in micro A : "
R=(VCC-VBE)/(IREF);#Mohm
print round(R,2)," is Resistance in Mohm "
#Ex 1.13
Iout=1;#mA
VBE=0.7;#V
VCC=30.0;#V
Beta=100.0;#unitless
IREF=Iout*(1+2/Beta);#mA
print IREF," is Reference current in (mA) "
R=(VCC-VBE)/(IREF);#kohm
print round(R,1),"is Resistance in (kohm) "
#Ex 1.14
Iout=0.5;#mA
VBE=0.7;#V
VCC=5.0;#V
Beta=50.0;#unitless
IREF=Iout*(1+2/Beta);#mA
print IREF," is Reference current in (mA) "
R=(VCC-VBE)/(IREF);#kohm
print round(R,3)," is Resistance in (kohm) "
#Ex 1.15
Iout=8;#micro A
VBE=0.7;#V
VCC=20.0;#V
Beta=100.0;#unitless
IREF=Iout*(1+2/Beta/(Beta+1));#micro A
print round(IREF,2)," is Reference current in (micro A) "
R=(VCC-2*VBE)/(IREF);#Mohm
print round(R,2)," is Resistance in (Mohm) "
#Ex 1.16
Beta=120;#unitless
VBE=0.7;#V
VCC=10.0;#V
R=5.6;#kohm
#IREF=IC1+I1;as Beta>>1
#I1=IC2+IB3;as Beta>>1
IREF=(VCC-VBE)/R;#mA
#IREF=IC*(2+1/Beta) or IREF=2*IC;as Beta>>1
IC=IREF/2;#mA
Iout=IC;#mA
print round(Iout,2),"is Iout for the circuit in (mA) "
#Ex 1.17
import math
Iout=6;#micro A
IREF=1.2;#mA
VBE2=0.7;#V
VT=26.0;#mV
VCC=20.0;#V
Beta=120;#unitless
R=(VCC-VBE2)/IREF;#kohm
IC2=(IREF-Iout/Beta)/(1+1/Beta);#mA
RS=VT/Iout*math.log(IC2*1000/Iout);#kohm
print int(R),"Kohm and ",round(RS,2),"kohm are the Values of resistance R & Rs for widlar current source design"
#Ex 1.18
import math
IREF=1;#mA
IO2=20.0;#micro A
IO3=40.0;#micro A
VBE1=0.7;#V
VT=26;#mV
VCC=10;#V
VEE=-VCC;#V
R=(VCC-VBE1-VEE)/IREF;#kohm
RE2=VT*10**-3/(IO2*10**-6)*math.log((IREF*10**-3)/(IO2*10**-6));#ohm
RE2=RE2/1000;#kohm
RE3=VT*10**-3/(IO3*10**-6)*math.log((IREF*10**-3)/(IO3*10**-6));#ohm
RE3=RE3/1000;#kohm
print R,", ",round(RE2,3),"and ", round(RE3,2)," are Values of resistance R, RE2 & RE3 for widlar current source design in kohm "
VBE2=VBE1-RE2*IO2*10**-3;#V
VBE3=VBE1-RE3*IO3*10**-3;#V
print round(VBE2,3),"and",round(VBE3,3)," are Values of VBE2 & VBE3 in V "
#Ex 1.19
Beta=100.0;#unitless
VBE=0.715;#V
VEE=10.0;#V
R=5.6;#kohm
IREF=(VEE-VBE)/R;#mA
IC1=IREF/(1+2/Beta);#mA
print round(IC1,2)," is Collector current in each transistor is equal as all are identical. It in (mA) "
IRC=3*IC1;#mA
print round(IRC,2),"is Current through resistance Rc in (mA) "
# the answer is slightly different in textbook due to approximation
#Ex 1.20
Vout=5.0;#V
Beta=180.0;#unitless
VBE=0.7;#V
VEE=10.0;#V
Vout=5;#V
R1=22.0;#kohm
R2=2.2;#kohm
IREF=(VEE-VBE)/R1;#mA
IC=(IREF-VBE/R2)/(1+2/Beta);#mA
IC1=IC*1000;#micro A(as VBE1=VBE2 IC1=IC2)
IC2=IC*1000;#micro A
print round(IC2,2),",",round(IC1,2)," are Current IC1 & IC2 in micro A "
RC=(VEE-Vout)/(IC1*10**-3);#kohm
print round(RC,2),"is Value of Rc in (kohm) "
#Answer is different in the textbook due to approximation
#Ex 1.21
AQ2byA1=0.5;
AQ3byA1=0.25;
AQ4byA1=0.125;
VBE=0.7;#V
VCC=15.0;#V
R=20.0;#kohm
IC1=(VCC-VBE)/R;#mA
IC2=IC1*AQ2byA1;#mA
IC3=IC1*AQ3byA1;#mA
IC4=IC1*AQ4byA1;#mA
print round(IC2,4),",",round(IC3,3),"and",round(IC4,3),"are the Values of current IC2, IC3 & IC4 in (mA) "
#Value of IC4 is displayed wrong in the textbook.