From: Dan White Date: Sun, 29 Jan 2012 21:12:57 +0000 (-0600) Subject: Add v-regulator resistor calcs X-Git-Tag: calibrations~304 X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=c8cfbbf40b1231b6a8f9a9729d7c563f8667ff56;p=430.git Add v-regulator resistor calcs --- diff --git a/sch-pcb/devboard/vreg.py b/sch-pcb/devboard/vreg.py new file mode 100644 index 0000000..ba0692e --- /dev/null +++ b/sch-pcb/devboard/vreg.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +from pylab import * +from wag import engstr as es + +def rvals(Vrange, Rpot): + Vmax = max(Vrange) + Vmin = min(Vrange) + R2 = Vmin * Rpot / (Vmax - Vmin) + R1 = (R2 + Rpot) * (2*Vmin - 1) + return [R1, R2] + +def vout(n, r1, r2, Rpot=1.0, Vref=0.5): + return Vref*(1 + ((1-n)*Rpot+r1)/(n*Rpot+r2)) + +n = arange(0, 1, 1/256.0) + +Rpot = 100e3 + +Vref = 0.5 +Vmin = 0.5 +Vmax = 1.8 +assert(Vmin >= Vref) + +r1, r2 = rvals([Vmin, Vmax], Rpot) + +print es(r1), es(r2) + +close('all') + +subplot(131) +plot(1-n, vout(n, r1, r2, Rpot, Vref), 'x') + +subplot(132) +r2mod = ((r1+Rpot/2)/1.4-Rpot/2) +plot(1-n, vout(n, r1, r2mod, Rpot, Vref), 'x') +ylabel('fixed r1') + +subplot(133) +r1mod = (1.4*(r2+Rpot/2)-Rpot/2) +plot(1-n, vout(n, r1mod, r2, Rpot, Vref), 'x') +ylabel('fixed r2') + +print 'r1mod:', es(r1mod) +print 'r2mod:', es(r2mod)