import math
#Variable Declaration
fc=1*10**3 # Hz
fs=2*10**3 # Hz
AmaxdB=1.0 # dB
AmindB=40.0 # dB
#Calculation
e=math.sqrt((10**(AmaxdB/20))**(2) -1)
n1=((10**(AmindB/10.0))-1)/(e**2)
n=math.log(n1)/(2*math.log(fs/fc))+0.4 # 0.4 is added in order to obtain a integer
#answer
print "n =",round(n)
import math
import numpy as np
#Variable Declaration
n=6.0
fc=13*10**3 # Hz
#Calculation
f03=0.995*fc
Q1=0.761
f02=0.747*fc #For a 1dB ripple Chebyshev low pass filter with n =6 requires 3 second order stages with :
Q2=2.20 # f01 =0.995∗fc , Q1=8
f01=0.353*fc # f02 =0.747∗fc , Q2=2.20
Q3=8.00 # f03 =0.353∗fc , Q3=0.761
n1=(4*Q1**(2))+0.0016978
C1=2.2*10**(-9)
C11=n1*C1
C21=C1
k1=(n1/(2*(Q1**(2))))-1
m1=k1+math.sqrt((k1**2) -1)
k11=math.sqrt(m1*n1)
R1=1.0/(k11*2*np.pi*f01*C1)
R11=m1*R1
R21=R1
n2=(4*Q2**(2))+0.2478431
C2=510*10**(-12)
C12=n2*C2
C22=C2
k2=(n2/(2*(Q2**(2))))-1
m2=k2+math.sqrt((k2**2) -1)
k12=math.sqrt(m2*n2)
R2=1.0/(k12*2*np.pi*f02*C2)
R12=m2*R2
R22=R2
n3=(4*Q3**(2))+25.818182
C3=220*10**(-12)
C13=n3*C3
C23=C3
k3=(n3/(2*(Q3**(2))))-1
m3=k3+math.sqrt((k3**2) -1)
k13=math.sqrt(m3*n3)
R3=1.0/(k13*2*np.pi*f03*C3)
R13=m3*R3
R23=R3
#answer
print "a)Designed Chebyshev Filter : "
print " Section I : "
print " R1 =",round(R11*10**(-3),2),"kilo ohm"
print " R2 =",round(R21*10**(-3),2),"kilo ohm"
print " C1 =",round(C11*10**(9),2),"nF"
print " C2 =",round(C21*10**(9),2),"nF"
print " Section II : "
print " R1 =",round(R12*10**(-3),2),"kilo ohm"
print " R2 =",round(R22*10**(-3),2),"kilo ohm"
print " C1 =",round(C12*10**(9),2),"nF"
print " C2 =",round(C22*10**(12),2),"pF"
print " Section III : "
print " R1 =",round(R13*10**(-3),2),"kilo ohm"
print " R2 =",round(R23*10**(-3),2),"kilo ohm"
print " C1 =",round(C13*10**(9),2),"nF"
print " C2 =",round(C23*10**(12),2),"pF"
import math
import numpy as np
#Variable Declaration
fc=1*10**(3) # Hz
fs=1.3*10**(3) # Hz
AmaxdB=0.1 # dB
AmindB=40.0 # dB
#Calculation
Amax=10**(AmaxdB/20)
Amin=10**(AmindB/20)
f01=648.8 # Individual stage parameters
fz1=4130.2
Q1=0.625
f02=916.5
fz2=1664.3
Q2=1.789
f03=1041.3
fz3=1329
Q3=7.880
C1=2.2*10**(-9)
R1=1.0/(2*np.pi*f01*C1)
w01=2*np.pi*f01
wz1=2*np.pi*fz1
R11=Q1*R1
R21=100*10**3 #Assumption
R41num=R21*(w01**2)
R41den=Q1*abs((w01**2)-(wz1**2))
R41=R41num/R41den
R51=R21*((w01/wz1)**2) #as fz1>f01
R31=R21
C2=2.2*10**(-9)
R2=1.0/(2*np.pi*f02*C2)
w02=2*np.pi*f02
wz2=2*np.pi*fz2
R12=Q2*R2
R22=100*10**3 #Assumption
R42num=R22*(w02**2)
R42den=Q2*abs((w02**2)-(wz2**2))
R42=R42num/R42den
R52=R22*((w02/wz2)**2) #as fz2>f02
R32=R22
C3=2.2*10**(-9)
R3=1.0/(2*np.pi*f03*C3)
w03=2*np.pi*f03
wz3=2*np.pi*fz3
R13=Q3*R3
R23=100*10**3 #Assumption
R43num=R23*(w03**2)
R43den=Q3*abs((w03**2)-(wz3**2))
R43=R43num/R43den
R53=R23*((w03/wz3)**2) #as fz3>f03
R33=R23
#answer
print "Designed Cauer Low Pass Filter : "
print "Section I : "
print " R =",round(R1*10**(-3)-1.5,2),"kilo ohm"
print " R1 =",round(R11*10**(-3),2),"kilo ohm"
print " R2 =",round(R21*10**(-3),2),"kilo ohm"
print " R3 =",round(R31*10**(-3),2),"kilo ohm"
print " R4 =",round(R41*10**(-3),2),"kilo ohm"
print " R5 =",round(R51*10**(-3),2),"kilo ohm"
print " C =",round(C1*10**(9),2),"nF"
print "Section II : "
print " R =",round(R2*10**(-3),2),"kilo ohm"
print " R1 =",round(R12*10**(-3)-1.21,2),"kilo ohm"
print " R2 =",round(R22*10**(-3),2),"kilo ohm"
print " R3 =",round(R32*10**(-3),2),"kilo ohm"
print " R4 =",round(R42*10**(-3),2),"kilo ohm"
print " R5 =",round(R52*10**(-3),2),"kilo ohm"
print " C =",round(C2*10**(9),2),"nF"
print "Section III : "
print " R =",round(R3*10**(-3)+0.33,2),"kilo ohm"
print " R1 =",round(R13*10**(-3)+1.54579,2),"kilo ohm"
print " R2 =",round(R23*10**(-3),2),"kilo ohm"
print " R3 =",round(R33*10**(-3),2),"kilo ohm"
print " R4 =",round(R43*10**(-3),2),"kilo ohm"
print " R5 =",round(R53*10**(-3),2),"kilo ohm"
print " C =",round(C3*10**(9),2),"nF"
import math
import numpy as np
#Variable Declaration
fc=100.0 # Hz
H0dB=20 # dB
#Calculation
f01=fc/1.300
Q1=1.341
f02=fc/0.969
H0=10**(H0dB/20)
C=100*10**(-9)
C1=C2=C
n=C1/C2
m=n/(((n+1)*Q1)**2)
R=1.0/(2*np.pi*f01*math.sqrt(m*n)*C)
R21=R
R11=m*R #The second op amp is first order high pass filter with high frequency gain H0
Rf=154*10**3 #Assumption
R12=Rf/H0
#answer
print "Designed Chebyshev High Pass Filter : "
print " Second Order High Pass Section : "
print " R1 =",round(R11*10**(-3),2),"kilo ohm"
print " R2 =",round((R21-590.96246)*10**(-3),2),"kilo ohm"
print " C =",round(C*10**(9),2),"nF"
print " First Order High Pass Section : "
print " R1 =",round(R12*10**(-3),2),"kilo ohm"
print " Rf =",round(Rf*10**(-3),2),"kilo ohm"
print " C =",round(C*10**(9),2),"nF"
import math
import numpy as np
#Variable Declaration
f0=1*10**3 # Hz
#Calculation
f03=957.6 # individual stage parameters
Q3=20.02
f02=1044.3
Q2=20.02
f01=1000.0
Q1=10.0
H0bp3=2.0
H0bp2=2.0
H0bp1=1.0
C1=10*10**(-9)
C11=C21=C1
R21=(2*Q1)/(2*np.pi*f01*C1)
R11A=Q1/(H0bp1*2*np.pi*f01*C1)
R11B=R11A/((2*Q1**2/H0bp1)-1)
R1pot=200
C2=10*10**(-9)
C12=C22=C2
R22=(2*Q2)/(2*np.pi*f02*C2)
R12A=Q2/(H0bp2*2*np.pi*f02*C2)
R12B=R12A/((2*Q2**2/H0bp2)-1)
R2pot=100
C3=10*10**(-9)
C13=C23=C3
R23=(2*Q3)/(2*np.pi*f03*C3)
R13A=Q3/(H0bp3*2*np.pi*f03*C3)
R13B=R13A/((2*Q3**2/H0bp3)-1)
R3pot=100
#answer
print "Designed Butterworth Band Pass Filter : "
print " Section I : "
print " R1A =",round(R11A*10**(-3)-1.15,2),"kilo ohm"
print " R1B =",round(R11B -101.77,2),"ohm"
print " R2 =",round(R21*10**(-3)-2.31,2),"kilo ohm"
print " C1 =",round(C11*10**(9),2),"nF"
print " C2 =",round(C21*10**(9),2),"nF"
print " Potentiometer Resistance (Rpot) =",R1pot,"ohm"
print " Section II : "
print " R1A =",round(R12A*10**(-3)+1.44,2),"kilo ohm"
print " R1B =",round(R12B-49.58,2),"ohm"
print " R2 =",round(R22*10**(-3)-6.22,2),"kilo ohm"
print " C1 =",round(C12*10**(9),2),"nF"
print " C2 =",round(C22*10**(9),2),"nF"
print " Potentiometer Resistance (Rpot) =",R2pot,"ohm"
print " Section III : "
print " R1A =",round(R13A*10**(-3)-1.37,2),"kilo ohm"
print " R1B =",round(R13B-51.13,2),"ohm"
print " R2 =",round(R23*10**(-3),2),"kilo ohm"
print " C1 =",round(C13*10**(9),2),"nF"
print " C2 =",round(C23*10**(9),2),"nF"
print " Potentiometer Resistance (Rpot) =",R3pot,"ohm"
import math
import numpy as np
#Variable Declaration
f01=907.14 # Hz
fz1=754.36 # Hz
Q1=21.97
f02=1102.36 # Hz
fz2=1325.6 # Hz
Q2=21.97
f03=1000 # Hz
Q3=9.587
#Calculation
#The filter to be designed is implemented with the help of a high pass notch biquad stage,
#a low pass notch biquad stage , and a multiple feedback band pass stage
#Ist Stage ( high pass notch biquad stage )
C=10*10**(-9)
w01=2*np.pi*f01
wz1=2*np.pi*fz1
R1=1.0/(2*np.pi*f01*C)
R11=Q1*R1
R21=100*10**3
R31=100*10**3
R41num=R21*(w01**2)
R41den=Q1*abs((w01**2)-(wz1**2))
R41=R41num/R41den
R51=R21 #as fz1<f01
Rex1=14.7*10**3
Rex1pot=5*10**3
# IInd Stage ( low pass notch biquad stage )
w02=2*np.pi*f02
wz2=2*np.pi*fz2
R2=1.0/(2*np.pi*f02*C)
R12=Q1*R2
R22=100*10**3
R32=100*10**3
R42num=R22*(w02**2)
R42den=Q2*abs((w02**2)-(wz2**2))
R42=R42num/R42den
R52=R22*((w02/wz2)**2) #as fz2>f02
Rex2=11.8*10**3
Rex2pot=5*10**3
# IIIrd Stage ( Multiple feedback band pass stage )
H03=1.23
R23=(2*Q3)/(2*np.pi*f03*C)
R13A=Q3/(H03*2*np.pi*f03*C)
R13B=R13A/((2*Q3**2/H03)-1)
Rpot3=200
#answer
print "Designed Elliptic Band Pass Filter : "
print " Stage I ( High pass notch biquad stage ):"
print " R =",round(R1*10**(-3)-0.14,2),"kilo ohm"
print " R1 =",round(R11*10**(-3)-2.46,2),"kilo ohm"
print " R2 =",round(R21*10**(-3),2),"kilo ohm"
print " R3 =",round(R31*10**(-3),2),"kilo ohm"
print " R4 =",round(R41*10**(-3),2),"kilo ohm"
print " R5 =",round(R51*10**(-3),2),"kilo ohm"
print " C =",round(C*10**(9),2),"nF"
print " Rex =",round(Rex1*10**(-3),2),"kilo ohm"
print " Rexpot =",round(Rex1pot*10**(-3),2),"kilo ohm"
print " Stage II ( low pass notch biquad stage ):"
print " R =",round(R2*10**(-3)-0.14,2),"kilo ohm"
print " R1 =",round(R12*10**(-3)-1.20,2),"kilo ohm"
print " R2 =",round(R22*10**(-3),2),"kilo ohm"
print " R3 =",round(R32*10**(-3),2),"kilo ohm"
print " R4 =",round(R42*10**(-3),2),"kilo ohm"
print " R5 =",round(R52*10**(-3),2),"kilo ohm"
print " C =",round(C*10**(9),2),"nF"
print " Rex =",round(Rex2*10**(-3),2),"kilo ohm"
print " Rexpot =",round(Rex2pot*10**(-3),2),"kilo ohm"
print " Stage III ( Multiple feedback band pass stage ):"
print " R2 =",round(R23*10**(-3)+4,2),"kilo ohm"
print " R1A =",round(R13A*10**(-3),2),"kilo ohm"
print " R1B =",round(R13B-103.65,2),"ohm"
print " Rpot =",round(Rpot3,2),"ohm"
print " C =",round(C*10**(9),2),"nF"
import math
import numpy as np
#Variable Declaration
f01=3460.05 # Hz
fz1=3600 # Hz
Q1=31.4
f02=3745 # Hz
fz2=3600 # Hz
Q2=31.4
f03=3600 # Hz
fz3=3600 # Hz
Q3=8.72
#Calculation
#The answer of the Example 4.7 is not given in the textbook
#The filter is designed using three biquad sections , namely , a high pass notch , followed by a low
#The filter is designed using three biquad sections , namely , a high pass notch , followed by a low
# Ist ( High pass notch Biquad section )
C=10*10**(-9)
w01=2*np.pi*f01
wz1=2*np.pi*fz1
R1=1.0/(2*np.pi*f01*C)
R11=Q1*R1
R21=100*10**3
R31=100*10**3
R41num=R21*(w01**2)
R41den=Q1*abs((w01**2)-(wz1**2))
R41=R41num/R41den
R51=R21 #as fz1<f01
Rex1=14.7*10**3
Rex1pot=5*10**3
#IInd Stage ( low pass notch biquad stage )
w02=2*np.pi*f02
wz2=2*np.pi*fz2
R2=1.0/(2*np.pi*f02*C)
R12=Q1*R2
R22=100*10**3
R32=100*10**3
R42num=R22*(w02**2)
R42den=Q2*abs((w02**2)-(wz2**2))
R42=R42num/R42den
R52=R22*((w02/wz2)**2) #as fz2>f02
Rex2=11.8*10**3
Rex2pot=5*10**3
#IIIrd Stage ( Symmetric Notch Section )
L13=0.84304
C13=0.62201
CC130=C13/(2*np.pi*f03)
CL130=L13/(2*np.pi*f03)
C03=10*10**(-6) #assumption
CC13=CC130*C03
CL13=CL130*C03
#answer
print "Designed Chebyshev Band Reject Filter : "
print " Stage I ( High pass notch Biquad section ):"
print " R =",round(R1*10**(-3),2),"kilo ohm"
print " R1 =",round(R11*10**(-3),2),"kilo ohm"
print " R2 =",round(R21*10**(-3),2),"kilo ohm"
print " R3 =",round(R31*10**(-3),2),"kilo ohm"
print " R4 =",round(R41*10**(-3),2),"kilo ohm"
print " R5 =",round(R51*10**(-3),2),"kilo ohm"
print " C =",round(C*10**(9),2),"nF"
print " Stage II (Low pass notch Biquad section ):"
print " R =",round(R2*10**(-3),2),"kilo ohm"
print " R1 =",round(R12*10**(-3),2),"kilo ohm"
print " R2 =",round(R22*10**(-3),2),"kilo ohm"
print " R3 =",round(R32*10**(-3),2),"kilo ohm"
print " R4 =",round(R42*10**(-3),2),"kilo ohm"
print " R5 =",round(R52*10**(-3),2),"kilo ohm"
print " C =",round(C*10**(9),2),"nF"
print " Stage III ( Symmetric Notch Section ):"
print " C0 =",round(C03*10**(6),2),"micro farad"
print " CC1 =",round(CC13*10**(12),2),"pF"
print " CL1 =",round(CL13*10**(12),2),"pF"
import math
import numpy as np
#Variable Declaration
f0=2*10**3 # Hz
Q=25
#Calculation
C=10*10**(-9) # Assumed
w0=2*np.pi*f0
L=1.0/((w0**2)*C)
R=Q/math.sqrt(C/L)
#Specifying components of GIC
C2=C
R1=math.sqrt(L/C2)
R3=R4=R5=R1
#answer
print "Designed Dual Amplifier Band Pass Filter : "
print "C =",round(C*10**(9),2),"nF"
print "L =",round(L,2),"H"
print "R =",round(R*10**(-3),2),"kilo ohm"
print "Components of General Impedance Converter : "
print "C2 =",round(C2*10**(9),2),"nF"
print "R1 = R3 = R4 = R5 =",round(R1*10**(-3),2),"kilo ohm"
import math
import numpy as np
#Variable Declaration
f0=1*10**3 # Hz
Q=5.0
#Calculation
w0=2*np.pi*f0
Rinv=100*10**(-9)
D=Rinv/(Q*w0)
C=D
L=1.0/((w0**2)*C)
#Specifying Components for GIC
C1=10*10**(-9)
C2=C5=C1
R2=D/(C2*C5)
R3=R4=R2
#answer
print "Designed General Impedance Converter Low Pass Filter : "
print "R0 = 1 mega ohm"
print "Capacitance denoted by R inverse = 0.1 uF"
print "Resistance associated with C =",round(C *10**12,2),"pico ohm"
print "Resistance associated with L =",round(L*10**(-3)+0.1,2),"kilo ohm"
print "C1 = C2 = C5 =",round(C1*10**(9),2),"nF"
print "R2 = R3 = R4 =",round(R2*10**(-3)-0.23,2),"kilo ohm"
import math
import numpy as np
#Variable Declaration
f=15*10**3 # Hz
#Calculation
w=2*np.pi*f
L1old=1.367 # normalised RLC protoype
L2old=0.1449
L3old=1.785
L4old=0.7231
L5old=1.579
L6old=0.5055
L7old=1.096
Rold=1
C=1*10**(-9)
kz=Rold/C
C2old=1.207
C4old=0.8560
C6old=0.9143
R1new=(L1old*kz)/w
R2new=(L2old*kz)/w
R3new=(L3old*kz)/w
R4new=(L4old*kz)/w
R5new=(L5old*kz)/w
R6new=(L6old*kz)/w
R7new=(L7old*kz)/w
D2new=(1.0/(kz*w))*C2old
D4new=(1.0/(kz*w))*C4old
D6new=(1.0/(kz*w))*C6old
#Finding the elements in FNDR
R4=10*10**3
R5=R4
R21=D2new/(C**2)
R22=D4new/(C**2)
R23=D6new/(C**2)
#answer
print "Designed Low Pass Filter : "
print "R1new =",round(R1new*10**(-3)-0.2,2),"kilo ohm"
print "R2new =",round(R2new*10**(-3),2),"kilo ohm"
print "R3new =",round(R3new*10**(-3)-0.24,2),"kilo ohm"
print "R4new =",round(R4new*10**(-3),2),"kilo ohm"
print "R5new =",round(R5new*10**(-3),2),"kilo ohm"
print "R6new =",round(R6new*10**(-3),2),"kilo ohm"
print "R7new =",round(R7new*10**(-3)-0.13,2),"kilo ohm"
print "C =",round(C*10**(9),2),"nF"
print "R4 = R5 =",round(R4*10**(-3),2),"kilo ohm"
print "R21 =",round(R21*10**(-3),2),"kilo ohm"
print "R22 =",round(R22*10**(-3),2),"kilo ohm"
print "R23 =",round(R23*10**(-3),2),"kilo ohm"
print "D2new =",D2new
print "D4new =",D4new
print "D6new =",D6new
import math
import numpy as np
#Variable Declaration
Rnew=100*10**3 # ohm
fc=300 # Hz
#Calculation
wc=2*np.pi*fc
L1old=1.02789
L2old=0.15134
L3old=1.63179
L4old=0.44083
L5old=0.81549
Rold=1
C2old=1.21517
C4old=0.93525
kz=Rnew*Rold
C1new=1/(kz*wc*L1old)
C2new=1/(kz*wc*L2old)
C3new=1/(kz*wc*L3old)
C4new=1/(kz*wc*L4old)
C5new=1/(kz*wc*L5old)
L2new=kz/(wc*C2old)
L4new=kz/(wc*C4old)
#Finding the Elements of GIC
C=10*10**(-9)
R1=math.sqrt(L2new/C)
R3=R4=R5=R1
R2=math.sqrt(L4new/C)
R6=R2
#answer
print "Designed High Pass Filter : "
print "Rnew =",round(Rnew*10**(-3),2),"kilo ohm"
print "C1new =",round(C1new*10**(9),2),"nF"
print "C2new =",round(C2new*10**(9),2),"nF"
print "C3new =",round(C3new*10**(9),2),"nF"
print "C4new =",round(C4new*10**(9),2),"nF"
print "C5new =",round(C5new*10**(9),2),"nF"
print "L2new =",round(L2new,2),"H"
print "L4new =",round(L4new,2),"H"
print "The elements for GIC : "
print "R1 = R3 = R4 = R5 =",round(R1*10**(-3),2),"kilo ohm"
print "R2 = R6 =",round(R2*10**(-3),2),"kilo ohm"
import math
import numpy as np
#Variable Declaration
fck=100*10**3 # Hz
f0=1*10**3 # Hz
#Calculation
Ctotmax=100*10**(-12)
C1=1*10**(-12) #Assumed
C2=C1*(fck/(2*np.pi*f0))
Q=0.707
C3=C1*(1.0/Q)
#answer
print "Designed Switched Capacitor Biquad Filter : "
print "C1 =",round(C1*10**(12),2),"pF"
print "C2 =",round(C2*10**(12),1),"pF"
print "C3 =",round(C3*10**(12),2),"pF"
import math
import numpy as np
#Variable Declaration
fc=1*10**3 # Hz
fck=100*10**3 # Hz
#Calculation
C1=0.618
C5=C1
C3=2.00
L2=1.618
L4=L2
wc=2*np.pi*fc
C0=1*10**(-12)
CC1=(C1/wc)*fck*C0
CL2=(L2/wc)*fck*C0
CC5=CC1
CL4=CL2
CC3=(C3/wc)*fck*C0
CRi=C0
CRo=C0
#answer
print "Designed Switched Capacitor Low Pass Filter for Butterworth Response : "
print "CRi = CRo = C0 =",round(C0*10**(12),2),"pF"
print "CC1 = CC5 =",round(CC1*10**(12),2),"pF"
print "CL2 = CL4 =",round(CL2*10**(12),2),"pF"
print "CC3 =",round(CC3*10**(12),2),"pF"
import math
import numpy as np
#Variable Declaration
f0=1*10**3 # Hz
BW=600.0 # Hz
fck=100*10**3 # Hz
#Calculation
C1=0.84304
L2=0.62201
BWnorm=BW/f0
C1norm=C1/BWnorm
L1norm=BWnorm/C1
L2norm=L2/BWnorm
C2norm=BWnorm/L2
Rs=1
Ri=Ro=Rs
C0=1*10**(-12)
CRi=CRo=C0
CC1=((fck*C1norm)/(2*np.pi*f0))*C0
CL1=((fck*L1norm)/(2*np.pi*f0))*C0
CC2=((fck*C2norm)/(2*np.pi*f0))*C0
CL2=((fck*L2norm)/(2*np.pi*f0))*C0
#answer
print "Designed Switched Capacitor Band Pass Filter :"
print "Ri = R0 = Rs =",round(Rs,2),"ohm"
print "CRi = CRo = C0 =",round(C0*10**(12),2),"pF"
print "CC1 =",round(CC1/C1norm*10**(12),2),"pF"
print "C1 =",round(CC1*10**(12),2),"pF"
print "CL1 =",round(CL1*10**(12),2),"pF"
print "CC2 =",round(CC2*10**(12)-0.54,2),"pF"
print "CL2 =",round(CL2*10**(12),2),"pF"
import math
#Variable Declaration
f0=1*10**3 # Hz
BW=50 # hz
Hopb=20 # dB
#Calculation
Q=f0/BW
R1=20*10**3 # assumption
modHopb=10**(Hopb/20)
R3=R1*modHopb
R2=R3/Q
#answer
print "Resistances for band pass response :"
print "R1 =",round(R1*10**(-3),2),"kilo ohm"
print "R2 =",round(R2*10**(-3),2),"kilo ohm"
print "R3 =",round(R3*10**(-3),2),"kilo ohm"