Saturday, July 9, 2016

HP 42S Programming Part II: Dew Point, Ellipse Area and Eccentricity, Easy Transverse

HP 42S Programming Part II:  Dew Point, Ellipse Area and Eccentricity, Easy Transverse

Click here for Part I:  Matrix Column Sum, GCD, Error Function

(I plan to post Part III next week.)

As mentioned in Part I, you can download an emulator for the HP 42S, Free42 here: http://thomasokken.com/free42/ .  The emulator is for many operating systems including Windows, Mac, iOS, and Android.  



HP 42S:  Dew Point (°C)


00 {99-Byte Prgm}
01 LBL “DEW”
02 “TEMP °C:”
03 PROMPT
04 STO “T”
05 “HUMIDITY %”
06 PROMPT
07 STO “H”
08 LN
09 17.27
10 RCL* “T”
11 237.3
12 RCL+ “T”
13 ÷
14 +
15 17.27
16 ÷
17 STO “V”
18 237.3
19 RCL* “V”
20 1
21 RCL- “V”
22 ÷
23 “DEW POINT °C”
24 ARCL ST X
25 AVIEW
26 STOP
27 END

Instructions:  Execute GTO DEW from Home.  Press [R/S].

Test:  Input:  T:  20°C, H = 0.50
Result:  9.2696°C

 HP 42S:  Area and Eccentricity of an Ellipse

The program ELLIPSE calculates the area and eccentricity of an ellipse. 

Formulas:
Assume a>b, where a and b represent the lengths of semi-diameters, respectively
Area:  A = π*a*b
Eccentricity:  ϵ = √(1 – (b/a)^2)

00 {76-Byte Prgm}
01 LBL “ELLIPSE”
02 “LARGE S-D:”  \\ S-D:  semi-diameter
03 PROMPT
04 STO “A”
05 “SMALL S-D:” 
06 PROMPT
07 STO “B”
08 RCL “A”
09 RCL* “B”
10 PI  \\ π
11 *
12 “AREA:”
13 AVIEW
14 PSE
15 STOP \\ R/S
16 1
17 RCL “B”
18 RCL÷ “A”
19 X^2
20 –
21 SQRT
22 “ECC:”
23 AVIEW
24 PSE
25 END

HP 42S Easy Transverse

Calculates the new point knowing the original coordinates, direction, and angle of travel.  The angle 0° comes from due east and rotates counterclockwise.  The program sets the HP 42S to degrees mode.  We make use of the Programmable Menu. 

00 {183-Byte Prgm}
01 LBL “EASYTRV”
02 DEG
03 0
04 STO “T”   \\ initialize total distance counter
05 “INITIAL EASTING”
06 PROMPT
07 STO “E”
08 “INIT. NORTHING”
09 PROMPT
10 STO “N”
11 LBL 00 \\ main label
12 XEQ 01 \\ go to calculation sub loop
13 LBL 03 \\ start menu label
14 CLMENU
15 “NEXT”
16 KEY 1 XEQ 01 \\ KEYX command
17 “QUIT”
18 KEY 2 GTO 02 \\ KEYG command
19 MENU
20 STOP
21 GTO 03 \\ end menu loop
22 LBL 01 \\ main calculation loop
23 CLRMENU \\ make both lines available for viewing
24 “ANGLE (0°-360°)”
25 PROMPT
26 STO “A”
27 “DISTANCE”
28 PROMPT
29 STO “D”
30 STO+ “T”
31 →REC
32 STO+ “E”
33 X<>Y
34 STO+ “N”
35 RCL “E”
36 “EAST:”
37 ARCL ST X
38 AVIEW
39 STOP
40 RCL “N”
41 “NORTH:”
42 ARCL ST X
43 AVIEW
44 RTN
45 LBL 2  \\ finalization sub routine
46 CLMENU
47 RCL “T”
48 “ΣDIST:”   \\  Σ is from the ALPHA-MATH menu
49 ARCL ST X
50 AVIEW
51 STOP
52 RCL “N”
53 RCL “E”
54 END

Test:
Initial Data Coordinates:  N = 1,000,  E = 1,000
Travel #1:  170 units at 118°  (28° NW)
Travel #2:  162 units at 45°  (45° NE)

Input:
[XEQ] {EASYT}
1000 [R/S] [R/S]
118 [R/S] 170 [R/S]

Result:
EAST: 920.1898 [R/S],  NORTH: 1,150.1011

{NEXT} 45 [R/S] 162 [R/S]

EAST:  935.5061 [R/S], NORTH:  1,192.4143

{QUIT} ΣDIST:  215 [R/S], N on Y stack, E on X stack. 


 This blog is property of Edward Shore, 2016.


1 comment:

Casio fx-3650p and HP 21S: The Intersection Point of a Quadrilateral

Casio fx-3650p and HP 21S: The Intersection Point of a Quadrilateral Introduction This program calculates the coordinates of the c...