from __future__ import division
V_s=1*10**-3#
R_s=1*10**6#
A_voc=10**4# #open-circuit voltage gain
R_i=2*10**6# #input resistance
R_o=2# #output resistance
R_L=8# #load resistance
V_i=V_s*(R_i/(R_i+R_s))# #input voltage(voltage-divider principle)
V_vcs=A_voc*V_i# #voltage controlled source voltage
V_o=V_vcs*(R_L/(R_L+R_o))# #output voltage(voltage-divider principle)
A_v=V_o/V_i#
A_vs=V_o/V_s#
A_i=A_v*R_i/R_L# #current gain
G=A_v*A_i# #power gain
print " All the values in the textbook are approximated, hence the values in this code differ from those of Textbook"
print 'Voltage gain Av = %0.2f '%A_v
print 'Voltage gain Avs = %0.2f '%A_vs
print 'Current gain = %0.2e '%A_i
print 'Power gain = %0.2e '%G
from __future__ import division
R_i_1=10**6#
R_o_1=500#
R_i_2=1500#
R_o_2=100#
R_L=100#
A_voc_1=200#
A_voc_2=100#
#voltage gain of the first stage...A_v_1=(V_o_1/V_i_1)=(V_i_2/V_i_2)=A_voc_1(R_i_2/(R_i_2+R_o_1))
A_v_1=A_voc_1*(R_i_2/(R_i_2+R_o_1))#
A_v_2=A_voc_2*(R_L/(R_L+R_o_2))#
A_i_1=A_v_1*R_i_1/R_i_2#
A_i_2=A_v_2*R_i_2/R_L#
A_i=A_i_1*A_i_2#
G_1=A_v_1*A_i_1#
G_2=A_v_2*A_i_2#
G=G_1*G_2#
print 'Current gain of first stage = %0.2f'%A_i_1
print 'Current gain of second stage = %0.2f '%A_i_2
print 'Voltage gain of first stage = %0.2f '%A_v_1
print 'Voltage gain of second stage = %0.2f '%A_v_2
print 'Power gain of first stage = %0.2e '%G_1
print 'Power gain of second stage = %0.2f '%G_2
print 'Overall power gain = %0.2e '%G
R_i_1=10**6#
R_o_1=500#
R_i_2=1500#
R_o_2=100#
R_L=100#
A_voc_1=200#
A_voc_2=100#
A_v_1=A_voc_1*(R_i_2/(R_i_2+R_o_1))# #Voltage gain of first stage
A_v_2=A_voc_2# #Voltage gain of second stage with open-circuit load
A_voc=A_v_1*A_v_2# #overall open-circuit voltage gain
R_i=R_i_1# #input resistance of cascading amplifier
R_o=R_o_2# #output resistance
print 'Hence the simplified model for the cascade is with an:'
print 'Input resistance = %0.2e ohms'%R_i
print 'Input resistance = %0.2f ohms'%R_o
print 'Overall open-circuit voltage gain = %0.2f'%A_voc
from __future__ import division
V_AA=15#
V_BB=15#
V_i=1*10**-3#
I_A=1#
I_B=0.5#
R_L=8#
R_o=2#
R_i=100*10**3#
A_voc=10**4#
P_i=V_i**2/R_i#
V_o=A_voc*V_i*(R_L/(R_L+R_o))#
P_o=V_o**2/R_L#
P_s=V_AA*I_A+V_BB*I_B#
P_d=P_s+P_i-P_o#
n=P_o*100/P_s#
print "All the values in the textbook are approximated, hence the values in this code differ from those of Textbook"
print '\nInput power = %.2f pW'%(P_i*10**12)
print 'Output power = %.2f watts'%P_o
print 'Supply power = %.2f watts'%P_s
print 'Dissipated power = %.2f watts'%P_d
print 'Efficiency of the amplifier = %.2f'%n
from __future__ import division
R_i=1*10**3#
R_o=100#
A_voc=100#
#I_i=V_i/R_i, I_osc=A_voc*V_i/R_o from these two we get A_isc=(i_osc/I_i)=(A_voc(R_i/R_o))
A_isc=A_voc*(R_i/R_o)#
print 'The resulting current-amplifier is with an:'
print 'input resitance = %0.2f ohms'%R_i
print 'output resistance = %0.2f ohms'%R_o
print 'and a short-cut current gain of: %0.2f'%A_isc
from __future__ import division
R_i=1*10**3#
R_o=100#
A_voc=100#
#i_osc=A_voc*V_i/R_o and G_msc=i_osc/V_i gives G_msc=A_voc/R_o
G_msc=A_voc/R_o#
print 'The resulting transconductance model is with an:'
print 'input resitance = %0.2f ohms'%R_i
print 'output resistance = %0.2f ohms'%R_o
print 'and transconductance = %0.2f siemens'%G_msc
from __future__ import division
R_i=1*10**3#
R_o=100#
A_voc=100#
#V_ooc=A_voc*V_i and I_i=V_i/R_i gives R_moc=V_ooc/I_i
R_moc=A_voc*R_i#
print 'The resulting transconductance model is with an:'
print 'input resitance = %0.2f ohms'%R_i
print 'output resistance = %0.2f ohms'%R_o
print 'and transresistance = %0.2f ohms'%R_moc
from __future__ import division
from math import cos,sin,sqrt,atan,log,pi
V_i=complex(0.1*cos(-pi/6),0.1*sin(-pi/6))#
V_o=complex(10*cos(pi/12),10*sin(pi/12))#
A_v=V_o/V_i#
A_v_max=sqrt(((A_v.real)**2)+((A_v.imag)**2))
phi=atan((A_v.imag)/(A_v.real))#
print " All the values in the textbook are approximated, hence the values in this code differ from those of Textbook"
print 'The complex voltage gain is with'
print 'a peak value of : %0.2f'%A_v_max
print 'a phase angle = %0.2f degrees'%phi
print 'and the decibel gain is %0.2f'%(20*log(A_v_max)/2.30258) #2.30258 is for base 10
from numpy import arange,pi,cos
%matplotlib inline
from matplotlib.pyplot import plot,title,show,subplot,xlabel,ylabel
from __future__ import division
t=arange(0,0.002+0.000001,0.000001)
V_i=[]
for x in t:
V_i.append(3*cos(2000*pi*x)-2*cos(6000*pi*x))
#let A_1000 and A_3000 be the gains
A_1000_peak=10#
A_1000_phi=0#
A_3000_peak=2.5#
A_3000_phi=0#
#multiplying by respective gains
V_o=[]
for x in t:
V_o.append(A_1000_peak*3*cos(2000*pi*x+A_1000_phi)-A_3000_peak*2*cos(6000*pi*x+A_3000_phi))
subplot(121)
title('Input-voltage vs time')
xlabel('time in ms')
ylabel('Internal-voltage in volts')
plot(t*10**3,V_i)
subplot(122)
title('Output-voltage vs time')
xlabel('time in ms')
ylabel('Output voltage in volts')
plot(t*10**3,V_o)
show()
from numpy import arange,pi,cos
%matplotlib inline
from matplotlib.pyplot import plot,title,show,subplot,xlabel,ylabel
from __future__ import division
t=arange(0,0.002+0.000001,0.000001)
V_i=[]
for x in t:
V_i.append(3*cos(2000*pi*x)-2*cos(6000*pi*x))
#for A
A_1000_A_peak=10#
A_1000_A_phi=0#
A_3000_A_peak=10#
A_3000_A_phi=0#
V_o_A=[]
for x in t:
V_o_A.append(A_1000_A_peak*3*cos(2000*pi*x+A_1000_A_phi)-A_3000_A_peak*2*cos(6000*pi*x+A_3000_A_phi))
#for B
A_1000_B_peak=10#
A_1000_B_phi=-pi/4#
A_3000_B_peak=10#
A_3000_B_phi=-3*pi/4#
V_o_B=[]
for x in t:
V_o_B.append(A_1000_B_peak*3*cos(2000*pi*x+A_1000_B_phi)-A_3000_B_peak*2*cos(6000*pi*x+A_3000_B_phi))
#for C
A_1000_C_peak=10#
A_1000_C_phi=-pi/4#
A_3000_C_peak=10#
A_3000_C_phi=-pi/4#
V_o_C=[]
for x in t:
V_o_C.append(A_1000_C_peak*3*cos(2000*pi*x+A_1000_C_phi)-A_3000_C_peak*2*cos(6000*pi*x+A_3000_C_phi))
print 'VoA(t)=30cos(2000pit)-10cos(6000pit)'
print 'VoB(t)=30cos(2000pit-pi/4)-10cos(6000pit-3pi/4)'
print 'VoC(t)=30cos(2000pit-pi/4)-10cos(6000pit-pi/4)'
subplot(311)
title('Output-voltage vs time for A')
xlabel('time in ms')
ylabel('Output-voltage for A in volts')
plot(t*10**3,V_o_A)
subplot(312)
title('Output-voltage vs time for B')
xlabel('time in ms')
ylabel('Output voltage for B in volts')
plot(t*10**3,V_o_B)
subplot(313)
title('Output-voltage vs time for C')
xlabel('time in ms')
ylabel('Output voltage for C in volts')
plot(t*10**3,V_o_C)
show()
from __future__ import division
from math import log
A_d=1000# #differential gain
V_d_peak=1*10**-3# #peak value of differential input signal
V_o_peak=A_d*V_d_peak# #peak output signal
V_cm=100#
V_o_cm=0.01*V_o_peak# #common mode contribution is 1% or less
A_cm=V_o_cm/V_cm# #common mode gain
CMRR=20*log(A_d/A_cm)/2.30258#
print " All the values in the textbook are approximated, hence the values in this code differ from those of Textbook"
print 'The minimum CMRR = %0.2f'%CMRR
from __future__ import division
#initialisation of variables
Rin= 1 #Mohms
Rs1= 100 #kohms
Rs2= 100 #kohms
Ioff= 84 #Amperes
Voff= 5 #mV
#CALCULARIONS
Vioff= Rin*Ioff*10**-3*(Rs1+Rs2)/(2*(Rin+10**-3*(Rs1+Rs2)))
Vvoff= Voff*Rin/(Rin+10**-3*(Rs1+Rs2))
#RESULTS
print 'Vioff = %.f mV '%Vioff
print '\n Vvoff = %.2f mV '%Vvoff