Chapter 7: Active Filters and Oscillators

Example 7.1

In [1]:
#Example 7.1
#Design a low pass filter at a cutoff frequency of 1kHz
#with a passband gain of 2

from __future__ import division     #to perform decimal division
import math


#Variable declaration
fh=1*10**3    #Cut-off frequency
C=0.01*10**-6 #Assumption
R1=10*10**3   #Assumption
Rf=R1         #Since passband gain is 2,R1 and Rf must be equal


#calculation
R=1/(2*math.pi*fh*C)

#result
print "Resistance R is",round(R/10**3,1),"kOhms"
print "Use 20 kohm POT as R"
print "Resistance R1 is",round(R1/10**3),"kilo ohms"
print "Resistance Rf is",round(Rf/10**3),"kilo ohms"
Resistance R is 15.9 kOhms
Use 20 kohm POT as R
Resistance R1 is 10.0 kilo ohms
Resistance Rf is 10.0 kilo ohms

Example 7.2

In [2]:
#Example 7.2
#Using the frequency scaling technique,convert the 1 kHz cutoff frequency of the
#lowpass filter of example 7-1 to a cutoff frequency of 1.6 kHz.

from __future__ import division     #to perform decimal division
import math


#Variable declaration
fc0=1*10**3   #Original cut-off frequency
fc1=1.6*10**3 #New cut-off frequency
R=15.9*10**3  #Original resistance value

#calculation
k=fc0/fc1
Rnew=R*k

#result
print "New Resistance Rnew is",Rnew,"Ohms"
New Resistance Rnew is 9937.5 Ohms

Example 7.3

In [11]:
#Example 7.3
#Plot the frequency response of the lowpass filter of example 7.1

from __future__ import division     #to perform decimal division
%matplotlib inline

from scipy import pi
from matplotlib.pyplot import ylabel, xlabel, title, plot, show, clf, semilogx
import math
import numpy as np

#Variable declaration
Af=2     #Passband gain of the filter
fh=1000  #Cut-off frequency

f1=10
f2=100
f3=200
f4=700
f5=1000
f6=3000
f7=7000
f8=10000
f9=30000
f10=100000


#calculation
av1=Af/math.sqrt(1+(f1/fh)**2)
av2=Af/math.sqrt(1+(f2/fh)**2)
av3=Af/math.sqrt(1+(f3/fh)**2)
av4=Af/math.sqrt(1+(f4/fh)**2)
av5=Af/math.sqrt(1+(f5/fh)**2)
av6=Af/math.sqrt(1+(f6/fh)**2)
av7=Af/math.sqrt(1+(f7/fh)**2)
av8=Af/math.sqrt(1+(f8/fh)**2)
av9=Af/math.sqrt(1+(f9/fh)**2)
av10=Af/math.sqrt(1+(f10/fh)**2)

#Magnitude plot
f=np.arange(0,100000)
s=2.0j*pi*f
p=2.0*pi*fh
A=Af*p/(s+p)

clf()                   #clear the figure
plot()
title('frequency response')
semilogx(f,20*np.log10(abs(A)))
ylabel('Voltage gain(dB)')
xlabel('frequency(Hz)')
show()


#result
print "Gain magnitude av1 at f1",round(av1,2)
print "Gain magnitude av2 at f2",round(av2,2)
print "Gain magnitude av2 at f2",round(av3,2)
print "Gain magnitude av2 at f2",round(av4,2)
print "Gain magnitude av2 at f2",round(av5,2)
print "Gain magnitude av2 at f2",round(av6,2)
print "Gain magnitude av2 at f2",round(av7,2)
print "Gain magnitude av2 at f2",round(av8,2)
print "Gain magnitude av2 at f2",round(av9,2)
print "Gain magnitude av2 at f2",round(av10,2)
Gain magnitude av1 at f1 2.0
Gain magnitude av2 at f2 1.99
Gain magnitude av2 at f2 1.96
Gain magnitude av2 at f2 1.64
Gain magnitude av2 at f2 1.41
Gain magnitude av2 at f2 0.63
Gain magnitude av2 at f2 0.28
Gain magnitude av2 at f2 0.2
Gain magnitude av2 at f2 0.07
Gain magnitude av2 at f2 0.02

Example 7.4.a

In [4]:
#Example 7.4.a
#Design a second order low-pass filter at a high cutoff frequency of 1 kHz.

from __future__ import division     #to perform decimal division
import math


#Variable declaration
fh=1*10**3         # Cut-off frequency
C2=0.0047*10**-6   # Assumption
C3=C2
R1=27*10**3        # Assumption

#calculation
R2=1/(2*math.pi*fh*C2)
R3=R2
Rf=0.586*R1


#result
print "Resistance R2 is",round(R2/10**3,2),"kOhm"
print "Resistance R3 is",round(R3/10**3,2),"kOhm"
print "Resistance Rf is",round(Rf/10**3,2),"kOhm"
print " Use 20 kohm POT as Rf"
Resistance R2 is 33.86 kOhm
Resistance R3 is 33.86 kOhm
Resistance Rf is 15.82 kOhm
 Use 20 kohm POT as Rf

Example 7.4.b

In [12]:
#Example 7.4.b
#Draw the frequency response of the network in example 7.4.a

from __future__ import division     #to perform decimal division
%matplotlib inline

from scipy import pi
from matplotlib.pyplot import ylabel, xlabel, title, plot, show, clf, semilogx
import math
import numpy as np
#Variable declaration
Af=1.586     #Passband gain of the filter
fh=1000      #Cut-off frequency

f1=10
f2=100
f3=200
f4=700
f5=1000
f6=3000
f7=7000
f8=10000
f9=30000
f10=100000


#calculation
av1=Af/math.sqrt(1+(f1/fh)**4)
av2=Af/math.sqrt(1+(f2/fh)**4)
av3=Af/math.sqrt(1+(f3/fh)**4)
av4=Af/math.sqrt(1+(f4/fh)**4)
av5=Af/math.sqrt(1+(f5/fh)**4)
av6=Af/math.sqrt(1+(f6/fh)**4)
av7=Af/math.sqrt(1+(f7/fh)**4)
av8=Af/math.sqrt(1+(f8/fh)**4)
av9=Af/math.sqrt(1+(f9/fh)**4)
av10=Af/math.sqrt(1+(f10/fh)**4)

#Magnitude plot
f=np.arange(0,100000)      #frequency range
s=2.0j*pi*f**2
p=2.0*pi*fh**2
A=Af*p/(s+p)

clf()                   #clear the figure
plot()
title('frequency response')
semilogx(f,20*np.log10(abs(A)))
ylabel('Voltage gain(dB)')
xlabel('frequency(Hz)')
show()


#result
print "Gain magnitude av1 at f1",round(av1,2)
print "Gain magnitude av2 at f2",round(av2,2)
print "Gain magnitude av2 at f2",round(av3,2)
print "Gain magnitude av2 at f2",round(av4,2)
print "Gain magnitude av2 at f2",round(av5,2)
print "Gain magnitude av2 at f2",round(av6,2)
print "Gain magnitude av2 at f2",round(av7,2)
print "Gain magnitude av2 at f2",round(av8,2)
print "Gain magnitude av2 at f2",round(av9*10**3,2),"*10^-3"
print "Gain magnitude av2 at f2",round(av10*10**3,2),"*10^-3"
Gain magnitude av1 at f1 1.59
Gain magnitude av2 at f2 1.59
Gain magnitude av2 at f2 1.58
Gain magnitude av2 at f2 1.42
Gain magnitude av2 at f2 1.12
Gain magnitude av2 at f2 0.18
Gain magnitude av2 at f2 0.03
Gain magnitude av2 at f2 0.02
Gain magnitude av2 at f2 1.76 *10^-3
Gain magnitude av2 at f2 0.16 *10^-3

Example 7.5.a

In [6]:
#Example 7.5.a
#Design a high pass filter at a cutoff frequency of 1 kHz with a passband gain
#of 2.

from __future__ import division     #to perform decimal division
import math


#Variable declaration
fh=1*10**3     #Cut-off frequency
C=0.01*10**-6  #Assumption
Af=2

#calculation
R=1/(2*math.pi*fh*C)
R1=10*10**3
Rf=R1          #since passband gain is 2


#result
print "Resistance R is",round(R/10**3,2),"kOhm"
print "Resistance R1 is",round(R1/10**3,2),"kOhm"
print "Resistance Rf is",round(Rf/10**3,2),"kOhm"
Resistance R is 15.92 kOhm
Resistance R1 is 10.0 kOhm
Resistance Rf is 10.0 kOhm

Example 7.5.b

In [18]:
#Example 7.5.b
#The circuit of figure 6-17,for the indicated value of resistors
#determine the full scale range for the input voltage.

from __future__ import division     #to perform decimal division
%matplotlib inline
import numpy as np
from scipy import pi
from matplotlib.pyplot import ylabel, xlabel, title, plot, show, clf, semilogx
import matplotlib.pyplot as plt
import math

#Variable declaration
Af=2     #Passband gain of the filter
fl=1000  #Cut-off frequency

f1=100
f2=200
f3=400
f4=700
f5=1000
f6=3000
f7=7000
f8=10000
f9=30000
f10=100000


#calculation
av1=(Af*(f1/fl))/math.sqrt(1+(f1/fl)**2)
av2=(Af*(f2/fl))/math.sqrt(1+(f2/fl)**2)
av3=(Af*(f3/fl))/math.sqrt(1+(f3/fl)**2)
av4=(Af*(f4/fl))/math.sqrt(1+(f4/fl)**2)
av5=(Af*(f5/fl))/math.sqrt(1+(f5/fl)**2)
av6=(Af*(f6/fl))/math.sqrt(1+(f6/fl)**2)
av7=(Af*(f7/fl))/math.sqrt(1+(f7/fl)**2)
av8=(Af*(f8/fl))/math.sqrt(1+(f8/fl)**2)
av9=(Af*(f9/fl))/math.sqrt(1+(f9/fl)**2)
av10=(Af*(f10/fl))/math.sqrt(1+(f10/fl)**2)

#Magnitude plot
f=np.arange(100,100000)
s=2.0j*pi*f
p=2.0*pi*fl
A=Af*s/(s+p)

clf()                   #clear the figure
plt.plot()
plt.title('frequency response')
semilogx(f,20*np.log10(abs(A)))
plt.ylabel('Voltage gain(dB)')
plt.xlabel('frequency(Hz)')
plt.show()


#result
print "Gain magnitude av1 at f1",round(av1,2)
print "Gain magnitude av2 at f2",round(av2,2)
print "Gain magnitude av2 at f2",round(av3,2)
print "Gain magnitude av2 at f2",round(av4,2)
print "Gain magnitude av2 at f2",round(av5,2)
print "Gain magnitude av2 at f2",round(av6,2)
print "Gain magnitude av2 at f2",round(av7,2)
print "Gain magnitude av2 at f2",round(av8,2)
print "Gain magnitude av2 at f2",round(av9,2)
print "Gain magnitude av2 at f2",round(av10,2)
Gain magnitude av1 at f1 0.2
Gain magnitude av2 at f2 0.39
Gain magnitude av2 at f2 0.74
Gain magnitude av2 at f2 1.15
Gain magnitude av2 at f2 1.41
Gain magnitude av2 at f2 1.9
Gain magnitude av2 at f2 1.98
Gain magnitude av2 at f2 1.99
Gain magnitude av2 at f2 2.0
Gain magnitude av2 at f2 2.0

Example 7.6.a

In [9]:
#Example 7.6.a
#Determine the low cutoff frequency fl of the filter shown in figure 7-8(a)

from __future__ import division     #to perform decimal division
import math


#Variable declaration
R2=33*10**3        #Resistance in ohms
R3=R2
C2=0.0047*10**-6   #Capacitance in Farads
C3=C2

#calculation
fl=1/(2*math.pi*math.sqrt(R2*R3*C2*C3))


#result
print "Lower cutoff frequency fl is",round(fl/10**3,0),"kHz"
Lower cutoff frequency fl is 1.0 kHz

Example 7.6.b

In [20]:
#Example 7.6.b
#Draw the frequency response plot of the filter in example 7.6.a

from __future__ import division     #to perform decimal division
%matplotlib inline

from scipy import pi
from matplotlib.pyplot import ylabel, xlabel, title, plot, show, clf, semilogx
import math
import numpy as np
#Variable declaration
Af=1.586     #Passband gain of the filter
fl=1000      #Cut-off frequency

f1=100
f2=200
f3=400
f4=700
f5=1000
f6=3000
f7=7000
f8=10000
f9=30000
f10=100000


#calculation
av1=Af/math.sqrt(1+(fl/f1)**4)
av2=Af/math.sqrt(1+(fl/f2)**4)
av3=Af/math.sqrt(1+(fl/f3)**4)
av4=Af/math.sqrt(1+(fl/f4)**4)
av5=Af/math.sqrt(1+(fl/f5)**4)
av6=Af/math.sqrt(1+(fl/f6)**4)
av7=Af/math.sqrt(1+(fl/f7)**4)
av8=Af/math.sqrt(1+(fl/f8)**4)
av9=Af/math.sqrt(1+(fl/f9)**4)
av10=Af/math.sqrt(1+(fl/f10)**4)

#Magnitude plot
f=np.arange(100,100000)
s=2.0j*pi*fl**2
p=2.0*pi*f**2
A=Af*p/(s+p)


clf()                   #clear the figure
plot()
title('frequency response')
semilogx(f,20*np.log10(abs(A)))
ylabel('Voltage gain(dB)')
xlabel('frequency(Hz)')
show()


#result
print "Gain magnitude av1 at f1",round(av1,4)
print "Gain magnitude av2 at f2",round(av2,4)
print "Gain magnitude av2 at f2",round(av3,4)
print "Gain magnitude av2 at f2",round(av4,4)
print "Gain magnitude av2 at f2",round(av5,4)
print "Gain magnitude av2 at f2",round(av6,4)
print "Gain magnitude av2 at f2",round(av7,4)
print "Gain magnitude av2 at f2",round(av8,4)
print "Gain magnitude av2 at f2",round(av9,4)
print "Gain magnitude av2 at f2",round(av10,4)
Gain magnitude av1 at f1 0.0159
Gain magnitude av2 at f2 0.0634
Gain magnitude av2 at f2 0.2506
Gain magnitude av2 at f2 0.6979
Gain magnitude av2 at f2 1.1215
Gain magnitude av2 at f2 1.5763
Gain magnitude av2 at f2 1.5857
Gain magnitude av2 at f2 1.5859
Gain magnitude av2 at f2 1.586
Gain magnitude av2 at f2 1.586

Example 7.7.a

In [12]:
#Example 7.7.a
#Design a wide band pass filter with fl=200 Hz, fh=1 kHz and passband gain=4.

from __future__ import division     #to perform decimal division
import math


#Variable declaration
fl=200         #Low cutoff freq in Hz
fh=1*10**3     #High cutoff freq in Hz
C=0.05*10**-6

#calculation
R=1/(2*math.pi*fl*C)
R1=10*10**3
Rf=R1          #Since passband gain is 2,R1 and Rf must be equal


#result
print "Resistance R1 is",round(R1/10**3,2),"kOhm"
print "Resistance R is",round(R/10**3,2),"kOhm"
print "Bandpass Gain Af is 4"
print "Resistance Rf is",round(Rf/10**3,2),"kOhm"
Resistance R1 is 10.0 kOhm
Resistance R is 15.92 kOhm
Bandpass Gain Af is 4
Resistance Rf is 10.0 kOhm

Example 7.7.b

In [21]:
#Example 7.7.b
#Draw the frequency response plot for the filter in example 7.7.a

from __future__ import division     #to perform decimal division
%matplotlib inline

from scipy import pi
from matplotlib.pyplot import ylabel, xlabel, title, plot, show, clf, semilogx
import math
import numpy as np
#Variable declaration
Af=4      #Passband gain of the filter
fl=200    #Cut-off frequency
fh=1000   #Higher Cut-off frequency

f1=10
f2=30
f3=100
f4=200
f5=447.2
f6=700
f7=1000
f8=2000
f9=7000
f10=10000


#calculation
av1=(Af*(f1/fl))/math.sqrt((1+(f1/fl)**2)*(1+(f1/fh)**2))
av2=(Af*(f2/fl))/math.sqrt((1+(f2/fl)**2)*(1+(f2/fh)**2))
av3=(Af*(f3/fl))/math.sqrt((1+(f3/fl)**2)*(1+(f3/fh)**2))
av4=(Af*(f4/fl))/math.sqrt((1+(f4/fl)**2)*(1+(f4/fh)**2))
av5=(Af*(f5/fl))/math.sqrt((1+(f5/fl)**2)*(1+(f5/fh)**2))
av6=(Af*(f6/fl))/math.sqrt((1+(f6/fl)**2)*(1+(f6/fh)**2))
av7=(Af*(f7/fl))/math.sqrt((1+(f7/fl)**2)*(1+(f7/fh)**2))
av8=(Af*(f8/fl))/math.sqrt((1+(f8/fl)**2)*(1+(f8/fh)**2))
av9=(Af*(f9/fl))/math.sqrt((1+(f9/fl)**2)*(1+(f9/fh)**2))
av10=(Af*(f10/fl))/math.sqrt((1+(f10/fl)**2)*(1+(f10/fh)**2))

#Magnitude plot
f=np.arange(10,100000)
s=2.0j*pi*f
p1=2.0*pi*fl
p2=2.0*pi*fh
A=(Af*s)*p2/((s+p1)*(s+p2))

clf()                   #clear the figure
plot()
title('frequency response')
semilogx(f,20*np.log10(abs(A)))
ylabel('Voltage gain(dB)')
xlabel('frequency(Hz)')
show()


#result
print "Gain magnitude av1 at f1",round(av1,4)
print "Gain magnitude av2 at f2",round(av2,4)
print "Gain magnitude av2 at f2",round(av3,4)
print "Gain magnitude av2 at f2",round(av4,4)
print "Gain magnitude av2 at f2",round(av5,4)
print "Gain magnitude av2 at f2",round(av6,4)
print "Gain magnitude av2 at f2",round(av7,4)
print "Gain magnitude av2 at f2",round(av8,4)
print "Gain magnitude av2 at f2",round(av9,4)
print "Gain magnitude av2 at f2",round(av10,4)
Gain magnitude av1 at f1 0.1997
Gain magnitude av2 at f2 0.5931
Gain magnitude av2 at f2 1.78
Gain magnitude av2 at f2 2.7735
Gain magnitude av2 at f2 3.3333
Gain magnitude av2 at f2 3.1508
Gain magnitude av2 at f2 2.7735
Gain magnitude av2 at f2 1.78
Gain magnitude av2 at f2 0.5655
Gain magnitude av2 at f2 0.3979

Example 7.7.c

In [14]:
#Example 7.7.c
#Calculate the value of Q for the filter.

from __future__ import division     #to perform decimal division
import math


#Variable declaration
fh=1*10**3            #Higher cut-off frequency
fl=200                #Lower cut-off frequency


#calculation
fc=math.sqrt(fl*fh)   #Center frequency
Q=fc/(fh-fl)          #Quality factor



#result
print "Center frequency fc is",round(fc,2),"Hz"
print "Quality factor Q is",round(Q,2)
Center frequency fc is 447.21 Hz
Quality factor Q is 0.56

Example 7.8.a

In [15]:
#Example 7.8.a
#Design the bandpass filter shown in figure 7-13(a) so that fc=1 kHz, Q=3 and
#Af=10.

from __future__ import division     #to perform decimal division
import math


#Variable declaration
fc=1*10**3      #Center frequency
Q=3             #Quality factor
Af=10           #Passband gain
C1=0.01*10**-6  #Assumption

#calculation
C2=C1
R1=Q/(2*math.pi*fc*C1*Af)
R2=Q/(2*math.pi*fc*C1*(2*Q**2-Af))
R3=Q/(math.pi*fc*C1)

#result
print "Resistance R1 is",round(R1/10**3,2),"kilo ohm"
print "Resistance R2 is",round(R2/10**3,2),"kilo ohm"
print "Resistance R3 is",round(R3/10**3,2),"kilo ohm"
Resistance R1 is 4.77 kilo ohm
Resistance R2 is 5.97 kilo ohm
Resistance R3 is 95.49 kilo ohm

Example 7.8.b

In [32]:
#Example 7.8.b
#Change the centre frequency of example 7.8.a to 1.5 kHz, keeping Af and
#bandwidth constant.


from __future__ import division     #to perform decimal division
import math


#Variable declaration
fc0=1*10**3      #Original center frequency
fc1=1.5*10**3    #New center frequency
R2=5.97*10**3    #Original resistance



#calculation
R2new=R2*(fc0/fc1)**2

#result
print "Resistance R1 is",round(R2new/10**3,2),"kilo ohm"
Resistance R1 is 2.65 kilo ohm

Example 7.9

In [17]:
#Example 7.9
#Design a wide-band reject filter having fh=200 Hz and fl=1 KHz.

from __future__ import division     #to perform decimal division
import math


#Variable declaration
fh=200                 # Low cutoff freq in Hz
fl=1*10**3             # High cutoff freq in Hz
C2=0.01*10**-6         # Assumption
R2=1/(2*math.pi*fl*C2)
C=0.05*10**-6
R1=10*10**3            # Assumption
Rf=R1                  # Since passband gain is 2,R1 and Rf must be equal
Af=4                   # Since gain of high pass and lowpass is set to 2


#calculation
R2=1/(2*math.pi*fl*C2)
R=1/(2*math.pi*fh*C)


#result
print "Resistance R2 of highpass section is",round(R2/10**3,2),"kilo ohm"
print "Resistance R of lowpass section is",round(R/10**3,2),"kilo ohm"
print "Bandpass Gain Af is",Af
print "Resistance R1 is",round(R1/10**3),"kilo ohm"
print "Resistance Rf is",round(Rf/10**3),"kilo ohm"
Resistance R2 of highpass section is 15.92 kilo ohm
Resistance R of lowpass section is 15.92 kilo ohm
Bandpass Gain Af is 4
Resistance R1 is 10.0 kilo ohm
Resistance Rf is 10.0 kilo ohm

Example 7.10

In [18]:
#Example 7.10
#Design a 60 Hz active notch filter.

from __future__ import division     #to perform decimal division
import math


#Variable declaration
fn=60            #Notch-out frequency in Hz
C=0.068*10**-6   #Assumption



#calculation
R=1/(2*math.pi*fn*C)


#result
print "Resistance R is",round(R/10**3,2),"kilo ohm"
Resistance R is 39.01 kilo ohm

Example 7.11

In [19]:
#Example 7.11
#For the all-pass filter of figure 7-16(a),find the phase angle phi if the
#frequency of vin is 1 kHz.

from __future__ import division     #to perform decimal division
import math


#Variable declaration
f=1*10**3                          #Input frequency in Hz
C=0.01*10**-6 
R=15.9*10**3                       #Resistance in ohms



#calculation
phi=math.atan(2*math.pi*f*C*R)     #Phase angle
phi1=-2*phi*180/math.pi

#result
print "Phase angle phi is",round(phi1),"degree"
Phase angle phi is -90.0 degree

Example 7.12

In [20]:
#Example 7.12
#Design the phase shift oscillator of figure 7-18 so that fo=200 Hz.

from __future__ import division     #to perform decimal division
import math


#Variable declaration
fo=200          # Frequency of oscillation
C=0.1*10**-6    # Assumption
R=3.3*10**3

#calculation
R=0.065/(fo*C)
R=3.3*10**3     #Using rounded value
R1=10*R         # To prevent loading of amplifier
Rf=29*R1

#result
print "Resistance R is",round(R/10**3,1),"kilo ohm"
print "Use Resistance R as 3.3 kohm"
print "Resistance Rf is",round(Rf/10**3),"kilo ohm"
Resistance R is 3.3 kilo ohm
Use Resistance R as 3.3 kohm
Resistance Rf is 957.0 kilo ohm

Example 7.13

In [21]:
#Example 7.13
#Design the wein bridge oscillator of figure 7-19 so that fo=965 Hz.

from __future__ import division     #to perform decimal division
import math


#Variable declaration
fo=965        # Frequency of oscillation
C=0.05*10**-6 # Assumption
R1=12*10**3   # Assumption

#calculation
R=0.159/(fo*C)
Rf=2*R1

#result
print "Resistance R is",round(R/10**3,1),"kilo ohm"
print "Resistance Rf is",round(Rf/10**3),"kilo ohm"
Resistance R is 3.3 kilo ohm
Resistance Rf is 24.0 kilo ohm

Example 7.14

In [22]:
#Example 7.14
#Design the quadrature oscillator of figure 7-20 so that fo=159 Hz.
#The opamp is the 1458/772.

from __future__ import division     #to perform decimal division
import math


#Variable declaration
fo=159        # Frequency of oscillation
C=0.01*10**-6 # Assumption

#calculation
R=0.159/(fo*C)

#result
print "Resistance values R1,R2,R3 is",round(R/10**3,1),"kilo ohm"
print "Capacitance values C1,C2,C3 is",round(C*10**6,2),"uF"
Resistance values R1,R2,R3 is 100.0 kilo ohm
Capacitance values C1,C2,C3 is 0.01 uF

Example 7.15

In [23]:
#Example 7.15
#Design the square wave oscillator of figure 7-21(a) so that fo=1 kHz.
#The opamp is 741 with dc supply voltages = 15, -15 V.

from __future__ import division     #to perform decimal division
import math


#Variable declaration
fo=1*10**3         # Frequency of oscillation
C=0.05*10**-6      # Assumption
R1=10*10**3        # Assumption

#calculation
R=1/(2*fo*C)
R2=1.16*R1

#result
print "Resistance R2 is",round(R2/10**3,1),"kilo ohm"
print "Resistance R is",round(R/10**3),"ohm"
Resistance R2 is 11.6 kilo ohm
Resistance R is 10.0 ohm

Example 7.16

In [24]:
#Example 7.16
#Design the triangular wave generator of figure 7-23 so that fo=2 kHz and
#Vo(pp)=7V. The opamp is a 1458/772 and supply voltages =15,-15 V.

from __future__ import division     #to perform decimal division
import math


#Variable declaration
fo=2*10**3         # Frequency of oscillation
vo=7               #Output voltage
Vsat=14            #Saturation voltage for opamp 1458
R3=40*10**3        #Assumption
C1=0.05*10**-6     #Assumption


#calculation
R2=(vo*R3)/(2*Vsat)
k=R3/(4*fo*R2)     #Using fo=R3/(4*R1*C1*R2),k=R1*C1;
R1=k/C1


#result
print "Resistance R2 is",round(R2/10**3),"kilo ohm"
print "Resistance R1 is",round(R1/10**3),"kilo ohm"
Resistance R2 is 10.0 kilo ohm
Resistance R1 is 10.0 kilo ohm

Example 7.17

In [25]:
#Example 7.17
#In the circuit of figure 7-25(c), V=12 V, R2=1.5 Kilo ohm, R1=R3=10 Kilo ohm
#and C1=0.001 uF.
#a)Determine the nominal frequency of all the output waveforms.
#b)Compute the modulation in the output frequencies if Vc is varied between 9.5 V
#and 11.5 V.


from __future__ import division     #to perform decimal division
import math


#Variable declaration
R2=1.5*10**3
R1=10*10**3
R3=10*10**3
C1=0.001*10**-6
V=12                  #Supply voltage
Vc1=9.5
Vc2=11.5

#calculation
Vc=R3*V/(R2+R3)       #Using voltage divider rule
fo=2*(V-Vc)/(V*R1*C1)
fo1=2*(V-Vc1)/(V*R1*C1)
fo2=2*(V-Vc2)/(V*R1*C1)
delta_fo=fo1-fo2      #Change in output freq


#result
print "Terminal voltage Vc is",round(Vc,2),"volts"
print "Approximate Nominal freq fo is",round(fo/10**3,2),"kHz"
print "Approximate Nominal freq fo1 is",round(fo1/10**3,2),"kHz"
print "Approximate Nominal freq fo2 is",round(fo2/10**3,2),"kHz"
print "Change in output freq delta_fo is",round(delta_fo/10**3,2),"kHz"
Terminal voltage Vc is 10.43 volts
Approximate Nominal freq fo is 26.09 kHz
Approximate Nominal freq fo1 is 41.67 kHz
Approximate Nominal freq fo2 is 8.33 kHz
Change in output freq delta_fo is 33.33 kHz