Posted on 11 Comments

A barn door tracker shield for Arduino

Interested in astrophotography? Do you want to first try this hobby before investing on expensive computerized EQ mounts? A barn door tracker can be a good starting point after trying fixed tripod astrophotography. A well built barn door tracker at a fraction of the cost of other commercial options can produce photos which can stun you. It will surprise you that a simple device like this can actually track the stars and other celestial objects.

The barn door tracker was created by George Haig. It is also called as the scotch mount or Haig mount. The plans for his tracker were first published by the Sky & Telescope magazine in their April 1975 issue. The original design was was improved upon by Dave Trott who introduced a second arm in the design. This improved tracking accuracy over time. His new design was published by the Sky & Telescope magazine in their February 1988 issue.  The original designs all involves manual actuation.

Today, a modern barn door tracker can be easily built with a stepper motor to automatically drive it.

The “smart” barn door tracker shield for Arduino

The features of the shield is listed below. The software for the shield is completely open source and you can modify it for your barn door. The software provided will work out of the box for the reference design provided here.

  • DRV8825 based stepper motor controller
  • Micro stepping of 1/32 steps, giving a single step granularity of 0.86 arc seconds for a 300mm arm / 8mm pitch.
  • Software
    • Open source
    • Tangent error correction
  • User controls
    • Track
    • Pause tracking
    • Fast forward
    • Rewind
  • A keypad with 4 keys is provided to get started. User can replace the keypad if required.
  • Automatic home detection through external limit switch or by manual overriding switch
  • One LED to provide status information
  • 12V 1A power input
  • Reverse polarity protection
  • Compatible with 12V NEMA 17 bipolar stepper motors
  • Provides power to the Arduino. No need to power the Arduino separately.

Gallery of images shot with this controller

Orion nebula and Horsehead nebula

Picture 1 of 5


Are you interested in ordering one?

If you are interested in ordering one, please fill in this form and I will get back to you with the details. Thanks!

Operation guide and steps

  1. For the operation of the tracker and tangent error correction, the controller needs to know the ‘home’ position (the lowermost, starting point). The operation of mount is suspended till the controller knows this home position. The controller will allow the use of the ‘rewind’ button to bring the tracker to the home position. Home position is detected through the external limit switch or manually by pressing the ‘home’ button on the controller. While waiting for home, the DX LED will be blinking. Every time the controller is switched on, this procedure must be done.
  2. After the barn door reaches home position, the ‘track’ button can be used to start tracking. Tracking can be stopped at any time by using the ‘stop’ button. ‘Forward’ and ‘Rewind’ buttons can be used to quickly move the camera arm up and down.
  3. The tracker will stop automatically when the predefined upper limit is reached. The tracker can be used again by using the ‘rewind’ button to bring it back to the home position.

Connecting the stepper motor

A NEMA 17 bipolar stepper motor is required for this controller. The stepper motor is connected to the controller through the screw terminals provided. Coil 1 is connected to A1,A2 terminals and Coil 2 is connected to the B1,B2 terminals. If the motor is rotating in the reverse direction, interchange the coils or swap the terminals.

Connecting the home limit switch

As mentioned earlier, the knowledge of the ‘home’ position is very important for the controller to perform the tangent error correction. There is a ‘home’ terminal in the controller which can be used to connect an external limit switch which will detect home position. If an external switch cannot be connected, an override button is provided on the controller itself to signal a home position.

Connecting the keypad

The controller has provision to connect four external switches/buttons for the play, stop, fast forward and rewind operations. The controller comes with a 4 button keypad which can be used for this purpose.

Power requirement

A 12V 1A external DC power supply is required for the controller. This power is internally routed to the Arduino and hence no separate power is required for the Arduino.

Detailed information on why do we need a tracker for photographing celestial objects and  what is long exposure is explained in this blog post here.


Electrical circuit diagram

Software source code

Posted on 5 Comments

Build your own barn door tracker. A reference design

This post provides you a reference design to start building your barn door tracker. You might want to refer to the other posts in this blog for detailed design choices. The design is for an “isosceles” barn door tracker. This design’s fundamental idea is to use readily available components in the market and to give an opportunity for people with minimal DIY skills to build it.

The bill of materials to build the tracker

Please note that you can exchange some of the components listed below to what is easily available for you. The choice of the 8mm pitch lead screw was made because this is available in high quality and at very low prices thanks to the popularity of DIY 3D printing machines. This lead screw (threaded rod) is used extensively in the build of 3D printing machines. If you change this, then corresponding change needs to be done in the software side to change the motor speed. If you are using your own motor speed controller, then take a look at the online speed calculator.

Ply wood for camera arm and fixed arm350mm x 200mm2
Ply wood for motor and nut carriers80mm x 100mm2
Door hinges76mm (3")6
Threaded rod or lead screw200mm length, 8mm pitch, trapezoidal thread (Standard for DIY 3D printing machines and hence widely available)1
Nut for threaded rod or lead screwTo suit your selection of threaded rod1
Shaft coupler8mm to 5mm (or to match your selection of threaded rod and stepper motor shaft)1
Stepper motorNEMA 17 bipolar stepper motor1
Stepper motor mounting bracketTo suit your motor. Flat.1
Control circuitReference circuit1
Ball head for camera mountingMini ball head for lenses up to 55mm. Heavier lenses will requires good ball heads1
Laser pointerGreen laser pointer for polar alignment1

Mechanical plan for the tracker

The following plan is can be viewed in full size by clicking on the image. Let’s do a quick run of the design:

  • The primary hinges connect the camera arm and the fixed arm like a “barn door”. That’s why this is called a barn door tracker
  • The other hinge pairs have the following uses
    • 1 pair connects the nut carrier to the camera arm
    • 1 pair connects the motor carrier to the fixed arm
    • These hinges provide the freedom for the carrier plates to automatically adjust their position as the two arms spread away from each other. This is a critical part of the design. The rigid threaded rod connected to both the carrier plates will force the hinges to adjust themselves to create the “isosceles” triangle
  • Note the dark gray color in the hinge mounting holes. Only these positions have to be screwed. The blank holes should be left without fastening with screws. This configuration gives the hinges the required freedom to allows them to automatically adjust.
  • The position of the ball head should be as close to the primary hinges as possible. This reduces the load on the stepper motor, allowing heavier lenses to be used.
  • The shoulder for the laser pointer can be anywhere, but needs to be as parallel as possible to the primary hinges. We use the laser pointer to do polar alignment. Polar alignment in the case of a barn door tracker is making the hinges point to the north celestial pole (pole star for practical reasons)

The electrical circuit

The barn door tracker has been around since 1975. This was a time in which access to electronics and micro-controllers would have been limited to specialized engineers and labs. Today the prolific proliferation and commodification of micro-controllers puts in the hand of the average DIY enthusiast. Especially systems like the Arduino make it very simple to code and download your software into micro-controllers. In our use case, the Arduino micro-controller is used for the following:

  • User interface – Buttons to control tracking, pause, rewind and fast-forward
  • Speed control of the stepper motor.
  • Home position detection
  • Mode selection – 300mm / 400mm arms, 8mm pitch / 1.5mm pitch

The other important component is the stepper motor controller. We choose to use a DRV8255 based controller. The DRV8255 manufactured by Texas Instruments is a integrated stepper motor controller. There are many DRV8255 carrier boards available. Most of them are pin compatible with each other. The breakout boards for TI’s DRV8825 micro-stepping bipolar stepper motor controllers feature adjustable current limiting, and six micro-stepping resolutions (1 step to 1/32-step). We choose to use 1/32 micro-stepping mode in our design.

The two most expensive components of this circuit are the Arduino (~$8) and the DRV8255 breakout board (~$5). Arduino clones are available for even lower prices.

The circuit requires a 12V DC power source capable of providing 1 amp current. The

I/O details of the circuit:

TerminalConnect toNotes
12V SUPPLY12V 1A external power supplyA NEMA 17 stepper motor will typically consume around 400 mA of power
TRACKPush button or keypadButton user presses to start tracking
PAUSEPush button or keypadButton user presses to pause tracking
F>FWDPush button or keypadButton user presses to wind the mount in the tracking direction
REWINDPush button or keypadButton user presses to wind the mount in the reverse direction
HOMELimit switch or buttonLimit switch placed in such a way that it signals the home (bottom most position of camera arm) to the controller. There is an overriding push button in case limit switch cannot be provided
COIL 1/AStepper motor coil #1
COIL 1/BStepper motor coil #1
COIL 2/AStepper motor coil #2
COIL 2/BStepper motor coil #2



If you want a fully built circuit, you can buy it from me. Please get in touch. More information is here. This is an Arduino shield. You will have to plug it in on top of an Arduino.

The software

The source code for the smart barn door tracker is posted below. This source code is to compiled and downloaded to the Arduino. This source code is fairly well documented if you need to make any changes of your own to suit your barn door tracker.



Reference build image gallery


Astro photography made with this mount

Orion nebula and Horsehead nebula

Picture 1 of 5


Posted on 4 Comments

An automatic barn door tracker calculation tool

Presenting an online calculator to perform all the calculations you would require to build an “isosceles” barn door tracker. Especially useful if you are not following any traditional designs available on the internet. You can also use this calculator to see the relationships between the various parameters which control the barn door tracker. Please note that all the calculations are in metric units (mm). You can use imperial units (inches) as long as use the same units in both “arm length” and “pitch”

In the calculation, we double the required pulse frequency to be generated by the micro controller. This is because we will be using the same timer to set the pulse port ‘on’ and ‘off’. The time between two ‘on’ signals will be half this doubled frequency’s time period (technically time between two low to high transition edges). It is self explanatory from the figure below.

Posted on 14 Comments

The tangent error in a barn door tracker

The barn door tracker’s geometry has an inherent error which creates a slow drift while tracking the sky. In the most basic of barn door trackers, this drift starts becoming apparent in about 10 minutes. In the “isosceles” barn door tracker described in this website, the drift starts to become apparent after 20 minutes. Mathematically the drift or error is because of the non linear relationship between the included angle of the triangle and the length of the base (threaded rod/nut displacement). A linear (or constant speed) increase in the length of the base of a triangle does not produce a linear increase in the included angle. This is apparent from the math below:

S = 2·L·sin(θ/2)
‘L’ is the length of the two the arms
‘θ’ is the included angle of the arms
‘S’ is the base or displacement of the nut/threaded rod.

θ = 2·sin1(S/(2·L))

When we solve for dθ/dt (rate of increase if angle) given a constant dS/dt, we get a non linear solution. In simpler terms, the angular velocity of the barn door tracker will not be constant when the threaded rot is rotated at a constant rate.

The following chart shows how the actual angle starts drifting away from the expected angle for a barn door tracker which is not compensated for the tangent error. This is for an isosceles barn door mount with an arm length of 300mm

The following chart shows the actual drift error, when the barn door tracker is not compensated for the tangent error. This is for an isosceles barn door mount with an arm length of 300mm

Traditional solutions

The traditional way to solve this problem was by means of mechanical improvements. Typically a second arm was introduced in the camera side. By the introduction of a second arm to drive the camera arm, tracking accuracy was greatly increased. This increase in accuracy allows exposure times of up to one hour. Another traditional method was by introducing a specially designed guide profile between the the camera arm and the actuator. This profile has a negative version of the tracking error thus canceling out the tracking error.

Modern “smart” solution

The traditional solutions substantially increased the fabrication difficulty of the barn door tracker. Also, these solutions were from an time when electronics and micro controllers were the toys of specialized engineers and technologists, out of reach of the average DIY enthusiasts. The solution to the tangent error through software is a simple and elegant one.

The tangent error is created because a constant speed applied on the threaded rod of the barn door tracker produces a non linear response in the angle of the tracker. The solution for this is to adjust the speed applied to the threaded rod continuously  so as to maintain a constant linear response in the angle of the tracker. This can be achieved by software running in a small micro controller like the Arduino. This concept is visualized in the chart below:

The software source code to perform this correction is provided free and open source here.


Posted on Leave a comment

Mathematics behind the barn door tracker

Let’s look at a bit of math behind how the barn door does it’s magic. This article is specifically about the “isosceles” barn door tracker. This is the only type of tracker considered in this site. Consider the diagram below. The barn door tracker has two arms:

  • A moving arm which carries the camera (AC in drawing below)
  • A fixed, stationary arm (AB in drawing below).

The moving or camera arm with the camera is connected to the fixed arm through a hinge. The aim is to make the camera arm rotate about the fixed arm at exactly the same speed at which the earth rotates.

The speed of earth’s rotation

  • The earth takes 23 hours 56 minutes 4 seconds to rotate around it’s axis.
  • Expressed in minutes, it is approximately 23×60 + 56 = 1,436 minutes
  • One rotation is equal to 360°
  • Implies speed of earth’s rotation : 360°/1,436 minutes ~ 0.25° per minute ~ 15° per hour.

Neutralizing the earth’s rotation

The primary goal of the barn door tracker is to rotate the camera arm at the rate of 0.25° every minute to neutralize the effect of earth’s rotation. That is, increase θ in the diagram below at the rate of 0.25° every minute.

Mechanically this is achieved by increasing the length ‘S’ with the help of a screw connected to a motor. When S increases, the angle θ increases. By increasing the length S at a precise calculated rate, the angle θ can be increased at 0.25° per minute, our goal. Let us see how this speed is arrived at.

We know that θ has to increase at 0.25° per minute. And to increase θ, we need to increase S. Let us derive the relation between S and θ.

△ ABC is an isosceles triangle. This is because both arms AB and AC are of the same length. To make our math simpler, let’s divide the  △ ABC into two equal parts separated by the dotted line. The two new triangles are right angle triangles. Let’s apply some basic trigonometry:

sin(θ/2) = (S/2)/L
sin(θ/2) = S/2·L
S = 2·L·sin(θ/2)

Let us calculate the required increase in S every hour for tracking (approximately).

At the beginning S = 0 mm, θ = 0°
After 1 hour, θ should be 15° (earth’s rotation speed)
S = 2·L·sin(θ/2) per hour
S = 2·L·sin(15/2) per hour
S = 2·L x 0.1305 per hour
S = 0.261·L per hour

Note: Earth’s rotation is not exactly 15° per hour. Remember earth takes 23h 56m 4s to make one rotation. This translates to 15.04° per hour. We will use this more accurate speed in the software we would write later.

As an example, if we had chosen the arm length L = 300mm in the design, S = 78.3mm at the end of 1 hour of tracking. See below:


Posted on Leave a comment

How does a barn door tracker work?

The primary goal of the barn door tracker is to rotate the camera at the rate of 0.25° every minute (15° every hour) to neutralize the effect of earth’s rotation. Why 15° every hour? because the earth is rotating at 15° every hour from west to east. Our barn door tracker will rotate the camera 15° every hour at the opposite direction of east to west. Equilateral mounts (EQ) mounts do this with the help of precision worm gear and wheels. These gears are difficult to assemble and cost very high in low quantities. We would use a simple and cheap threaded rod and a nut instead of worm gears and wheels. We cannot match the precision and quality of commercial EQ mounts, but you will be surprised at the kind of tracking and photographs which can be achieved with an extremely simple and cost effective device which you can build yourself — the barn door tracker.

The kind of barn door tracker discussed here is the “isosceles” barn door tracker. This type of barn door tracker has an inherent problem called the “tangent error” induced by the geometry of the design. This error becomes apparent after about 20 minutes of tracking (for a 50mm lens).  But we will completely eliminate this error by writing some smart software which will compensate and make the tangent error disappear. But why do we choose to build an isosceles barn door tracker knowing that it has an inherent flaw? Because it is the simplest type of barn door tracker to build and we can use the magic of software running on a $1 micro controller to completely eliminate this flaw. Many different complicated mechanical designs are available to compensate for this error. These designs include the curved bolt tracker, double arm tracker and cam corrected tracker. But these are relatively more difficult to build and require more exacting build requirements. These were solutions from a time when micro controllers were out of reach of a DIY enthusiast. With new and cheap micro controller platforms like the Arduino, it is very easy to implement a software solution to this error through software. I have made the software for this open source and is available free in this website.

The concept

Two pieces of wood connected with a hinge (just like a barn door, and hence the name) are spread open at 15° per hour. A camera mounted on one of the pieces of wood would also be riding along and rotating about the hinge at 15° per hour, matching the speed of rotation of the earth. This is the fundamental idea. The two pieces of wood are called the “arms”. The one at the base is called the fixed arm. This fixed arm is mounted on the tripod and is held stationary. The other arm is the camera arm where the camera is mounted.

The actuator

The two arms are opened about the hinge with the simplest of actuators. A rotating threaded screw rod and a fixed nut. The nut is connected to the camera arm. When the threaded screw rod rotates, the nut will move up, pushing the camera arm up. The rotation of the threaded rod is done by a stepper motor.

We need to control the rate at which the camera arm moves up for tracking. The rate is 15° per hour. This rate can be controlled by the speed at which the stepper motor rotates the threaded rod. The speed at which the threaded rod rotates will determine the speed at which the nut rises, which in turn is connected to the camera arm.

Let us see the relation between the threaded rod’s rotation and the nut’s linear movement.

In a the bolt or in our case the threaded rod, if it makes one rotation, the nut paired with it will move a distance of 1 pitch. In a barn door tracker, we have the fixed arm and the camera arm connected at one end with a hinge. If we attach the nut to the other end of the camera arm and the threaded rod to the other end of fixed arm, then we have our actuation system. If we rotate the threaded rod, the camera arm which is connected to the nut will start start moving. If we can control the speed of the rotation of the threaded rod in such a way that the camera arm moves at 15° per hour, have tracking!

Controlling the actuator for achieving tracking speed of 15° per hour

What is an isosceles barn door tracker? It is a barn door tracker where the geometry of the system is an isosceles triangle. The two arms – the camera arm and the fixed arm are of equal length and forms two equal sides of an isosceles triangle. The third side is the threaded rod and acts as the base of the triangle.

In the discussions above, it became apparent that we have to rotate the the threaded rod at a specific rate to actuate the movement of the camera arm at 15° per hour. Let us arrive at this “rate” to achieve this goal.

For an isosceles triangle, the length ‘S’ of the base can be calculated using the formula

S = 2·L·sin(θ/2)
‘L’ is the length of the two equal sides
‘θ’ is the included angle of the equal sides.

Let us calculate how much the triangle’s base should expand, or in other terms how much the nut in the threaded rod should move in one hour to achieve 15° between the two arms. Note that the the distance between the nut and the base of the threaded rod is the ‘base’ of the triangle.

S = 2·L·sin(15/2) in one hour
S = 2·L x 0.1305 in one hour
S = 0.261·L in one hour

For example, let’s assume that our barn door tracker’s arm length ‘L’ is 300mm. Then ‘S’ at 1 hour will be 0.261 x 300mm = 78.3mm. In this case, the threaded rod should rotate enough number of times to move the nut up by 78.3mm. This will rotate the camera arm by 15°

Let us now calculate the number of revolutions required to achieve the target offset of the nut. For this, we need the pitch ‘p’ of the threaded rod. If the threaded rod has a pitch of 1.5mm, it means that one rotation of the rod will move the nut up by 1.5mm. From this information, let us derive the formula to connected the distance ‘S’ the nut has to move to rotations ‘R’

Let the pitch be ‘p’
R = S/p
replacing S from the previous formula,
R = (0.261·L)/p

Let’s add to our previous example. Let the pitch ‘p’ be 1.5mm. In this case, ‘R’ will be 0.261 x 300mm / 1.5mm = 52.2 rotations. So we have to achieve 52.2 rotations in one hour to track at 15° per hour

Speed of rotation is generally expressed in revolutions per minute rather than revolutions per hour. So let’s modify our formula for ‘R’ to express in revolutions per minute.

R = (0.261·L)/p (revolutions per hour)
RPM = R/60 = (0.261·L)/(60·p) (revolutions per minute)

So in our example, the speed required will be (0.261 x 300mm) / (1.5mm x 60) = 0.87 RPM. If we connect a motor to the threaded rod and run it at 0.87 RPM, a barn door tracker with an arm length of 300mm will start tracking the sky!


Posted on 1 Comment

Quick introduction to the barn door tracker

Why do we need a tracker for photographing celestial objects?

Celestial objects baring the Sun, Moon and some bright stars are extremely dim and they require very long exposures to capture. The light from these objects are so faint it takes many seconds or minutes, even hours in some cases to capture them using a camera.

What is long exposure?

A digital camera works by collecting and recording the photons emitted by or reflected by the object we wish to capture. Under normal day time photography, the camera’s sensor requires only a few milliseconds to record these photons. For celestial objects which are very faint, the sensor requires many minutes or even hours in some cases to collect the photons. This is called long exposure.

What is the problem of long exposures?

The earth is rotating! The stars and other celestial objects in the sky are fixed. It is not the sun or stars that are rising in the east and setting in the west. Rather it is us rotating from west to east which makes it look as if they are rising from the east and setting in the west. Since the camera is sitting on earth, it is rotating along with it. If we have pointed the camera at a star, after a few minutes the camera will be pointing elsewhere and not at the star we had originally pointed it at.

What is the solution?

Tracking. Tracking is basically making the camera point at the same target by compensating for the earth’s rotation. The earth is rotating at approximately 15° per hour. The tracker will compensate for this by rotating at 15° per hour in the opposite direction. The earth rotates west to east, and the tracker rotates from east to west at the same speed to compensate from the movement.

Commercial, off the shelf options

  • Computerized equatorial mounts (German Equatorial Mounts, EQ mounts)
    Entry level photography capable mounts cost around $1,500. High end, good quality mounts cost upwards of $4,500.
  • Scissor mounts (Astrotrak etc.)
    Costs around $650.
  • Entry level tracking EQ mounts and clock drives
    Costs ranges from around $350 to $400 (Star adventurer, Polarie etc)

What is the option for a beginner? Or if you want to test your interest before investing on the commercial mounts?

The Barn Door tracker. Even a smart, reasonably accurate barn door tracker costs only around $60. With basic DIY skills you can build one yourself. Or, you can get help from a carpenter or local machine shop.

Checkout what is possible with a barn door mount:

 The Orion nebula, Running man nebula, Horsehead nebula and Flame nebula shot with a barn door tracker controlled by the smart barn door controller. The image is a stack of 120 x 15 second exposures taken with a 135 mm lens.


The orion constellation. Orion nebula, Flame and Horsehead nebula are also visible. This was shot with a barn door tracker controlled by the smart barn door controller. The image is a stack of 60 x 60 second exposures taken with a 50 mm lens.

History of the barn door tracker

The barn door tracker was created by George Haig. It is also called as the scotch mount or Haig mount. The plans for his tracker were first published by the Sky & Telescope magazine in their April 1975 issue. The original design was was improved upon by Dave Trott who introduced a second arm in the design. This improved tracking accuracy over time. His new design was published by the Sky & Telescope magazine in their February 1988 issue.  The original designs all involves manual actuation. Modern barn door trackers are motorized and hands free.

Basic working principle


The rotation of the screw rod (yellow) will make the top surface of the barn door to move upwards. By precisely controlling the speed, we can make the top surface rotate around the hinge at the same speed of the earth and thus achieving tracking. The camera is mounted on top surface (blue).


Basic components of the “smart” Barn door tracker

  • 2 pieces of wood which make the 2 arms of the barn door
  • 6 Hinges (for isosceles mounts)
  • 1 Bipolar stepper motor
  • Arduino (or clone) micro-controller
  • Stepper motor driver module
  • 8mm pitch screw rod and nut

It’s that simple, but there is a catch

The simple design of the isosceles barn door tracker has a design flaw known as “tangent error”. Applying trigonometry, we can see that by applying a constant linear rate of increase in the base of the isosceles triangle does not produce a constant linear increase in the included angle. The angle is what we care about as it is the one compensating for the earth’s rotation. After about 10 minutes of tracking, there will be drift in tracking and the target starts to drift.

Solving for “tangent error”

  • Traditional methods
    • The traditional solutions are from a time when micro-controllers were the toys of specialized engineers and technologists.
    • The solution was by adjusting the mechanics, introducing another arm. This is a beautiful solution but makes it more difficult to build.
    • Complicated to understand the math behind the solution.
  • Modern “smart” approach
    • Software code written in the Arduino microcontroller to adjust the speed of the motor driving the screw rod continuously and automatically to compensate for the geometry induced tangent error.