Skip to content

Instantly share code, notes, and snippets.

@andete
Last active August 29, 2015 14:00
Show Gist options
  • Save andete/11082555 to your computer and use it in GitHub Desktop.
Save andete/11082555 to your computer and use it in GitHub Desktop.
mcp1650 inductor calculation DCM mode
#!/usr/bin/env python
import time
from math import log10
Vin = 5.0
if Vin < 3.8:
D = 0.8
else:
D = 0.56
Vout = 100.0
Lmin = 0.1E-6
Lstart = 1E-6
Lmax = 100E-6
Iout = 20E-3
Pout = Vout * Iout
eff = 0.8
Pin = Pout/eff
print "Pin:", Pin
Fsw = 750E3
Ton = (1./Fsw)*D
print "Ton:", Ton
Llow = Lmin
Lhigh = Lmax
while True:
L = 10**((log10(Llow) + log10(Lhigh)) / 2)
Ipk = (Vin/L)*Ton
Eind = .5*L*Ipk*Ipk
Pind = Eind*Fsw
print "L:%e, Ipk:%f, Pind:%f" % (L, Ipk, Pind)
if Pind < Pin:
Lhigh = L
else:
Llow = L
time.sleep(1.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment