The diabolical labs of Fenton Heavy Industries have been busy lately! About 4-5 years ago I picked up one of these – a really neat little 128×128 OLED serial display. My initial plan was to make a 1/10-scale terminal to go with my 1/10-scale Cray-1, but I eventually abandoned the idea of building a whole miniaturized data center and the screen just languished in my spare parts box. A few months ago I decided that I needed some better desk art, though, and I finally decided it was time to use the screen.
My general goal was to build a ‘living’ object that would evolve over time, and be fun to glance at occasionally. I could have gone with a ‘Conway’s game of life’-style display, but writing a stable solar system simulation has been on my never-ending To-Do list for years now. My day job mostly consists of designing big, optically-themed computers, so going with a small, optically-themed computer seemed fitting. Meet HANS – a tiny digital orrery named after the guy that invented the telescope. It’s built using a Teensy 3.0 I had lying around, a much-neglected 1″-OLED display, and data from NASA’s extremely helpful HORIZONS site.
The machine itself is really simple – it’s just a Teensy 3.0 with a UART hooked up to the serial OLED display. It’s powered from the Teensy’s USB connector, and it uses the orange LED built into the Teensy to provide a nice internal glow. The electronics are so simple it’s not really worth including a schematic. The case is built using a 3D-printed base, lid and frame, printed in grey PLA on my Replicator 2.
The side panels are laser-cut out of black cardboard and backed by a translucent white light-diffuser material we had lying around at NYCResistor. I wanted to stick with the ‘digital telescope’ theme, so the OLED display is actually mounted in the top of the box, with a little lense I found lying around somewhere to give it a slight fisheye effect. The lid masks off part of the display to make it appear as a round display with a radius of 64 pixels that shows a top-down view of our inner solar system.
The software is pretty simple, and it was written with stability in mind, not performance. Everything is done using double-precision floating point (despite the Teensy’s lack of hardware floating point support), and the units are done in kg, meters and newtons. I was trying to trade off having a semi-reasonable scale while still keeping the display readable, so I settled on just showing the inner part of the solar system. The actual planets/sun are not to scale for artistic reasons, but their positions should be. The display actually shows the inner 2AU of our solar system, with a scale of 1AU=30 pixels, and the sun’s barycenter as the center of the display. The simulation includes the Sun, Mercury, Venus, Earth, the Moon, and Mars, and computers all of the forces between all of the objects every timestep.
All of the initial condition data comes from NASA’s awesome HORIZONS site, with the Sun’s barycenter as the origin. Internally, all data is kept in unnecessarily high precision (double precision floating point), and no effort whatsoever was put into optimizing it to simulate faster. Despite being a fairly pathetic computer, the Teensy has 128KB of flash, 64KB of RAM and runs at 84 MHz. This doesn’t really come close to taxing it.
Ah, but what integrator am I using, you might ask? Or maybe you wouldn’t ask that, as most people that don’t write simulators of physical phenomena for a living don’t know what integrators are. This simulation uses the Velocity Verlet integrator with a ridiculously short timestep of around 1 minute. Isn’t that horrendously slow, you might ask? Yes, but it doesn’t matter! HANS simulates roughly 1 day of solar system time every 10 seconds of wall-clock time, or approximately 1 year per hour. The simulation really does work perfectly, and is extremely stable (it’s run for ever 3 months without any issues, which is probably a record for any of my hobby projects!).
Trouble in Paradise
As I sat at my desk and pondered the tiny universe I had created, I noticed something interesting happening – my solar system had started to drift off the screen! The screen was hard-coded to use the Sun’s barycenter at the start of the simulation as the origin of the 2AU-diameter circle. It was gradual at first, but over the course of 3-4 months, I noticed the whole solar system slowly flying away (although all of the planets were continuing to happily orbit the Sun in their proper orbits). My first thought was “Surely this was just a numerical artifact of my hastily written simulation,” but after discussing it with some of my coworkers one day (it helps to work with former astrophysicists), the problem turned out to be much more interesting. My solar system actually *was* flying away, and it was a real physical effect.
I mentioned earlier that I was only simulating the inner solar system, due to the tiny display I was using. The epheremis data for the bodies that I pulled from NASA came from our whole solar system, though. What would happen if everything in our solar system past Mars just disappeared one day? Well, it turns out all of those gas giants (I’m looking at you, Jupiter!) impart a slightly wobble to our Sun, and if they disappeared suddenly, over the course of 2000-3000 years, the solar system would drift 1-2AU from where it would otherwise be.
The ‘proper’ way to fix this is just to re-center the display around the Sun whenever I display a new snapshot, but I thought it was such a fun effect that I haven’t actually fixed it yet. I could also just add in the additional planets, but not have them make it onto the display, or change the display to have a logarithmic distance scale and fit more planets in. It would also be fun to incorporate small comets or something else that only appear occasionally, just to make it more interesting. If I get bored in the future I may add some more features, but overall I’m very satisfied with how it turned out, and it was a fun result to have accidentally run a somewhat interesting experiment and laboriously calculated the result.
If you feel like making your own…
Feel free to download the source code and play around with it. Having your own universe on your desk is a lot of fun =)