from math import log10
from __future__ import division
Av=0.1
print "Av= %0.2f"%(Av) #Voltage gain
AvdB=20*log10(Av)
print "Av(dB)=20*log10(Av)= %0.2f"%(AvdB),"dB " #Voltage gain in decibel
Av=0.707
print "Av= %0.2f"%(Av) #Voltage gain
AvdB=20*log10(Av)
print "Av(dB)=20*log10(Av)= %0.2f"%(AvdB),"dB " #Voltage gain in decibel
Av=1
print "Av= %0.2f"%(Av) #Voltage gain
AvdB=20*log10(Av)
print "Av(dB)=20*log10(Av)= %0.2f"%(AvdB),"dB " #Voltage gain in decibel
Av=10
print "Av= %0.2f"%(Av) #Voltage gain
AvdB=20*log10(Av)
print "Av(dB)=20*log10(Av)= %0.2f"%(AvdB),"dB " #Voltage gain in decibel
Av=100
print "Av= %0.2f"%(Av) #Voltage gain
AvdB=20*log10(Av)
print "Av(dB)=20*log10(Av)= %0.2f"%(AvdB),"dB " #Voltage gain in decibel
Av=1000
print "Av= %0.2f"%(Av) #Voltage gain
AvdB=20*log10(Av)
print "Av(dB)=20*log10(Av)= %0.2f"%(AvdB),"dB " #Voltage gain in decibel
#NOTE:calculated voltage gain in dB for Av=0.707 is -3.0116117dB
from math import sqrt,log10
from __future__ import division
Ri=0.5*10**(3)
print "Ri= %0.2f"%(Ri)+ " ohm" # Amplifier input resistance
RL=0.05*10**(3)
print "RL= %0.2f"%(RL)+ " ohm" # Load resistance
Vom=1
print "Vom= %0.2f"%(Vom)," volts" # Output voltage
Vo=Vom/sqrt(2)#RMS value of Output voltage
Vim=1*10**(-3)
print "Vim= %0.2f"%(Vim)," volts" # Peak Input voltage
Vi=Vim/sqrt(2)#RMS Input voltage
Av=20*log10(Vo/Vi)
print "Av(in dB)=20*log10(Vo/Vi)= %0.2f"%(Av)," dB " #Voltage gain in decibel
Iim=Vim/Ri
print "Iim= Vim/Ri= %0.2f"%(Iim)," A" # Input peak current
Ii=Iim/sqrt(2) #RMS value of input current
Iom=Vom/RL
print "Iom= Vom/RL= %0.2f"%(Iom)," A" # Output peak current
Io=Iom/sqrt(2) #RMS value of Output current
Ai=20*log10(Io/Ii)
print "Ai=20*log10(Io/Ii)= %0.2f"%(Ai)," dB " #Current gain in decibel
pi=Vi**2/Ri
print "pi= Vi**2/Ri= %0.2f"%(pi)," W" # Input power
po=Vo**2/RL
print "po= Vo**2/RL= %0.2f"%(po)," W" # Output power
Ap=10*log10(po/pi)
print "Ap=10*log10(po/pi)= %0.2f"%(Ap)," dB " #Power gain in decibel
from __future__ import division
RL=1*10**(3)
print "RL= %0.2f"%(RL)+ " ohm" #Load resistance
RF=500*10**(3)
print "RF= %0.2f"%(RF)+ " ohm" #Feedback resistance
Beta_o=50
print "Beta_o = %0.2f"%(Beta_o) #BJT gain
rbe=1*10**(3)
print "rbe= %0.2f"%(rbe)+ " ohm" #Base-emitter resistance
gm=50*10**(-3)
print "gm = %0.2f"%(gm)," A/V"# transconductance for BJT
rc=50*10**(3)
print "rc= %0.2f"%(rc)+ " ohm" #collector resistance
print "part(i)"
Adm1=(-gm*RL)
print "Adm1=(-gm*RL)= %0.2f"%(Adm1) # Differential mode gain for BJT for DIDO and SIDO modes
Adm2=(0.5*gm*RL)
print "Adm2=(0.5*gm*RL)= %0.2f"%(Adm2) # Differential mode gain for BJT for DISO and SISO modes
Rid=2*rbe
print "Rid=2*rbe= %0.2f"%(Rid)+ " ohm" #input differential mode resistance
Acm=(-RL)/(2*RF)
print "Acm=(-RL)/(2*RF)= %0.2e"%(Acm) # Common mode gain for BJT for DISO and SISO modes
Ric=Beta_o*RF
print "Ric=Beta_o*RF= %0.2e"%(Ric)+ " ohm" # common mode input resistance
CMRR=2*gm*RF
print "CMRR=2*gm*RF= %0.2f"%(CMRR) # common mode rejection ratio
print "part(ii)"
Vi1=(-0.5)*10**(-3)
print "Vi1= %0.2e"%(Vi1)," volts" # input voltage1
Vi2=(+0.5)*10**(-3)
print "Vi2= %0.2e"%(Vi2)," volts" # input voltage2
Vcm=(10)*10**(-3)
print "Vcm= %0.2f"%(Vcm)," volts" # common mode voltage
Vd=Vi1-Vi2
print "Vd=Vi1-Vi2= %0.2e"%(Vd)," volts" # differential voltage
Vod=abs(Vd*Adm2)
print "Vod=abs(Vd*Adm2)= %0.2f"%(Vod)," volts" # output differential voltage for DISO and SISO modes
Voc=abs(Vcm*Acm)
print "Voc=abs(Vcm*Acm)= %0.2e"%(Voc)," volts" # output common mode voltage
Error=(Voc/Vod)*100
print "percentage error=(Voc/Vod)*100= %0.2f"%(Error),"%"#percentage error due to CM signal
print "part(iii)"
RLeff=(RL*Rid)/(RL+Rid)
print "RLeff=(RL*Rid)/(RL+Rid)= %0.2f"%(RLeff)+ " ohm" # Effective load resistance
Adm=gm*RLeff
print "Adm=gm*RLeff= %0.2f"%(Adm) # Modified Differential mode gain for BJT for DIDO and SIDO modes
Acm=(-RLeff)/(2*RF)
print "Acm=(-RLeff)/(2*RF)= %0.2e"%(Acm) # Modified Common mode gain for BJT for DISO and SISO modes
CMRR=abs(Adm/(Acm))
print "CMRR=abs(Adm/(Acm))= %0.2f"%(CMRR) # Modified common mode rejection ratio
#NOTE: In Book, Formulae used for Acm in part(iii) is written as Acm=(-RL)/(2*RF)but ans is calculated by using RLeff in place of RL.So i have written formulae as Acm=(-RLeff)/(2*RF) in programming.
# Assigned variable name: in part(i) Adm for DIDO and SIDO modes is represented by Adm1 and Adm for DISO and SISO modes is represented by Adm2 to resist any anamoly in the programming.
from __future__ import division
VCC=(10)
print "VCC= %0.2f"%(VCC)," volts" # Collector voltage supply
VEE=VCC
print "VEE=VCC= %0.2f"%(VEE)," volts" # Emitter supply voltage
IQ=2*10**(-3)
print "IQ = %0.2f"%(IQ)," ampere" # operating current for CC class-Aamplifier
VBE=(0.7)
print "VBE= %0.2f"%(VBE)," volts" # Base-emitter voltage
print "part(i)"
RL=VCC/IQ
print "RL=VCC/IQ= %0.2f"%(RL)+ " ohm" #Load resistance
Pomax=VCC**2/(2*RL)
print "Pomax=VCC**2/(2*RL)= %0.2f"%(Pomax)," W" # maximum Output power
PDC=2*VCC*IQ
print "PDC=2*VCC*IQ= %0.2f"%(PDC)," W" # Total D.C power supply
Etta_max=(Pomax/PDC)*100
print "Efficiency,Etta_max=(Pomax/PDC)*100= %0.2f"%(Etta_max),"%" #maximum power amplifier conversion efficiency
PDmax=VCC*IQ
print "PDmax=VCC*IQ= %0.2f"%(PDmax)," W" # maximum power dissipation
print "part(ii)"
Vcm=(5)
print "Vcm= %0.2f"%(Vcm)," volts" # common mode voltage
Po=Vcm**2/(2*RL)
print "Po=Vcm**2/(2*RL)= %0.2e"%(Po)," W" # Output power
Etta=(Po/PDC)*100
print "Efficiency,Etta=(Po/PDC)*100= %0.2f"%(Etta)," %" # power amplifier conversion efficiency
PDCavg=PDmax-Po#Using law of conservation of energy
print "PDCavg=PDmax-Po= %0.2f"%(PDCavg)," W" # Average power dissipated in BJT
from math import pi,sqrt
from __future__ import division
VCC=(10)
print "VCC= %0.2f"%(VCC)," volts" # Collector voltage supply
VEE=VCC
print "VEE=VCC= %0.2f"%(VEE)," volts" # Emitter supply voltage
ICQ_0=10*10**(-3)
print "ICQ_0 = %0.2e"%(ICQ_0)," ampere" # Zero signal collector current
RL=5
print "RL= %0.2f"%(RL)+ " ohm" #Load resistance
print "part(i)"
Po=0# Since Output power at Zero signal condition is Zero
print "Po=%0.2f"%(Po)," W" # Output power at Zero signal condition
PDC=2*VCC*ICQ_0
print "PDC=2*VCC*ICQ_0= %0.2f"%(PDC)," W" # Total D.C power supply for Zero signal condition
print "part(ii)"
Vcm=VCC#For Full output voltage swing Vcm=VCC
print "Vcm=VCC = %0.2f"%(Vcm)," volts" # common mode voltage for full swing condition
Icm=VCC/RL
print "Icm = VCC/RL=%0.2e"%(Icm)," ampere" # common mode current
Po=(1/2)*(Icm*Vcm)
print "Po=(1/2)*(Icm*Vcm)=%0.2f"%(Po)," W" # Output power at full swing condition
ICavg=(Icm)/(pi)
print "ICavg=(Icm)/(pi)=%0.2e"%(ICavg)," ampere" # Average value of common mode current
PDC=2*(ICavg*VCC)
print "PDC=2*VCC*ICavg= %0.2f"%(PDC)," W" # Total D.C power supply for full swing condition
Etta=(Po/PDC)*100
print "Efficiency,Etta=(Po/PDC)*100= %0.2f"%(Etta)," %" # power amplifier conversion efficiency
print "part(iii)"
Vcm1=(5)#given value
print "Vcm1= %0.2f"%(Vcm1)," volts" # common mode voltage for output swing Vcm=5 V
ICavg1=(Vcm1)/(pi*RL)
print "ICavg1=(Vcm1)/(pi*RL)=%0.2e"%(ICavg1)," ampere" # Average value of common mode current
Po1=(Vcm1**2)/(2*RL)
print "Po1=(Vcm1**2)/(2*RL)=%0.2f"%(Po1)," W" # Output power for output swing Vcm=5 V
PDC1=2*(ICavg1*VCC)
print "PDC1=2*VCC*ICavg1= %0.2e"%(PDC1)," W" # Total D.C power supply for output swing Vcm=5 V
Etta=(Po1/PDC1)*100
print "Efficiency,Etta=(Po1/PDC1)*100= %0.2f"%(Etta)," %" # power amplifier conversion efficiency for output swing Vcm=5 V
# NOTE:Correct value of Efficiency,Etta=(Po1/PDC1)*100= 39.269908 % for part(iii) but book ans is 39.31%(because of approximation used during calculation)
from __future__ import division
Av=1*10**(5)
print "Av= %0.2f"%(Av) #Voltage gain
VCC=(10)
print "VCC= %0.2f"%(VCC)," volts" # Collector voltage supply
vo=VCC
print "vo= VCC=%0.2f"%(vo)," volts" # maximum output voltage
Vdmax=VCC/Av
print "Vdmax= VCC/Av=%0.2e"%(Vdmax)," volts" # Difference input voltage at OP-amp terminals