(34S )- Sunrise/Sunset version II - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (34S )- Sunrise/Sunset version II (/thread-3062.html) |
(34S )- Sunrise/Sunset version II - Dieter - 02-11-2015 09:42 PM The following WP34s program is a modified version of the one posted by Jeff O. a few days ago. It uses less memory registers and takes advantage of various 34s features, e.g. the date functions and inline integers. The output is different from Jeff's version, now all three results are displayed simultaneously. The calculation is the same as in Jeff's version - I do not know much about all this, so I did not change the mathematics. Only some prestored constants (15, 18, 360, 24 etc.) were replaced with inline integers. Register use could be reduced significantly so that now R00 to R13 are all what's required. The number of registers might be reduced even further, but I did not want to change the calculation itself. I added a routine to automatically adjust the output for daylight savings time. It assumes the rules within the European Union, i.e. DST starts on last Sunday in March and ends on last Sunday in October. If a date falls within this period flag A is set and the "=" annunciator comes on. The mentioned rule is valid since 1996. The routine does not check for earlier dates and assumes the same rules for any year. If you do not want to include DST simply omit steps 4 to 6. You may even completely ignore time zones and use UTC by setting the timezone offset in R03 to 0. If you live outside the EU you may code your own DST routine. It just has to set flag A if the date falls within the DST period (and CF A otherwise). For more details please see Jeff's remarks on his program version. Registers 1 to 4 store some parameters you should personalize in the program code. Instead of the sample position (Frankfurt/Main, Germany) you should insert your local position (R01 and R02). Also the definition for sunrise/sunset (angle relative to zenith) can be adjusted (now 90°50'). Finally, here is the code: Code: LBL"SUN" Registers and flags: Code: Registers: Usage: Enter a date (in the current date format), and XEQ"SUN" returns the time of sunrise, sunset and the day length. The "=" annunciator signals that DST is assumed. The following example assumes d.my mode. If a different date mode is set, simply enter the date accordingly. Code: 11,022015 XEQ"SUN" I did not do any comprehensive tests, so the program may contain errors. As usual, any corrections, suggestions and comments are welcome. Dieter RE: WP 34S - Sunrise/Sunset version II - Jeff O. - 02-13-2015 12:14 AM Nice work Dieter. I have been working on my program too and will soon post a new version incorporating some improvements you used, like inline integers, plus a version of your DST code modified for the conventions used in the US and Canada. |