Jump to content

Electrical Panel Phase Balance Calculator LSP Lispertine


ryankevin15

Recommended Posts

Okay, here's the deal. I need a LISP that calculates phase balance which is basically percent error between two numbers in the following form. However, we need it to take a selection and find the largest number, smallest number and make the following calculation, regardless of the numbers in the set.

 

(Big - Small)/Big * 100 = X.X%

 

Currently, we use an ADD.LSP which takes a selection and adds up the numbers. I am not familiar enough with the programming in order to take this relatively simple arithmetic and make it a working LSP.

 

I have attached the ADD command if anyone is able to do something like this.

 

add.LSP

 

It should work by making a selection, then prompting the user to select where to place the phase balance (By adjusting the selected text to the updated value X.X%).

Link to comment
Share on other sites

4995gga

 

In the image above. This program, if I can ever get it to work, would work by selecting all three numbers, hitting spacebar and then selecting the number next to phase balance, and then hitting spacebar again.

Link to comment
Share on other sites

If you look in the lower right hand corner of the post you want to edit you should see the words Edit Post. Click on the phrase.

Link to comment
Share on other sites

Try this:

(defun KGA_Conv_Pickset_To_ObjectList (ss / i ret)
 (if ss
   (repeat (setq i (sslength ss))
     (setq ret (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) ret))
   )
 )
)

(defun c:PhaseBalance ( / ss numLst numMin numMax res trg)
 (if
   (and
     (princ "\nSelect source entities: ")
     (setq ss (ssget '((0 . "TEXT") (1 . "~*[~-.0-9]*") (1 . "~*`.*`.*") (1 . "~?*-*"))))
     (setq trg (car (entsel "\nSelect target entity: ")))
     (= "AcDbText" (vla-get-objectname (setq trg (vlax-ename->vla-object trg))))
   )
   (progn
     (setq numLst
       (mapcar
         '(lambda (obj) (read (vla-get-textstring obj)))
         (KGA_Conv_Pickset_To_ObjectList ss)
       )
     )
     (setq numMin (apply 'min numLst))
     (setq numMax (apply 'max numLst))
     ;; Formula: (Big - Small)/Big * 100 = X.X%
     (setq res (strcat (rtos (/ (- numMax numMin) numMax 0.01) 2 1) "%"))
     (princ (strcat "\nPhase Balance: "  res))
     (vla-put-textstring trg res)
   )
 )
 (princ)
)

Link to comment
Share on other sites

Can you make one that takes a total wattage from a panel and divides it by 360 to find the amperage? I'd call it like 360 or something. Wow, still very amazed that you coded that!

Link to comment
Share on other sites

  • 2 weeks later...

Roy_043,

 

Could you potentially make a lisp that takes a value (total demand in Watts) and divide by 360 for 208V for total demand amps? Also, when using 480V we divide by 831. These two lisps will make things much quicker. And also, in the phase balance lips, is there any rounding applied to that value? Did you make the phase balance one yourself or just happened to already have it?

Edited by ryankevin15
Link to comment
Share on other sites

Roy_043,

 

Could you potentially make a lisp that takes a value (total demand in Watts) and divide by 360 for 208V for total demand amps? Also, when using 480V we divide by 831. These two lisps will make things much quicker. And also, in the phase balance lips, is there any rounding applied to that value? Did you make the phase balance one yourself or just happened to already have it?

 

If you just want to change the decimal place accuracy of the output, take a look at the RTOS function in Roy_043's code.

 

http://ronleigh.com/autolisp/afude12.htm#rtos

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...