Chapter 7 : Active Filters

Example 7.1 Page No.269

In [7]:
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
 The value of R is = 1.6 Kilo ohms
 The value of Ao   = 1.586
 Frequency in Hz            Gain magnitude in dB 2o log (Vo/Vi)
 ========================================================
100             ||                4.006
200             ||                4.006
500             ||                4.006
1000             ||                0.996
5000             ||                -23.96
10000             ||                -35.994

Example 7.2 Page No.270

In [5]:
# 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"
 The value of Ao1 =  2.235
 The value of Ao2 =  1.152
 The value of Rf1 =  12.35 Kilo Ohm
 The value of Rf2 =  15.2 Kilo Ohm
 The value of Ri1 =  10 Kilo Ohm
 The value of Ri2 =  100 Kilo Ohm

Example 7.3 Page No.271

In [6]:
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))
 The order of the filter will be = 7

Example 7.4 Page No.272

In [8]:
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
 The value of R is = 1.6 Kilo ohms
 The value of Ao   = 1.586
 Frequency in Hz            Gain magnitude in dB 2o log (Vo/Vi)
 ========================================================
100             ||                0.016
200             ||                0.063
500             ||                0.385
1000             ||                1.121
5000             ||                1.586
10000             ||                1.586

Example 7.5 Page No.276

In [9]:
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)
The value of c1 = 0.01 uF
The value of R1 = 8.0 kilo Ohms
The value of c2 = 0.01 uF
The value of R2 = 39.8 Kilo Ohms
The value of Q  = 0.56

Example 7.6 Page No.279

In [11]:
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"
The value of Capasitor =  0.1 uF
The value of Resistor  =  31.8 Kilo Ohm

Example 7.7 Page No.280

In [17]:
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)
The value of c1 = 0.1 uF
The value of R1 = 0.8 kilo Ohms
The value of c2 = 0.1 uF
The value of R2 = 4.0 Kilo Ohms
The value of Q  = 0.56

Example 7.10 Page No.298

In [18]:
# 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"
The value of R1 = 10 Ohms
The value of R2 = 20 Kilo Ohms
The value of R3 = 14.14 Kilo Ohms
The value of clock frequency = 20 Kilo Hertz
In [ ]: