The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
(34C) Ohm's Law
04-14-2021, 09:58 PM
Post: #1
(34C) Ohm's Law
I enjoy seeing how programs work then trying to improve upon them.

This is my version of the Ohm's Law program from HP's 34C Student Engineering Applications book. This version is fewer steps but takes longer to run.

The program uses these formulas:
V = IR
P = IV = I^2R
V=voltage(R0) I=current(R1) R=resistance(R2) P=power(R3)

You store 2 quantities in the registers listed and clear the registers for the other two. The program computes the 2 unknowns and stores them in their respective registers. When the program ends, the display shows the power.

The program first computes I. If I is unknown, then some pair of the remaining variables must be known. We attempt to compute I from all 3 pairs (V&R, V&P, or R&P).

Now we know that I is valid. If R is unknown then only V or P could be unknown. We attempt to compute R from I&V, or I&P.

Now we know that I and R are valid. We compute P and V from these two.
Code:
001 LBL A
002 RCL 3    ; P
003 RCL 2    ; R
004 X!=0?    
005 /        ; P/R
006 SQRT    ; SQRT(R/P), or 0 if P=0 or R=0
007 X!=0?    ; If R and P were known
008 STO 1    ; then store I= SQRT(P/R)
009 1
010 STO I
011 RCL 3    ; P
012 RCL 0    ; V
013 GSB 1    ; I = P/V if P&V are known
014 1
015 STO I
016 RCL 0    ; V
017 RCL 2    ; R
018 GSB 1    ; I = V/R if V&R are known
019 2
020 STO I
021 RCL 3    ; P
022 RCL 1    ; I
023 X^2        ; I^2
024 GSB 1    ; R = P/(I^2) if P&I are known
025 2
026 STO I
027 RCL 0    ; V
028 RCL 1    ; I
029 GSB 1    ; R = V/I if V&I are known
030 RCL 2    ; R
031 RCL 1    ; I
032 *        ; IR
033 STO 0    ; V=IR, even if was already known
034 RCL 1    ; I
035 *        ; I^2*R
036 STO 3    ; P=I^2*R, even if it was already known
037 RTN
038 LBL 1    ; Function to store Y/X in (i) if Y&X are known
039 X!=0?    ; If X=0 then leave it there
040 /        ; Result is 0 if Y=0
041 X!=0?    ; If X and Y were non-zero then
042 STO (i)    ;   store it.
043 RTN
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(34C) Ohm's Law - David Hayden - 04-14-2021 09:58 PM
RE: (34C) Ohm's Law - PedroLeiva - 04-15-2021, 12:10 PM



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