06-19-2014, 03:46 PM (This post was last modified: 06-20-2014 08:39 AM by Ángel Martin.)
Post: #1
 Ángel Martin Senior Member Posts: 1,263 Joined: Dec 2013
Like me, you may have also missed the excellent article in the old forum by Guillermo Castarés with programs to solve electric circuits:

http://www.hpmuseum.org/software/41/41elcirc.htm

The approached he followed was remarkable in two aspects – first it had a precise usage of the PVT routine from the Math Pac using complex matrices; which wasn’t documented at all in the flimsy manual that was provided with that module.

More interesting was his idea of using ASCII files to define the circuit topology: type, elements, values, etc. This approach allows a very effective use of the system capabilities, without the need to re-enter all data each time allowing quick what-if scenarios for component value changes.

Not to mention that you could build up a library of circuits in X-memory very nicely. For example, these are the files for the Math Pac and the Advantage Pac manuals (Remember student “AC Dimmer”?), listed with their respective solutions.

Code:
 MPAC        ACDIM I4        0    I2 0V1 34 0    1    0V1 5 0 0R1 1        2    0Z1 10 1R2 1        3    1Z2 0 200 0R2 1        4    0Z2 0 -30 2R3 1        5    END 0R3 1             3R4 1        I1 = 0.0372 + 0.1311 0R4 2        I2 = 0.0437 + 0.1543 END                          I1 = 21             I2 = 8             I3 = 3             I4 = 1

I’ve taken the opportunity to update the program, replacing the PVT call with the much faster MSYS in the Advantage Pac (or in the SandMatrix, of course); an splendid example of the MCODE advantages.

And to round up the task a new data-entry program is also provided, which builds the ASCII file from the scratch in an interactive way just entering the information in the prompts.

The new data-entry program “EEE” is completely independent, and its end result is an ASCII file to use as input for “EEA”, the circuit solver program.

Raw files are attached if you want to take them for a spin. Note that they use functions form the AMC_OSX module for a more convenient UI – but you can replace them with those in the CCD with the same names.

Code:
 1    LBL "EEE"  2    "NAME? "  3    PMTA 4    15 5    SF 25 6    CLFL 7    FC?C 25 8    CRFLAS 9    , 10    SEEKPTA 11    "TYPE? VI"  12    PMTK 13    CF 02 14    E  15    X#Y? 16    SF 02 17    "V" 18    FS? 02 19    "I" 20    CLA 21    XTOA 22    APPREC 23    "#NODE"  24    FS? 02 25    "#LOOP"  26    "|-S=?"  27    PROMPT 28    STO 02 29    CLA 30    ARCLI 31    APPCHR 32    "ELMNTS=?"  33    PROMPT 34    E3/3+ 35    STO 00 36    LBL 00 37    CF 00 38    CLA 39    RCL 00 40    ARCLI 41    "|-: "  42    FC? 02 43    "|-I" 44    FS? 02 45    "|-V" 46    "|-RGLCXBYZY" 47    PMTK 48    XEQ IND X 49    STO 01 50    LBL 12 51    "FROM^TO=?"  52    PROMPT 53    X=Y? 54    GTO 12 55    RCL 02 56    X<Y? 57    GTO 12 58    X<> Z 59    RCL 02 60    X<Y? 61    GTO 12 62    RDN 63    XEQ 10 64    0 65    "VALUE=?"  66    FS? 00 67    "IM^RE=?" 68    PROMPT 69    XEQ 11 70    FS? 00 71    XEQ 11 72    ISG 00 73    GTO 00 74    "END" 75    APPREC 76    RTN 77    LBL 01 78    SF 00 79    86 80    FC? 02 81    73 82    RTN 83    LBL 02 84    82 85    RTN 86    LBL 03 87    71 88    RTN 89    LBL 04 90    76 91    RTN 92    LBL 05 93    67 94    RTN 95    LBL 06 96    88 97    RTN 98    LBL 07 99    66 100    RTN 101    LBL 08 102    SF 00 103    90 104    RTN 105    LBL 09 106    SF 00 107    89 108    RTN 109    LBL 10 110    CLA 111    ARCLI 112    RCL 01 113    XTOA 114    X<> Z 115    ARCLI 116    "|- "  117    APPREC 118    RTN 119    LBL 11 120    CF 01 121    CLA 122    FRC 123    X=0? 124    SF 01 125    X<> L 126    FS? 01 127    ARCLI 128    FC? 01 129    ARCL X 130    "|- " 131    APPCHR 132    X<>Y 133    END          289 bytes

Modified EEA Program follows - maintains the same logic as the original to read the circuit file and create the system matrices, only slightly modified the data output routine to account for the differences between PVT and MSYS. Refer to the original article for user instructions and documentation.

Code:
 1    LBL " EEA" 2    CLRG 3    CLX 4    SEEKPTA 5    GETREC 6    ATOX 7    STO 09 8    ANUM 9    ST+ X 10    STO 14 11    X^2 12    LASTX 13    ST+ X 14    + 15    15 16    + 17    SF 25 18    ARCL IND X 19    FC?C 25 20    PSIZE 21    SF 00 22    SF 01 23    LBL 08 24    GETREC 25    AVIEW 26    ATOX 27    48 28    - 29    STO 00 30    ATOX 31    STO 07 32    ATOX 33    48 34    - 35    STO 01 36    ANUM 37    STO 02 38    ATOX 39    LBL 09 40    ATOX 41    44 42    X<=Y? 43    GTO 09 44    CLX 45    ANUM 46    STO 03 47    CLA 48    RCL 09 49    XTOA 50    "|-ELS" 51    ASTO X 52    XEQ IND X 53    FC? 00 54    GTO 07 55    FS? 02 56    XEQ 01 57    FC? 02 58    XEQ 03 59    GTO 08 60    LBL 07 61    "WAIT…"  62    AVIEW 63    RCL  14 64    X^2 65    LASTX 66    + 67    14 68    + 69    STO 00 70    "R" 71    AIP 72    RCL 14 73    2E-3 74    + 75    MATDIM 76    RCL 14 77    E3 78     / 79    RCL 14 80    STO 13 81    + 82    ASTO 12 83    "R14" 84    MATDIM 85    "|-," 86    ARCL 12 87    MSYS 88    LBL 10 89    RCL 13 90    2E3 91     / 92    E  93    + 94    STO 01 95    LBL 12 96    RCL 00 97    RCL 01 98    ST+ X 99    E 100    - 101    + 102    STO 02 103    CLA 104    RCL 09 105    XTOA 106    RCL 01 107    AIP 108    ASTO 10 109    "|-(RE)=" 110    ARCL IND 02 111    PROMPT 112    CLA 113    ARCL 10 114    "|-(IM)=" 115    RCL 13 116    RCL 02 117    + 118    ARCL IND X 119    PROMPT 120    ISG 01 121    GTO 12 122    GTO 10 123    ….     the rest is as the original      [code]

Hope you enjoy it - Many thanks to Guillermo for the original contribution!

Attached File(s)
01-24-2018, 01:43 PM
Post: #2
 damaltor Member Posts: 240 Joined: Dec 2015
RE: 41 Electric Circuits - Reloaded
Hey,

i am trying to bring this on my calculator. Two questions:

in the EEA program, there are some lines with "E", for example Line 77: E3. is this "1E3", as in 1 EEX 3?
Also in line 92, there is a single "E". is this the EEX key, and if so why do you use it in this place?

secondly, the EEE program uses "PMTK" and "PMTA". I guess these are CCD module functions. is there a good way to replace them with standard, advanced, or ex.func functions?

thanks!
01-24-2018, 02:49 PM
Post: #3
 rprosperi Senior Member Posts: 5,069 Joined: Dec 2013
RE: 41 Electric Circuits - Reloaded
(01-24-2018 01:43 PM)damaltor Wrote:  in the EEA program, there are some lines with "E", for example Line 77: E3. is this "1E3", as in 1 EEX 3?
Also in line 92, there is a single "E". is this the EEX key, and if so why do you use it in this place?

These are synthetic commands, which are both shorter and faster than the 'normal' version of their respective commands, but otherwise functionally the same. You can enter them the normal way and the program will work the same. E3 is the same as 1.00E3 ([1] [EEX] [3]), E is 1.00E1, etc.

Any of the normal synthetic resources can explain how to create these commands, but likely it's not worth the effort (though it is fun).

--Bob Prosperi
01-24-2018, 04:30 PM (This post was last modified: 01-24-2018 04:32 PM by Massimo Gnerucci.)
Post: #4
 Massimo Gnerucci Senior Member Posts: 2,377 Joined: Dec 2013
RE: 41 Electric Circuits - Reloaded
(01-24-2018 02:49 PM)rprosperi Wrote:
(01-24-2018 01:43 PM)damaltor Wrote:  in the EEA program, there are some lines with "E", for example Line 77: E3. is this "1E3", as in 1 EEX 3?
Also in line 92, there is a single "E". is this the EEX key, and if so why do you use it in this place?

E is 1.00E1, etc.

E is 1E0=1, methinks

Greetings,
Massimo

-+×÷ ↔ left is right and right is wrong
01-24-2018, 08:04 PM
Post: #5
 rprosperi Senior Member Posts: 5,069 Joined: Dec 2013
RE: 41 Electric Circuits - Reloaded
(01-24-2018 04:30 PM)Massimo Gnerucci Wrote:
(01-24-2018 02:49 PM)rprosperi Wrote:  E is 1.00E1, etc.

E is 1E0=1, methinks
4

Youthinks correctly, my mistake. E = 1E0 = [1] [EEX] [0].

Sorry 'bout that.

--Bob Prosperi
01-26-2018, 08:20 AM (This post was last modified: 01-26-2018 08:21 AM by damaltor.)
Post: #6
 damaltor Member Posts: 240 Joined: Dec 2015
RE: 41 Electric Circuits - Reloaded
Ok, great. Thank you very much.

I had a second problem: I could not get the command MSYS into barcode form with the barcode generator at http://rwiker.github.io/hp41barcode/# because the command was not recognized. after looking through the source code of the barcode generator, i found out that the command was coded as MSVS instead of MSYS. i wondered why that would be the case, and found that the error is already present in the "official" xrom code list:
http://www.hpmuseum.org/software/xroms.htm
after googling around i found that spelling error in some other locations too, probably picked up from the hpmuseum xrom list. i wonder why that mistake was never found?

i will replace the synthetics with the "usual" commands, thats fine for me still, how about PMTK and PMTA and such? as far as i recognize they are just alpha mode addons, which probably arent even really needed for the program to run and can be replaced by simpler commands, but if there are known direct replacements i would be happy to use them.
11-28-2018, 07:39 PM
Post: #7
 morex Junior Member Posts: 18 Joined: Nov 2018
RE: 41 Electric Circuits - Reloaded
Hello Ángel Martin and everybody.

I'm here again after several years and I just discoverer your kind words about my old electric circuit program.

Happy that someone found it interesting or useful.

Thanks a Lot.
You did my day!

Regards.
Guillermo Castarés
12-11-2018, 10:26 AM
Post: #8
 Ángel Martin Senior Member Posts: 1,263 Joined: Dec 2013
RE: 41 Electric Circuits - Reloaded
(11-28-2018 07:39 PM)morex Wrote:  Happy that someone found it interesting or useful.
Thanks a Lot.
You did my day!

It's great to have you back, many thanks again for sharing your original work.

Saludos,
ÁM
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)