Tracking the moon and other celestial objects using a microcontroller.

Project Update

A few years have passed since I've looked at this project. But now that I am re-building the antennas it is a perfect opportunity to clean up and rebuild my moon tracking hardware. Particularly so now that I am in an environment with a lower rf noise floor and I am able to see the noise generated by the current hardware (mostly due to the colour tft display).
So the main aims for the version 3 build:

  • Reduce the radiated noise emission from the hardware:
    • Make a 2 layer PCB with better groundplanes.
    • Build the hardware into a screened aluminium box.
    • Add more RFI filtering to all inputs and outputs.
  • Replace the display:
    • Improve readability and contrast (particulary in daylight).
    • Speed up display refresh.
    • Increase font size.
    • Consolidate Display data to make for a less cluttered look.
  • Re-write the menu system to make it more user-friendly
  • Allow for future expansion by providing a USB port and a GPS input.

I am finding that a 128x64 pixel monochrome LCD is quite readable, and allows for nice large fonts. The lack of colour is not an issue, and the display refresh rate is quite respectable now.

I also took the time to re-organise some of the software (especially within the menu tree), and fix up a few small bugs that got through the last build.
The accuracy of the astonomical calculations remain unchanged at better than +-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.
A USB converter and RS232 driver have been added to allow for future expansion. Automatic backlight dimming has also been incorporated.

The update has been well worth the effort - I can no longer detect any noise at all eminating from the new hardware.

Hardware Design

The ATMEGA64 microcontroller remains at 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 encoder and signal conditioning PCB.

Mechanical interface

The pulley used to couple the mast rotation to the encoder

The Spirolator

This simple mechanical coupling works surprisingly well.

New MoonTrack hardware.

A more elegant single enclosure solution.

Screen Detail

An extreme close-up of the LCD screen.

Menu System

A simple on-screen menu constructed with a doubly-linked list in software.

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


Moon Tracker ver 3
22/03/19 A new version.
144MHz EME Array
20/02/19 Resurrect the old 144MHz high gain antenna array.
06/11/17 Make allowances for the Thunderbolt date rollover issue.
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