Tracking the moon and other celestial objects using a microcontroller.

Project Update

After a couple of years of using my original moon camera hardware, I decided it was time to upgrade my microcontroller based moon tracking system.
Particularly as I am migrating towards 1296MHz where antenna beamwidths are narrower, I felt it a good opportunity to revisit this project with a couple of aims in mind:

  • Improve the overall accuracy of the astronomical calculations.
  • Add more data to the display:
    • Moon distance
    • Moon right ascension and declination
    • Colour highlighting to indicate when objects are above the horizon
  • Allow tracking of other celestial objects:
    • Sun
    • Leo
    • Pictor
    • Aquarius
  • Re-write the menu system to make it more user-friendly
  • Remove the remote mounted camera
  • Make it smaller

Removing the remote antenna-mounted ccd camera might seem a strange idea, but in the 3 years of using this system, I have learned that the tracking is sufficiently robust as to not require any visual feedback in the form of a camera. So i decided that to make version 2 smaller and reduce power consumption I would remove the camera as an unnecessary gimmick.

Much of the software was re-written, and a small colour TFT LCD display was used (less than $5 online).
The accuracy of the tracking has now been improved to be within +-0.1deg. Atmospheric refraction has been added to the calculations to improve accuracy at rise and set times. Doppler calculation has also been improved and is now within a few tens of Hertz at 1296MHz.
The Real Time Clock (RTC) has been replaced with a more accurate IC which boasts an internal laser trimmed oscillator.
Most of the other electronics have remained unchanged.

Hardware Design

The ATMEGA64 microcontroller is the heart of this project. It is used for all the astronomical calculations, motor control and user input (via a 5 button key-pad, with an on-screen menu style User Interface.

So first to the encoder. After some searching, I have found a suitable compromise between accuracy, resolution and cost: A 12-bit absolute rotary encoder made by Georg Hylinski, DF1SR (see Useful Links). It uses a AS5045 magnetic rotary sensor IC, and is housed in a standard potentiometer case for easy mechanical integration.
The HH-12 uses a 3-wire Synchronous Serial Interface, and requires a 5V supply. I decided to use a bit of signal conditioning to improve the noise immunity and provide a modicum of protection against induced noise spikes, so I used a MAX232 RS232 level converter to provide a bipolar signaling scheme to run between the encoders and mooncam hardware. This is NOT an RS232 interface, it just uses the same voltage levels as RS232.
The encoder is coupled directly to the mast using a modified form of a "spirolator", published by Ed Gray W0SD in 1989. I first came across this idea in the EME Newsletter Collection of Geert PA3CSG (see Useful Links). The mechanical accuracy of this system depends upon:

  • The stretch in the string
  • The pulley diamater vs mast diameter
  • Slippage on the pulley

Schematics for the new hardware, as well as some photos, as shown below. The resolution of the new system is now better than 0.1 degree in azimuth, and the new integrated motor drive has cleared some valuable desk space.


Power Supply and motor drive.

Sensor signal conditioning.

Magnetic Absolute Encoder

12-bit absolute magnetic enclosure, by DF1SR.

Encoder and interface.

The encoder mounted in an enclosure.

Mechanical interface

The pulley used to couple the mast rotation to the encoder

The Spirolator

This simple mechanical coupling works surprisingly well.

New Moon Cam hardware.

A more elegant single enclosure solution.

Screen Detail

An extreme close-up of the LCD screen.

The mechanical coupling between the mast and azim encoder works much better than I expected. I have detected no slippage thus far.

Software Design

The software can be divided into 3 basic sections:

  • Astronomical Calculations
    • Moon position, distance, right ascension and declination
    • Moon Doppler shift
    • Sun Position
    • Leo, Pictor and Aquarius Position
    • Sky Temperature
  • Antenna Control
    • Positional Feedback signal conditioning
    • Motion limits
    • Hysteresis settings
    • Automatic and manual Antenna control settings
  • User Interface
    • Display Control
    • Linked list menu system
    • User Data Stroage and manipulation
      • Geographic location
      • Time and Date
      • Feedback Calibration
      • Rotator mechanical limits
      • Frequency
    • Keypad Debounce

A good place to start with celestial mechanics is (of course) the internet (see Useful Links). Much may also be learned from Meuus "Astronomical Algorithms" and Duffett-Smith and Zwart "Practical Astronomy with your Calculator or Spreadsheet"

As it turns out, the code for the astronomical calculations requires only a small amount of fancy footwork - mainly required to ensure errors due to rounding and truncation are minimised. The resulting pointing errors are worst at moon rise and moon set times, and are around +-0.1deg. Given my parabolic reflector antenna has a beamwidth of around 7deg, this error can be safely ignored. As my antenna motors have no speed control, a simple Bang-Bang controller was coded, with some independant user selectable hysteresis limits to avoid hunting.

A further useful feature added was the ability to compute the background Sky Temperature, which gives an indication of whether or not the moon is in a "quiet" part of the sky (as seen by an observer on earth). This calculation requires the use of an all sky temperature map. Fortunately, the excellent work published by Haslam et al is available for download (see Useful Links), and provides some excellent data of the sky at 408MHz.

The data set is large (Haslam's resolution is approximately 0.8 degrees). This results in a lot of data to shoe-horn into a small 8-bit microcontroller. Moreover, such resolution is not needed for Amateurs, as we are unable to achieve shuch small beamwidths. So we must integrate the data to allow for a lower resolution (bigger beamwidth in the antenna). I have taken the data and filtered and re-sampled it so as to provide a more meaningful sky temperature number, as well as fit into a microcontroller. Shown in the plots below are Sky Temperatures(K) for the whole sky (in Galactic co-ordinates). On the left, the original Haslam data set. On the right, my filtered and decimated data set.

Haslam 408MHz Sky Temperature

Filtered 408MHz Sky Temperature Data set

The control system is ultimately limited by the mechanical backlash and dynamics of the rotator motors. In my case, the backlash is around 0.4 degrees.

Useful Links


1296MHz Activities
26/06/16 Antenna Improvements.
Moon Tracker Ver 2
23/06/16 A new version.
1296MHz Activities
29/09/15 Build a small dish.
26/07/15 Low-noise Preamplifier Design.
1296MHz Activities
19/04/15 Power Amplifier Design.
1296MHz Activities
13/01/15 Design and build a tower for 3m parabolic dish.
30/09/14 LCD monitor for my Thunderbolt GPSDO.
02/08/14 A home-made Noise Figure Meter.
Moon Tracker Update
09/04/14 New rotator and better position feedback sensors added.
1296MHz Antenna
09/02/14 Begin construction of a 1296MHz feed horn for the 3m dish.
1296MHz Activities
28/01/14 After success at 144MHz, operation at 1296MHz is planned.
Moon Tracker Update
11/09/13 Added a Background Sky Temperature calculation into the Moon Tracker.
Moon Tracker Update
28/08/13 Just Added some software limits to rotation of motors.
Roger Beep installed
09/08/13 Added a Roger Beep to my radio.
Andy's Website
06/05/13 Start build of website.


Andy, VK3ANX
Yarra Valley, Australia