(defun eff-imp (r1 &optional r2)
"Calculate the effective input impedance, given two resistances.
-For use in `amps->volts' and related. The handling of only one
-resistance given is done here, instead of doing it in every
-function that uses this."
- (if (eq nil r2)
- r1
- (inv (+ (inv r1) (inv r2)))))
+For use in `amps->volts' and related."
+ (inv (+ (inv r1) (inv r2))))
-(defun amps->volts (amps r1 &optional r2)
+(defun amps->volts (amps imp)
"Calculate the voltage, given amperage and impedance.
Multiplies the amperage by the effective impedance calculated
with `eff-imp'."
- (* amps (eff-imp r1 r2)))
+ (* amps imp))
-(defun volts->amps (volts r1 &optional r2)
+(defun volts->amps (volts imp)
"Calculate the amperage, given voltage and impedance.
Divides the voltage by the effective impedance calculated with
`eff-imp'."
- (/ volts (eff-imp r1 r2)))
+ (/ volts imp))
(provide 're-electronics-defuns)
;;; re-electronics-defuns.el ends here
(visual-fill-column-enable-sensible-window-split t))
(keymap-global-set "C-c v"
- (lambda nil
- (interactive)
- (visual-fill-column-mode 'toggle)))
+ (lambda nil
+ (interactive)
+ (visual-fill-column-mode 'toggle)))
(use-package corfu
:ensure
:config
(openwith-mode t)
(setq openwith-associations
- (list (list (openwith-make-extension-regexp
- '("xls" "xlsx" "doc" "docx" "ppt" "pptx" "odt" "ods" "odg" "odp"))
- "libreoffice"
- '(file)) ; Windows falls back to system default
- (list (openwith-make-extension-regexp
- '("adpro"))
- "ProductivitySuite"
- '(file))
- (list (openwith-make-extension-regexp
- '("pdf"))
- "zathura"
- '(file))))) ; Windows falls back to ms-office
+ (list (list (openwith-make-extension-regexp
+ '("xls" "xlsx" "doc" "docx" "ppt" "pptx" "odt" "ods" "odg" "odp"))
+ "libreoffice"
+ '(file)) ; Windows falls back to system default
+ (list (openwith-make-extension-regexp
+ '("adpro"))
+ "ProductivitySuite"
+ '(file))
+ (list (openwith-make-extension-regexp
+ '("pdf"))
+ "zathura"
+ '(file))))) ; Windows falls back to ms-office
(use-package auctex :ensure t :defer t)
(slime-net-coding-system 'utf-8-unix))
(add-hook 'slime-mode-hook
- (lambda nil (unless (slime-connected-p) (save-excursion (slime)))))
+ (lambda nil (unless (slime-connected-p) (save-excursion (slime)))))
(use-package paredit :ensure t :bind (("C-c p" quote paredit-mode)))
(defvar *plc-resolution* 16)
(defvar *plc-max-voltage* 10.0)
-(defun P3K ()
- (setq *plc-resolution* 16
- *plc-max-voltage* 10.0))
+(defun 16B () (setq *plc-resolution* 16
+ *plc-max-voltage* 10.0))
-(defun SLC ()
- (setq *plc-resolution* 16
- *plc-max-voltage* 10.0))
+(defun 13B () (setq *plc-resolution* 13
+ *plc-max-voltage* 10.0))
-(defun P1K ()
- (setq *plc-resolution* 16
- *plc-max-voltage* 10.0))
-
-(defun DL4 ()
- (setq *plc-resolution* 13
- *plc-max-voltage* 10.0))
+(defalias 'P3K '16B)
+(defalias 'SLC '16B)
+(defalias 'P1K '13B)
+(defalias 'DL4 '13B)
(defun max-counts (resolution)
"Calculate the max count for a PLC analog, given card's bit-resolution."
Calculates a ratio of cin/`max-counts', then multiplies by vmax."
(* (/ cin (max-counts *plc-resolution*)) *plc-max-voltage*))
-(defun amps->counts (amps r1 &optional r2)
+(defun amps->counts (amps imp)
"Convert a current signal to PLC Counts.
-Converts the amperage to a voltage using `amps->volts' (with r1
-and optional r2), then applies `volts->counts' to the resulting
-voltage, vmax, and resolution."
- (volts->counts *plc-max-voltage* (amps->volts amps r1 r2) *plc-resolution*))
+Converts the amperage to a voltage using `amps->volts',then applies
+ `volts->counts' to the resulting voltage,vmax, and resolution."
+ (volts->counts *plc-max-voltage* (amps->volts amps imp) *plc-resolution*))
(defun count-range (upper lower)
"Given an upper and lower voltage, return the list of upper and lower PLC counts."
;;; Code:
(require 're-math-defuns)
-
-;; Unit wendings
-
-;;; Leŋþ
-(defun mm->in (mm)
- "Convert milimeters to inches."
- (/ mm 25.4))
-
-(defun in->mm (in)
- "Convert inches to milimeters."
- (* in 25.4))
-
-;;; Heat
-(defun k->c (tempk)
- "Convert degrees Kelvin to degrees Celsius."
- (- tempk 273.15))
-
-(defun c->k (tempc)
- "Convert degrees Celsius to degrees Kelvin."
- (+ tempc 273.15))
-
-(defun c->f (tempc)
- "Convert degrees Celsius to degrees Fahrenheit."
- (+ (* tempc 1.8) 32.0))
-
-(defun f->c (tempf)
- "Convert degrees Fahrenheit to degrees Celsius."
- (/ (- tempf 32.0) 1.8))
-
-(defun k->f (tempk)
- "Convert degrees Kelvin to degrees Fahrenheit.
-Applies `c->f' to `k->c'."
- (c->f (k->c tempk)))
-
-(defun f->k (tempf)
- "Convert degrees Fahrenheit to degrees Kelvin.
-Applies `c->k' to `f->c'."
- (c->k (f->c tempf)))
-
-;;; Pressure
-(defun bar->psi (bar)
- "Convert bar to psi."
- (* 14.5 bar))
-
-(defun psi->bar (psi)
- "Convert psi to bar."
- (/ psi 14.5))
-
-(defun kpa->psi (kpa)
- "Convert kpa to psi."
- (* 6.89 kpa))
-
-(defun psi->kpa (psi)
- "Convert psi to kpa."
- (/ psi 6.89))
-
-(defun mmhg->psi (mmhg)
- "Convert mmhg to psi."
- (/ mmhg 51.71))
-
-(defun psi->mmhg (psi)
- "Convert psi to mmhg."
- (* 51.71 psi))
-
-(defun inhg->psi (inhg)
- "Convert inhg to psi."
- (mmhg->psi (in->mm inhg)))
-
-(defun psi->inhg (psi)
- "Convert psi to inhg."
- (mm->in (psi->mmhg psi)))
-
-;;; Weight
-(defun g->oz (grams)
- "Convert grams to ounces."
- (/ grams 28.34))
-
-(defun oz->g (ounces)
- "Convert ounces to grams."
- (* ounces 28.34))
-
-(defun kg->lb (kilograms)
- "Convert kilograms to pounds."
- (* kilograms 2.2))
-
-(defun lb->kg (pounds)
- "Convert pounds to kilograms."
- (/ pounds 2.2))
+(require 're-unit-conversions)
;; Cooling
(defun cfm-circ (fpm radius)
--- /dev/null
+;;; re-unit-conversions.el -*- lexical-binding: t; -*-
+;; This file is not part of GNU Emacs
+
+;;; Code:
+
+(require 're-math-defuns)
+
+;; Leŋþ
+(defun mm->in (mm)
+ "Convert milimeters to inches."
+ (/ mm 25.4))
+
+(defun in->mm (in)
+ "Convert inches to milimeters."
+ (* in 25.4))
+
+;; Heat
+(defun k->c (tempk)
+ "Convert degrees Kelvin to degrees Celsius."
+ (- tempk 273.15))
+
+(defun c->k (tempc)
+ "Convert degrees Celsius to degrees Kelvin."
+ (+ tempc 273.15))
+
+(defun c->f (tempc)
+ "Convert degrees Celsius to degrees Fahrenheit."
+ (+ (* tempc 1.8) 32.0))
+
+(defun f->c (tempf)
+ "Convert degrees Fahrenheit to degrees Celsius."
+ (/ (- tempf 32.0) 1.8))
+
+(defun k->f (tempk)
+ "Convert degrees Kelvin to degrees Fahrenheit.
+Applies `c->f' to `k->c'."
+ (c->f (k->c tempk)))
+
+(defun f->k (tempf)
+ "Convert degrees Fahrenheit to degrees Kelvin.
+Applies `c->k' to `f->c'."
+ (c->k (f->c tempf)))
+
+;; Pressure
+(defun bar->psi (bar)
+ "Convert bar to psi."
+ (* 14.5 bar))
+
+(defun psi->bar (psi)
+ "Convert psi to bar."
+ (/ psi 14.5))
+
+(defun kpa->psi (kpa)
+ "Convert kpa to psi."
+ (* 6.89 kpa))
+
+(defun psi->kpa (psi)
+ "Convert psi to kpa."
+ (/ psi 6.89))
+
+(defun mmhg->psi (mmhg)
+ "Convert mmhg to psi."
+ (/ mmhg 51.71))
+
+(defun psi->mmhg (psi)
+ "Convert psi to mmhg."
+ (* 51.71 psi))
+
+(defun inhg->psi (inhg)
+ "Convert inhg to psi."
+ (mmhg->psi (in->mm inhg)))
+
+(defun psi->inhg (psi)
+ "Convert psi to inhg."
+ (mm->in (psi->mmhg psi)))
+
+;; Weight
+(defun g->oz (grams)
+ "Convert grams to ounces."
+ (/ grams 28.34))
+
+(defun oz->g (ounces)
+ "Convert ounces to grams."
+ (* ounces 28.34))
+
+(defun kg->lb (kilograms)
+ "Convert kilograms to pounds."
+ (* kilograms 2.2))
+
+(defun lb->kg (pounds)
+ "Convert pounds to kilograms."
+ (/ pounds 2.2))
+
+(provide 're-unit-conversions)
+;;; re-unit-conversions.el ends here