Mars Clock

I'm building a Mars clock for a friend who's friend works at JPL on the mars mission. Their whole family is living on mars time and they really need a way to tell the time. Here is my original hardware plan:

Arduino Uno
Ultimate GPS (for auto-setting RTC)
7-Segment LEDs

I've got the equations to generate mars time from earth time (they're pretty easy, just lots of little algebra), but the AVR on the Arduino isn't really cut out for the floating point math. So I either need to a) get rid of the floating point math or b) switch to something else.

I want this to be cheap and replicable. I've just gotten a RasPi, so I might try that but a whole linux computer to make a clock seems a little crazy. Does anyone have ideas?
huslage

Posts: 10
Joined: Wed Jul 18, 2012 11:21 am

Re: Mars Clock

Why do you need floating-point? Time calculations are always done in fixed-point. It's much more accurate.

Instead of the GPS, just use an accurate RTC like the chonodot

Posts: 34563
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Mars Clock

I have been building a Mars Clock by driving a regular wall clock with my own bipolar pulse to the motor. I'm using a 12F675 with a crystal. I'm now in the process of adjusting the timing of the clock. The code is pretty simple and makes a 50 msec bipolar pulse every two seconds. That is Mars seconds. By driving at 2 second intervals make a standard clock into a 24 hour clock. I removed the minutes hands because they travel only 1/2 around per hour when done this way. It would be better to take a 24 hour clock and drive it with the circuit. If anyone is interested, I can post a schematic and code. Photos:https://picasaweb.google.com/100095560370569958736/Marsclock
botsmaker

Posts: 5
Joined: Sun Aug 26, 2012 5:36 pm

Re: Mars Clock

The floating point math is because the martian day is on odd length and converting earth time to martian time is finicky.

The wall clock idea is neat, but I'm aiming for digital here.
huslage

Posts: 10
Joined: Wed Jul 18, 2012 11:21 am

Re: Mars Clock

Well, anything you can do in floating point, you can do in fixed point. What's the equation?

Posts: 34563
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Mars Clock

Or forget about converting from 'earth time'. Just set up a hardware timer at the right frequency:
http://letsmakerobots.com/node/28278
http://www.mythic-beasts.com/~markt/ATmega-timers.html

Posts: 61606
Joined: Sat Feb 07, 2009 10:11 am

Re: Mars Clock

Hi Bots,

Adafruit Support's suggestion makes more sense than doing lots of arithmetic.
Just count the correct number of millis for a Martian minute (or second).
You keep the traditional 60-sec / min, 60-min / hr, 24-hr / day.

IMHO I like the idea of a day being represented by 24-planet hours, regardless of the planet.
That makes some planets have more earth-hours per day, some less.
But, a day is still divided into 24 equal segments and is from solar-noon to solar-noon.

Good Luck with your project, John

john444

Posts: 443
Joined: Sun Mar 04, 2012 2:42 pm
Location: Claremore, Ok

Re: Mars Clock

The algorithm is here http://www.giss.nasa.gov/tools/mars24/help/algorithm.html My math skills suck so I can't figure out what the right counter frequency would be.
huslage

Posts: 10
Joined: Wed Jul 18, 2012 11:21 am

Re: Mars Clock

Hi Huslage,

If you can live without leap-seconds, Martian dates, Martian calenders or calculating
a specific local time at a specific place on Mars, then here is an approximation:
Since it seems that Mars takes 39-min, 35.244-sec(Terrestrial Time)
longer than Earth to make one revolution (day) then, here is how I calculated it.
(TT) = Terrestrial Time, (MT) = Martian Time

1-day(TT) = 86,400-sec(TT). 1-day(MT) = 88,775.244-sec(TT)
1,027.491-millisec(TT) = 1-sec(MT) [Sad that it does not come out more evenly]

Then just do the regular 60-sec/min, 60-min/hr, 24-hr/day.

john444

Posts: 443
Joined: Sun Mar 04, 2012 2:42 pm
Location: Claremore, Ok

Re: Mars Clock

I'm glad I found this forum. I've been thinking about making a super simple Mars watch. I looked around to see if anybody else had made one and it turns out a jeweler made a mechanical one for JPL ( http://www.jckonline.com/article/287435-U_S_Jeweler_Creates_Mars_Time_Watch_for_JPL.php )........................
and an engineering student made a digital one ( http://www.popsci.com/diy/article/2012-09/make-your-own-mars-watch-keep-time-mars-rovers )..............................

I had hoped to stay under the pricing and complicated programming/workmanship they had to input (\$50-\$400 price points).
The difference in time between seconds on Mars and Earth is (Earth 1.0274912510416665 second = Mars 1 second) so my idea was to simplify the code and make the watches extremely low cost and easy to reproduce. I thought since you can write a delay based on milliseconds you might be able to write a digit 000,000(plus one) at a delay rate of 1027-1028 until you reach 243,935 at which point the program would return to start at 000,000. and start again adding 1 digit every 1027 milliseconds.

This is the first piece of code I'm messing with (terribly inefficient)

Code: Select all | TOGGLE FULL SIZE
`void setup()                    {  Serial.begin(9600);               Serial.println(.01);       delay(1027);    Serial.println(.02);    delay(1027);    Serial.println(.03);    delay(1027);    Serial.println(.04);}void loop()                       {                                 }`

I'm no programmer so there may be a lot I'm missing but this seemed to me to be the simplest cheapest way to make a reasonably accurate watch for everyday use. I would compare these to a cheap watch you might get at Walmart for under \$10, obviously it's not going to be a Roh Lex (banned word apparently) and at times you'll have to reset it if it gets off a few minutes, but I think it's a promising start. I welcome (and ask for) ANY response positive or negative on this. I'm open to suggestions and criticism. Thanks!
daremick

Posts: 25
Joined: Wed Sep 26, 2012 10:17 pm

Re: Mars Clock

There are some points I would like to make:

First: I am glad people are taking the initiative to do something instead of just wringing their hands and lamenting the lack of an existing product. This is what I had to do for a clock for my apartment:

Second: There do exist (somewhat) reasonably priced analog 24-hour clocks, for Earth time. If you use one of these and slow it down for Mars time, you will then have a clock showing Mars hours, minutes, and seconds. You can find them on eBay; just search for "24 hour" clock (with quotes around "24 hour").

Fourth: If you are going for mean Mars solar time (1 Mars day = 24 h 39 min 35.244 sec Earth time = 1.027491252 Earth day = 88775.244 Earth seconds, or to put it another way, 1 Earth day = 0.973244296 Mars day), then the only "floating point" arithmetic you need is a single division (or multiplication) by a number close to 1. You don't even need that, really. For example, instead of calculating this
Code: Select all | TOGGLE FULL SIZE
`x / 1.027491252`
or this
Code: Select all | TOGGLE FULL SIZE
`x * 0.973244296`
you can calculate this, in integer arithmetic, and it will come out just about the same:
Code: Select all | TOGGLE FULL SIZE
`x - (x / 37) + (x / 3686)`
or if you want to truly meticulous, use this:
Code: Select all | TOGGLE FULL SIZE
`x - (x / 37) + (x / 3686) + (x / 38400000)`

(Note: The accuracy of this approach is as least as good as, and probably better than, that of just taking an analog Earth clock and slowing it down.)

Fifth: It is NOT simple to convert your local Earth time to Mars time. This is because Mars does not observe Daylight Saving time, but much of Earth does, which throws off your calculations during your region's Daylight Saving Time. If you want simplicity (and I'm sure you do), start with Universal Time (a.k.a. Greenwich Mean Time) and then convert to Mars time.

Sixth: The Chronodot is A-OK. I have one on my clock. This way, I don't need radio signals.

Seventh: If your math skills suck, find someone with decent math skills to help. That can make this kind of work a lot easier.
odometer

Posts: 98
Joined: Sun Aug 21, 2011 11:01 pm

Re: Mars Clock

Or, you could use this method, which I just made up:

Code: Select all | TOGGLE FULL SIZE
`k = ????; // value of earth_seconds at 00:00:00 Mars timex = earth_seconds - k;y = x - (x / 8) - (x / 53) + (x / 19820);mars_seconds = (x - (y / 32));`

For this to work, the variable earth_seconds will need to have been calculated in some other part of the code beforehand. This is the total number of seconds that have passed since some specified time on earth. Unix time (look it up) is an example of a system that would work for this; it uses 00:00:00 UTC on 1 Jan 1970. (Note: Unix Time sweeps leap seconds under the carpet. If this bothers you, just add the total number of leap seconds so far -- 25 or so -- to your value for Unix Time. But I wouldn't bother.)

The variable k should be set to the number of earth_seconds at 00:00:00 Mars time. The exact value of this number depends on which "time zone" on Mars you are using. (Yes, the concept of time zones applies to any planet that has day and night, not just Earth. And yes, this can get complicated.)

For speed, you can replace some of the divisions by "bit shifts". You will then end up with this:

Code: Select all | TOGGLE FULL SIZE
`k = ????; // value of earth_seconds at 00:00:00 Mars timex = earth_seconds - k;y = x - (x >> 3) - (x / 53) + (x / 19820);mars_seconds = (x - (y >> 5));`
odometer

Posts: 98
Joined: Sun Aug 21, 2011 11:01 pm

Re: Mars Clock

Kind of surprised that no has discussed setting up a hardware timer to do this. Or adjusting the arduino system timer in wiring.c.

It should simply be a matter of expressing the system clock speed in "Mars Hertz" and then applying all the usual timer setup calculations. If this relationship is correct,
daremick wrote:(Earth 1.0274912510416665 second = Mars 1 second)
then 16MHz becomes 16,439,860MarsHz.

Posts: 34563
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Mars Clock

If you want an RTC backup, you will have to do conversion anyway.

I don't get why try alter the speed of an RTC or Arduino clock. Is that math really that hard?!

If you don't want to use the time information from an external RTC, then just count chunks of 1027491 microseconds in software. Each such chunk is a Mars second, more or less. When you get to 60 Mars seconds, then you have one Mars minute, etc. Counting chunks of time of arbitrary but uniform length (in out case, 1027491 microseconds) is very straightforward. Look at the "Blink without delay" example in the tutorial.

It's really not a good idea to use 1027 milliseconds to approximate 1.027491... seconds. If you do, the clock will be out two minutes in three days.

I don't understand why go so far out of your way to avoid a little math. If you are really concerned about the math slowing down the Arduino, then just do the "hard" math once every minute or so, and count chunks of 1027491 microseconds (or even 1027 milliseconds, if you like) in between.
odometer

Posts: 98
Joined: Sun Aug 21, 2011 11:01 pm

Re: Mars Clock

odometer wrote:If you want an RTC backup, you will have to do conversion anyway.

I don't get why try alter the speed of an RTC or Arduino clock. Is that math really that hard?!

If you don't want to use the time information from an external RTC, then just count chunks of 1027491 microseconds in software. Each such chunk is a Mars second, more or less. When you get to 60 Mars seconds, then you have one Mars minute, etc. Counting chunks of time of arbitrary but uniform length (in out case, 1027491 microseconds) is very straightforward. Look at the "Blink without delay" example in the tutorial.

It's really not a good idea to use 1027 milliseconds to approximate 1.027491... seconds. If you do, the clock will be out two minutes in three days.

I don't understand why go so far out of your way to avoid a little math. If you are really concerned about the math slowing down the Arduino, then just do the "hard" math once every minute or so, and count chunks of 1027491 microseconds (or even 1027 milliseconds, if you like) in between.

I'm not sure if you're addressing the original poster or me because there's no name in your post. Thanks for the advice if it was for me, and if it was for me no I am not trying to avoid math my post states that I am trying to make it "simple" as in low cost hardware and minimal code (as it applies to total size, for example 12kb versus 30kb) I have no problem doing any math or in depth code, although again as I mentioned I am no programmer and this is a great learning project for me. I have no idea how to program a stepper motor let alone do math in the IDE. But unlike a lot of new people I see on these forums I am also not expecting anyone to hand me the answers. Again if that post was for me thank you for the advice I will work on this as well as my own solutions. Great support.
daremick

Posts: 25
Joined: Wed Sep 26, 2012 10:17 pm