zeabrah’s lair

14 June, 2008

leakage in R-chain

Filed under: dev — Tags: , — alexeybrazhe @ 11:01 pm

From time to time I will post here some little code snippets from what I write.
All code is under GPL ;)

This time it is a leakage resitance calculator:


(defun make-R-elem (R1 R2)
  (list R1 R2))

(defun axial-R (elem)
  (car elem))

(defun leak-R (elem)
  (cadr elem))

(defun make-R-chain (axial leak &key (number 10))
  (do ((chain nil)
       (n 0  (1+ n)))
      ((> n number) (nreverse chain))
    (push (make-R-elem axial leak) chain)))

(defun leak-resistance (chain)
 "Leakage resistanse of the repeated  circut:
       o---/\/\/\---+------o
         R1 (axial) |
                    /
                    \
                    / R2 (leakage)
                    \
                    /
                    |
                   --- Gnd
   elements are in a list: ((R1 R2) (R1 R2))
  "
  (let ((elem (car chain)))
   (if (null (cdr chain))
    (+ (axial-R elem) (leak-R elem))
    (+ (axial-R elem)
       (/ 1.0 (+ (/ 1.0 (leak-R elem))
                 (/ 1.0 (leak-resistance (cdr chain)))))))))

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.