# Chapter 12: Oscillator Design¶

## Example 12.1, Page 480¶

In [1]:
import math

#Variable declaration
R1=10000    #ohms
R2=1        #ohms
C=.002*10**-6   #F
L=10**-6        #H

#Calculations&Results
#B=complex(0,W*L)/complex(R1-W**2*R2*C*L,W*(L+R1*R2*C))
W=math.sqrt(R1/(R2*L*C))
f=W/(2*math.pi)
print "f=%.3eHz"%f
A=1+R1*R2*C/L
print "A=%.f"%A

W=2.24e+09 rad/s
f=3.559e+08Hz
A=21


## Example 12.2, Page 486¶

In [2]:
import math

#Variable declaration
#unit in SI
L1=10**-9   #H
L2=10**-9   #H
Go=4.5*10**-3
RL=50       #ohms
W=2*math.pi*150*10**6

#Calculations&Results
n=math.sqrt(1/(Go*RL))
print "n=%.4f"%n
L3=L2/n**2
print "considering L1=L2=1nH"
print "nL3=%.4e H"%L3
C=1/((L1+L2)*W**2)
print "C=%.3e F"%C

n=2.1082
considering L1=L2=1nH
nL3=2.2500e-10 H
C=5.629e-10 F


## Example 12.4, Page 496¶

In [3]:
import math

#Variable declaration
Cvar=3.5*10**-12
C1=150*10**-12
C2=72*10**-12
L=32*10**-9

#Calculations&Results
C=Cvar+C1*C2/(C1+C2)
f=1/(2*math.pi*math.sqrt(L*C))
print "C=%.3e F\nf=%.3e Hz\n"%(C,f)
Cvar=32*10**-12
C=Cvar+C1*C2/(C1+C2)
f=1/(2*math.pi*math.sqrt(L*C))
print "C=%.3e F\nf=%.3e Hz\n"%(C,f)
Cvar=3.5*10**-12
C=Cvar+C1*C2/(C1+C2)
f=1/(2*math.pi*math.sqrt(L*C))
print "C=%.3e F\nf=%.3e Hz"%(C,f)

C=5.215e-11 F
f=1.232e+08 Hz

C=8.065e-11 F
f=9.907e+07 Hz

C=5.215e-11 F
f=1.232e+08 Hz


## Example 12.5, Page 508¶

In [4]:
import math

#Variable declaration
Ve=2
Be=math.pi/2

#Calculations&Results
Kd=Ve/math.sin(Be)
print "Kd=%.0f"%Kd
#Ko=dW/Vd
Ko=2*math.pi*100*1000
dWH=Kd*Ko
dfH=dWH/(2*math.pi)
print "dfH=%.e Hz"%dfH

Kd=2
dfH=2e+05 Hz


## Example 12.6, Page 509¶

In [5]:
import math

#Variable declaration
Ve=2
Bemax=math.pi/2

#Calculations&Results
Kd=Ve/Bemax
print"Kd=%.4f"%Kd
Ko=2*math.pi*10**5
dWH=Kd*Ko*Bemax
print "dfH=%.e Hz"%(dWH/(2*math.pi))

Kd=1.2732
dfH=2e+05 Hz


## Example 12.7, Page 510¶

In [6]:
import math

#Variable declaration
Vin=2.  #Volt
Vosc=2.    #Volt
VPD=2.  #volt
Ein=0.75
Eosc=0.75
Vd=1

#Calculations&Results
dW=2*math.pi*10**7
Km=VPD/(Vin*Vosc)
print "Km=%.1f V**-1"%Km
Kd=0.5*Km*Ein*Eosc
Ko=dW/Vd
#(a)
qd=2*math.pi*(11-10)*10**6/(Ko*Kd)
print "(a)qd=%.4f rad = %.2f degree\n"%(qd,qd*180/math.pi)
#(b)
qd=2*math.pi*(9-10)*10**6/(Ko*Kd)
print "(b)qd=%.4f rad = %.2f degree"%(qd,qd*180/math.pi)

Km=0.5 V**-1



## Example 12.8, Page 514¶

In [8]:
import math

#Variable declaration
Wo=2*math.pi*2*10**6
Wf=2*math.pi*2.5*10**6
Ko=10**7
Ka=10
Kd=0.5
N=20
E=0.8
Wn=10**4
C2=0.5*10**-6   #F

#Calculations
Vd=(Wo-Wf)/Ko
Ve=Vd/Ka
Qe=Ve/Kd
K=Kd*Ka*Ko/N
dW=math.sqrt(2*(2*E*Wn*K-Wn**2))
df=dW/(2*math.pi)
T1=K/Wn**2
T2=2*E/Wn-1/K
R2=T2/C2
R1=T1/C2-R2

#Result

Vd=-0.3142 V
Ve=-0.0314 V
K=2.50e+06
df=4.4960e+04 Hz
T1=0.0250 s
T2=1.5960e-04 s
R2=319.20 ohm
R1=49680.8 ohm


## Example 12.11, Page 521¶

In [10]:
import math
import cmath

#Variable declaration
FG=1.25*cmath.exp(complex(0,40*math.pi/180))

#Calculations
Z_G=(1+FG)/(1-FG)

#Result
print "Z_G = ",Z_G

Z_G =  (-0.868874963372+2.48223138143j)


## Example 12.12, Page 524¶

In [11]:
import cmath
import math

#Variable declaration
Z=50    #ohms
S11=2.18*cmath.exp(complex(0,math.pi/180*(-35)))
S21=2.75*cmath.exp(complex(0,math.pi/180*(96)))
S12=1.26*cmath.exp(complex(0,math.pi/180*(18)))
S22=0.52*cmath.exp(complex(0,math.pi/180*(155)))
FL=0.59*cmath.exp(complex(0,math.pi/180*(-104)))

#Calculations&Results
def mod(n):
r=n.real
i=n.imag
x=math.sqrt(r**2+i**2)
return x

deln=S11*S22-S12*S21
k=(1-mod(S11)**2-mod(S22)**2+mod(deln)**2)/(2*mod(S12*S21))
print "del=",deln
print "k=%.2f"%k
Cs=(S11-deln*S22.conjugate())/(mod(S11)**2-mod(deln)**2)
print "Cs=",Cs.conjugate()
rs=mod((S12*S21)/(mod(S11)**2-mod(deln)**2))
print "rs=%.3f"%rs
CL=(S22-deln*S11.conjugate())/(mod(S22)**2-mod(deln)**2)
print "CL=",CL.conjugate()
rL=mod(S12*S21/(mod(S22)**2-mod(deln)**2))
print "rL=%.2f"%rL
Fin=S11+(S12*S21*FL)/(1-S22*FL)
print "Fin=",Fin
Zin=50*(1+Fin)/(1-Fin)
print "Zin=",Zin
ZG=complex(27.9,1.91)
print "ZG=",ZG
FG=(ZG-50)/(ZG+1)
print "FG=",FG        #calculation mistake in calculating FG in book
VSWR=(1.0+mod(FG))/(1.0-mod(FG))
print "VSWR=%.3f"%VSWR #calculation mistake in book

del= (0.842542468258-2.183708613j)
k=0.21
Cs= (-3.66734964984-2.88457333776j)
rs=4.772
CL= (0.903667080025+0.588666300069j)
rL=0.67
Fin= (3.96087399-0.167756815837j)
Zin= (-83.6657406194-1.90742918076j)
ZG= (27.9+1.91j)
FG= (-0.757031373959+0.116122142708j)
VSWR=7.543


## Example 12.13, Page 526¶

In [12]:
import math
import cmath

#Variable declaration
S11=0.9*cmath.exp(complex(0,math.pi/180*150))
S21=1.7*cmath.exp(complex(0,-math.pi/180*80))
S12=0.07*cmath.exp(complex(0,math.pi/180*120))
S22=1.08*cmath.exp(complex(0,-math.pi/180*56))

#Calculations&Results
def mod(n):
r=n.real
i=n.imag
x=math.sqrt(r**2+i**2)
return x

del1=(1-S11)*(1-S22)-S12*S21
print "del1=",del1
Z_11=((1+S11)*(1-S22)+S21*S12)/del1
print "Z_11=",Z_11
Z_12=2*S12/del1
print "Z_12=",Z_12
Z_21=2*S21/del1
print "Z_21=",Z_21
Z_22=((1-S11)*(1+S22)+S21*S12)/del1
print "Z_22=",Z_22
Zinductor=complex(0,(2*math.pi*2.75*10**9*1.45*10**-9))
Z_inductor=Zinductor/50

print "\nZ_inductor=",Z_inductor

A=[[Z_11,Z_12],[Z_21,Z_22]]+[Z_inductor]
print "[Z_s11,Z_s12;Z_s21,Z_s22]=",A   #calculation mistake in the book here. Hence all subsequent answers differ from textbook

deln=(Z_11+1)*(Z_22+1)-A[0][1]*A[1][0]
print "\ndel=",deln

Ss12=2*A[0][1]/deln
print "Ss12=",Ss12
Ss21=2*A[1][0]/deln
print "Ss21=",Ss21
Ss11=((A[0][0]-1)*(A[1][1]+1)-(A[0][1]*A[1][0]))/deln
print "Ss11=",Ss11
Ss22=((A[0][0]+1)*(A[1][1]-1)-A[0][1]*A[1][0])/deln
print "Ss22=",Ss22
delm=S11*S22-S21*S12
print "\ndel=",mod(delm)

k=(1-mod(S11)**2-mod(S22)**2+mod(delm)**2)/(2*mod(S12*S21))
print "k=%.4f"%k
Cs=S11-delm*S22.conjugate()/(mod(S11)**2-mod(delm)**2)
print "Cs=",Cs
rs=mod((S12*S21)/(mod(S11)**2-mod(delm)**2))
print "rs=",rs
CL=(S22-delm*S11.conjugate())/(mod(S22)**2-mod(delm)**2)
print "CL=",CL
rL=mod(S12*S21/(mod(S22)**2-mod(delm)**2))
print "rL=",rL
FL=0.5689*cmath.exp(complex(0,math.pi/180*167.8))
print "FL=",FL
Fin=S11+S12*S21*FL/(1-S22*FL)
print "\nFin=",Fin
Zin=50*(1+Fin)/(1-Fin)
print "Zin=",Zin
ZG=-Zin.real/3-complex(0,Zin.imag)
print "ZG=",ZG

del1= (1.01653194645+1.33850110966j)
Z_11= (0.133525378871+0.269048287394j)
Z_12= (0.032258372159+0.0767961005771j)
Z_21= (-1.37405578463-1.48462738731j)
Z_22= (-0.145806851505-2.01010748778j)

Z_inductor= 0.501084028248j
[Z_s11,Z_s12;Z_s21,Z_s22]= [[(0.13352537887145693+0.2690482873935853j), (0.032258372158985874+0.07679610057712603j)], [(-1.3740557846347101-1.4846273873131535j), (-0.14580685150547484-2.0101074877822773j)], 0.501084028247572j]

del= (1.43937679805-1.89527485894j)
Ss12= (-0.035+0.0606217782649j)
Ss21= (0.295201902034-1.67417318012j)
Ss11= (-0.779422863406+0.45j)
Ss22= (0.603928335748-0.895360578359j)

del= 0.907176449692
k=-0.6447
Cs= (-69.842355424+31.0661347384j)
rs= 9.17564828775
CL= (0.227457776559-0.788396146499j)
rL= 0.34650348518
FL= (-0.556051902259+0.120222676703j)

Fin= (-0.809707524676+0.410225034971j)
Zin= (2.5569630942+11.9136278815j)
ZG= (-0.852321031399-11.9136278815j)