Lunar Phase Clock

by Aleator777 in Circuits > Clocks

125454 Views, 1131 Favorites, 0 Comments

Lunar Phase Clock

lunar clock.jpg


In this Instructable we will be building a dynamic lunar lamp with the Raspberry Pi. With your very own lunar clock you'll always know the current phase of the moon, no matter the weather!

History and Theory

LunarPhasesGFX.bmp

Budding astronomer? Recently bitten by a werewolf? Whatever your lunar-phase-knowing needs, the Lunar Phase Clock has you covered! If you're interested in getting started on the build, move on over to the next step. Here we'll talk about the astronomy behind the project.

So what are the phases of the Moon?

Just as the Earth orbits the Sun, so too the Moon orbits the Earth. The Moon is tidally locked to the Earth, which means that because the Moon completes its own rotation in the same time it take to orbit around the Earth, we always see the same side of the Moon. While we may be stuck to the same view of the Moon, the relationship between the Earth and Sun as the Moon completes its orbit is constantly changing. This means that it will be illuminated to varying degrees (or not at all!) and will take on a distinct shape. These distinct shapes are what we refer to as the lunar phases. The Moon completes a cycle around the Earth every 29.53 days; this is referred to as a synodic month.

Materials

IMG_0518.JPG

Materials:

Raspberry Pi (RadioShack #277-196)
SD card
protoboard (RadioShack #276-168)
(2x) LED strip (RadioShack #55065456) web only
(8x) n-channel MOSFET (3V3 Gate-Source level or lower) Mouser
(8x) 10K resistor (RadioShack # 271-1126)
12V AC adapter (RadioShack #Catalog #: 273-318)
USB wifi adapter (RadioShack #55044156) web only
USB power supply (RadioShack #55075817) web only
Micro USB cable (RadioShack #26-2738)
22 gauge wire (RadioShack #278-1218)
(2x) 4/40 nut (RadioShack #64-3018)
(2x) .75" 4/40 machine screw (RadioShack #64-3011)
(4x) 2" 6/32 screw
(4x) 6/32 nut
plywood

Configuring the Raspberry Pi: OS and Networking

RaspiWifiTitle.bmp

For these next steps, you'll need to have the Raspberry Pi set up with an operating system and hooked up to a full keyboard/mouse/HD monitor setup or connected to a computer via SSH. Click through the link below to see my brief companion guide for setting up the wireless connection Netgear Wi-Fi adapter. This guide also includes a link to a great Instructable for setting up the Raspberry Pi. Since the RasPi doesn't have a hardware clock, we'll be using the internet as a consistent time source. We'll also need to install a few things in order for us to use the GPIO on the pi. Setting up an internet connection varies depending on how your network is set up. For this Instructable, we'll be using a wireless connection via USB.

Connect the Raspberry Pi to the NetGear G54/N150

Configuring the Raspberry Pi: Python Program

python-logo.bmp

Initially, I had considered having the moon-clock pulling the lunar data from the internet over wifi, but as luck would have it, there's an algorithm for calculating the current lunar phase for a given date. Math to the rescue! I found the algorithms here. The particular algorithm we'll be using was written by John Conway, whom you may know as the person behind the cellular automata program "Game of Life." The lunar phase algorithm was written in java, but it was not too difficult to translate this over to python.

Before we can run the Python program we'll need to install the GPIO library and developer headers.

Type the following into the terminal:

sudo apt-get install python-dev

sudo apt-get install python-rpi.gpio

We'll need to install and run the Python program as soon as the Pi boots up. Download the attached program "moonlight.py" and copy it over to the Pi. Make sure it's in the directory "/home/pi" (some info on moving the program over)

We'll make the program into an executable with:

sudo chmod +x moonlight.py

Next we'll need to open up another file. Type in:

sudo nano /etc/rc.local

Comment out any text below by putting a "#" at the start of the line. Below the text type in:

sudo python /home/pi/moonlight.py &

Hit ctrl+x to save and then "y" to confirm the changes to the file. Now when the Pi boots up our program will run automatically.

Downloads

Build the Circuit: Design

LunarMOSFETdriver.bmp
IMG_0281.jpg

Here is the schematic for our LED driver board. We're using N-channel MOSFETs to connect the 12V powered LEDs to ground. I chose N-channel MOSETSs as this setup has logic "high" pulses from the Pi activating the lights, which was more intuitive to program.

Build the Circuit: MOSFETS

IMG_0285.jpg

Space the MOSFETs evenly on the circuit board all facing the same direction.

Build the Circuit: Resistors

IMG_0283.jpg
IMG_0286.jpg
IMG_0284.jpg

Bend the leads of the resistors over so they'll fit into two adjacent holes on the board. Place one resistor from the gate pin of the MOSFET (the leftmost pin when looking directly at it) to the power bus in the middle of the board.

Build the Circuit: Terminal Blocks

IMG_0287.jpg

Place the terminal blocks along the edge of the board so that one of the pins is aligned with the drain pin (middle pin) of each MOSFET.

Build the Circuit: Wiring

IMG_0288.jpg
IMG_0289.jpg
IMG_0290.jpg
IMG_0292.jpg
IMG_0291.jpg
IMG_0294.jpg
IMG_0296.jpg
IMG_0297.jpg
IMG_0295.jpg
IMG_0298.jpg
IMG_0301.jpg

Using the clipped leads of the resistors, make tiny jumpers with a pair of needle-nose pliers.

Build the Circuit: Light Strips

IMG_0243.jpg
IMG_0244.jpg
IMG_0246.jpg
IMG_0247.jpg
IMG_0249.jpg
IMG_0250.jpg

Unroll the LED spool and cut the strip into 16 pieces of 3 LEDs. The strip has copper pads every 3 LEDs for power and ground.

Building the Frame: Design

MoonVectorDesign.bmp

The Lunar Phase Clock is made of stacked sheets of laser-cut plywood for the body and the base. I designed the frame in Illustrator and used an Epilog 120 watt laser to cut out the pieces from 1/4 inch ply and 1/8 inch acrylic. The body plates are stacked together with segmented ribs that organized the light into eight distinct segments. This gives us enough resolution to display the main phases of the Moon. The LEDs lay flat along the back panel and shine light through a sheet of paper that has an image of the Moon printed on it. The paper acts to diffuse the light for more gentile progressions as the segments light up. The body is held together with 4 screws along the top rim. This allows it to be easily disassembled if the LEDs were to be damaged or the face replaced.

The base of the clock is made of three stack pieces of ply that have slots for the body to slide into. The holes are designed with tight tolerances so that the body and base can be held together with a "friction fit." The quarter-circle edge pieces serve to support the weight of the body and hide the wiring and electronics from view.

Download and cut out the attached .ai files.

"MoonFrameComplete" should be 1/4 inch wood. (Note that the ribbed piece should be cut out three times)

"MoonClearPlates" should be 1/8 inch clear acrylic.

Glue the Frame

IMG_0141.jpg
IMG_0125.JPG
IMG_0126.jpg
IMG_0131.jpg
IMG_0128.jpg
IMG_0124.jpg
IMG_0134.jpg
IMG_0137.jpg
IMG_0136.JPG
IMG_0138.JPG
IMG_0142.jpg
IMG_0267.jpg

Lay the three base pieces out on a large surface. With course sand paper, remove the unsightly laser burns and charred sap from the edges. Making note of the proper layout, flip the two top pieces over and coat with wood glue. Lay the middle piece upon the base, using the finger holes as a guide to properly align them. Lay the top piece upon the middle plate, using the large rectangular body slot as a guide. Clamp the base pieces together and allow to dry for 24 hours.

Moon Graphic

IMG_0175.jpg
IMG_0177.jpg
IMG_0176.jpg
IMG_0237.jpg
IMG_0236.jpg

Print out the attached Moon graphic and cut out along the white line. Place the new piece between the two circular pieces of acrylic.

Downloads

Finish the Frame

IMG_0238.jpg
IMG_0239.jpg
IMG_0251.jpg
IMG_0253.jpg
IMG_0254.jpg
IMG_0255.jpg
IMG_0256.jpg
IMG_0258.jpg
IMG_0241.jpg
IMG_0259.jpg
IMG_0261.jpg

Lay the solid base plate down with one ribbed piece on top. Using a pencil, outline the inside segments; we'll use this as a guide for properly placing the LED's.

Take the eight elongated LED strips and fish the power wires through the holes near the middle of the base plate. Bend the white wires between each segment so that the strips follow the curves of each segment. Glue the underside of the strips in place.

Place the next two ribbed body plates, followed by the plates with the hole large enough for the acrylic circles. Place the acrylic containing the Moon shape into the body, using the straight edges of the paper to properly align the Moon with the edge.

Place the face-plate over the acrylic sheets. This holds them in place and covers the edges of the paper. Fasten the panels together with the 2 inch screws.

Mount Electronics

IMG_0268.jpg
IMG_0277.jpg
IMG_0276.jpg
IMG_0307.jpg

Mount the Raspberry Pi over the two left holes with the 4/40 screws. Attach the wires from the strips to the driver board, referring to the schematic on step 7 (The leftmost wires while facing the back are attached to the lowest pin number).

Power Supplies

IMG_0278.jpg
IMG_0279.jpg
IMG_0309.jpg

Cut off the plug of the 12 volt power supply and plug the wires into the terminal block of the driver board.

Plug the micro USB cable into the Pi and the USB adapter. Plug in the 12 volt supply into the wall.

Finishing

MoonMain.bmp
IMG_0308.jpg
MoonFullClock.bmp
DJ3.gif

The Lunar Phase Clock is fine and dandy on its own, but a touch of color could certainly improve upon its laser-cut appearance. I decided to give my clock a dark stain and a few coats of polyurethane to seal it in. There's lots of open flat panels to coat, so it would make a great canvas for some custom artwork too.