Jump to content

Ohm's Law Calculator


The Buzzard

Recommended Posts

In your statement:

 

 (action_tile "sFN"                                                           ;When action_tile sFN is selected
  "(setq IMG $value)                                                          ;Set variable IMG ~ (Image) to list value
   (itoa 0)                                                                   ;Return the conversion of an integer into a string 
   (OLC_UFI)"                                                                 ;Go to OLC_UFI Image Function

Upon the user changing the tile with key "SFN", you are setting the variable "IMG" to the value of the tile ($value).

 

Then, you have a stand-along statement (itoa 0), which is not being set to any variable, nor is it having any impact on the program - it is just another calculation for the computer to process.

 

Then, you invoke your program: "OLC_UFI" which uses the value assigned to "IMG" to determine which image to display.

Link to comment
Share on other sites

  • Replies 104
  • Created
  • Last Reply

Top Posters In This Topic

  • The Buzzard

    56

  • Lee Mac

    29

  • CAB

    11

  • SEANT

    3

Top Posters In This Topic

Posted Images

Not keeping up with all the thread talk but I updated My version 4 with changed to the DCL file

and lisp. The functions have been Incorporated to keep variables local and some variables renamed.

 

Alan, the call to the DCL file within the LISP needs to be changed to suit the DCL filename :wink:

Link to comment
Share on other sites

Not keeping up with all the thread talk but I updated My version 4 with changed to the DCL file

and lisp. The functions have been Incorporated to keep variables local and some variables renamed.

 

Thanks CAB I will review it. At the moment I am out of it.

Not much in the way of sleep lately.

Link to comment
Share on other sites

Thanks CAB I will review it. At the moment I am out of it.

Not much in the way of sleep lately.

 

CAB,

I noticed you do not have the latest change to the calculations.

there were a couple of missing abs that were fixed.

 

;;; F03 - Calculate Function - Calculate All Inputs.                           ;Describe function
(defun OLC_CAI ()                                                              ;Define function
 (setq c$plex "" S:FN (nth S:FN SFN_list))                                    ;Return the nth element of the list 
 (setq SFN S:FN)                                                              ;Set SFN from value of S:FN
 (cond                                                                        ;If one of the following conditions apply
   ((or                                                                       ;Return the logical OR of a list of expressions
      (and                                                                    ;Return the logical AND of the supplied arguments
        (member SFN '("1" "4" "6"))                                           ;Search list for an occurrence of an expression 
        (zerop KV4)                                                           ;Verify that a number evaluates to zero 
      )                                                                       ;End and
      (and                                                                    ;Return the logical AND of the supplied arguments
        (= SFN "5")                                                           ;SFN ~ (Select Formula No.) = 5
        (zerop KV3)                                                           ;Verify that a number evaluates to zero 
      )                                                                       ;End and
      (and                                                                    ;Return the logical AND of the supplied arguments
        (member SFN '("3" "8" "10" "12"))                                     ;Search list for an occurrence of an expression 
        (zerop KV2)                                                           ;Verify that a number evaluates to zero 
      )                                                                       ;End and
      (and                                                                    ;Return the logical AND of the supplied arguments
        (= SFN "11")                                                          ;SFN ~ (Select Formula No.) = 11
        (zerop KV1)                                                           ;Verify that a number evaluates to zero 
      )                                                                       ;End and
    )                                                                         ;End or
    (OLC_DBZ)                                                                 ;Goto OLC_DBZ Error Function
   )
   ((= "1" SFN)                                                               ;SFN ~ (Select Formula No.) = 1
    (setq E KV3 R KV4 I (/ E R) P (/ (* E E) R)))                             ;Calculate I ~ (Current) & P ~ (Power)
   ((= "2" SFN)                                                               ;SFN ~ (Select Formula No.) = 2
    (setq I KV2 R KV4 E (* R I) P (* I I R)))                                 ;Calculate E ~ (Voltage) & P ~ (Power)
   ((= "3" SFN)                                                               ;SFN ~ (Select Formula No.) = 3
    (setq E KV3 I KV2 R (/ E I) P (* E I)))                                   ;Calculate R ~ (Resistance) & P ~ (Power)
   ((= "4" SFN)                                                               ;SFN ~ (Select Formula No.) = 4     
    (setq P KV1 R KV4 E (sqrt (abs (* P R))) I (sqrt (abs (/ P R))))          ;Calculate E ~ (Voltage) & I ~ (Current)
    (and (minusp (* P R)) (setq c$plex "i")))
   ((= "5" SFN)                                                               ;SFN ~ (Select Formula No.) = 5
    (setq P KV1 E KV3 R (/ (* E E) P) I (/ P E)))                             ;Calculate R ~ (Resistance) & I ~ (Current)
   ((= "6" SFN)                                                               ;SFN ~ (Select Formula No.) = 6
    (setq E KV3 R KV4 P (/ (* E E) R) I (/ E R)))                             ;Calculate P ~ (Power) & I ~ (Current)
   ((= "7" SFN)                                                               ;SFN ~ (Select Formula No.) = 7
    (setq I KV2 R KV4 P (* I I R) E (* R I)))                                 ;Calculate P ~ (Power) & E ~ (Voltage)
   ((= "8" SFN)                                                               ;SFN ~ (Select Formula No.) = 8
    (setq P KV1 I KV2 R (/ P (* I I)) E (/ P I)))                             ;Calculate R ~ (Resistance) & E ~ (Voltage)
   ((= "9" SFN)                                                               ;SFN ~ (Select Formula No.) = 9     
    (setq P KV1 R KV4 I (sqrt (abs (/ P R))) E (sqrt (abs (* P R))))          ;Calculate I ~ (Current) & E ~ (Voltage)
    (and (minusp (* P R)) (setq c$plex "i"))) 
   ((= "10" SFN)                                                              ;SFN ~ (Select Formula No.) = 10
    (setq E KV3 I KV2 P (* E I) R (/ E I)))                                   ;Calculate P ~ (Power) & R ~ (Resistance)
   ((= "11" SFN)                                                              ;SFN ~ (Select Formula No.) = 11
    (setq P KV1 E KV3 I (/ P E) R (/ (* E E) P)))                             ;Calculate I ~ (Current) & R ~ (Resistance)
   ((= "12" SFN)                                                              ;SFN ~ (Select Formula No.) = 12
    (setq P KV1 I KV2 E (/ P I) R (/ P (* I I))))                             ;Calculate E ~ (Voltage) & R ~ (Resistance)
 )                                                                            ;End cond
 (OLC_DCO)                                                                    ;Go to OLC_DCO Output Function
)                                                                              ;End define function
;;;////////////////////////////////////////////////////////////////////////////

Link to comment
Share on other sites

Alan, the call to the DCL file within the LISP needs to be changed to suit the DCL filename :wink:

Thanks Lee, file & ZIP updated.

Link to comment
Share on other sites

CAB,

I noticed you do not have the latest change to the calculations.

there were a couple of missing abs that were fixed.

I think I do.

Notice I revised the section changing SFN$ to base zero!

Eliminated the use of variables kV1 through kV4.

Added some error checks for user input incase user enters invalid characters.

Link to comment
Share on other sites

I think I do.

Notice I revised the section changing SFN$ to base zero!

Eliminated the use of variables kV1 through kV4.

Added some error checks for user input incase user enters invalid characters.

CAB,

 

The square root functions 4 & 9 are not working properly. I took a look at the calculation function and the calcs for 9 seem to be in 8. There is some sort of mixup going on there. Calc 8 of does not work either.

 

Just thought I would point that out.

Link to comment
Share on other sites

CAB,

 

The square functions 4 & 9 are not working properly. I took a look at the calculation function and the calcs for 9 seem to be in 8. There is some sort of mixup going on there. Calc 8 of does not work either.

 

Just thought I would point that out.

 

Tested the rest. Calc formulas 5, 11 & 12 are also not working.

Link to comment
Share on other sites

Sorry, missplaced a paren.

Please try this file.

 

 

Ok it checks out. The reason I was confused is your using the list position values 0 thru 11 where I use SNF variable value 1 thru 12. It makes sense to me now.

Link to comment
Share on other sites

Attention to All,

 

Version 5 of the Ohm's Law Calculator Lisp has been posted to the first post. This version has some major improvements that were implemented by CAB. A revision list has also been posted.

 

Great work CAB

 

Thanks and enjoy the program,

The Buzzard

Link to comment
Share on other sites

Glad to have been of some assistance.

I see you didn't care for the 'sub assembly definitions' in my version 4 DCL.:)

 

Actually I did like it, But I am very familar with my method at the moment. I plan to read up on your method and become more comfortable with. Thank for the help. These codes I have been working on are not for me, But for the membeship here. I get more learning experience making an attempt at these codes with the level of knowledge that I have. I am very glad people here are willing to help each other. I hope to get better at this stuff in the future.

This was a very interesting thread to say the least. It had a bit of eveything in it.

 

Thanks,

The Buzzard

Link to comment
Share on other sites

  • 8 months later...

With the first formula selected you need to supply values in E and R.

You put values in E & P, So you will get a divide by zero error.

When ever you select a formula, You need to supply the two value you

have selected in their proper boxes.

Link to comment
Share on other sites

  • 2 weeks later...

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...