Programs: 
OHMSLAWS 

Version: 
1.0, 12 February 2006 

Description: 
The OHMSLAWS program computes any two of the power, voltage, current, and resistance in a simple resistance circuit from two known factors. 

Compatibility: 

The OHMSLAWS program computes the unknown quantities that can be deduced from known quantities using the following equations of a simple resistance circuit:
E = I R
P = E I
P = I^{2} R
The variable E stands for electromotive force, or voltage, measured in volts; the variable P stands for power, measured in watts; the variable I stands for current, measured in amperes; and the variable R stands for resistance, measured in ohms. All values must be positive: the program assumes that the case of zero in any value is sufficiently uninteresting that you will not compute it.
Enter the OHMSLAWS program into the calculator, using either the calculator data cable or entering the program directly.
Convert all known values into MKS electrical units (watts, amperes, volts, ohms). The results in the solution will also be expressed in this system.
Run the program.
The program will display the prompt “0:Done 1:P 2:E 3:I 4:R” and pause for you to input a code. This menu is shown in the screen shot to the right. These codes refer to: P, the power (code 1); E, the electromotive force (voltage) (code 2); I, the current (amperage) (code 3); and R, the resistance (code 4).
You enter each known factor by first entering the appropriate code (1 through 4), then entering the factor’s value. The program displays the name of the unit in which the factor is measured after you enter the factor’s code, to help ensure the correct factor is entered. This twostep process of identifying the data to be entered, then entering the data, is indicated in the screen shot to the left.
If you enter an incorrect value for a factor, you can enter the factor again with the correct value. The most recently entered factor value is the value that is used. If you enter an incorrect factor code, you may enter a value of zero. The program interprets a factor value of zero as indicating the factor is unknown. The value you enter for a factor must be nonnegative; the program will repeat the prompt until you enter a positive value or a zero.
When you have entered all the known factor values, use the code 0 to indicate that entry of the factor values is complete. The program will then compute and display the factor values that were not entered and can be deduced from the factors that were entered. The display of values is shown in the screen shot to the right.
The program displays the message “Done” when it has displayed all the factors which can be determined from the factors you entered. This may occur without the display of any factors which were deduced, if the information you entered was insufficient to deduce any factors. This message is shown in the screen shot to the left.
The program is available in a ZIP file, or may be entered as shown below. Remember that this program is copyrighted; see the copyright issues page for limitations on redistribution.
Program OHMSLAWS (600 bytes):
'OHMSLAWS 1.0
0→A~E
Do
"0:Done"
"1:P 3:I"
"2:E 4:R"?→A
If A=1
Then Do
"Watts"?→B
LpWhile B<0
IfEnd
If A=2
Then Do
"Volts"?→C
LpWhile C<0
IfEnd
If A=3
Then Do
"Amps"?→D
LpWhile D<0
IfEnd
If A=4
Then Do
"Ohms"?→E
LpWhile E<0
IfEnd
LpWhile A≠0
Do
0→A
If (B=0)(C≠0)(D≠0)
Then CD→B
1→A
IfEnd
If (B≠0)(C=0)(D≠0)
Then B÷D→C
1→A
IfEnd
If (B≠0)(C≠0)(D=0)
Then B÷C→D
1→A
IfEnd
If (B=0)(D≠0)(E≠0)
Then D^{2}E→B
1→A
IfEnd
If (B≠0)(D=0)(E≠0)
Then √(B÷E)→D
1→A
IfEnd
If (B≠0)(D≠0)(E=0)
Then B÷D^{2}→E
1→A
IfEnd
If (C=0)(D≠0)(E≠0)
Then DE→C
1→A
IfEnd
If (C≠0)(D=0)(E≠0)
Then C÷E→D
1→A
IfEnd
If (C≠0)(D≠0)(E=0)
Then C÷D→E
1→A
IfEnd
LpWhile A≠0
If B≠0
Then "Watts"
B
IfEnd
If C≠0
Then "Volts"
C
IfEnd
If D≠0
Then "Amps"
D
IfEnd
If E≠0
Then "Ohms"
E
IfEnd
"Done"
[ Previous page  Top of page  Next page ]
Copyright © 2006 Brian Hetrick
Page last updated 12 February 2006.