Showing posts with label sight reduction table. Show all posts
Showing posts with label sight reduction table. Show all posts

Saturday, November 11, 2023

HP 42S/DM42 Programs in the Style of HP 65/67 Cards

HP 42S/DM42 Programs in the Style of HP 65/67 Cards


Programming Cards


In the 1970s, a programmable scientific calculators stored programs on magnetic cards.   The magnetic cards were then loaded on to calculator.   Two such calculators that used magnetic cards are the legendary HP 65 and HP 67, both from Hewlett Packard.    


The aim of these programs is to simulate classic programs from the HP 65 and HP 67 as they are stored on the cards, with prompts and messages to enhance the user experience.

The HP 65 had five user-definable keys A-E, while the HP 67 adds five additional user-defined labels a-e through a shift-key combination.

The MENU command on the HP 42S* creates a user key menu within a program, up to six keys.   I use this command to simulate running programs from loading cards.

(*and Free42, Plus42, Swiss Micros DM42)

The file included in the link below include four programs that are ported from various application books (pacs) of the HP 65 and HP 67.   


Demonstration Program:  demo.raw


When the program is run, a card is "simulated".   


I usually have the card in this format:

Left keys:  inputs, will sometimes give outputs

Key 4 (or 5): labeled CALC, get outputs

Key 6:  EXIT.  Exits the program.  Simulates removing the card.  


Demonstration


Key 1:  enter X coordinate

Key 2:  enter Y coordinate

Key 4:  calculate the norm

Key 6:  exit the program



Notes:  before GTO 30,  I have a pause command (PSE) so the menu returns.  

If I have multiple outputs, I have a stop command (STOP).  


Message convention: 

Prompts with a colon:  (:)  input

Prompts with an equals sign:  (=)  output


#  comments


00 { 134-Byte Prgm }

01▸LBL "DEMO"

02 "VECT NORM/ANG"         #  short description of the program

03 AVIEW

04 PSE                                        #  pauses the screen (allows for print)

05 "BY EWS"

06 AVIEW

07 PSE

08▸LBL 30                           # label 30 starts the menu

09 "→X"

10 KEY 1 XEQ 21

11 "→Y"

12 KEY 2 XEQ 22

13 "CALC"

14 KEY 4 XEQ 24

15 "EXIT"

16 KEY 6 XEQ 26

17 MENU                       # menu setup

18▸LBL 00

19 STOP

20 GTO 00                     # repeats the menu unless a menu key is pressed

21▸LBL 21                   # enter X

22 STO 01

23 "X:"

24 ARCL ST X   

25 AVIEW

26 PSE

27 GTO 30

28▸LBL 22                # enter Y

29 STO 02

30 "Y:"

31 ARCL ST X

32 AVIEW

33 PSE

34 GTO 30

35▸LBL 24            # calculate

36 RCL 02

37 RCL 01

38 →POL

39 "NORM="

40 ARCL ST X

41 AVIEW

42 STOP

43 "ANGLE="

44 ARCL ST Y

45 AVIEW

46 PSE

47 GTO 30

48▸LBL 26       # exit routine

49 CLMENU

50 EXITALL

51 .END.


Sample Output:


VECT NORM/ANG

BY EWS

X:5.7500

Y:6.8500

NORM=8.9434

ANGLE=49.9894


Program Space vs. Information Labels


When messages and alpha strings are added, along with the necessary AVIEW, PSE, and STOP commands, the program space requirements increase.   I put these messages to make the program as user friendly as possible.  



What's Included in the Zip Drive


Five programs:


Demonstration Program:  demo.raw

Sight Reduction Table:  str.raw

Physiologic Shunt and Fick:  phsy.raw

1-D Normal Shocks for Ideal Gases:  shock.raw

P and S Seismic Wave Velocity:  seismic.raw


PDF file of instructions and program listing



Download here (zip file):  

https://drive.google.com/file/d/1_0F_DHCGxcLbmCtrhMQbKShjrpBUgB7i/view?usp=share_link


Enjoy and please let me know, I plan to create another volume of these style of programs.  



Note:  The next blog entry will be on November 18, 2023


Eddie 


All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Wednesday, July 4, 2018

Fun with the HP 15C


Fun with the HP 15C

Happy Independence Day, United States!

Fractional Derivative:  kth Derivative of f(x) = x^n

This program calculates the kth derivative of x^n. The program allows for partial derivatives of x^n (where k is not an integer, such as half-integers).

Formula:

d^k/dx^k x^n = n!/(n-k)! * x^(n-k)

Input:
R0: point (x’)
R1:  n
R2: k

Program:

Step
Key
Code
001
LBL A
42, 21, 11
002
RCL 0
45, 0
003
RCL 1
45, 1
004
RCL - 2
45, 30, 2
005
y^x
14
006
LAST x
43, 36
007
x!
42, 0
008
1/x
15
009
*
20
010
RCL 1
45, 1
011
x!
42, 0
012
*
20
013
RTN
43, 32

Example:

d/dx^4 x^8  at x = 6

R0 = x’ = 6
R1 = n = 8
R2 = k = 4

Result:  2177280

d/dx^1.5 x^3.4 at x = 1

R0 = x’ = 1
R1 = n = 3.4
R2 = k = 1.5

Result:  5.5469

Sight Reduction Table

The program calculates altitude and azimuth of a given celestial body.

Inputs:

R1: Local Hour Angle (LHA), west is positive, east is negative
R2: The observer’s latitude on Earth, north is positive, south is negative (L)
R3: Declination of the celestial’s body, north is positive, south is negative (δ)

Each entry will need to be in decimal format.  If your angels are in HMS (hours-minutes-seconds) format, convert the angels to decimals by H before storing the values.

Formulas:

Altitude: 
H = asin (sin δ sin L + cos δ cos L cos LHA)

Azimuth:
Z = acos ((sin δ – sin L sin H) ÷ (cos H cos L))
If sin LHA < 0 then Z = 360° - Z

Outputs:

Altitude (in decimal), R/S, Azimuth (in decimal)

Program:

Step
Key
Code
001
LBL C
42, 21, 13
002
DEG
43, 7
003
RCL 3
45, 3
004
SIN
23
005
RCL 2
45, 2
006
SIN
23
007
*
20
008
RCL 3
45, 3
009
COS
24
010
RCL 2
45, 2
011
COS
24
012
*
20
013
RCL 1
45, 1
014
COS
24
015
*
20
016
+
40
017
ASIN
43, 23
018
STO 4
44, 4
019
R/S
31
020
SIN
23
021
RCL 2
45, 2
022
SIN
23
023
*
20
024
CHS
16
025
RCL 3
45, 3
026
SIN
23
027
+
40
028
RCL 4
45, 4
029
COS
24
030
RCL 2
45, 2
031
COS
24
032
*
20
033
÷
10
034
ACOS
43, 24
035
STO 5
44, 5
036
RCL 1
45, 1
037
SIN
23
038
TEST 2 (x<0)
43, 30, 2
039
GTO 1
22, 1
040
3
3
041
6
6
042
0
0
043
RCL - 5
45, 30, 5
044
STO 5
44, 5
045
LBL 1
42, 21, 1
046
RCL 5
45, 5
047
RTN
43, 32

Source:  “NAV 1-19A Sight Reduction Table”    HP 65 Navigation Pac.  Hewlett Packard, 1974.

Three Point Lagrangian Interpolation

This program calculates a point (x0, y0) given three known points (x1, y1), (x2, y2), and (x3, y3) where x0 is in between min(x1, x2, x3) and max(x1, x2, x3).  Ideally, x1 < x2 < x3.

Input:

R0 = x0 (on the x stack)

Store before running the program:

R1 = x1, R4 = y1
R2 = x2, R5 = y2
R3 = x3, R6 = y3

Other registers used: R7, R8, R9

Step
Key
Code
001
LBL E
42, 21, 15
002
STO 0
44, 0
003
RCL 4
45, 4
004
STO 7
44, 7
005
RCL 5
45, 5
006
STO 8
44, 8
007
RCL 6
45, 6
008
STO 9
44, 9
009
RCL 0
45, 0
010
RCL - 1
45, 30, 1
011
STO * 8
44, 20, 8
012
STO * 9
44, 20, 9
013
RCL 0
45, 0
014
RCL – 2
45, 30, 2
015
STO * 7
44, 20, 7
016
STO * 9
44, 20, 9
017
RCL 0
45, 0
018
RCL – 3
45, 30, 3
019
STO * 7
44, 20, 7
020
STO * 8
44, 20, 8
021
RCL 1
45, 1
022
RCL – 2
45, 30, 2
023
STO ÷ 7
44, 10, 7
024
CHS
16
025
STO ÷ 8
44, 10, 8
026
RCL 1
45, 1
027
RCL – 3
45, 30, 3
028
STO ÷ 7
44, 10, 7
029
STO ÷ 9
44, 10, 9
030
RCL 2
45, 2
031
RCL – 3
45, 30, 3
032
STO ÷ 8
44, 10, 8
033
STO ÷ 9
44, 10, 9
034
RCL 7
45, 7
035
RCL + 8
45, 40, 8
036
RCL + 9
45, 40, 9
037
RTN
43, 32

Example:

R1 = 5, R4 = 0.4
R2 = 10, R5 = 0.9
R3 = 15, R6 = 1.3

R0 = 12, result: 1.0720

R0 = 8, result: 0.7120

Source:  R. Woodhouse.  “Lagrangian Interpolation Routines” Datafile Summer 1984 Vol. 3 No. 3, Page 14

Quadratic Equation with Complex Coefficients

This program solves the equation where B and C are complex numbers:

x^2 + B*x + C = 0

where the roots are:

x = -B/2 ± (B^2/4 – C)

Store the following values before running:

R1 = real(B),  R2 = imag(B)
R3 = real(C), R4 = imag(C)

Output:

Root 1 (press [ f ], hold (i) for the complex part), R/S, Root 2

Program:

Step
Key
Code
001
LBL C
42, 21, 13
002
GSB 1
32, 1
003
GSB 2
32, 2
004
+
40
005
R/S
31
006
GSB 1
32, 1
007
GSB 2
32, 2
008
-
30
009
RTN
43, 32
010
LBL 1
42, 21, 1
011
RCL 1
45, 1
012
RCL 2
45, 2
013
I
42, 25
014
2
2
015
CHS
16
016
÷
10
017
RTN
43, 32
018
LBL 2
42, 21, 2
019
RCL 1
45, 1
020
RCL 2
45, 2
021
I
42, 25
022
x^2
43, 11
023
4
4
024
÷
10
025
RCL 3
45, 3
026
RCL 4
45, 4
027
I
42, 25
028
-
30
029
11
030
RTN
43, 32

Example:

x^2 + (-1 + i)*x + (3i) = 0

R1 = -1, R2 = 1
R3 = 0, R4 = 3

Results:
1.8229 – 1.8229i
-0.8229 + 0.8229i

x^2 + 3*x + (-5 + 6i) = 0

R1 = 3, R2 = 0
R3 = -5, R4 = 6

Results:
1.3862 – 1.0394i
-4.3862 + 1.0394i

Eddie

All original content copyright, © 2011-2018.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.  Please contact the author if you have questions.

Python (TI-84 Plus CE) and Swiss Micros DM32: The Integral of y = abs(r * x + s)

Python (TI-84 Plus CE) and Swiss Micros DM32: The Integral of y = abs(r * x + s) The Integral of y = abs(r * x + s) This algor...