Auto Tracking Camera System

Updated 31 March 2022

The purpose of this project is to design a system that will automatically track stars or satellites. The first version, described here, is specifically to track stars and operate a Raspberry Pi HQ camera to take a series of long-exposure images that can be stacked to enhance the image.

The platform may also be manually controlled via a joystick.

This project digs deep into a few areas, here's some assumed knowledge:

  • Astro-photography
  • The celestial coordinate conversion maths
  • Installing and configuring the Raspberry Pi OS
  • Installing Python 3 software
  • Creating a bash script
  • Installing and configuring the Arduino IDE
  • Using VNC to connect with computers on a network

Information on all these may be found online.

Information on the celestial coordinate system and conversion may be found at these two sites:

Crash course on Celestial Coordinates (http://spiff.rit.edu/classes/phys373/lectures/radec/radec.html)

Converting between Coordinate systems (http://www.stargazing.net/kepler/altaz.html)

The code for the Raspberry Pi, Arduino processor and the camera capture bash script is supplied. The python code is specifically for star tracking. Also, the 3D printing files are supplied in STL format.

This auto-tracking camera system was designed and run on a Linux system. Communication with the tracker may also be performed via Wi-Fi and VNC. Using VNC, it has also been run remotely on a Windows computer. It is possible to connect directly to the tracker via USB for local testing.

Also, note that I designed an auto-leveling tripod mount for the tracker. There are some pictures depicting this but I have not provided any details of its construction or programming. It works but it is still a work in progress and not yet ready for publication.

I have not supplied the code for satellite tracking. I hold an amateur radio license, so satellite tracking is designed for radio communications with satellites. The actual platforms may have to be redesigned to cater for a specific antenna system.

NOTE: If you are interested in using the Pi camera in a telescope without auto-tracking, please look at the PiKon project.

https://linktr.ee/PiKon

Parts List

Operation

The following briefly describes the use of the tracking platform as an introduction to a more detailed description of its design. The primary requirement, apart from constructing the tracker, is to install a planetarium program. There are many available but the one I use is Stellarium because it works on both Linux and Windows. There is an online version but it is best to download and install it. 

https://stellarium.org/

Place the tracker on a level surface with the front-facing due North. When within one degree of North, the green LED will come on. To use the built-in GPS, the tracker must also be outside or at least have access to a large part of the sky. Initially, it may take a few minutes to acquire enough satellites to get a reading – allow at least 15 minutes initially.

On your computer, connect to the Raspberry Pi on the tracker using VNC.

Start Stellarium, set your location (Press F6) and then set Stellarium to use decimal degrees in the configuration window (F2) under ‘Tools’. Also in the configuration windows under ‘Information’, set the information you want displayed but ensure that ‘Right ascension/Declination (of date)’ is selected. Become familiar with the navigation around the stars. This is done using the mouse to move around and the mouse wheel for zoom.

Select a target to photograph. In this example, click on the star Rigel in the constellation of Orion:

A view of the Stellarium software designed to show you the locations of various stars

At the top left, the information display will show the Right ascension and Declination (RA/DEC) and the current Azimuth and Altitude at your location.

Now connect to the Raspberry Pi on the tracker via VNC and open a terminal. Change to the directory where the python program is stored and start it. The system will attempt to acquire your latitude and longitude from the GPS unit. If this is not available, it will default to the programmed one (change to suit your location). It will then ask for the USB port name to communicate with the Arduino processor. This is always the same port unless you have plugged something into another port, so I have left the option there.

A terminal window showing connection to an Arduino via USB

Press enter and then enter the RA/DEC from Stellarium

A terminal window allowing the user to input RA/DEC from Stellarium

Once entered, the tracker will then rotate the azimuth and altitude platforms to point at the selected star and begin tracking. It will also print out the current azimuth and altitude of the tracker. This can be compared with those displayed on Stellarium.

A terminal window showing the progress of rotating to the given coordinates

Note that there is a message line saying ‘Enter c to cancel’

Since this is a Python program, Ctrl-C may be entered at any time to cancel the program. However, this will leave the Tracker platforms at their current location. Entering the letter ‘c’ will first return the platforms to their original starting position before closing the program.

If the tracker needs to be manually returned, the joystick may be used. Press the joystick button once to engage the joystick, an LED will light on the Arduino. Use the joystick to return the platforms to their home position and then press the button to disengage it.

Once tracking has commenced, the bash script supplied can begin taking long exposure images. Ensure that the lens is focused on infinity and the aperture is fully open.

If the script is in the same directory as the tracker python program, start the script: ./Camera_Astro_Picture.sh

The script will capture a 20 second exposure at ISO800 with full contrast and 80% brightness every 30 seconds for 30 minutes. A message will be displayed at the start and end of the capture sequence – refer to the script for details.

The images will be captured to a specified directory. The image of Orion supplied is a single frame as taken. Stacking software may be used to enhance an overall image. There is a Raspberry Pi program called V4L2 Test Bench. Install it using Add/Remove Software. This will give you access to the camera directly and allow you to view the video via VNC for focusing and testing.

Purpose and Scope

The initial purpose was to design and build a device that would track stars so that long exposure pictures could be taken with a relatively cheap camera – the Raspberry Pi HQ camera. This is the primary purpose of the device, however it can also track satellites using different maths and data input. I have written the software for this but it is not published here.

One reason for developing this system was that some astro-photography enthusiasts were saying that it was a waste of time using such a cheap camera. They much prefer their $2000 to $20,000 DSLR cameras. Yes, but not everyone can afford them. I set out to see how good a Pi can be. Please look at the attached picture below – this is the first image taken by the camera. It is a single 20 second exposure at ISO 800 of the Orion constellation, taken in the tropics, so skies weren’t perfectly clear. There are even two meteors captured. Stacking 60 exposures will return a reasonable picture. Mission successful.

a-picture-of-the-orion-constellation

The selected camera was a Raspberry Pi HQ camera with a 16mm lens.

Raspberry Pi HQ Camera specifications

  • Sony IMX477R stacked, back-illuminated sensor, 12.3 megapixels, 7.9 mm sensor diagonal
  • Output: RAW12/10/8, COMP8
  • Back focus: Adjustable (12.5 mm–22.4 mm)
  • Lens standards: C-mount, CS-mount (C-CS adapter included)

Design Principles

The project is split into two sections.

  • Coordination conversion of RA/DEC to ALT/AZ coordinates
  • Stepper motor control

Coordination Conversion

This section uses a Raspberry Pi to do the coordinate conversion maths. My system uses a 3B version which is powerful enough. I will not elaborate on the maths. It's worth a look into it if you’re interested.

Programming

The coordination conversion is a lot of maths and I wrote the program in python 3. Part of the maths requires accurate knowledge of your location on the planet – latitude and longitude. This could have been entered manually but I installed a GPS unit to make life easier for mobility. If it cannot get a GPS reading, it will default to one built in to the programming. This should be changed to your default location.

Also note that the magnetic deviation should be changed in the Arduino code to suit your location.

The system runs over my Wi-Fi network but can also be run using my Android phone as a hotspot. So, the entire system can be controlled from your computer/laptop or via VNC on any computer. Make sure you configure the Raspberry Pi with a static IP address to make life easier. On the computer, I run the Stellarium planetarium program to select the star or constellation to track. Clicking on the target will display the right ascension and declination (RA/DEC) coordinates of the object. These are manually entered into the python program. This could be done via cut and paste on a Linux system but Windows doesn’t play well with it, so I dropped it.

The code then gets the local date and time, calculates the Julian date and hour angle and then the altitude and azimuth (ALT/AZ) of the object.

Stepper Motor Calculations

Typically, auto-tracking mounts use rotary encoders and motors to determine the position and then move to the required coordinates. I have a perverse nature and decided to use stepping motors and worm gears to do the positioning. This eliminates the need for rotary encoders.

The stepper motors are common NEMA 17 type with a resolution of 200 steps per rotation. Each motor then drives its platform through a 60:1 worm drive gear. 200 steps per revolution is an angular accuracy of 1.8 degrees. After the worm drive, this accuracy is 0.03 degrees. So one revolution is 12000 steps or 33.3 steps per degree of rotation.

The tracker must initially be aligned to be horizontally level, pointing true north and the altitude platform also level at zero degrees. Once activated, the program will calculate the number of steps to send to the motor controller to position both the altitude and azimuth platforms. Once the initial position has been achieved, the program will send only the differential number of steps to move the platforms to the next position. It also records the total number of steps for both motors so that the final command can return the motors to their initial starting home position.

During tracking, the current ALT/AZ coordinates are printed to the screen. The tracking can be terminated any time by typing in the letter ‘c’. This will interrupt the program and return the motors to the home position. Ctrl-C will terminate the program but leave the tracker at its current position, hence ‘c’ was used to home it.

The step data is sent from the Raspberry Pi to the Arduino of the stepper motor controller via a USB connection.

Stepper Motor Control

The two stepper motors are NEMA 17, 200 steps per revolution devices. These are controlled using an Arduino Uno for processing with an Adafruit Motor Shield V2.3 for motor control.

Two other devices are included for control by the Arduino, these are a small joystick, added for manual control and a 3 axis magnetometer sensor for determining true North.

Libraries

Motor control uses AccelStepper, so this needs to be downloaded from GitHub as well as the Adafruit Motorshield and Adafruit SM303DLH libraries.

3D Printing

Also supplied are the 3D printing STL files that I used to make the platform, etc.

  • 50mm Plate 25mm Flange 9mm Hole 2.5mm Mounts 
  • 100mm Support 20mm Flange Stepper and Fan Mount (2 required)
  • 180mm plate 20mm mount 6mm hole 
  • Altitude Platform 160mm mount hole 6mm 
  • Fan_mount_40mm (2 required)
  • Joystick Mount – joystick sits on this to insulate it from the base plate
  • Lens Hood – slips over the 16mm lens
  • RPi Camera Shield – protects the back of the camera electronics
  • RPi Mount (2 required)

Wiring Information

Much of the wiring should be evident from the pictures. Specifics are listed below.

The power supply is built on a piece of veroboard, so knowledge and use of electronic construction techniques are required.

Mounting of most components of the tracker uses a drill and tap for 3mm screws.

Power Supply

Everything is run from 12v, either via a 12v battery or a plug pack.

The 5A Step-Down Voltage Regulator accepts 12v input for the Arduino and both cooling fans.

The output of the regulator is smoothed by a 1000uF capacitor which then feeds the Raspberry Pi and Stepper Motors via the Adafruit Motor Shield.

Raspberry Pi Wiring

Raspberry Pi power

I soldered the 5v supply to the board.

However, it could be connected via the GPIO

Connect pin 2 for 5v and 0v to any other GPIO ground pin.

Connection to GPS

Raspberry Pi

GPS

Pin 4 – 5v

VCC

Pin 6 – Ground

Gnd

Pin 10 – RxD

Tx

Arduino Wiring

The Arduino is run from 12v directly.

Joystick

Arduino

Joystick

Gnd

Gnd

5v

5v

A0

VRx

A1

VRy

D2

Sw

LSM303DLHC Wiring

Arduino

LSM303

5v

Vin

Gnd

Gnd

SDA

SDA

SCL

SCL

D4

220 ohm resistor and LED to Gnd

Appendix - Images of the Auto Tracking Camera System

star-tracker-on-three-legs

Three table legs from local hardware store.

There are six bracing straps, only three are installed at the moment. They are staggered as shown to reduce any resonances that may occur during tracking. The “clips” around the legs are printed on the 3D printer.

electronics-mounted-to-frame-2x-arduinos-and-raspberry-pi

Overhead view of the entire platform. At the rear right, one of the auto level stepping motors can be seen. On the left hand corner is an Arduino process controller with the stepping motor controller mounted on top of it. The little board next to it is a 12v to 5v power supply. The Arduino and controllers run on 12v but the motors run on 5v. On the left hand side of the table is a small joystick for manually adjusting the auto level motors if required – usually just for calibration.

electronics-with-functions-labelled

This is a labeled picture of the electronics with the functions of the bits and pieces. 

side-view-of-tracker

Side view of the system. This shows both auto level stepping motors. On the tracking unit in the centre you can see the manual joystick for manual Alt/Az control of the tracker. Also the little board with the green LED is the True North indicator. A 3 axis magnetometer is read by the Arduino processor and calculates the bearing. Adjustment from magnetic to true North is done so that the LED indicator comes on within one degree of North.

front-view-lens-and-camera-mounted

Top front view. Shows auto level stepper motor at the bottom. Center is the tracker altitude and azimuth platforms. The azimuth platform contains the Raspberry Pi computer. This does all the main programming/processing for either star Equatorial to Alt/Az conversions or Satellite TLE data to Alt/Az conversions. It then does the computing from Alt/Az coordinates to stepper motor control information. At the end of a run, it will automatically return both Alt and Az platforms to due North and zero degrees. The white rectangular device under the camera is the GPS antenna. Accurate Lat/Lon is required for the maths to do the computations. Worm gears are shown for the Altitude control.

levelling-screw-stepper-motor

This is a close up of one of the legs. It shows the 18cm lead screw shaft going into the leg for auto levelling.

Attachment - Project Files

Have a question? Ask the Author of this guide today!

Please enter minimum 20 characters

Your comment will be posted (automatically) on our Support Forum which is publicly accessible. Don't enter private information, such as your phone number.

Expect a quick reply during business hours, many of us check-in over the weekend as well.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.