The Museum of HP Calculators

HP Forum Archive 18

 Programming a clock exerciseMessage #1 Posted by mike reed on 8 Jan 2009, 6:23 p.m. ```Here's a little exercise for ya - participation voluntary. You are a starship pilot and routinely make port at many different worlds. Each world's rotation is different; some slower, resulting in a longer day, and some faster resulting in a shorter one. Compounding the problem is the fact that the "Local governments" of these worlds have not adopted a "standard" 24 hour day. Some have 20 "hours" some 25, etc, AND the "hour" does not necessarily have 60 "minutes", nor a "minute" 60 seconds. You want to build an electronic watch (or clock) that you can set for the period (length of a day expressed in "Earth" hours), number of hours per period, number of minutes per hour, and number of seconds per minute. The clock will then accurately keep time for you on the planet you are visiting. The timekeeping abilities of this clock (and the programming language for it) are exactly the equivalent of an HP48-SX (see - i DID get HP calculator in there somewhere ;-) )Your task is to write the smallest program possible to make the clock work. Period Planet (std hrs) Hrs/period Min/Hr Sec/min Adaen 28.376 25 90 90 Baell 20.421 18 75 50 Calea 22.381 20 60 60 Dawaer 26.258 20 100 50 OK - you can throw rocks at me now... ;oD ```

 Re: Programming a clock exerciseMessage #2 Posted by Allen on 8 Jan 2009, 8:38 p.m.,in response to message #1 by mike reed May I assume since the speed of the starship and the mass of the planets is not noted that relativestic time dilation effects are not to be corrected for in any of the the clocks? And that the standard SI unit for a second is consistent across the worlds. Alternatively, I could assume that "STD HRS" in the table above refers to a standard 3600 seconds that we might have on earth. Edited: 8 Jan 2009, 8:47 p.m.

 Re: Programming a clock exerciseMessage #3 Posted by Mike Reed on 9 Jan 2009, 10:17 a.m.,in response to message #2 by Allen Quote: May I assume since the speed of the starship and the mass of the planets is not noted that relativestic time dilation effects are not to be corrected for in any of the the clocks? Yes, discount relativistic dilation; the clock is for use while grounded on a planet - your starship's control console has a clock that is for use while in transit. :o) And that the standard SI unit for a second is consistent across the worlds. NO - that's the problem. The duration of each unit hour/minute/second is different on each world and none correspond to the same units on earth. For instance on the planet Adaen, whose rotational period is 28.376 EARTH hours, their day is divided into 25 local hours, each consisting of 90 local minutes which in turn consist of 90 local seconds. The rotational period of Adaen is 25.000 Adaen hours. Alternatively, I could assume that "STD HRS" in the table above refers to a standard 3600 seconds that we might have on earth. Yep; STD HRS refer to time as measured HERE on good old Terra Firma!

 Re: Programming a clock exerciseMessage #4 Posted by David Hayden on 13 Jan 2009, 10:02 a.m.,in response to message #1 by mike reed What is desired accuracy of the clock? For example, one Adaen second is about 4132.55 ticks of the HP 49's clock (which has 8192 ticks per earth second). So if I round off to 4133 ticks per Adaen second then I can get an answer, but it will drift, being off my 11.59 earth seconds after one Adaen day. Not much of a clock. At the other extreme, we could say that the clock should run for eternity and remain accurate to within one clock tick forever. That's a bigger challenge.

 Re: Programming a clock exerciseMessage #5 Posted by mike reed on 13 Jan 2009, 11:02 a.m.,in response to message #4 by David Hayden Quote: What is desired accuracy of the clock? For example, one Adaen second is about 4132.55 ticks of the HP 49's clock (which has 8192 ticks per earth second). So if I round off to 4133 ticks per Adaen second then I can get an answer, but it will drift, being off my 11.59 earth seconds after one Adaen day. Not much of a clock. True - not much of a clock... I'm only looking for "wristwatch" accuracy here, not "atomic clock". My Casio G-Shock is good for about 7 seconds a week which should be fine. Looking at the numbers for Adaen, it appears it may be necessary to add or subtract (4133/11.59)/25 "leap" ticks each hour to keep a reasonable accuracy in the timepiece. The clock program should calculate this itself, and take care of it for you. At the other extreme, we could say that the clock should run for eternity and remain accurate to within one clock tick forever. That's a bigger challenge. That would be a MUCH bigger challenge, especially within the parameters of the problem, as i don't THINK the HP48sx has a Caesium clock in it! LOL

Go back to the main exhibit hall