[comp.sys.handhelds] Parallel Resistor Calculator

sandy47@.ucsc.edu (Larry McElhiney) (03/01/91)

Don't you just hate it when you post a program (groan) and find a bug
in it two hours later??? Well at least I'm in good company lately *:-).

Please reload the new version 1.2 of PARAL, and happy computing!

Apologies to the Bandwidth watchers.

----------------------------------------------------------------------

The following HP48 program which finds parallel resistance elements 
will be useful for both electronics technicians and hobbyests. 

USE:  Put the value of the resistance you want on the stack and press 
PARAL (softkey 'A' in the 'CST' menu). PARAL presents a list of values 
(standard 1%) which when paralleled will yield the desired value. The 
accuracy of each combination is also displayed. The required accuracy 
is specified by the variable ACCU.  The soft key ACCUR ('B') stores 
and retrieves this accuracy variable. 

Pressing any key while PARAL is running will advance the display to 
the next 'page' of values. The previous 'page' may be displayed by 
pressing the soft key PREV ('E'). The program may be exited by 
pressing softkey QUIT ('F'). Note that the soft key functions will not 
be visible during the execution of the program but will continue to 
function normally. 

THEORY:  PARAL uses an equation derived with the HP48 from a list of 
valid 1% values.  This list was created using the formula 

            INV(96)
    X = X*10        for all values between 1 ohm and 1 G ohm

                                0.0239852613838*X
The HP48 found  0.976300098965*e                  

This equation and its inverse form the basis of PARAL. When X is any 
integer a unique one percent value will be found. The values created 
with this equation must then be rounded to 3 digits in order to 
represent the standard one percent value set. The inverse of this 
equation creates n 'bins' which, when integer, represent the nth one 
percent value.    

PARAL is accurate to at least 4 decimal places for all values 
from 1 ohm to 9.76E499 ohms (now that's a big resistor *:-)). 

SPECIAL LOADING INSTRUCTIONS: 

The GROB element must be edited and turned into a single line 
before it can be loaded into the calculator.  If you are loading
this program by hand :( get a cable! (or create a blank GROB and
store in in BLNK -> #130d #63d BLANK 'BLNK' STO).

---

%%HP: T(3)A(D)F(.); 

@ PARAL - Large Version L. Hoppis 2/25/91 DONE Rev 1.2

DIR

  RPAR
    \<< DUP .976300098965 / LN 2.39852613838E-2 / CEIL 1 +
      RCLF -49 CF -50 CF -40 CF \-> r x f
      \<< PICT { # 0d # 0d } BLNK REPL { # 0d # 0d } PVIEW 
        x 'INDX' STO 0 'y' STO
        DO INDX 2.39852613838E-2 * EXP .976300098965 * DUP 
          MANT 2 RND SWAP XPON ALOG * DUP 
          r OVER * SWAP r - / 
          .976300098965 / LN 2.39852613838E-2 / 
          IF DUP FP .5 <
            THEN FLOOR
            ELSE CEIL
            END 
          2.39852613838E-2 * EXP .976300098965 * DUP 
          MANT 2 RND SWAP XPON ALOG * DUP2 DUP2 
          * ROT ROT + / r %CH
          IF ABS DUP ACCU <
            THEN 2 RND \->STR " %  -- " + ROT DSP " || " + 
              ROT DSP + + PICT SWAP 1 \->GROB # 16d y # 7d 
              * # 2d + 2 \->LIST SWAP GOR
            ELSE 3 DROPN
            END 'y' 1 STO+ 'INDX' 1 STO+
          IF y 8 >
            THEN 0 'y' STO TONE 0 WAIT
              CASE DUP 15.1 == 
                THEN
                  IF x 9 + INDX <
                    THEN 'INDX' 18 STO-
                    END
                END
              END PICT { # 0d # 0d } BLNK REPL
            ELSE 0
            END
        UNTIL 16.1 ==
        END 'y' PURGE f STOF r
      \>>
    \>>

  DSP
    \<< DUP MANT SWAP XPON
        CASE 
          DUP 6 \>=
            THEN 6 - "M\GW"
            END 
          DUP 3 \>=
            THEN 3 - "k\GW"
            END " \GW"
          END SWAP ALOG ROT * \->STR
        CASE 
          DUP SIZE 2 <
            THEN ".00" +
            END 
          DUP SIZE 3 <
            THEN ".0" +
            END 
          DUP SIZE 4 <
            THEN 
              IF DUP "." POS
                THEN "0" +
                END
            END
          END SWAP +
    \>>

  TONE
    \<< 5000 .02 BEEP 3000 .01 BEEP\>>

  ACCU .5

  INDX 299

  BLNK GROB 131 64 
     FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7010000000000000000000000000000000401
     000000000000000000000000000000040100000000000000000000000000000004010
     000000000000000000000000000000401000000000000000000000000000000040100
     00000000000000000000000000000401000000000000000000000000000000E401000
     0000000000000000000000000002401000000000000000000000000000000E4010000
     000000000000000000000000002401000000000000000000000000000000E40100000
     000000000000000000000000004010000000000000000000000000000002401000000
     000000000000000000000000240100000000000000000000000000000024010000000
     000000000000000000000002401000000000000000000000000000000E40100000000
     000000000000000000000004010000000000000000000000000000002401000000000
     000000000000000000000240100000000000000000000000000000024010000000000
     000000000000000000002401000000000000000000000000000000240100000000000
     000000000000000000004010000000000000000000000000000002501000000000000
     0000000000000000006501000000000000000000000000000000E5010000000000000
     00000000000000000A501000000000000000000000000000000250100000000000000
     00000000000000000401000000000000000000000000000000E401000000000000000
     0000000000000002401000000000000000000000000000000E4010000000000000000
     000000000000002401000000000000000000000000000000E40100000000000000000
     000000000000004010000000000000000000000000000002401000000000000000000
     000000000000240100000000000000000000000000000024010000000000000000000
     000000000002401000000000000000000000000000000E40100000000000000000000
     000000000004010000000000000000000000000000000401000000000000000000000
     000000000040100000000000000000000000000000004010000000000000000000000
     000000000401000000000000000000000000000000F50100000000000000000000000
     00000080601000000000000000000000000000008C601000000000000000000000000
     000008260100000000000000000000000000000826010000000000000000000000000
     000082601000000000000000000000000000008C60100000000000000000000000000
     00080601000000000000000000000000000000F501000000000000000000000000000
     000040100000000000000000000000000000004010000000000000000000000000000
     000401000000000000000000000000000000040100000000000000000000000000000
     004010000000000000000000000000000000401000000000000000000000000000000
     040FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF70 



  CST { { "PARAL" { RPAR } } { "ACCUR" {\<< ACCU \>> \<< 'ACCU'STO \>> } } 
        { "" { } } { "NEXT" { } } { "PREV" { } } { "QUIT" { } } }

  PPAR { (-6.5,-3.1) (6.5,3.2) X 0 (0,0) FUNCTION Y }

END

--
Larry L. Hoppis         PO Box 472, Mt. Hermon, CA  95041  USA
quality!hoppis@ucscc.UCSC.edu

(408) 336-3651