# Chapter 15: Active Filters

### Example 15.1, Page Number: 491

In [1]:
%matplotlib inline

Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].
For more information, type 'help(pylab)'.
In [2]:
f0=15*10**3;    #center frequency in hertz
BW=1*10**3;
Q=f0/BW;
if Q>10:
print('narrow band filter, Q = %d'%Q)

narrow band filter, Q = 15

### Example 15.2, Page Number: 494

In [3]:
R2=10*10**3;
R1=0.586*R2;    #FOR BUTTERWORTH RESPONSE
print('R1 in ohms =%d'%R1)
print('5.6kilo ohm will be ideally close to maximally flat butterworth response')

R1 in ohms =5860
5.6kilo ohm will be ideally close to maximally flat butterworth response

### Example 15.3, Page Number: 496

In [4]:
import math
R_A=1*10**3;
R2=1*10**3;
R_B=R_A;
R=R_A;
C_A=0.022*10**-6;
C_B=C_A;
C=C_A;
f_c=1/(2*math.pi*R*C);   #critical frequency
R1=0.586*R2;    #for butterworth response
print('critical frequency in hertz =%f'%f_c)
print('value of R1 in ohms = %d'%R1)

critical frequency in hertz =7234.315595
value of R1 in ohms = 586

### Example 15.4, Page Number: 498

In [5]:
import math
f_c=2860.0;
R=1.8*10**3;
C=1/(2*math.pi*f_c*R);
R2=R;
R1=0.152*R2;    #BUTTERWORTH RESPONSE IN FIRST STAGE
R4=R;
R3=1.235*R4;    #BUTTERWORTH RESPONSE IN SECOND STAGE
C=C*10**8
print('capacitance in farads = %f *10^-8'%C);
print('R1 in ohms for butterworth response in first stage = %.1f'%R1)
print('R3 in ohms for butterworth response in second stage = %d'%R3)

capacitance in farads = 3.091588 *10^-8
R1 in ohms for butterworth response in first stage = 273.6
R3 in ohms for butterworth response in second stage = 2223

### Example 15.5, Page Number: 500

In [6]:
import math
f_c=10*10**3;    #critical frequency in hertz
R=33*10**3;    #Assumption
R2=R;
C=1/(2*math.pi*f_c*R);
R1=0.586*R2;    #for butterworth response
C=C*10**10
print('Capacitance in Farads = %f * 10^-10'%C)
print('R1 in ohms taking R2=33kilo-ohms = %d'%R1)
R1=3.3*10**3;    #Assumption
R2=R1/0.586;    #butterworth response
print('R2 in ohms taking R1=3.3kilo-ohms = %f'%R2)

Capacitance in Farads = 4.822877 * 10^-10
R1 in ohms taking R2=33kilo-ohms = 19338
R2 in ohms taking R1=3.3kilo-ohms = 5631.399317

### Example 15.6, Page Number:503

In [7]:
import math
R1=68.0*10**3;
R2=180.0*10**3;
R3=2.7*10**3;
C=0.01*10**-6;
f0=(math.sqrt((R1+R3)/(R1*R2*R3)))/(2*math.pi*C);
A0=R2/(2*R1);
Q=math.pi*f0*C*R2;
BW=f0/Q;
print('center frequency in hertz = %f'%f0)
print('maximum gain = %f'%A0)
print('bandwidth in hertz = %f'%BW)

center frequency in hertz = 736.134628
maximum gain = 1.323529
bandwidth in hertz = 176.838826

### Example 15.7, Page Number: 504

In [8]:
import math
R4=1000.0;
C1=0.022*10**-6;
R7=R4;
C2=C1;
R6=R4;
R5=100.0*10**3;
f_c=1/(2*math.pi*R4*C1);    #critical frequency in hertz for each integrator
f0=f_c    #center frequency
Q=(1+(R5/R6))/3;
BW=f0/Q;
print('center frequency in hertz = %f'%f0)
print('value of Q = %f'%Q)
print('bandwidth in hertz = %f'%BW)

center frequency in hertz = 7234.315595
value of Q = 33.666667
bandwidth in hertz = 214.880661

### Example 15.8, Page Number: 507

In [9]:
import math
R4=12.0*10**3;
C1=0.22*10**-6;
R7=R4;
C2=C1;
R6=3.3*10**3;
Q=10;
f0=1/(2*math.pi*R7*C2);
R5=(3*Q-1)*R6;
print('center frequency in hertz = %f'%f0)
print('R5 in ohms = %d'%R5)
print('Nearest value is 100 kilo-ohms')

center frequency in hertz = 60.285963
R5 in ohms = 95700
Nearest value is 100 kilo-ohms