import math
#initialisation of variables
rs=600.0
R1=12.0*10**3
Rl=100.0*10**3
C1=0.013*10**-6
#Calculations
print("when Rl is not connected")
fc=1.0/(2*3.14*R1*C1)
print(" when Rl is connected")
fc=1.0/(2*3.14*((R1*Rl)/(R1+Rl))*C1)
Attn=3#at fc attenuation is =3dB
falloffrate=6
print("attenuation at 2fc")
Attn=3+6
print("attenuation at 2fc is %ddB " %Attn)
Attn=3+6+6
#Results
print(" attenuation at 4fc is %ddB " %Attn)
import math
#initialisation of variables
Ib=500.0*10**-9
f=1.0*10**3
#Calculations
R1=(70.0*10**-3)/Ib
R1=140*10**3#use standard value
R2=R1
C1=(1/(2*3.14*R1*f))*10**12
#Results
print(" capacitor used is of %.2f pF " %C1)
import math
#initialisation of variables
print("first order high pass active filter")
f=5.0*10**3
C1=1000.0*10**-12
fu=1.0*10**6
#Calculations
R1=1.0/(2*3.14*f*C1)
BW=fu-f
print(" bandwidth is %.2f kHz " %(BW/1000))
import math
#initialisation of variables
f=1.0*10**3
Ib=500.0*10**-9
print("butterworth second order filter")
#Calculations
R=(70.0*10**-3)/Ib
R1=R/2.0
R1=68.1*10**3#use standard value
R2=R1
R3=2.0*R1
Xc1=math.sqrt(2)*R2
C1=1/(2*3.14*f*math.sqrt(2)*R2)
C2=2*C1
fc=1/(2*3.14*(math.sqrt(R1*R2*C1*C2)))
#Results
print("actual cutoff frequency is %d kHz " %(fc/1000))
import math
#initialisation of variables
f=12.0*10**3
C1=1000.0*10**-12
print("butterworth second order filter")
C2=C1
#Calculations
R2=(math.sqrt(2))/(2*3.14*f*C1)
R1=.5*R2
R3=R2
fc=1.0/(2*3.14*(math.sqrt(R1*R2*C1*C2)))
#Results
print("actual cutoff frequency is %d KHz " %(fc/1000))
import math
#initialisation of variables
f=30.0*10**3
C1=1000.0*10**-12
print(" third order low pass filter")
print("-20 dB per decade stage")
#Calculations
fc1=f/.65
R1=1.0/(2*3.14*fc1*C1)
R2=R1
print("-40dB per decade stage")
C3=1000*10**-12
C2=2*C3
fc2=f/.8
R4=1/(2*3.14*fc2*C3*(math.sqrt(2)))
R3=R4
R5=R3+R4
#Results
print("The value of R5 is %.2f kohm" %(R5/1000))
import math
#initialisation of variables
f=20.0*10**3
print("3rd order high pass filter")
print("-20dB per decade stage")
R1=121.0*10**3
#Calculations
fc1=.65*f
C1=1/(2*3.14*fc1*R1)
#this is so small it might be effected by stray capacitor.redesign %first choosing a suitable capacitance C1
C1=100*10**-12
R1=1/(2*3.14*f*C1)
R2=R1
print("-40dB per decade stage")
C3=1000*10**-12
R4=(math.sqrt(2))/(2*3.14*.8*f*C3)
C2=C3
R3=.5*R4
R5=R4
#Results
print("The value of R5 is %.2f kohm" %(R5/1000))
import math
#initialisation of variables
f1=300.0
f2=30.0*10**3
print(" single stage band pass filter")
#Calculations
C2=1000*10**-12
R2=1/(2*3.14*f2*C2)
R1=R2
Xc1=R1#at voltage gain Av=1
C1=1/(2*3.14*f1*R1)
R3=R2
#Results
print("The value of R3 is %.2f kohm" %(R3/1000))
import math
#initialisation of variables
f1=300.0
f2=30.0*10**3
#Calculations
fo=math.sqrt(f1*f2)
BW=f2-f1
Q=fo/BW
#Results
print("The value of Q is %.2f " %(Q))
import math
#initialisation of variables
R1=60.4*10**3
R4=1.21*10**3
C=.012*10**-6
R2=121.0*10**3
#Calculations
Q=math.sqrt((R1+R4)/(2*R4))
fo=Q/(3.14*C*R2)
print(" center frequency is %3.2fHz " %fo)
BW=fo/Q
#Results
print(" bandwidth is %3.1fHz " %BW)
import math
#initialisation of variables
f1=10.3*10**3
f2=10.9*10**3
C1=1000.0*10**-12
#Calculations
C2=C1
fo=math.sqrt(f1*f2)
R5=1.0/(2*3.14*fo*C1)
R1=R5
Q=fo/(f2-f1)
R2=R1*(2*Q-1)
#Results
print("The value of R2 is %.2f kohm" %(R2/1000))
import math
#initialisation of variables
f1=10.3*10**3
f2=10.9*10**3
Hobp=34
#Calculations
math.sqrt(f1*f2)
Q=fo/(f2-f1)
R3=120.0*10**3
R2=R3/Q
R1=R3/Hobp
k=50*fo
#Results
print("The value of k is %.2f " %(k/1000))