Program listing for RPN Sunrise/Sunset

10142017, 04:10 PM
Post: #1




Program listing for RPN Sunrise/Sunset
In the Articles section there is a listing for Program to calculate Sunrise/Sunset times. I came across a character in the program listing on line 68 (and others) that is puzzling. It looks like it should be an operator, but the section of listing below includes the other common arithmetic operators. Can someone explain what this is?
66 18 67 RCL 07 68 • 69 24 70 / 71 RCL 05 72 + 73 STO 08 74 .9856 75 x 76 3.289 77 • 78 STO 09 Link to the article: http://www.hpmuseum.org/cgisys/cgiwrap/...?read=1131 X <> IND L 

10142017, 05:25 PM
(This post was last modified: 10142017 05:37 PM by Dieter.)
Post: #2




RE: Program listing for RPN Sunrise/Sunset
(10142017 04:10 PM)Craig Bladow Wrote: In the Articles section there is a listing for Program to calculate Sunrise/Sunset times. I came across a character in the program listing on line 68 (and others) that is puzzling. It looks like it should be an operator, but the section of listing below includes the other common arithmetic operators. Can someone explain what this is? If you look at the DOY routine it seems that this "•" must be a minus. This also matches line 68 where the difference between 6:00 resp. 18:00 h and the longitude divided by 15° (R07) is calculated. The same is true for the code around line 145 where, depending on flag 02, either a longitude or 360° minus this is calculated. BTW there seems to be a similar problem with the 35s version. There are several lines with an "1." which also seems to stand for a "–" minus. However I wonder why this "•" or "1." lines appear in the listing while elsewhere a simple "–" seems to work fine. Dieter 

10142017, 05:44 PM
Post: #3




RE: Program listing for RPN Sunrise/Sunset
Thanks Dieter, I'll give "minus" a try.
X <> IND L 

10142017, 06:26 PM
(This post was last modified: 10142017 06:26 PM by SlideRule.)
Post: #4




RE: Program listing for RPN Sunrise/Sunset
Craig
from the 33s listing for the equivalent section of program code: C0029 FS? 0 If set use 18 for sunset calculation C0030 18 C0031 RCL G C0032 24 C0033 / so I'ld say Dieter nailed it. BEST! SlideRule 

10142017, 09:20 PM
Post: #5




RE: Program listing for RPN Sunrise/Sunset
Thanks!
I found this also in the DOY program: 11 FS? 01 DMY mode Should be 11 FS? 31 DMY mode Still get a DATA ERROR, so need to do some more debugging. X <> IND L 

10152017, 05:16 PM
(This post was last modified: 10152017 06:05 PM by Dieter.)
Post: #6




RE: Program listing for RPN Sunrise/Sunset
(10142017 09:20 PM)Craig Bladow Wrote: Still get a DATA ERROR, so need to do some more debugging. FTR: I tried the HP41 version in V41 and it works just fine. The times for today exactly match those from a good online calculator. However, I think the program can be improved. I also wonder if the FLOOR routine is really required. But I don't get any errors. At least not for my location and timezone. What values did you try? Edit: The program calculates floor(R10/90) and floor(R11/90). Both R10 and R11 are the result of a mod 360 operation which always returns a value >= 0. So I think the complete FLOOR routine is obsolete and can be replaced with a simple INT command. And maybe the whole thing can be done even more elegantly with MOD. Edit 2: I now have replaced the following lines of the original program... Code: 99 ATAN ...with this: Code: 99 ATAN And it seems to work. But please do your own tests and report here if you find any cases where errors occur. Dieter 

10152017, 10:15 PM
Post: #7




RE: Program listing for RPN Sunrise/Sunset
Thanks for validating the program Dieter! It turns out I misplaced a decimal point in one of the constants so I am now getting good results. Once I save this to mag card(s) I will try your modifications. Since my longitude is > 90 degrees West it will be a good test of your changes.
X <> IND L 

10162017, 02:10 AM
Post: #8




RE: Program listing for RPN Sunrise/Sunset
Dieter, yes it works with your changes for my location. Thank you!
X <> IND L 

10162017, 11:15 AM
(This post was last modified: 10162017 12:47 PM by Dieter.)
Post: #9




RE: Program listing for RPN Sunrise/Sunset
(10142017 09:20 PM)Craig Bladow Wrote: I found this also in the DOY program: BTW, there is no need to check flag 31 at all. Instead of Dec 31 simply count the DOY from 1 Jan, which is 1.01yyyy in either mode. ;) Here is a way to do so: Code: 01 LBL"DOY" Edit: The original program uses data registers up to R15. Since some values are only stored and recalled once and can be held on the stack, the program can be modified so that it requires only registers up to R10. Maybe even less. And I got it down to less than 330 bytes (including the DOY routine) so that it will fit on three card tracks. I don't know if the author of the original program, M. Joury, is still reading this forum, so I'm not sure if it's OK for him if I would post my "streamlined" version of his program. The implemented algorithm looks very accurate. Dieter 

10172017, 01:14 PM
(This post was last modified: 10182017 12:44 AM by Craig Bladow.)
Post: #10




RE: Program listing for RPN Sunrise/Sunset
Dieter,
I think the updated version, with corrections of errors in the posting on the HP Articles portion of the old website, would be a valuable contribution to the HP41c software library. X <> IND L 

« Next Oldest  Next Newest »

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