# Chapter 7 Filters and Rectifiers¶

## Example 7.1 Pg 232¶

In :
from __future__ import division
from math import pi, sqrt
# Design active low filter with cut-off frequency 10 kHz
fc = 10 # # kHz
C = 0.01 # #uF # we assume

# the cut-off frequency of active low pass filter is defined as
# fc = (1/2*pi*R3*C)#

# R3 can be calculated as
R3 = (1/(2*pi*fc*C))#
print 'The resistor value is = %0.2f'%R3,' k ohm '

The resistor value is = 1.59  k ohm


## Example 7.2 Pg 233¶

In :
from __future__ import division
from math import pi, sqrt
# Design active low filter with cut-off frequency 15 kHz
fc = 15*10**3 # # Hz
C = 0.1*10**-6 # #F # we assume

# the cut-off frequency of active low pass filter is defined as
# fc = (1/2*pi*R3*C)#

# R3 can be calculated as
R3 = (1/(2*pi*fc*C))#
print 'The resistor value is = %0.f'%R3,' ohm '

# the pass band gain of filter is given by
# Af = 1+(R2/R1)#
# assume that the inverting terminal resistor R2=0.5*R1#
# in Af equation if we put R2=0.5R1 in R1 R1 cancellout each other
Af = 1+(0.5)
print 'The pass band gain is = %0.2f'%Af,' '

The resistor value is = 106  ohm
The pass band gain is = 1.50


## Example 7.3 Pg 234¶

In :
from __future__ import division
from math import pi, sqrt
# Design active low filter with cut-off frequency 20 kHz
fc = 20 # # kHz
f = 100 # # frequency of filter
Af = 10 #  # desired pass band gain
C = 0.05 # #nF # we assume

# the cut-off frequency of active low pass filter is defined as
# fc = (1/2*pi*R3*C)#

# R3 can be calculated as
R3 = (1/(2*pi*fc*1e3*C*1e-9))/1e3 # Kohm
print 'The resistor value is = %0.f'%R3,' Kohm '

# the pass band gain of filter is given by
# Af = 1+(R2/R1)#
# assume that the inverting terminal resistor R1= 100 k ohm#
R1 = 100 # # k ohm
R2 = (Af*R1)-R1#
print 'The resistor R2 value is = %0.2f'%R2,' k ohm '

# the magnitude of an active low pass filter is given as
A = Af/(sqrt(1+(f/fc)**2))#
print 'The magnitude of an active low pass filter is = %0.2f'%A,' '

#the phase angle of the filter
from math import atan , degrees
Angle = -degrees(atan(f/fc))#
print 'The phase angle of the filter is = %0.2f'%Angle,' '

The resistor value is = 159  Kohm
The resistor R2 value is = 900.00  k ohm
The magnitude of an active low pass filter is = 1.96
The phase angle of the filter is = -78.69


## Example 7.4 Pg 236¶

In :
from __future__ import division
from math import pi, sqrt
# to determine the cut-off frequency and pass band gain Af
R1 = 1 # # k ohm
R2 = 12 # # k ohm
R3 = 1.2 #  # k ohm
C = 0.05 # #uF # we assume

# the frequency of the first order low pass filter is defined as
fc = (1/(2*pi*R3*C))#
print 'The frequency of the first order low pass filter is = %0.2f'%fc,' kHz '

# the pass band gain of filter is given by
Af =(1+R2/R1)#
print 'The pass band gain of filter is = %0.2f'%Af,''

The frequency of the first order low pass filter is = 2.65  kHz
The pass band gain of filter is = 13.00


## Example 7.5 Pg 236¶

In :
from __future__ import division
from math import pi, sqrt
# to design a first order high pass filter with cut-off frequency 2kHz
Af = 10 #
fc = 2 # # kHz
R3 = 2 # #K ohm # we assume
R1 = 10 # # k ohm
# the capacitor of high pass filter is given by
C = 2*pi*R3*fc#
print 'The capacitor of high pass filter is = %0.2f'%C,' uF '

# the voltage gain of the high pass filter is
# Af = 1+(R2/R1)#
R2 = R1*(Af-1)#
print 'The second resistor value is = %0.2f'%R2,' K ohm '

The capacitor of high pass filter is = 25.13  uF
The second resistor value is = 90.00  K ohm


## Example 7.6 Pg 237¶

In :
from __future__ import division
from math import pi, sqrt
# to design an active high pass filter with cut-off frequency 10kHz
fc = 10 # # kHz
C = 0.01 # #uF # we assume
# the cut-off frequency of active high pass filter is given by
# fc = 2*pi*R3*C#
# R3 can be calculated as
R3 = (1/(2*pi*fc*C))#

print 'The resistance R3 is = %0.2f'%R3,' K ohm '

The resistance R3 is = 1.59  K ohm


## Example 7.7 Pg 238¶

In :
from __future__ import division
from math import pi, sqrt
# to design an active high pass filter with cut-off frequency 25kHz
fc = 25 # # kHz
C = 0.1 # #nF # we assume
# the cut-off frequency of active high pass filter is given by
# fc = 2*pi*R3*C#
# R3 can be calculated as
R3 = (1/(2*pi*fc*1e3*C*1e-9)) / 1e3 # Kohm
print 'The resistance R3 is = %0.f'%R3,' Kohm '

# the desire pass band gain of filter is given by
#Af = 1+(R2/R1)#
# assume that the inverting terminal resistor R2=0.2*R1#
# in Af equation if we put R2=0.2R1 in R1 R1 cancellout each other
Af = 1+(0.2)
print 'The pass band gain is = %0.2f'%Af,' '

The resistance R3 is = 64  Kohm
The pass band gain is = 1.20


## Example 7.8 Pg 239¶

In :
from __future__ import division
from math import pi, sqrt
## # to design an active high pass filter with cut-off frequency 20kHz
Af = 15 #
fc = 20 # #kHz
f = 80 # # kHz  the frequency of filter
C = 0.05 # #nF # we assume
# the cut-off frequency of active high pass filter is given by
# fc = 2*pi*R3*C#
# R3 can be calculated as
R3 = (1/(2*pi*fc*C))#
print 'The resistance R3 is = %0.f'%(R3*1000),' K ohm '  # Round Off Error

# the desire pass band gain of filter is given by
#Af = 1+(R2/R1)#
# assume that the inverting terminal resistor R1=50 K ohm#
R1 = 50 # # K ohm
R2 = (R1*Af)-(R1)
print 'The resistance R2 is = %0.2f'%R2,' K ohm '

# the magnitude of an active high pass filter is given as
A = Af*(f/fc)/(sqrt(1+(f/fc)**2))#
print 'The magnitude of an active high pass filter is = %0.2f'%A,' '

#the phase angle of the filter
from numpy import inf
Angle = degrees(-atan(f/fc)+atan(inf))
print 'The phase angle of the filter is = %0.2f'%Angle,' degree'  # Round Off Error

The resistance R3 is = 159  K ohm
The resistance R2 is = 700.00  K ohm
The magnitude of an active high pass filter is = 14.55
The phase angle of the filter is = 14.04  degree


## Example 7.9 Pg 241¶

In :
from __future__ import division
from math import pi, sqrt
# to calculate upper and lower cut-off frequency of the band pass filter
R1 = 10*10**3 # #K ohm
R2 = 10 # #K ohm
C1 = 0.1*10**-6 # # uF
C2 = 0.001 #  #uF

# the lower cut-off frequency of band pass filter is
fLC = 1/(2*pi*R1*C1)#
print 'The lower cut-off frequency FLC of band pass filter is = %0.1f'%fLC,' Hz '

# The upper cut-off frequency of band pass filter is
fUC = 1/(2*pi*R2*C2)#
print 'The upper cut-off frequency FUC of band pass filter is = %0.2f'%fUC,' kHz '

The lower cut-off frequency FLC of band pass filter is = 159.2  Hz
The upper cut-off frequency FUC of band pass filter is = 15.92  kHz


## Example 7.10 Pg 242¶

In :
from __future__ import division
from math import pi, sqrt
# to design an active band pass filter with lower cut-off frequency 10 kHz an upper 50 kHz
fL = 10 # # kHz
fH = 50 # # kHz
C1 = 0.002 # # nF
C2 = 0.002 #  # nF

# the lower cut-off frequency of band pass filter is
# fL = 1/(2*pi*R3*C1)#
R3 = 1/(2*pi*fL*C1)#
print 'The resistance R3 Value is = %0.2f'%R3,' M ohm '

# The upper cut-off frequency of band pass filter is
# fH = 1/(2*pi*R6*C2)#
R6 = 1/(2*pi*fH*C2)#
print 'The resistance R6 value is = %0.2f'%R6,' M ohm '

The resistance R3 Value is = 7.96  M ohm
The resistance R6 value is = 1.59  M ohm


## Example 7.11 Pg 243¶

In :
from __future__ import division
from math import pi, sqrt
# to design an active band pass filter with lower cut-off frequency 20 kHz an upper 40 kHz
fL = 20 # # kHz
fH = 40 # # kHz
# the inverting terminal resistance 2R1=R2 and 4R4=R5
C1 = 0.001 # # nF
C2 = 0.001 #  # nF

# the lower cut-off frequency of band pass filter is
# fL = 1/(2*pi*R3*C1)#
R3 = 1/(2*pi*fL*C1)#
print 'The resistance R3 Value is = %0.2f'%R3,' M ohm '

# The upper cut-off frequency of band pass filter is
# fH = 1/(2*pi*R6*C2)#
R6 = 1/(2*pi*fH*C2)#
print 'The resistance R6 value is = %0.2f'%R6,' M ohm '

# the desire pass band gain of filter is defined as
R1 = 1 # # M ohm we assume
#we define inverting terminal resistance 2R1=R2
R2 = 2 # # M ohm
# then
R4 = 1 # #M ohm
R5 = 4 # # M ohm
Af = (1+(R2/R1))*(1+(R5/R4))#
print 'The desire pass band gain of filter is = %d'%Af,' '

The resistance R3 Value is = 7.96  M ohm
The resistance R6 value is = 3.98  M ohm
The desire pass band gain of filter is = 15


## Example 7.12 Pg 244¶

In :
from __future__ import division
from math import pi, sqrt
# to design an active band pass filter with lower cut-off frequency 20 kHz an upper 80 kHz
f = 100 # # kHz  the frequency of band pass filter
fL = 20 # # kHz
fH = 80 # # kHz
# the inverting terminal resistance R1=0.5*R2 and R4=0.25*R5
C1 = 0.001 # # nF
C2 = 0.001 #  # nF

# the lower cut-off frequency of band pass filter is
# fL = 1/(2*pi*R3*C1)#
R3 = 1/(2*pi*fL*C1)#
print 'The resistance R3 Value is = %0.2f'%R3,' M ohm '

# The upper cut-off frequency of band pass filter is
# fH = 1/(2*pi*R6*C2)#
R6 = 1/(2*pi*fH*C2)#
print 'The resistance R6 value is = %0.2f'%R6,' M ohm '  # Round Off Error

# the desire pass band gain of filter is defined as
R1 = 1 # # M ohm we assume
#we define inverting terminal resistance R1=0.5*R2
R2 = 2 # # M ohm
# then
R4 = 1 # #M ohm
R5 = 4 # # M ohm
Af = (1+(R2/R1))*(1+(R5/R4))#
print 'The desire pass band gain of filter is = %0.2f'%Af,' '

# the magnitude of gain of band pass filter is given as
A = Af*(f**2/(fL*fH))/((sqrt(1+(f/fL)**2))*(sqrt(1+(f/fH)**2)))#
print 'The magnitude of gain of band pass filter  is = %0.2f'%A,' '  # Round Off Error

#the phase angle of the filter
from numpy import inf
Angle = degrees(2*atan(inf)-atan(f/fL)-atan(f/fH))
print 'The phase angle of gain of band pass filter  is = %0.f'%Angle,'degree'  # Round Off Error

The resistance R3 Value is = 7.96  M ohm
The resistance R6 value is = 1.99  M ohm
The desire pass band gain of filter is = 15.00
The magnitude of gain of band pass filter  is = 11.49
The phase angle of gain of band pass filter  is = 50 degree


## Example 7.13 Pg 247¶

In :
from __future__ import division
# to determine the output voltage of the precision rectifier circuit
Vi = 10 # #V i/p volt
R1 = 20 # # K ohm
R2 = 40 # # K ohm
Vd = 0.7 # # V   the diode voltage drop

# the output of the half wave precision rectifier is defined as
# Vo = -(R2/R1)*Vi # for Vi < 0
#    = 0 otherwise
# i.e for Vi > 0
#              Vo = 0
# for Vi < 0
Vo = -(R2/R1)*Vi
print 'The output of the half wave precision rectifier Vo is = %0.2f'%Vo,' V '

The output of the half wave precision rectifier Vo is = -20.00  V


## Example 7.14 Pg 247¶

In :
from __future__ import division
# to determine the output voltage of the precision rectifier circuit for i/p voltage a) Vi = 5 b) Vi = -5
Vi = 5 # #V i/p volt
R1 = 5 # # K ohm
R2 = 15 # # K ohm
Vd = 0.7 # # V   the diode voltage drop

# the output of the half wave precision rectifier is defined as
# Vo = -(R2/R1)*Vi # for Vi < 0
#    = 0 otherwise

# for Vi = 5 V
# i.e for Vi > 0
#              Vo = 0
# for Vi < 0
Vo = -(R2/R1)*Vi#
print 'The output of the half wave precision rectifier Vo is = %0.2f'%Vo,' V '

# for Vi = -5 V
# i.e for Vi > 0
#              Vo = 0
# for Vi < 0
Vi =-5 # # V
Vo = -(R2/R1)*Vi#
print 'The output of the half wave precision rectifier Vo is = %0.2f'%Vo,' V '

The output of the half wave precision rectifier Vo is = -15.00  V
The output of the half wave precision rectifier Vo is = 15.00  V


## Example 7.15 Pg 248¶

In :
from __future__ import division
# to determine the output voltage of the precision rectifier circuit for i/p voltage a) Vi = 7 b) Vi = -7
Vi = 7 # #V i/p volt
R1 = 5 # # K ohm
R3 = 5 # # K ohm
R4 = 5 # # K ohm
R2 = 15 # # K ohm
R5 = 15 # # K ohm
Vd = 0.7 # # V   the diode voltage drop

# the output of the full wave precision rectifier is defined as
# Vo = -A*Vi #      for Vi < 0                      equation 1
#    = A*Vi  #      otherwise                       equation 2

# or  Vo = abs(A*Vi) #

# The gain of precision full wave rectifier
A = (((R2*R5)/(R1*R3))-(R5/R4)) #
print 'The gain of precision full wave rectifier A is = %0.2f'%A,' '

# for Vi = 7 V           the output voltage is
Vi = 7 #
Vo = -A*Vi #      # from equation 1
Vo =  A*Vi #      # from equation 2
Vo = abs(A*Vi) #
print 'The output voltage Vo is = %0.2f'%Vo,' V '

# for Vi = -7 V           the output voltage is
Vi = -7 #
Vo = -A*Vi #      # from equation 1
Vo =  A*Vi #      # from equation 2
Vo = abs(A*Vi) #
print 'The output voltage Vo is = %0.2f'%Vo,' V '

The gain of precision full wave rectifier A is = 6.00
The output voltage Vo is = 42.00  V
The output voltage Vo is = 42.00  V