In [10]:
%matplotlib inline
from cmath import phase, pi
from math import degrees,sqrt
import matplotlib.pyplot as plt
Rs = 39000
C = 0.1e-6
L = 10
Rl = 384
plotpoints = 5000
def Vo(f, Vi = 1):
RLC = 1/(2*pi*f*C*1j) + Rl + (2*pi*f*L*1j)
return Vi * (RLC/(Rs+RLC))
frequencies = [ pow(10,4.0*i/plotpoints) for i in range(plotpoints)]
mags = []
phases = []
fmin = 1
magmin = 2
for f in frequencies:
vo = Vo(f)
mag = abs(vo)
mags.append(mag)
phases.append(phase(vo))
if mag < magmin:
fmin = f
magmin = mag
print "Expect Voutmin=%0.4f at %.2fHz"%(float(Rl)/(Rl+Rs),1/(2*pi*sqrt(L*C)))
print "Calculated Vout=%0.4f at %.2fHz"%(magmin,fmin)
plt.figure()
plt.figure(figsize=(12, 6))
plt.semilogx(frequencies,mags)
plt.semilogx(frequencies,phases)
plt.grid(True)
plt.show()
with $f_{resonance}$ and C, calculate $L = \frac{1}{(2 \pi f)^2 C}$
Put your values of f and C here to calculate your L
In [19]:
f = 160.6
C = 0.1e-6
L = 1/(pow((2*pi*f),2)*C)
print "L=%0.1f"%L
In [ ]: