# Chapter9 - Active filters¶

## Ex 9.2 - page : 273¶

In [3]:
from __future__ import division
from math import pi
fH=1 #kHz
Ap=2 #Pass band gain
print "Various design parameters are :-"
C=0.05 #micro F#Chosen for the design
print "Capacitance is %0.2f micro F " %C
R=1/(2*pi*fH*1000*C*10**-6)/1000 #kohm
print "Resistance R = %0.1f kohm " %R
#Ap=1+Rf/Ri
RfBYRi=Ap-1 #Rf=Ri here
#R=Rf||Ri
Ri=2*R #kohm
Rf=Ri #kohm
print "Resistance Ri = %0.1f kohm " %Ri
print "Resistance Rf = %0.1f kohm " %Rf

Various design parameters are :-
Capacitance is 0.05 micro F
Resistance R = 3.2 kohm
Resistance Ri = 6.4 kohm
Resistance Rf = 6.4 kohm


## Ex 9.3 - page : 273¶

In [4]:
from __future__ import division
f0=800 #Hz
#For Butterworth filter : f0=fH=f_3dB
fH=f0 #Hz
f_3dB=f0 #Hz
BW=fH #Hz
print "Bandwidth = %0.2f Hz " %BW

Bandwidth = 800.00 Hz


## Ex 9.4 - page 274¶

In [6]:
from __future__ import division
from math import pi
fH=2 #kHz(Cutoff frequency)
Ap=1 #Pass band gain
print "Various design parameters are :-"
C=0.05 #micro F#Chosen for the design between 0.01 & 1 micro F
print "Capacitance = %0.2f micro F " %C
R=1/(2*pi*fH*1000*C*10**-6)/1000 #kohm
print "Resistance R = %0.1f kohm " %R
Rdash=R #/kohm(To eliminate the effect of offset)
print "Resistance R* = %0.1f kohm " %Rdash

Various design parameters are :-
Capacitance = 0.05 micro F
Resistance R = 1.6 kohm
Resistance R* = 1.6 kohm


## Ex 9.5 - page : 275¶

In [9]:
from __future__ import division
from math import pi
f0=1 #kHz(Cutoff frequency)
f0dash=1.5 #kHz(Cutoff frequency)
print "Various design parameters are :-"
#For Butterworth filter
fH=f0 #kHz
fHdash=f0dash #kHz
K=f0/f0dash #ratio
R=3.2 #kohm
Rdash=K*R #kohm
print "Resistance Rdash = %0.1f kohm " %Rdash
C=0.05 #micro F#Chosen for the design
print "Capacitance = %0.2f micro F " %C
fHdash=1/(2*pi*Rdash*1000*C*10**-6)/1000 #kHz
print "Cutoff frequency is %0.1f kHz " %fHdash

Various design parameters are :-
Resistance Rdash = 2.1 kohm
Capacitance = 0.05 micro F
Cutoff frequency is 1.5 kHz


## Ex 9.6 - page : 278¶

In [13]:
from __future__ import division
from math import pi
fL=400 #Hz
Ap=2 #Pass band gain
print "Various design parameters are :-"
C=0.05 #micro F#Chosen for the design between 0.01 & 1 micro F
print "Capacitance is %0.2f micro F " %C
R=1/(2*pi*fL*C*10**-6)/1000 #kohm
print "Resistance R = %0.2f kohm " %R
#Ap=1+Rf/Ri
RfBYRi=Ap-1 #Rf=Ri here
#R=Rf||Ri
Ri=2*R #kohm
Rf=Ri #kohm
print "Resistance Ri = %0.1f kohm " %Ri
print "Resistance Rf = %0.1f kohm " %Rf
# Answer in the textbook are inaccurate.

Various design parameters are :-
Capacitance is 0.05 micro F
Resistance R = 7.96 kohm
Resistance Ri = 15.9 kohm
Resistance Rf = 15.9 kohm


## Ex 9.7 - page : 279¶

In [14]:
from __future__ import division
from math import pi
fL=400 #Hz
fLdash=800 #Hz
K=fL/fLdash #ratio
print "Various parameters for retuning are :-"
R=8.2 #kohm
Rdash=K*R #kohm
print "Resistance Rdash = %0.2f kohm " %Rdash
Rf=2*Rdash #kohm
Ri=2*Rdash #kohm
print "Resistance Ri = %0.1f kohm " %Ri
print "Resistance Rf = %0.1f kohm " %Rf

Various parameters for retuning are :-
Resistance Rdash = 4.10 kohm
Resistance Ri = 8.2 kohm
Resistance Rf = 8.2 kohm


## Ex 9.8 - page : 285¶

In [18]:
from __future__ import division
from math import pi, sqrt
f0=3 #kHz(Critical frequency)
Ap=4 #Pass band gain
#For Butterworth filter using sallen key
alfa=1.414; klp=1 #constant
fH=f0 #kHz
f_3dB=f0 #kHz
print "Various design parameters are :-"
C1=0.01 #micro F#Chosen for the design
print "Capacitance C1 = %0.2f micro F " %C1
C2=alfa**2*C1/4 #micro F
print "Capacitance C2 = %0.3f micro F " %C2
C2=0.004 # micro F
R=1/(2*pi*fH*10**3*sqrt(C1*10**-6*C2*10**-6))/1000 #kohm
print "Resistance R = %0.1f kohm " %R
R=8.2 #kohm
#For offset minimization
Rdash=2*R #kohm
print "Resistance R* = %0.2f kohm " %Rdash
RfBYRi=Ap-1 #Rf=Ri here
#Ri=10 kohm chosen for design
Ri=10 #kohm
Rf=RfBYRi*Ri #kohm
print "Resistance Ri = %0.1f kohm " %Ri
print "Resistance Rf = %0.1f kohm " %Rf

Various design parameters are :-
Capacitance C1 = 0.01 micro F
Capacitance C2 = 0.005 micro F
Resistance R = 8.4 kohm
Resistance R* = 16.40 kohm
Resistance Ri = 10.0 kohm
Resistance Rf = 30.0 kohm


## Ex 9.9 - page : 288¶

In [25]:
from __future__ import division
from math import pi, sqrt
f0=2 #kHz(Critical frequency)
Ap=5 #dc gain
#For Butterworth filter using sallen key
alfa=1.414; klp=1 #constant
fH=f0 #kHz
f_3dB=f0 #kHz
Ap1=3-alfa #gain
RfBYRi=Ap1-1 #ratio
print "Various design parameters are :-"
C=0.05 #micro F#Chosen for the design
print "Capacitance C = %0.2f micro F " %C
R=klp/(2*pi*fH*10**3*C*10**-6)/1000 #kohm
print "Resistance R = %0.1f kohm " %R
#For offset minimization
#2*R=Rf||Ri=Rf/(RfBYRi+1)
Rf=2*R*(RfBYRi+1) #kohm
print "Resistance Rf = %0.1f kohm " %Rf
Ri=Rf/RfBYRi #kohm
print "Resistance Ri = %0.1f kohm " %Ri
#Ap=4 #dc gain in this case
Ap=4 #dc gain
Ap2=Ap/Ap1 #remainimg gain after 2nd order butterworth filter
RfdashBYRidash=Ap2-1 #ratio
#Ridash=10 #kohm chosen for design
Ridash=10 #kohm
print "Resistance Ridash = %0.2f kohm " %Ridash
Rfdash=RfdashBYRidash*Ridash #kohm
print "Resistance Rfdash = %0.f kohm " %Rfdash

Various design parameters are :-
Capacitance C = 0.05 micro F
Resistance R = 1.6 kohm
Resistance Rf = 5.0 kohm
Resistance Ri = 8.6 kohm
Resistance Ridash = 10.00 kohm
Resistance Rfdash = 15 kohm


## Ex 9.10 - page : 289¶

In [28]:
from __future__ import division
from math import pi, sqrt
f0=2 #kHz(Critical frequency)
fH=f0 #kHz
f_3dB=f0 #kHz
#For Butterworth filter using sallen key
alfa=1.414; klp=1 #constant
Ap=3-alfa # band pass gain
RfBYRi=Ap-1 #ratio
print "Various design parameters are :-"
C=0.05 #micro F#Chosen for the design
print "Capacitance C = %0.2f micro F " %C
R=1/(2*pi*fH*10**3*C*10**-6)/1000 #kohm
print "Resistance R = %0.1f kohm " %R
#For offset minimization
#2*R=Rf||Ri=Rf/(RfBYRi+1)
Rf=2*R*(RfBYRi+1) #kohm
print "Resistance Rf = %0.1f kohm " %Rf
Ri=Rf/RfBYRi #kohm
print "Resistance Ri = %0.1f kohm " %Ri
#Answer in the book is not accurate. Some calculation mistake is there while working for offset minimization.

Various design parameters are :-
Capacitance C = 0.05 micro F
Resistance R = 1.6 kohm
Resistance Rf = 5.0 kohm
Resistance Ri = 8.6 kohm


## Ex 9.11 - page : 290¶

In [31]:
from __future__ import division
from math import pi, sqrt
f0=2 #kHz(Critical frequency)
fH=f0 #kHz
f_3dB=f0 #kHz
#For Bessel filter of 2nd order
alfa=1.73; klp=0.785 #constant
Ap=3-alfa # band pass gain
RfBYRi=Ap-1 #ratio
print "Various design parameters are :-"
C=0.05 #micro F#Chosen for the design
print "Capacitance C = %0.2f micro F " %C
R=klp/(2*pi*fH*10**3*C*10**-6)/1000 #kohm
print "Resistance R = %0.2f kohm " %R
#For offset minimization
#2*R=Rf||Ri=Rf/(RfBYRi+1)
Rf=2*R*(RfBYRi+1) #kohm
print "Resistance Rf = %0.2f kohm " %Rf
Ri=Rf/RfBYRi #kohm
print "Resistance Ri = %0.2f kohm " %Ri
# Answer in the textbook are inaccurate.

Various design parameters are :-
Capacitance C = 0.05 micro F
Resistance R = 1.25 kohm
Resistance Rf = 3.17 kohm
Resistance Ri = 11.75 kohm


## Ex 9.12 - page : 291¶

In [36]:
from __future__ import division
from math import pi, sqrt
f0=.12 #kHz(Cutoff frequency)
fH=f0 #kHz
#For Butterworth filter of 2nd order
alfa=1.414; klp=1 #constant
Ap=3-alfa # band pass gain
RfBYRi=Ap-1 #ratio
print "Various design parameters are :-"
C=0.33 #micro F#Chosen for the design choosing between 0.01 & 1 micro F
print "Capacitance C = %0.2f micro F " %C
R=klp/(2*pi*fH*10**3*C*10**-6)/1000 #kohm
print "Resistance R = %0.f kohm " %R
#For offset minimization
#2*R=Rf||Ri=Rf/(RfBYRi+1)
Rf=2*R*(RfBYRi+1) #kohm
print "Resistance Rf = %0.2f kohm " %Rf
Ri=Rf/RfBYRi #kohm
print "Resistance Ri = %0.f kohm " %Ri
# Answer in the textbook are inaccurate.

Various design parameters are :-
Capacitance C = 0.33 micro F
Resistance R = 4 kohm
Resistance Rf = 12.75 kohm
Resistance Ri = 22 kohm


## Ex 9.13 - page : 295¶

In [40]:
from __future__ import division
from math import pi, sqrt, floor
fL=20 #Hz(Cutoff frequency)
#For Butterworth filter of 2nd order
alfa=1.414; klp=1 #constant
Ap=3-alfa # band pass gain
RfBYRi=Ap-1 #ratio
print "Various design parameters are :-"
C=0.22 #micro F#Chosen for the design choosing between 0.01 & 1 micro F
print "Capacitance C = %0.2f micro F " %C
R=klp/(2*pi*fL*C*10**-6)/1000 #kohm
print "Resistance R = %0.2f kohm " %R
#For offset minimization
#R=Rf||Ri=Rf/(RfBYRi+1)
Rf=R*(RfBYRi+1) #kohm
print "Resistance Rf = %0.f kohm " %Rf
Ri=Rf/RfBYRi #kohm
Ri=floor(Ri) #kohm
print "Resistance Ri = %0.f kohm " %Ri

Various design parameters are :-
Capacitance C = 0.22 micro F
Resistance R = 36.17 kohm
Resistance Rf = 57 kohm
Resistance Ri = 97 kohm


## Ex 9.14 - page : 297¶

In [43]:
from __future__ import division
from math import pi, sqrt
fH=2 #kHz(Cutoff frequency)
Ap=4 #Pass band gain
print "Butterworth filter = cascading of 1st and 2nd order high pass filter."
#Butterworth polynomial is (s+1)*(s**2+s+1)
alfa=1 #for sallen key
Ap2=3-alfa #gain for 2nd order filter
Ap1=Ap/Ap2 #gain for 1st order filter
#Design parameters for 1st order filter :
print "Various design parameters for 1st order filter are :-"
C=0.01 #micro F#Chosen for the design
print "Capacitance C = %0.2f micro F " %C
R=1/(2*pi*fH*10**3*C*10**-6)/1000 #kohm
print "Resistance R = %0.2f kohm " %R
R=8.2 #kohm
#Ap1=Rf/Ri+1   with Ap1=2 we have Rf=Ri
Rf=2*R #kohm
Ri=2*R #kohm
print "Resistance Rf = %0.2f kohm & Ri = %0.2f kohm " %(Rf,Ri)
#Design parameters for 2nd order filter :
kLp=1/alfa #unitless
#Ap2=Rfdash/Ridash+1   with Ap2=2 we have Rfdash=Ridash
print "Various design parameters for 2nd order filter are :-"
C=0.033 #micro F#Chosen for the design
print "Capacitance C = %0.3f micro F " %C
R=kLp/(2*pi*fH*10**3*C*10**-6)/1000 #kohm
print "Resistance R = %0.2f kohm " %R
Rf=2*R #kohm
Ri=2*R #kohm
print "Resistance Rfdash =%0.1f kohm & Ridash = %0.1f kohm " %(Rf,Ri)

Butterworth filter = cascading of 1st and 2nd order high pass filter.
Various design parameters for 1st order filter are :-
Capacitance C = 0.01 micro F
Resistance R = 7.96 kohm
Resistance Rf = 16.40 kohm & Ri = 16.40 kohm
Various design parameters for 2nd order filter are :-
Capacitance C = 0.033 micro F
Resistance R = 2.41 kohm
Resistance Rfdash =4.8 kohm & Ridash = 4.8 kohm


## Ex 9.15 - page : 301¶

In [48]:
from __future__ import division
from math import pi, sqrt
fL=200 #Hz
fH=1  #kHz
Ap=4 #Pass band gain
fc=sqrt(fH*1000*fL) #Hz(Cutoff frequency)
BW=fH*1000-fL #Hz
Q=fc/BW #Quality Factor
print "Quality factor is %0.2f " %Q
print "As Q<12, it is a wide band filter."
Ap1=2 #Pass band gain for high pass section
print "Various design parameters for high pass section are :-"
C=0.033 #micro F#Chosen for the design
print "Capacitance C = %0.3f micro F " %C
R=1/(2*pi*fL*C*10**-6)/1000 #kohm
print "Resistance R = %0.1f kohm " %R
#Ap1=Rf/Ri+1   with Ap1=2 we have Rf=Ri
Rf=2*R #kohm
Ri=2*R #kohm
print "Resistance Rf = %0.f kohm  & Ri = %0.f kohm " %(Rf,Ri)
Ap2=2 #Pass band gain for low pass section
print "Various design parameters for low pass section are :-"
C=0.033 #micro F#Chosen for the design
print "Capacitance C = %0.3f micro F " %C
K=fL/(fH*1000) #unitless
Rdash=K*R #kohm
print "Resistance Rdash = %0.1f kohm " %Rdash
#Ap1=Rf/Ri+1   with Ap1=2 we have Rf=Ri
Rf=2*Rdash #kohm
Ri=2*Rdash #kohm
print "Resistance Rf = %0.f kohm & Ri = %0.f kohm " %(Rf,Ri)

Quality factor is 0.56
As Q<12, it is a wide band filter.
Various design parameters for high pass section are :-
Capacitance C = 0.033 micro F
Resistance R = 24.1 kohm
Resistance Rf = 48 kohm  & Ri = 48 kohm
Various design parameters for low pass section are :-
Capacitance C = 0.033 micro F
Resistance Rdash = 4.8 kohm
Resistance Rf = 10 kohm & Ri = 10 kohm


## Ex 9.16 - page : 306¶

In [52]:
from __future__ import division
from math import pi, sqrt
print "Part(a)"
fc=1.2 #kHz
Q=4 #Quality Factor
Ap=10 #Pass band gain
print "Here 2*Q**2=32>AP=10, hence it can be designed using single op-amp."
print "Various design parameters are :-"
C=0.05 #micro F#Chosen for the design
print "Capacitance C = %0.2f micro F " %C
#fc/Q=1/(pi*R2*C)
R2=Q/(fc*1000)/pi/(C*10**-6)/1000 #kohm
print "Resistance R2 = %0.1f kohm " %R2
R1=R2/(2*Ap) #kohm
print "Resistance R1 = %0.2f kohm " %R1
R3=R1*1000/(4*pi**2*R1*1000*R2*1000*(C*10**-6)**2*(fc*1000)**2-1) #ohm
print "Resistance R3 = %0.2f ohm " %R3
print "Part(b)"
R3=460 #ohm
fc_new=1.5 #kHz
fc_old=1.2 #kHz
R3new=R3*(fc_old/fc_new)**2 #ohm
print "Resistance R3 should be changed from %0.2f ohm to %0.2f ohm" %(R3, R3new)
#Answer for R3 is wrong in the book

Part(a)
Here 2*Q**2=32>AP=10, hence it can be designed using single op-amp.
Various design parameters are :-
Capacitance C = 0.05 micro F
Resistance R2 = 21.2 kohm
Resistance R1 = 1.06 kohm
Resistance R3 = 482.29 ohm
Part(b)
Resistance R3 should be changed from 460.00 ohm to 294.40 ohm


## Ex 9.17 - page : 308¶

In [56]:
from __future__ import division
from math import pi, sqrt
fL=3 #kHz
fH=3.6 #kHz
Ap=-6 #Pass band gain
fc=sqrt(fH*fL)*1000 #Hz
BW=(fH-fL)*1000 #Hz
Q=fc/BW #Quality factor
print "Quality factor is %0.2f" %Q
print "Here 1<=Q<=12 criteria fulfills, hence it can be designed using single op-amp."
print "Various design parameters are :-"
C=0.01 #micro F#Chosen for the design
print "Capacitance C = %0.2f micro F " %C
#fc/Q=1/(pi*R2*C)
R2=1/pi/(BW)/(C*10**-6)/1000 #kohm
print "Resistance R2 = %0.f kohm " %R2
R1=-R2/(2*Ap) #kohm
print "Resistance R1 = %0.2f kohm " %R1
R3=R1*1000/(4*pi**2*R1*1000*R2*1000*(C*10**-6)**2*(fc)**2-1) #ohm
print "Resistance R3 = %0.f ohm " %R3
print "Design Verification : "
print "(i) Is 2*Q**2>|Ap| ?\n", 2*Q**2>abs(Ap)
print "For op-amp 741, GBW=1 MHz"
GBW=1 #MHz
print "Is GBW*10**6>20*Q**2*fc ?\n",GBW*10**6>20*Q**2*fc
print "2nd criteria failed. The op-amp should have higher GBW product. Use LF411"

Quality factor is 5.48
Here 1<=Q<=12 criteria fulfills, hence it can be designed using single op-amp.
Various design parameters are :-
Capacitance C = 0.01 micro F
Resistance R2 = 53 kohm
Resistance R1 = 4.42 kohm
Resistance R3 = 491 ohm
Design Verification :
(i) Is 2*Q**2>|Ap| ?
True
For op-amp 741, GBW=1 MHz
Is GBW*10**6>20*Q**2*fc ?
False
2nd criteria failed. The op-amp should have higher GBW product. Use LF411


## Ex 9.18 - page : 310¶

In [60]:
from __future__ import division
from math import pi, sqrt
Ap=-10 #Pass band gain
Q=22 #Quality factor
fc=50 #Hz
print """Roll off rate of single op-amp=20 dB/decade.
No. of stages will be 3.
Desired design can be obtained by cascading three stages."""
n=3 #no. of op-amps(as single op-amp has 20 dB/decade)
fc1=fc #Hz
fc2=fc #Hz
fc3=fc #Hz
Q1=Q*sqrt(2**(1/n)-1) #Quality factor of each stage
Q2=Q1 #Quality factor
Q3=Q1 #Quality factor
Ap1=-(-Ap)**(1/n) #Band pass gain of each stage
Ap2=Ap1 #Band pass gain
Ap3=Ap1 #Band pass gain
#Design of a single op-amp
C=0.1 #micro F#Chosen for the design
print "Various design parameters for a single stages are :"
print "Capacitance C = %0.2f micro F " %C
R2=Q1/pi/(fc)/(C*10**-6)/1000 #kohm
print "Resistance R2 = %0.f kohm " %R2
R1=-R2/(2*Ap1) #kohm
print "Resistance R1 = %.f kohm " %R1
R3=R1/(4*pi**2*R1*1000*R2*1000*(C*10**-6)**2*(fc)**2-1) #kohm
print "Resistance R3 = %0.1f ohm " %R3
#Answer for R2 is wrong in the book.

Roll off rate of single op-amp=20 dB/decade.
No. of stages will be 3.
Desired design can be obtained by cascading three stages.
Various design parameters for a single stages are :
Capacitance C = 0.10 micro F
Resistance R2 = 714 kohm
Resistance R1 = 166 kohm
Resistance R3 = 1.4 ohm


## Ex 9.20 - page : 326¶

In [62]:
from __future__ import division
from math import pi, sqrt
fNO=50 #Hz
Q=20 #Quality Factor
print "Various design parameters are :-"
C=1 #micro F#Chosen for the design
print "Capacitance C = %0.2f micro F " %C
R=1/(2*pi*fNO)/(C*10**-6)/1000 #kohm
print "Resistance R = %0.2f kohm " %R
#Q=(RA+RB)/4/RA
RA=1 #kohm(chosen for the design)
RB=Q*4*RA-RA #kohm
print "Resistance RA = %0.f kohm " %RA
print "Resistance RB = %0.f kohm " %RB

Various design parameters are :-
Capacitance C = 1.00 micro F
Resistance R = 3.18 kohm
Resistance RA = 1 kohm
Resistance RB = 79 kohm