#Ex12_1 Pg-587
#calculate Frequency of oscillations produced
import math
C1=0.001e-6 #capacitor c1 in farad
C2=0.01e-6 #capacitor c2 in farad
L=5e-6 #inductance in Henry
print '%s' %("To maintain vibrations in a colpitts oscilator,")
print '%s' %("hfe >= C2/C1")
hfe=C2/C1 #transistor current gain
print '%s %.f' %("=",hfe)
print '%s' %("So the value of hfe of transistor used must be greater than 10")
print '%s' %("Frequency of oscillations produced")
x=1/(C1)+1/(C2)
y=1/(L)
f=math.sqrt(x*y)
print '%s %.1f' %("=*1e7 Hz",f*1e-7)
# answer in the book is wrong
#Ex12_2 Pg-588
#calculate frequency of oscillations
import math
RL=3.3*10.**(3.) #load resistor in ohm
R=5.6*10.**(3.) #resistor R in ohm
C=0.001*10.**(-6.) #capacitance in farad
print '%s' %("For oscillations to be maintained in a RC oscillator")
hfe=(23.+(29.*R/RL)+(4.*RL/R)) #transistor current gain
print '%s %.f' %("=",hfe)
print '%s' %("Frequency of oscillations")
f=1./(2.*math.pi*C*math.sqrt((4.*R*RL)+(6.*R**2.)))
#frequency of oscillation (textbook answer is wrong
# because of the used of wrong value of C)
print '%s %.1f' %("=Hz",f)
#Ex12_3 Pg-588
#calculate Series resonant frequency,Q of the crystal
import math
L=0.33 #inductance in henry
C=0.065*10.**(-12.) #capacitance in farad
Cm=10.**(-12.) #capacitance in farad
R=0.55*10.**(3.) #resistor R in ohm
print '%s' %("Series resonant frequency, fs = 1/2*math.pi*math.sqrt(L*C)")
fs=1./(2.*math.pi*math.sqrt(L*C))
print '%s %.2f' %("= MHz",fs*1e-6)
print '%s' %("Q of the crystal = 2*pi*fs*L/R")
Q=(2*math.pi*fs*L)/R #quality factor (textbook answer wrong)
print '%s %.0f' %("=",Q)
#Ex12_4 Pg-602
#calculate Series resonant frequency,The equialent parallel capacitance,Parallel resonant frequency
import math
L=3. #inductance in henry
Cs=0.05*10.**(-12.) #capacitance in farad
Cm=10.*10.**(-12.) #capacitance in farad
R=2.*10.**(3.) #resistor R in ohm
print '%s' %("Series resonant frequency, fs = 1/2*pi*sqrt(LC)")
fs=1./(2.*math.pi*math.sqrt(L*Cs))
print '%s %.0f' %("= KHz",fs*1e-3)
print '%s' %("The equialent parallel capacitance, Cp = Cm*Cs/Cm+Cs")
Cp=Cm*Cs/(Cm+Cs) #quality factor
print '%s %.4f' %("= pF",Cp*1e12)
print '%s' %("Parallel resonant frequency, fp = 1/2*pi*sqrt(L*Cp)")
fp=1/(2*math.pi*math.sqrt(L*Cp))
print '%s %.0f' %("= kHz",fp*1e-3)
#Ex12_5 Pg-602
#calculate Fundamental frequency of oscillations of crystal
print '%s' %("Fundamental frequency of oscillations of crystal")
print '%s' %("fr = K/t")
print '%s' %("Let new thickness of the crystal be t''")
print '%s' %("fr''/fr = t''/t = 99/100")
print '%s' %("So, new frequency fr'' = k/t''")
print '%s' %("or fr'' = (99/100)*fr")
print '%s' %("or reduction in frequency,")
print '%s' %("fr-fr'' = fr-(99/100)*fr")
print '%s' %("= fr(1/100)")
print '%s' %("or fr-fr''/fr = 1/100 ")
print '%s' %("Therefore, fr'' reduces by 1%")