#Given
R1=2.2#kohm
G=-100 #Voltage gain
Rf=-G*R1#kohm
print "Value of Rf: ",Rf ,"kohm"
#Given
Vin=2.5 #mV
R1=2 #kohm
Rf=200 #kohm
G=-Rf/R1 #Gain
Vo=G*Vin/1000.0 #V
print "Output Voltage Vo=",Vo
#Given
G=-10 #Gain
Ri=100 #kohm input resistance
R1=Ri #kohm
R2=-G*R1 #kohm
print R1,"is the Value of R1 in kohm "
print int(R2/1000),"the Value of R2 in Mohm "
import math
#Given
FT1=1 #Filter Transmission
FT2=0.99 #Filter Transmission
FT3=0.9 #Filter Transmission
FT4=0.1 #Filter Transmission
A1= int(-20*math.log10(FT1)) #dB
A2= round(-20*math.log10(FT2),3) #dB
A3= round(-20*math.log10(FT3),3) #dB
A4= -20*math.log10(FT4) #dB
print "For filter transmission=1, Attenuation(dB)=", A1
print "For filter transmission=0.99, Attenuation(dB)=",A2
print "For filter transmission=0.9, Attenuation(dB)=",A3
print "For filter transmission=0.1, Attenuation(dB)=",A4
#Answer in the book is wrong for 0.99 filter transmission.
#Given
import math
fo=2 #kHz
Ap=10.0 #Band pass gain
C=0.1 #micro F(have to choose C, 0.01<C<1)
R2=round(1/(2*math.pi*fo*math.pow(10,3)*C*math.pow(10,-6)),1) #ohm
R1=R2/Ap #ohm
print "Design values are :"
print C,"is the Capacitance(micro F)"
print int(round(R1)),"is the Resistance R1(ohm)"
print round(R2/1000.0,1),"is the Resistance R2(kohm)"
#Answer in the book is wrong R2 should be .8kohm instead of 8kohm.
import math
#Given
fo=1 #kHz
Ap=1.586 #Band pass gain
C=0.005 #micro F C1=C2=0.005(Assumed)
R=round(1/(2*math.pi*fo*math.pow(10,3)*C*math.pow(10,-6)),2) #ohm
Rf=10 #kohm(Assumed)
Ri=Rf/(Ap-1) #kohm
print "Design values are :"
print round(R/1000,2)," is the Resistance in kohm, R1=R2=R"
print round(Ri,2),"is the Resistance Ri(kohm)"
print Rf,"is the Resistance Rf(kohm)"
print C,"is the Capacitance(micro F), C1=C2=C"
import math
#Given
fo=3 #kHz
Ap=4 #Band pass gain
alfa=1.414 #for butterworth filter
C1=0.01 #micro F(Assumed)
C2=round(math.pow(alfa,2)*C1/4.0,3) #micro F
R=round(1/(2*math.pi*fo*math.pow(10,3)*math.sqrt(C1*math.pow(10,-6)*C2*math.pow(10,-6))*1000.0),3) #kohm
Rf=2*R #kohm(Assumed)
print "Design values are :"
print C1,"is the Capacitance C1(micro F)"
print C2,"is the Capacitance C2(micro F)"
print R,"is the Resistance R(kohm)"
print "For offset minimization, Resistance Rf(kohm)=",Rf
#/For additional pass band gain
Ri=10.0 #kohm(Assumed)
Rf=(Ap-1)*Ri #kohm
print "For additional band pass gain:"
print Ri,"is the Resistance Ri(kohm)"
print Rf,"is the Resistance Rf(kohm)"
#Answer in the book is incorrect for C2.
import math
#Given
fo=2 #kHz
alfa=1.414 #for butterworth filter
Ap=3-alfa #band pass gain
RfBYRi=(Ap-1) #op-amp gain
C=0.05 #micro F(Assumed)
R=round(1/(2*math.pi*fo*10**3*C*10**-6)/1000,1) #kohm
#For offset minimization 2*R=Rf||Ri
Rf=round(2*R*RfBYRi+2*R,2) #kohm
Ri=round(Rf/RfBYRi,3) #kohm
print "Design values are :"
print C,"is the Capacitance C(micro F)"
print R,"is the Resistance R(kohm)"
print Rf,"is the Resistance Rf(kohm)"
print Ri,"is the Resistance Ri(kohm)"
#Ex 3.9
import math
fo=1.2 #kHz
alfa=1.414 #for butterworth filter
Ap=3-alfa #band pass gain
RfBYRi=(Ap-1) #op-amp gain
C=0.03 #micro F(have to choose C, 0.01<C<1)
R=round(1/(2*math.pi*fo*10**3*C*10**-6)/1000,1) #kohm
#For offset minimization 2*R=Rf||Ri
Rf=round(2*R*RfBYRi+2*R,2) #kohm
Ri=round(Rf/RfBYRi,1) #kohm
print "Design values are :"
print C,"is the Capacitance(micro F)"
print R,"is the Resistance R(kohm)"
print Rf,"is the Resistance Rf(kohm)"
print Ri,"is the Resistance Ri(kohm)"
#Ex 3.10
import math
fL=200 #Hz
fH=1*1000 #Hz
Ap=4 #band pass gain
BW=fH-fL #Hz
f0=math.sqrt(fH*fL) #Hz
fc=math.sqrt(fH*fL) #Hz
Q=fc/BW #Quality factor
print round(Q,2),"is the Quality factor "
print "As Q<12 it is wide band filter "
print fL,"is the Design values for high pass section with Ap1=2 & fL(Hz) : "
Ap1=2 #band pass gain for high pass section
C=0.033 #micro F(have to choose C, 0.01<C<1)
R=int(1/(2*math.pi*fL*C*10 **-6)/1000.0) #kohm
RfBYRi=(Ap-1) #op-amp gain
Rf=2*R #kohm
Ri=2*R #kohm
print C,"is the Capacitance(micro F) "
print R,"is the Resistance R(kohm) "
print Rf,"=Resistance Rf(kohm) "
print Ri,"=Resistance Ri(kohm) "
print fH,"=Design values for low pass section with Ap2=2 & fH(Hz) : "
Ap2=2 #band pass gain for low pass section
C=0.033 #micro F(have to choose C, 0.01<C<1)
k=fL/fH #scaling factor
Rdash=0.2*R #kohm
Ri=2*Rdash #kohm
Rf=Ri #kohm(for Ap2=2)
print C,"=Capacitance(micro F) "
print Rdash,"=Resistance Rdash(kohm) "
print Rf,"=Resistance Rf(kohm) "
print Ri,"=Resistance Ri(kohm) "
print "For design purpose use rounded value 10 kohm for Rf & Ri "
#Ex 3.11
import math
fL=200 #Hz
fH=1*1000 #Hz
Ap=4 #band pass gain
BW=fH-fL #Hz
f0=math.sqrt(fH*fL) #Hz
fc=math.sqrt(fH*fL) #Hz
Q=int(fc/BW) #Quality factor
print Q, "=Quality factor"
print "As Q<10 it is wide band filter"
print fH, "=Design values for low pass section with Ap2=2 & fH(Hz) :"
Ap2=2 #band pass gain for low pass section
C=0.03 #micro F(have to choose C, 0.01<C<1)
Rdash=round(1/(2*math.pi*fH*C*10**-6)/1000,1) #kohm
print C, "=Capacitance(micro F)"
print Rdash, "=Resistance Rdash(kohm)"
print "Value of Resistance Rf & Ri can be choosen as 10 kohm for filter design."
print fL, "=Design values for high pass section with Ap1=2 & fL(Hz) :"
Ap1=2 #band pass gain for high pass section
C=0.05 #micro F(have to choose C, 0.01<C<1)
R=round(1/(2*math.pi*fL*C*10**-6)/1000,1) #kohm
RfBYRi=(Ap-1) #op-amp gain
print C, "=Capacitance(micro F)"
print R, "=Resistance R(kohm)"
print "Value of Resistance Rf & Ri can be choosen as 10 kohm for filter design."
#Ex 3.12
import math
fo=1.2*1000 #Hz
Q=4 #Quality factor
Ap=10 #band pass gain
C=0.05 #micro F(have to choose C, 0.01<C<1)
R2=round(2*Q/(2*math.pi*fo*C*10** -6)/1000,2) #kohm
R1=round(R2/2/Ap,2) #kohm
R3=round(R1/(4*math.pi**2*R1*1000*R2*1000*(C*10** -6)** 2*fo** 2-1),2) #kohm
print "Design values are :"
print C,"= Capacitance(micro F)"
print R1,"= Resistance R1(kohm)"
print R2,"= Resistance R2(kohm)"
print R3*1000,"= Resistance R3(ohm)"
#Answer in the book is wrong for R3.
#Ex 3.13
import math
fH=100 #Hz
fL=1*1000 #Hz
print "This filter is a combination of -:"
print "High pass filter having fH=100 Hz"
print "Low pass filter having fL=1 kHz"
print "And a summing amplifier"
#High pass filter
print "Design values for high pass section :"
C=0.05 #micro F(have to choose C, 0.01<C<1)
R=round(1/(2*math.pi *fL*C*10 **-6)/1000,2) #kohm
Ap=2 #assumed
#Rf=Ri #for gain=2
Rf=10 #kohm(assumed)
Ri=10 #kohm(assumed)
print C,"= Capacitance(micro F)"
print R,"= Resistance R(kohm)"
print "Value of Resistance Rf & Ri can be choosen as 10 kohm for filter design."
#Low pass filter
print "Design values for low pass section :"
C=0.1 #micro F(have to choose C, 0.01<C<1)
Rdash=round(1/(2*math.pi *fH*C*10 **-6)/1000,2) #kohm
Ap=2 #assumed
#Rfdash=Ridash #for gain=2
Rf_dash=10 #kohm(assumed)
Ri_dash=10 #kohm(assumed)
print C,"= Capacitance(micro F)"
print Rdash,"= Resistance Rdash(kohm)"
print "Value of Resistance Rf_dash & Ri_dash can be choosen as 10 kohm for filter design."
#Ex 3.14
import math
fN=50 #Hz
C=0.5 #micro F(have to choose C, 0.01<C<1)
R=round(1/(2*math.pi*fN*C*10 **-6)/1000,2) #kohm
print "Design values are : "
print C ,"= Capacitance(micro F) "
print R ,"= Resistance R(kohm) "
#Ex 3.15
import math
fo=1*1000#Hz
fo_dash=1.5*1000#Hz
C=0.01#micro F(have to choose C, 0.01<C<1)
R=round(1/(2*math.pi*fo*C*10**-6)/1000,3)#kohm
K=1.2*1000/fo_dash#scaling factor
Rdash=round(K*R,3)#/kohm
print "Design values are :"
print C,"= Capacitance(micro F)"
print R,"= Resistance R(kohm)"
print Rdash,"= Resistance Rdash(kohm)"
#Ex 3.16
Vf=0.0125 #V
Vo=0.5 #V
Beta=Vf/Vo #unitless
#A*Beta=1 for oscillation
A=1/Beta #gain
print A,"= Minimum Gain"
#Ex 3.17
import math
R=50#kohm(R1=R2=R3=R)
C=60#pF(C1=C2=C3=C)
f=round(1/(2*math.pi*R*1000*C*10**-12*math.sqrt(6)),2)#Hz
print round(f/1000,3),"= Frequency of oscillation(kHz)"
#Ex 3.18
import math
f=2*1000#Hz
R=10#kohm(Assumed)(R1=R2=R)
C=1/(2*math.pi*R*1000*f)#F
print "Value of resistance R1=R2 can be choosen as 10 kohm"
print round(C*10**9,2),"= Cpacitance(nF)"
print "Value of resistance R4 can be choosen as 10 kohm & R3=2*R4=20 kohm for Beta to be 1/3"
#Ex 3.19
import math
R=200#kohm(R1=R2=R)
C=200#pF(C1=C2=C)
f=1/(2*math.pi*R*1000*C*10**-12)#Hz
print round(f*10**-3,3),"= Frequency of oscillation(kHz)"
#Answer in the book is wrong
#Ex 3.20
import math
import numpy
omegaBYomega0=[0, 0.5, 1, 5, 10, 100]
T=numpy.zeros(6);
G=numpy.zeros(6);
A=numpy.zeros(6);
f=numpy.zeros(6);
#T=omega0/sqrt(omega0**2+omega**2) #Gain
for i in range(0,6):
T[i]=round(1/sqrt(1**2+omegaBYomega0[i]**2),3) #Gain
G[i]=round(20*math.log10(T[i]),2) #dB
A[i]=round(-20*math.log10(T[i]),2) #dB
f[i]=round(-math.atan(omegaBYomega0[i])*180/math.pi,2) #degree
print "omega/omega0 T(j*omega) (G(dB)) A(dB) f"
for i in range(0,6):
print omegaBYomega0[i],"\t\t\t\t",T[i],"\t\t\t\t",G[i],"\t\t\t\t",A[i],"\t\t\t\t",f[i]
#Ex 3.21
import math
omega1=0.1#rad/s
omega2=1.0#rad/s
omega3=10.0#rad/s
T1=round(1/math.sqrt(1+omega1**6))#Transfer function
T2=round(1/math.sqrt(1+omega2**6),3)#Transfer function
T3=round(1/math.sqrt(1+omega3**6),3)#Transfer function
f1=-math.atan((2*omega1-omega1**3)/real(1-2*omega1**2))*180/math.pi#degree
f2=-math.atan((2*omega2-omega2**3)/real(1-2*omega2**2))*180/math.pi#degree
f3=-math.atan((2*omega3-omega3**3)/real(1-2*omega3**2))*180/math.pi#degree
print "Value of T= ",T1,"& f1 for 0.1 rad/s:",round(f1,1),"degree"
print "Value of T= ",T2,"& f2 for 1 rad/s: ",f2-180,"degree"
print "Value of T= ",T3,"& f3 for 10 rad/s: ",round(f3,2),"degree"
#Ex 3.22
import math
f0=10*1000 #Hz(3-dB frequency)
DCgain=10 #dc gain
R1=10 #kohm
R2=DCgain*R1 #kohm
C=round(1/(2*math.pi*f0*R2*1000)*10**9,3) #nF
print "Design values are :"
print R2,"= Resistance R2(kohm) "
print C,"= Capacitance C(nF)"
# Ex 3.23
import math
f0=100 # Hz(3-dB frequency)
Ri_inf=100 # kohm(High frequency input resistance)
Tinf=1 # high frequency gain
R1=Ri_inf # kohm
R2=Tinf*R1 # kohm
C=round(1/(2*math.pi*f0*R2*1000)*10**9,1) #nF
print "Design values are :"
print R2,"= Resistance R1=R2(kohm) "
print C,"= Capacitance C(nF)"
# Ex 3.24
import math
Ap=12 # dB(Pass band gain)
G=round(10**(Ap/20)) # gain(unitless)
Ri=100 # kohm(as high input impedence required)
R1=Ri # kohm
# Low pass filter design
ALP=-1
AHP=-4 # (to satisfy R2<=100 # kohm)
R2=-ALP*R1 # kohm
f0=10*1000 # Hz(3-dB frequency)
C=round(1/(2*math.pi*f0*R2*1000)*10**9,3) # nF
print "Design values for low pass filter "
print R2,"= Resistance R1=R2 in kohm "
print C,"= Capacitance C(nF)"
# High pass filter design
R3=25 # kohm(Assumed)
R4=-AHP*R3 # kohm
f0=100 # Hz(3-dB frequency)
C=round(1/(2*math.pi*f0*R3*1000)*10**9,1) # nF
print "Design values for high pass filter "
print R4,",",R3,"= Resistance R3 & R4 in kohm respectively "
print C,"= Capacitance C(nF)"
#Ex 3.25
import math
omega=10**4 #rad/s
C=10.0 #nF
fi1=math.radians(-30.0) #degree
fi2=math.radians(-90.0) #degree
fi3=math.radians(-120.0) #degree
fi4=math.radians(-150.0) #degree
R1=(math.tan(-fi1/2)/(C*10**-9*omega)/1000) #kohm
R2=math.tan(-fi2/2)/(C*10**-9*omega)/1000 #kohm
R3=math.tan(-fi3/2)/(C*10**-9*omega)/1000 #kohm
R4=math.tan(-fi4/2)/(C*10**-9*omega)/1000 #kohm
print "For phase shift=-30 degree, Resistance(kohm=",round(R1,2)
print "For phase shift=-90 degree, Resistance(kohm)=",round(R2,2)
print "For phase shift=-120 degree, Resistance(kohm)=",round(R3,2)
print "For phase shift=-150 degree, Resistance(kohm)=",round(R4,2)
# Ex 3.26
import math
omega1=0 # rad/s
omega2=inf # rad/s
omega0=math.degrees(10**4) # rad/s(Assumed)
fi1=math.atan(omega2/omega0)-math.atan(omega2/-omega0) # degree
fi2=math.atan(omega1/omega0)-math.atan(omega1/-omega0) # degree
print "For omega=0 phase shift(degree)=",int(fi1*180/math.pi)
print "For omega=infinity phase shift(degree)=",int(fi2*180/math.pi)
#Ex 3.28
import math
f0=1*1000 #Hz
BW=2*math.pi*50 #Hz
C=10 #nF
Q=2*math.pi*f0/BW #quality factor
R=1/(2*math.pi*f0*C*10**-9)/1000 #kohm
R1=10 #kohm(Assumed)
RF=10 #kohm(Assumed)
R3BYR2=2*Q-1
R2=10 #kohm(Assumed)
R3=R3BYR2*R2 #kohm
print "Design values for KHN circuit:"
print RF,",",R1,"= Use Resistance R1 & RF in kohm"
print R2,"= Use Resistance R2 in kohm"
print R3,"= Resistance R3 in kohm"
K=2-1/Q #scaling factor
CenterFrequency=K*Q
print CenterFrequency,"= CenterFrequency "