Lat/Lon <-> UTM for HP-42s



#2

Encouraged by the exuberant response to my posting of the corresponding WP-34S program, I decided to port it to the HP-42s also.

I have implemented support for southern-hemisphere coordinates, designated by the use of negative UTM zones (i.e. Cape Town coordinates will use zone -34). The WP-34S version now has this also, I'll post an updated entry shortly. Forcing a coordinate to a zone (using "->ZN") also forces the N/S hemisphere, so computing UTM for Cape Town in zone 34 (North) will give a negative northing.

A number of things changed between the two implementations, the most notable being that I precomputed the nine alpha, beta and delta coefficients, which probably costs me a few digits in precision (the WP-34S constants are computed from the WGS-84 parameters 'a' and 'f1' and appear to carry 16 significant digits, while I can only enter constants with 12 digits in the HP-42s). The computations (v_trig, dot3) are basically the same, however.

The 42s doesn't have local registers or the STOS/RCLS commands, so several additional global registers are being used. Some routines store values for others. Several more local labels (no SKIP/BACK commands).

On the other hand, the more capable display and menu system of the 42s means that the user interface is more self-describing. I don't know of a 42s equivalent of "ENTRY?", so set/get of UTM zone was placed on different keys.

The listing is below, a raw file for "free42" can be created using 'raw2txt.pl' or I will supply it on request.

Enjoy!


00 { 921-Byte Prgm }
01>LBL "UTM"
02 RAD
03 XEQ 01
04 0.9996
05 STO 21
06 6367449.14582
07 STO 22
08 1.67922038638E-3
09 STO 23
10 8.37731818819E-4
11 STO 10
12 7.6084969587E-7
13 STO 11
14 1.2034877876E-9
15 STO 12
16 8.37732164082E-4
17 STO 13
18 5.90611086372E-8
19 STO 14
20 167699117944E-21
21 STO 15
22 3.35655144863E-3
23 STO 16
24 6.57191319317E-6
25 STO 17
26 1.76774599621E-8
27 STO 18
28 CF 00
29 CF 01
30 CF 02
31 CF 03
32 CF 04
33 CLMENU
34 "->UTM"
35 KEY 2 XEQ A
36 "->L/L"
37 KEY 3 XEQ B
38 "->ZN"
39 KEY 4 XEQ C
40 "ZN->"
41 KEY 5 XEQ D
42 XEQ 02
43 MENU
44>LBL 20
45 STOP
46 GTO 20
47>LBL A
48 XEQ 01
49 FC? 00
50 XEQ 98
51 ->RAD
52 RCL- 20
53 STO 31
54 X<>Y
55 ->RAD
56 STO 30
57 SIN
58 ATANH
59 LASTX
60 RCL 23
61 SQRT
62 1
63 RCL+ 23
64 ?
65 2
66 ?
67 STO ST Z
68 ?
69 ATANH
70 ?
71 -
72 SINH
73 STO 32
74 RCL 31
75 COS
76 ?
77 ATAN
78 STO 33
79 2
80 ?
81 CF 01
82 CF 02
83 0
84 XEQ 97
85 SF 01
86 3
87 XEQ 97
88 RCL 31
89 SIN
90 RCL 32
91 X^2
92 1
93 +
94 SQRT
95 ?
96 ATANH
97 STO 34
98 2
99 ?
100 SF 02
101 6
102 XEQ 97
103 10
104 0
105 6
106 XEQ 96
107 RCL+ 34
108 RCL? 21
109 RCL? 22
110 5E5
111 +
112 STO 24
113 2
114 RCL? 34
115 CF 01
116 0
117 XEQ 97
118 10
119 3
120 0
121 XEQ 96
122 RCL+ 33
123 RCL? 21
124 RCL? 22
125 FC? 04
126 GTO 10
127 7
128 10^X
129 +
130>LBL 10
131 STO 25
132 XEQ 02
133 RTN
134>LBL B
135 XEQ 01
136 5E5
137 -
138 RCL? 21
139 RCL? 22
140 STO 36
141 X<>Y
142 FC? 04
143 GTO 21
144 7
145 10^X
146 -
147>LBL 21
148 RCL? 21
149 RCL? 22
150 STO 35
151 2
152 ?
153 CF 01
154 CF 02
155 0
156 XEQ 97
157 SF 01
158 3
159 XEQ 97
160 2
161 RCL? 36
162 SF 02
163 6
164 XEQ 97
165 13
166 0
167 6
168 XEQ 96
169 RCL- 36
170 +/-
171 STO 34
172 2
173 RCL? 36
174 CF 01
175 0
176 XEQ 97
177 13
178 3
179 0
180 XEQ 96
181 RCL- 35
182 +/-
183 STO 33
184 SIN
185 RCL 34
186 COSH
187 ?
188 ASIN
189 STO 32
190 2
191 ?
192 SF 01
193 CF 02
194 0
195 XEQ 97
196 16
197 0
198 XEQ 95
199 RCL+ 32
200 ->DEG
201 STO 25
202 RCL 34
203 SINH
204 RCL 33
205 COS
206 ?
207 ATAN
208 RCL+ 20
209 ->DEG
210 STO 24
211 XEQ 02
212 RTN
213>LBL C
214 STO 19
215 CF 04
216 X!=0?
217 GTO 31
218 STO 20
219 CF 00
220 RTN
221>LBL 31
222 X<0?
223 SF 04
224 ABS
225 6
226 ?
227 183
228 -
229 ->RAD
230 STO 20
231 CLX
232 RCL 19
233 SF 00
234 RTN
235>LBL D
236 RCL 19
237 RTN
238>LBL 01
239 STO 24
240 Rv
241 STO 25
242 Rv
243 STO 26
244 Rv
245 STO 27
246 Rv
247 RTN
248>LBL 02
249 RCL 27
250 RCL 26
251 RCL 25
252 RCL 24
253 RTN
254>LBL 98
255 CF 04
256 6
257 ?
258 31
259 +
260 IP
261 X<>Y
262 X<0?
263 SF 04
264 X<>Y
265 FS? 04
266 +/-
267 STO 19
268 31
269 X!=Y?
270 GTO 32
271 RCL 25
272 56
273 X>Y?
274 GTO 32
275 CLX
276 64
277 X<Y?
278 GTO 32
279 1
280 STO+ 19
281 GTO 33
282>LBL 32
283 RCL 25
284 72
285 X>Y?
286 GTO 33
287 RCL 24
288 6
289 X>Y?
290 GTO 33
291 X^2
292 X<Y?
293 GTO 33
294 Rv
295 3
296 +
297 12
298 ?
299 IP
300 2
301 ?
302 31
303 +
304 STO 19
305>LBL 33
306 RCL 19
307 ABS
308 6
309 ?
310 183
311 -
312 ->RAD
313 STO 20
314 RCL 25
315 RCL 24
316 RTN
317>LBL 97
318 STO 28
319 X<>Y
320 STO 29
321 XEQ 94
322 STO IND 28
323 1
324 STO+ 28
325 2
326 RCL? 29
327 XEQ 94
328 STO IND 28
329 1
330 STO+ 28
331 3
332 RCL? 29
333 XEQ 94
334 STO IND 28
335 RCL 29
336 RTN
337>LBL 94
338 FS? 01
339 GTO 34
340 FS? 02
341 COSH
342 FC? 02
343 COS
344 RTN
345>LBL 34
346 FS? 02
347 SINH
348 FC? 02
349 SIN
350 RTN
351>LBL 95
352 SF 03
353>LBL 96
354 STO 37
355 Rv
356 STO 38
357 Rv
358 FS? 03
359 GTO 39
360 STO 39
361 Rv
362>LBL 39
363 3
364 STO 40
365 Rv
366 0
367>LBL 40
368 RCL IND 37
369 RCL? IND 38
370 FC? 03
371 RCL? IND 39
372 +
373 1
374 STO+ 37
375 STO+ 38
376 STO+ 39
377 Rv
378 DSE 40
379 GTO 40
380 CF 03
381 .END.

Possibly Related Threads...
Thread Author Replies Views Last Post
  UTM <-> Lat/Lon for WP-34S Tom Grydeland 1 200 09-05-2013, 05:41 PM
Last Post: Tom Grydeland
  42s questions and 42s vs 35s snaggs 13 991 09-19-2011, 02:44 AM
Last Post: snaggs
  Electri-Calc LT bill platt 6 395 12-04-2008, 11:26 PM
Last Post: bill platt

Forum Jump: