%matplotlib inline
#Variable Declaration:
import math
fH=10.0*10**3 #Frequency in hertz
f=12.0*10**3 #Frequency in hertz
#Calculations:
t=(f**2/fH**2)
Hif=1/(math.sqrt(1+t)) #Calculating magnitude of voltage tranfer fuction
Hifdb=20*math.log(Hif)/math.log(10) #Calculating magnitude of voltage tranfer fuction
#Result:
print('Delta Vi=%.2f dB'%Hifdb)
#Variable Declaration:
import math
fh=2000.0 #Cut-off frequency in hertz
A=2.0 #Gain
C=0.01*10**-6 #Capacitance in farad
#Calculations:
R=1/(2*math.pi*fh*C) #Calculating value of resistance
R=R/1000.0 #Calculating resistance value
#Results:
print('R= %.3f kohm'%R)
#Rf/Ri=A-1
print('\n Hence Rf=Ri=10kohm')
#Variable Declaration:
import math
fh=10.0*10**3 #Cut-off frequency in hertz
f=12.0*10**3 #Signal freuency in hertz
R=200.0*10**3 #Resistance value in ohm
#Calaculations:
RC=1/(2*math.pi*fh) #Calculating value of resistance
C=RC/R #Calculating value of capacitance
C3=1.414*C #Calculating value of capacitance
C4=0.707*C #Calculating value of capacitance
t=(f**4/fh**4)
Hif=1/(math.sqrt(1+t)) #Calculating magnitude of voltage tranfer fuction
Hifdb=20*math.log(Hif)/math.log(10) #Calculating magnitude of voltage tranfer fuction
#Result:
print('Hif= %.2f dB'%Hifdb)
#Variable Declaration:
import math
N=2.0 #Order of filter
fh=2.0*10**3 #upper cut-off frequency in hertz
C=0.1*10**-6 #Capacitance value in farad
alpha=1.414 #Value of damping coefficient
#Calculations:
R=1/(2*math.pi*fh*C) #Calculating resistance value
Rkohm=R/1000.0 #Calculating resistance value
A=3-alpha #Calculating passband gain
RfbyRi=A-1 #Calculating ratio Rf/Ri
#Results:
print('R= %.1f kohm'%Rkohm)
print('\nRf/Ri= %.3f'%RfbyRi)
print('\nHence, take Rf=5.86 kohm and Ri=10 kohm')
#Variable declaration:
import math
fh=10.0*10**3 #cut-off frequency in hertz
f=12.0*10**3 #Signal frequency in hertz
#For third order low pass butterworth filter
#Calculations:
t=(f**6/fh**6)
Hif=1/(math.sqrt(1+t)) #Calculating magnitude of voltage transfer function
Hifdb=20*math.log(Hif)/math.log(10) #Calculating magnitude of voltage transfer function
#Result:
print('Hif= %.4f dB'%Hifdb)
#For fourth order low pass butterworth filter
#Calculation:
t=(f**8/fh**8)
Hif=1/(math.sqrt(1+t))
Hifdb=20*math.log(Hif)/math.log(10)
#Result:
print('\nHif= %.2f dB'%Hifdb)
#Variable Declaration:
import math
N=2.0 #Order of filter
fh=2000.0 #cut-off frequency in hertz
C=0.1*10**-6 #Capacitance values in farad
alpha1=0.765 #damping coefficient
alpha2=1.848 #damping coefficient
#Calculations:
R=1/(2*math.pi*fh*C) #Calculating resistance value
Rkohm=R/1000.0 #Calculating resistance value
A1=3-alpha1 #Calculating passband gain
A2=3-alpha2 #Calculating passband gain
Rf1byRi1=A1-1 #Calculating Rf1/Ri1 ratio
Rf2byRi2=A2-1 #Calculating Rf2/Ri2 ratio
#Results:
print('R= %.1f kohm'%Rkohm)
print('\nRf1/Ri1= %.3f'%Rf1byRi1)
print('\nHence, take Rf1=12.35 kohm and Ri1=10 kohm')
print('\nRf2/Ri2= %.3f'%Rf2byRi2)
print('\nHence, take Rf2=15.2 kohm and Ri2=100 kohm')
#Variable Declaration:
import math
A=2.0 #Gain
fL=2.0*10**3 #Frequency in hertz
C=0.01*10**-6 #Capacitance value in farad
#Calculations:
R=1/(2*math.pi*fL*C) #Calculating value of resistance
Rkohm=R/1000.0 #Calculating value of resistance
RfbyRi=A-1 #Calculating ratio Rf/Ri
#Results:
print('R= %.1f kohm'%Rkohm)
print('\nRf/Ri= %.3f'%RfbyRi)
print('\nHence, take Rf=10 kohm and Ri=10 kohm')
#Variable Declaration:
import math
R2=16.0*10**3 #Resistance in ohm
R3=16.0*10**3 #Resistance in ohm
Rf=15.8*10**3 #Resistance in ohm
Ri=27.0*10**3 #Resistance in ohm
C2=0.01*10**-6 #Capacitance in farad
C3=0.01*10**-6 #Capacitance in farad
#Calculations:
fL=1/(2*math.pi*math.sqrt(R2*R3*C2*C3)) #Calculating lower cut-off frequency
fL=fL/1000.0 #Calculating lower cut-off frequency
A=1+Rf/Ri #Calculating passband gain
#Results:
print('\nfL= %.1f kHz'%fL)
print('\nA= %.3f'%A)
a=[-35.99,-23.96,-3.12,1.00,3.95,4.00,4.01,4.01,4.01]
b=[log10(100),log10(200),log10(700),log10(1000),log10(3000),log10(7000),log10(10000),log10(30000),log10(100000)]
plot(b,a,'b')
plot(log10(100),-35.99,'o')
plot(log10(200),-23.96,'o')
plot(log10(700),-3.12,'o')
plot(log10(1000),1.00,'o')
plot(log10(3000),3.95,'o')
plot(log10(7000),4.00,'o')
plot(log10(10000),4.01,'o')
plot(log10(30000),4.01,'o')
plot(log10(100000),4.01,'o')
m=arange(-40,1,0.0005)
x5=(3*m)/m
plot(x5,m,'--')
k = arange(2.0001,3.5, 0.0005)
plot(k,4.006*k/k,'--')
text(1.6,4.006,'+4.006')
text(3.3,-38,'Passband')
text(2.3,-38,'Stopband')
text(2.2,-10,'40 dB/decade')
text(3,2,'3dB')
title('Frequency response of ssecond order high-pass filter')
ylabel('Voltage gain in dB')
xlabel('frequency index n where n=log(f)')
#Variable Declaration:
import math
fh=50000.0 #frequency in hertz
C=0.001*10**-6 #capacitance in farad
#Calculations:
R=1/(2.0*math.pi*fh*C) #Calculating value of resistance
Rkohm=R/1000.0 #Calculating value of resistance
R1=R/1.082 #Calculating value of resistance
R2=R/0.9241 #Calculating value of resistance
R3=R/2.613 #Calculating value of resistance
R4=R/0.3825 #Calculating value of resistance
Hif=0.02
s=(Hif**2)/(1-Hif**2)
s1=s**0.125
f=fh/1.6815 * s1 #Calculating value of frequency
fkhz=f/1000.0 #Calculating value of frequency
#Results:
print('R= %.3f kohm'%Rkohm)
print('\nR1= %.3f kohm'% (R1/1000))
print('\nR2= %.3f kohm'% (R2/1000))
print('\nR3= %.3f kohm'% (R3/1000))
print('\nR4= %.3f kohm'% (R4/1000))
print('\nf= %.2f kHz'% fkhz)
#Variable Declaration:
import math
fh=2500.0 #Frequency in hertz
fL=250.0 #Frequency in hertz
#Calculations:
B=fh-fL #Calculating bandwidth
fr=math.sqrt(fh*fL) #Calculating frequency
fc=(fL+fh)/2 #Calculating frequency
#Results:
print('Bandwdth B= %d Hz'%B)
print('\nResonant Frequency fr= %.2f Hz'%fr)
print('\nCenter Frequency fr= %d Hz'%fc)
print('\nHence, resonant frequency is always less than center frequency')
#Variable Declaration:
import math
#Part A
fr=1000.0 #Frequency in hertz
B=3000.0 #Bandwidth in hertz
#Calculations:
Q=fr/B #Calculation Quality factor
#Part B
fL= math.sqrt((B*B/4)+fr**2) - B/2 #Calculating lower cut-off frequency
#Part C
fh=fL+B #Calculating high cut-off frequency
#Results:
print('Quality factor Q= %.2f '%Q)
print('Since Q<0.5, this is a wideband filter')
print('\nfL= %.2f Hz'%fL)
print('\nfh= %.2f Hz'%fh)
#Variable Declaration:
import math
# Part A
#For a bandpass filter
R=20000.0 #Resistance in ohm
Rr=2700.0 #Resistance in ohm
C=0.01*10**-6 #Capacitance in farad
#Calculations:
fr=0.1125*(math.sqrt(1+R/Rr))/(R*C) #Calculating resonant frequency
#Part B
B=0.1591/(R*C) #Calculating Bandwidth
#Results:
print('Resonant frequency= %.1f Hz'%fr)
print('\nBandwidth= %.1f Hz'%B)
#Variable Declaration:
fr=200.0 #Resonant frequency in hertz
B=20.0 #Bandwidth in hertz
C=0.33*10**-6 #Capacitance in farad
#Calculations:
Q=fr/B #Calculating quality factor
R=0.1591/(B*C) #Calculating resistance value
Rr=R/(2.0*Q*Q-1) #Calculating resistance value
R=R/1000.0 #Calculating resistance value
#Results:
print('\nR= %.1f kohm'%R)
print('\nRr= %.1f ohm'% Rr)
#Variable Declaration:
R=1.0*10**6 #Resistance in ohm
C=40.0*10**-12 #Capacitance value
#Calculations:
fck=1/(R*C) #Calculating clock frequency
fck=fck/1000 #Calculating clock frequency
#Result:
print('Fck= %.1f kHz'%fck)