import numpy as np
import math
# Given Data
fh = 10**3
C = 0.1*10**-6
Rf = 5.86*10**3
Ri = 10**4
# Solution
R = 1/(2*np.pi*C*fh)
Ao = (1 + Rf/Ri)
a = np.array([100, 200, 500, 1000, 5000, 10000])
print " The value of R is =",round(R/1000,1),"Kilo ohms"
print " The value of Ao =",Ao
print " Frequency in Hz Gain magnitude in dB 2o log (Vo/Vi)"
print " ========================================================"
for i in a:
val = round(20 * math.log10(Ao/(math.sqrt(1 + (i/fh)**4))),3)
print i," || ",val
# Design of a 4th order Butter worth Low pss filter
fh = 10**3
C = 0.1*10**-6
a1 = 0.765
a2 = 1.848
Ao1 = 3 - a1
Ao2 = 3 - a2
# let Rf1 = 12.35 kilo Ohm and Rf2 = 15.2 kilo ohm finding the Ri1 and Ri2
Rf1 = 12.35*10**3
Rf2 = 15.2*10**3
Ri1 = Rf1/(Ao1 - 1)
Ri2 = Rf2/(Ao2 - 1)
print " The value of Ao1 = ",Ao1
print " The value of Ao2 = ",Ao2
print " The value of Rf1 = ",Rf1/1000,"Kilo Ohm"
print " The value of Rf2 = ",Rf2/1000,"Kilo Ohm"
print " The value of Ri1 = ",int(Ri1/1000),"Kilo Ohm"
print " The value of Ri2 = ",int(Ri2/1000),"Kilo Ohm"
import math
# Solution to fing out the value of n or order
# We know the equation is 20 log|(H(jw)| = 20 log (Ao/(math.sqrt(1+(w/wh)**n))
# putig the values into the equation we will get 0.01**2 = 1/(1 + 2**2*n)
# solving the equation to get the value of n
# 2**(2*n) = 1/(1 + (0.01)**2)
# taking log to the base 2 on both sides
n = math.log(((10**4)-1),2)/2
print " The order of the filter will be =",int(math.ceil(n))
import numpy as np
import math
# Given Data
fl = 10**3
C = 0.1*10**-6
Rf = 5.86*10**3
Ri = 10**4
# Solution
R = 1/(2*np.pi*C*fl)
Ao = (1 + Rf/Ri)
a = np.array([100, 200, 500, 1000, 5000, 10000])
print " The value of R is =",round(R/1000,1),"Kilo ohms"
print " The value of Ao =",Ao
print " Frequency in Hz Gain magnitude in dB 2o log (Vo/Vi)"
print " ========================================================"
for i in a:
val = round(Ao/math.sqrt(1 + (fl/i)**4),3)
print i," || ",val
import math
# Given Data
fl = 400
fh = 2*10**3
Ao = 4
# For design top get Ao = 2 the values of Rf = Ri
Rf = Ri = 10*10**3
# for LPF
C1 = 0.01*10**-6
R1 = 1/(2*math.pi*fh*C1)
# for HPF
C2 = 0.01*10**-6
R2 = 1/(2*math.pi*fl*C2)
fo = math.sqrt(fh*fl)
Q = fo/(fh - fl)
print "The value of c1 =",C1*10**6,"uF"
print "The value of R1 =",round(R1/1000,1),"kilo Ohms"
print "The value of c2 =",C2*10**6,"uF"
print "The value of R2 =",round(R2/1000,1),"Kilo Ohms"
print "The value of Q =",round(Q,2)
import math
# Given Data
fo = 50
C = 0.1*10**-6
# Solution
R = 1/(2*math.pi*fo*C)
print "The value of Capasitor = ",C*10**6,"uF"
print "The value of Resistor = ",round(R/1000,1),"Kilo Ohm"
import math
# Given Data
fl = 400
fh = 2*10**3
Ao = 4
# For design top get Ao = 2 the values of Rf = Ri
Rf = Ri = 10*10**3
# for LPF
C1 = 0.1*10**-6
R1 = 1/(2*math.pi*fh*C1)
# for HPF
C2 = 0.1*10**-6
R2 = 1/(2*math.pi*fl*C2)
fo = math.sqrt(fh*fl)
Q = fo/(fh - fl)
print "The value of c1 =",C1*10**6,"uF"
print "The value of R1 =",round(R1/1000,1),"kilo Ohms"
print "The value of c2 =",C2*10**6,"uF"
print "The value of R2 =",round(R2/1000),"Kilo Ohms"
print "The value of Q =",round(Q,2)
# given data
fc = 400
Ao = -2
Vcc = 5
R1 = 10*10**3
HoLP = 2
R2 = HoLP * R1
# for second order butterworth filter Q = 0.707
Q = 0.707
R3 = Q * R2
fclock = 50 * fc
# Dispalying the outputs
print "The value of R1 =",R1/1000,"Ohms"
print "The value of R2 =",R2/1000,"Kilo Ohms"
print "The value of R3 =",R3/1000,"Kilo Ohms"
print "The value of clock frequency =",fclock/1000,"Kilo Hertz"