Chapter 8: Oscillators

example 8.1, Page No.272

In [10]:
#feed bck factor
import math

#variable declaration
A=50.0                 #unitless

#Calculations
Beta=1/A               #unitless

#Result
print("Barkhausen criterion for oscillator : Beta*A=1")
print("Feedback Factor to make oscillator : %.2f"%Beta)
Barkhausen criterion for oscillator : Beta*A=1
Feedback Factor to make oscillator : 0.02

example 8.2, Page No.277

In [9]:
#Range of variable capacitor
import math
#variable declaration
L=100                  #in uH
L=L*10**-6             #in H
f1=500.0               #in kHz
f1=f1*10**3            #in Hz
f2=1500.0              #in kHz
f2=f2*10**3            #in Hz

#Calculations
#Formula : f=1/(2*%pi*sqrt(L*C))
C1=1/(4*math.pi**2*f1**2*L)
C2=1/(4*math.pi**2*f2**2*L)

#Result
print("Range of capacitor : %.0f pF to %.0f pF"%(C2*10**12,math.ceil(C1*10**12)))
Range of capacitor : 113 pF to 1014 pF

example 8.3, page No.283

In [14]:
#C2 of colpitt oscilator
import math
#variable declaration
L=100.0             #in mH
L=L*10**-3          #in H
C1=0.1              #in uF
C1=C1*10**-6        #in F
f=100.0*10**3       #in Hz
f=f*10**3           #in Hz

#Calculations
#Formula : f=1/(2*pi*sqrt(L*C))
C=1.0/(4*math.pi**2*f**2*L)
#Formula : C=C1*C2/(C1+C2)
C2=C*C1/(C1-C)

#Result
print("C2 in farad : %.3f * 10^15"%(C2*10**15))
#Note : Answer in the book is wrong.
C2 in farad : 0.025 * 10^15

example 8.4, page No. 288

In [15]:
#Frequency of oscillation
import math

#variable declaration
R=100              #in kOhm
R=R*10**3          #in Ohm
C=0.01             #in uF
C=C*10**-6         #in F

#calculations
fo=math.sqrt(6)/(2*math.pi*R*C)

#result
print("Frequency of oscillation in Hz : %.3f"%fo)
#Note : Answer in the book is not accurate.
Frequency of oscillation in Hz : 389.848

example 8.5, Page No.288

In [18]:
#Amplifier voltage gain
import math

print("Put alfa=sqrt(6) to find the gain");
alfa=math.sqrt(6)           #unitless

#calculation
Beta=1/(1-5*alfa**2);
#Barkhausen critera : A*|Beta|>=1
Beta=-Beta
A=1/Beta

#Result
print("Minimum Gain of Amplifier must be  :%.0f "%A)
Put alfa=sqrt(6) to find the gain
Minimum Gain of Amplifier must be  :29 

example 8.6, Page No.292

In [6]:
#Frequency of oscillation and min current gain
import math
#variable declaration
R1=50.0                      #in kohm
R1=R1*10**3                  #in ohm
C1=0.001                     #in uF
C1=C1*10**-6                 #in F
R2=1.0                       #in kohm
R2=R2*10**3                  #in ohm
C2=0.01                      #in uF
C2=C2*10**-6                 #in F

#calculation

#Part (i)
#Formula : f=1/(2*%pi*sqrt(C1*C2*R1*R2))
f=1/(2*math.pi*math.sqrt(C1*C2*R1*R2))

#Part (ii)
CurrentGain=1+C2/C1+R1/R2

#Result
print("Frequency of oscillations in kHz :%.3f "%(f/1000.0))
print("Current Gain :%.0f "%CurrentGain)
#Note:Answer for Frequency of oscillations is incorrect in the book
Frequency of oscillations in kHz :7.118 
Current Gain :61 

example 8.7, Page No.292

In [13]:
#Resistnce to cover frequency range
import math
#variable declaration
fmin=20.0               #in Hz
fmax=20.0               #in kHz
Cmin=30.0               #in pF
Cmax=300.0              #in pF

#Calculations
#Formula : fo=1/(2*%pi*R*C))
R=1/(2*math.pi*fmin*Cmax*10**-12)

#To cover frequency range from 200Hz to 2kHz R should be decrease by factor of 10
R_dash = R/10.0         
#TO cover the frequency range from 2kHz to 20kHz, R should be decrease by factor of 100
R_dash_2= R/100.0
#Result
print("Minimum Fequeny correspond to maximum capacitance.")
print("Required resistance in Mohm : %.1f"%(R/10**6))
print("\nR_dash in MOhm = %.2f (for frequency range 200Hz to 2kHz)"%(R_dash/10**6))
print("\nR_dash_2 in kOhm = %.0f(for frequency range 2kHz to 20kHz)"%(R_dash_2*1000//10**6))
Minimum Fequeny correspond to maximum capacitance.
Required resistance in Mohm : 26.5

R_dash in MOhm = 2.65 (for frequency range 200Hz to 2kHz)

R_dash_2 in kOhm = 265(for frequency range 2kHz to 20kHz)

example 8.8, Page No.296

In [35]:
#Resonant Frequency
import math
#variable declaration
f=500.0                  #in kHz
T1=50.0                  #in degree C
T2=60.0                  #in degree C
TC=-20.0                 #in ppm/degree C

#Calculations
ChangeInFreq=TC*(f*10**-3)*(T1-T2) #in Hz
ResonantFreq=f*1000-ChangeInFreq   #in Hz

#Result
print("Resonant frequency in kHz : %.1f"%(ResonantFreq/1000))
#Note : answer in the book is wrong.
Resonant frequency in kHz : 499.9

example 8.9, Page No.296

In [19]:
#Resonant Frequency
import math
#Variable declarations
f=450.0               #in kHz
T1=30.0               #in degree C
T2=50.0               #in degree C
TC=-10.0              #in ppm/degree C

#Calculations
PercentChange=-TC*100/10**6                               #in %
TotalChangeInFreq=(PercentChange/100)*(f*10**3)*(T2-T1)   #in Hz
ResonantFreq=f*1000-TotalChangeInFreq                     #in Hz

#Result
print("Resonant frequency in kHz :%.3f "%(ResonantFreq/1000))
Resonant frequency in kHz :449.910 

example 8.10, Page No.297

In [20]:
#Parallel and series resonant frequencies
import math
#Variable declaration
L=0.5                  #in H
C=0.05                 #in pF
R=1                    #in kohm
Cm=1                   #in pF

#Calculations
fs=1/(2*math.pi*math.sqrt(L*C*10**-12))
fp=1/(2*math.pi*math.sqrt((L*C*10**-12*Cm*10**-12)/(C*10**-12+Cm*10**-12)))

#Result
print("Series resonant frequency in MHz :%.3f"%(fs/10**6))
print("Parallel resonant frequency in MHz :%.3f"%(fp/10**6))
Series resonant frequency in MHz :1.007
Parallel resonant frequency in MHz :1.031

Miscellaneous example 8.1, Page No.302

In [40]:
#Value of L
import math
#Variable declaration
L2=0.4              #in mH
C=0.004             #in µF
f=120               #in KHz
L1=1/(4*math.pi**2*(f*10**3)**2*C*10**-6)-L2*10**-3

#Result
print("Value of L1(in mH) :%.2f"%(L1*10**3))
Value of L1(in mH) :0.04

Miscellaneous example 8.2, page No.303

In [22]:
#Value of C and hfe
import math
#variable declaration
fo=10.0                 #in KHz
R1=25.0                 #in kohm
R2=60.0                 #in kohm
Rc=40.0                 #in kohm
R=7.1                   #in kohm
hie=1.8                 #in kohm

#Calculations
C=1/(2*math.pi*fo*10**3*R*10**3*math.sqrt(6+4*Rc/R))
hfe=23+29*R/Rc+4*Rc/R

#Result
print("Value of Capacitor(in nF) %.3f"%(C*10**9))
print("Value of hfe is ≥ %.3f"%hfe)
Value of Capacitor(in nF) 0.420
Value of hfe is ≥ 50.683

Miscellaneous example 8.3, Page No.303

In [47]:
#Value of Capacitor
import math
#variable declaration
R=100.0               #in kohm
fo=10.0               #in KHz

#Calculations
C=1/(2*math.pi*fo*10**3*R*10**3)

#Result
print("Value of Capacitor(in pF) :%.0f"%(C*10**12))
Value of Capacitor(in pF) :159

Miscellaneous example 8.4, page No.304

In [23]:
#Various parameter of colpitt oscillator
import math

#variable declaration
L=40.0                #in mH
C1=100.0              #in pF
C2=500.0              #in pF
Vout=10.0             #in volt

#Calculations
fo=1/(2*math.pi*math.sqrt(L*10**-3*C1*10**-12*C2*10**-12/(C1*10**-12+C2*10**-12)))
print("Frequency of oscillation (in KHz) :%.1f"%(fo*10**-3))
Vf=Vout*C1/C2
Gain=C2/C1
Gain=10                #given
C1=C2/Gain             #in pF
fo=1/(2*math.pi*math.sqrt(L*10**-3*C1*10**-12*C2*10**-12/(C1*10**-12+C2*10**-12)))

#Result

print("Feedback voltage in volt :%.0f"%Vf)
print("Minimum Gain is %.0f"%Gain)
print("For a gain of 10 C1 in pF is :%.0f"%C1)
print("New frequency of oscillation (in KHz) :%.3f"%(fo*10**-3))
Frequency of oscillation (in KHz) :87.2
Feedback voltage in volt :2
Minimum Gain is 10
For a gain of 10 C1 in pF is :50
New frequency of oscillation (in KHz) :118.032

Miscellaneous example 8.5, Page No.305

In [61]:
#Resonant frequencies and Q factor
import math
#Variable declaration
L=0.5                   #in H
Cs=0.06                 #in pF
Cp=1.0                  #in pF
R=5.0                   #in Kohm

#calculations
fs=1/(2*math.pi*math.sqrt(L*Cs*10**-12))
Q=2*math.pi*fs*L/(R*10**3)
print("Seies resonance frequency(in KHz): %.1f"%(fs/10**3))
print("Q-factor f the crystal at fs is %.0f"%Q)
fp=(1/(2*math.pi))*math.sqrt((Cs*10**-12+Cp*10**-12)/(L*Cs*10**-12*Cp*10**-12))
Q=2*math.pi*fp*L/(R*10**3)
print("\nSeies resonance frequency(in KHz) : %.0f"%(fp/10**3))
print("Q-factor f the crystal at fs is %.0f"%Q)
Seies resonance frequency(in KHz): 918.9
Q-factor f the crystal at fs is 577

Seies resonance frequency(in KHz) : 946
Q-factor f the crystal at fs is 594