--- /dev/null
+(defun eff-imp (r1 r2) (/ (+ (inv r1) (inv r2))))
+
+(defun amps->volts (amps imp) (* amps imp))
+
+(defun volts->amps (volts imp) (/ volts imp))
--- /dev/null
+(defalias ^ expt)
+
+(defmacro square (x) `(^ ,x 2))
+
+(defmacro cube (x) `(^ ,x 3))
+
+(defmacro inv (x) `(/ (float ,x)))
+
+(defmacro E (number exponent) `(* (float ,number) (^ 10 ,exponent)))
--- /dev/null
+(defparameter *volt-max* 10.0)
+(defparameter *resolution* 16)
+(defparameter *impedance* 249)
+
+(defun 13B () (setq *resolution* 13 *volt-max* 10.0))
+(defun 16B () (setq *resolution* 16 *volt-max* 10.0))
+
+(defalias P3K 16B)
+(defalias SLC 16B)
+(defalias P1K 13B)
+(defalias DL4 13B)
+
+(defun max-counts (resolution) (- (^ 2 resolution) 1))
+
+(defun volts->counts (vin)
+ (float (* (/ vin *volt-max*) (max-counts *resolution*))))
+
+(defun counts->volts (cin)
+ (float (* (/ cin (max-counts *resolution*)) *volt-max*)))
+
+(defun amps->counts (amps imp) (volts->counts (amps->volts amps imp)))
+
+(defun count-range (upper lower)
+ (list (volts->counts upper) (volts->counts lower)))
+
+(defun volt-range (upper lower)
+ (list (counts->volts upper) (counts->volts lower)))
+
+(defun divisor (count-max count-min scaled-max scaled-min)
+ (/ (float (- count-max count-min)) (- scaled-max scaled-min)))
+
+(defun offset (count-min scaled-min divisor)
+ (- scaled-min (/ count-min divisor)))
+
+(defun scale (count-max count-min scaled-max scaled-min)
+ (let ((div (divisor count-max count-min scaled-max scaled-min)))
+ (list div (offset count-min scaled-min div))))
+
+(defun final (analog-input divisor offset)
+ (+ offset (/ analog-input divisor)))
+
+(defun input (scaled-value divisor offset)
+ (* divisor (- scaled-value offset)))
--- /dev/null
+(defun cfm-circ (fpm radius) (float (* pi fpm (square (/ radius 12)))))
+
+(defun cfm-rect (fpm width height) (float (* fpm (/ width 12) (/ height 12))))
+
+(defun sat-water-press (temp)
+ (+ 0.0182795
+ (* temp 0.001029904)
+ (* (square temp) 2.579408e-05)
+ (* (cube temp) 2.400493e-07)
+ (* (^ temp 4) 8.100939e-10)
+ (* (^ temp 5) 3.256805e-11)
+ (* (^ temp 6) -1.001922e-13)
+ (* (^ temp 7) 2.44161e-16)))
+
+(defun hum-ratio (humidity swp)
+ (let ((hum-press (* (/ humidity 100.0) swp)))
+ (/ (* hum-press 0.62198) (- 14.7 hum-press))))
+
+(defun gn-water-per-lb (humidity temp)
+ (* 7000 (hum-ratio humidity (sat-water-press temp))))
--- /dev/null
+(defun mm->in (mm) (/ mm 25.4))
+
+(defun in->mm (in) (* in 25.4))
+
+(defun k->c (tempk) (- tempk 273.15))
+
+(defun c->k (tempc) (+ tempc 273.15))
+
+(defun c->f (tempc) (+ (* tempc 1.8) 32))
+
+(defun f->c (tempf) (/ (- tempf 32) 1.8))
+
+(defun k->f (tempk) (c->f (k->c tempk)))
+
+(defun f->k (tempf) (c->k (f->c tempf)))