#Ex 2.1
# data from fig of Ex2.1
VCC=5.0;#V
IS=10**-14.0;#A
RS=39*1000.0;#ohm
VBE12=0.7;#V(Assumed)
VBE11=0.7;#V(Assumed)
VEE=-5;#V
IREF=(VCC-VBE12-VBE11-VEE)/RS*10**6;#micro A
print "Estimated input reference current , IREF(micro A)",round(IREF,2)
VT=25*10**-3;#V(Thermal Voltage)
VBE=VT*log(IREF*10**-6/IS);#V
IREF=(VCC-VBE-VBE-VEE)/RS*10**6;#micro A
print "More precise value of reference current , IREF(micro A)",round(IREF,2)
#Replacing Vcc by 15 V in the original design
VCC2=15.0;#V
VEE2=-15.0;#V
IREF=(VCC2-VBE-VBE-VEE2)/RS*10**6;#micro A
VBE=VT*log(IREF*10**-6/IS);#V
R5=(VCC-VBE-VBE-VEE)/(IREF*10**-6);#ohm
R5=round(R5/1000);#kohm
print "Value of R5(kohm) : ",R5
#Ex 2.2
import math
# data from fig of Ex2.2
IC10=20*10**-6;#A
IREF=0.5*10**-3;#A
IS=10**-14;#A
VT=25*10**-3;#V(Thermal Voltage)
R4=VT/IC10*math.log(IREF/IC10);#ohm
print "For Widlar current source design, the value of R4(kohm) : ",round(R4/1000,2)
#Ex 2.3
import math
# given data
Gm1=10.0;#mA/V
Gm1=Gm1/1000;#A/V
Cc=50.0;#pF
Cc=Cc*10**-12;#F
Rt=10**8;#ohm(Shunting resistance with Cc)
# solution
Ao=Gm1*Rt;#unitless
fp=1/(2*math.pi*Rt*Cc);#Hz
ft=Gm1/(2*math.pi*Cc)/10**6;#MHz
print "Frequency at which gain is maximum, fp in Hz",round(fp,1)
print "Unit gain frequency, ft(MHz)",round(ft,1)
#Bode plot can not be plotted with the given data in the question by using python functions.
#Ex 2.4
import math
# given data
SR=10.0/10**-6;#V/s
Vout=10.0;#V(magnitude of output voltage)
fm=SR/(2*math.pi*Vout)/1000;#kHz
print "Full power bandwidth(kHz)",round(fm,1)
VT=25.0/1000;#V(Thermal voltage)
ft=SR/(2*math.pi*4*VT)/10.0**6;#MHz
print "Unity gain bandwidth(MHz)",round(ft,1)
#Ex 2.5
VCC=5;#V
VEE=-5;#V
VBE=0.6;#V
VCE23=0.6;#V
VCE_sat=0.2;#V
Vo_max=VCC-VCE_sat-VBE;#V
Vo_min=VEE+VCE_sat+VBE+VCE23;#V
print "Maximum output voltage(V)",round(Vo_max,2)
print "Minimum output voltage(V)",round(Vo_min,2)