"Given an upper and lower PLC count, return the list of upper and lower voltage."
(list (counts->volts upper) (counts->volts lower)))
-(defun divisor (raw-max raw-min scaled-max scaled-min)
+(defun divisor (counts-max counts-min engineering-max engineering-min)
"Calculate 1/slope given PLC Max/Min and Eng. Max/Min."
- (/ (float (- raw-max raw-min)) (- scaled-max scaled-min)))
+ (/ (float (- counts-max counts-min)) (- engineering-max engineering-min)))
-(defun offset (divisor scaled-min raw-min)
+(defun offset (divisor engineering-min counts-min)
"Calculate offset given Divisor and both minimums."
- (- scaled-min (/ raw-min divisor)))
+ (- engineering-min (/ counts-min divisor)))
-(defun count-scale (raw-max raw-min scaled-max scaled-min)
+(defun count-scale (counts-max counts-min engineering-max engineering-min)
"Calculate the divisor and offset, from counts and eng values."
- (let* ((div (divisor raw-max raw-min scaled-max scaled-min)))
- (list div (offset div scaled-min raw-min))))
+ (let* ((div (divisor counts-max counts-min engineering-max engineering-min))
+ (ofst (offset div engineering-min counts-min)))
+ (list div ofst)))
(defun scale (signal-max signal-min engineering-max engineering-min &optional impedance)
"Calculate the divisor and offset, from signal and eng values.
(count-range (amps->volts signal-max impedance)
(amps->volts signal-min impedance))
(count-range signal-max signal-min)))
- (pmax (car rng))
- (pmin (cadr rng)))
- (count-scale pmax pmin engineering-max engineering-min)))
+ (counts-max (car rng))
+ (counts-min (cadr rng)))
+ (count-scale counts-max counts-min engineering-max engineering-min)))
-(defun final (analog-input divisor offset)
+(defun final (counts divisor offset)
"Calculate the scaled value of an input."
- (+ (/ analog-input divisor) offset))
+ (+ (/ counts divisor) offset))
(defun input (scaled-value divisor offset)
"Calculate the input counts from a scaled value."
(defun sat-water-press (temp)
"Calculate the saturated water pressure at a temp (F)."
- (+ 0.0182795
- (* temp 0.001029904)
- (* (square temp) (E 2.579408 -5)
- (* (cube temp) (E 2.400493 -7))
+ (+ (E 1.82795 -2)
+ (* temp (E 1.029904 -3))
+ (* (^ temp 2) (E 2.579408 -5))
+ (* (^ temp 3) (E 2.400493 -7))
(* (^ temp 4) (E 8.100939 -10))
(* (^ temp 5) (E 3.256805 -11))
(* (^ temp 6) (E -1.001922 -13))
- (* (^ temp 7) (E 2.44161 -16)))))
+ (* (^ temp 7) (E 2.44161 -16))))
-(defun hum-ratio (humidity swp)
+(defun hum-press (humidity swp)
+ "Calculate the Humidity-Pressure."
+ (* (/ humidity 100.0) swp))
+
+(defun hum-ratio (humidity-pressure)
"Calulate the humidity ratio.
-Takes humidity in %RH, and a Saturated Water Pressure."
- (let ((hum-press (* (/ humidity 100.0) swp)))
- (/ (* hum-press 0.62198) (- 14.7 hum-press))))
+Takes humidity-pressure."
+ (/ (* humidity-pressure 0.62198) (- 14.7 humidity-pressure)))
(defun gn-water-per-lb (humidity temp)
"Calculate the grains of water per lb of air.
Takes humidity in %RH, and temp in F."
- (* 7000 (hum-ratio humidity (sat-water-press temp))))
+ (* 7000 (hum-ratio (hum-press humidity (sat-water-press temp)))))
(provide 're-refrigeration-defuns)
;;; re-refrigeration-defuns.el ends here