Category Archives: Astrophotography

Building a barn door mount, part 2: calculating mount movements

In part 1 of this series, I described how to construct an Arduino based motor controller. This time around it is time to look at the mathematics behind the movement of the mount. As noted previously, the mount will be driven by a threaded rod. As the motor rotates the rod in a nut attached to the camera board, it generates linear motion, however, the board needs to open up with constant angular motion. For simplicity it is intended to construct a type 1 barndoor mount with an isosceles drive rod, as illustrated in the following diagram

Barndoor mount

In the above diagram the threaded rod has length R between the two boards, forming an angle θ. It can readily be seen from the diagram that the isosceles triangle formed by the two boards and the rod can be split into a pair of identical right angle triangles. Basic trigonometry tells us that the sine of the principal angle in a right angle triangle is equal to the ratio between the opposite and hypotenuse:

formula-1

In our diagram above, the principal angle is θ/2, the length of the opposite is R/2 and the hypotenuse is L. Plugging those symbols into the first formula we get:

formula-2

In order to drive the threaded rod, the value we want to calculate is R, so we need to re-arrange the formula to get R on the left hand side:

formula-3

The Arduino isn’t directly controlling the length of the rod though, rather it is controlling its rotation. The length of the rod is the ratio between the number of rotations and the number of threads per centimetre. This gives us a second formula for R

formula-4

Lets substitute this new formula for R, into the previous formula:

formula-5

A few moments ago we mentioned that the quantity we actually control is the rotation of the rod, so the formula must be re-arranged to get the number of rotations on the right hand side:

formula-6

With this formula, we know how many rotations are needed to achieve a given angle between the boards, but what exactly is the angle we need ? The Earth doesn’t take exactly 24 hours to rotate a full 360 degrees, in fact it is about 23 hours, 56 minutes, 4.0916 seconds. This value is known as the sidereal time or rate. With this information we can now define a formula to derive the value for θ at any given time t, since starting operation of the mount from a closed position:

formula-7

Since θ is the value we need, lets re-arrange that formula to get θ on the right hand side

formula-8

This formula for θ can now be substituted into the earlier formula for calculating the rotations of the rod:

formula-10

The final term can be slightly simplified by removing a factor of 2

formula-11

This formula operates in degrees, but when doing calculations in software it is desirable to measure angles in radians. There is a simple formula for converting from degrees to radians:

formula-9

With this information it is now possible to update the formula for calculating rotations to operate in radians by substituting in the conversion formula:

formula-12

A little while ago it was said that the Arduino is controlling the number of rotations of rod. This isn’t strictly true, it is in fact controlling the number of steps of the motor. A motor will have a certain number of steps it can do in one rotation, which gives a step size in degrees.  The formula for calculating rotations can thus be adapted to calculate the number of steps

formula-13

This is our last formula and it has 4 variables to be filled in with accurate values

  • stepsize: the stepper motor used in the electronics does 200 steps per rotation giving a step size of 1.8. This is a common size for this type of stepper motor. Another typical size is 64 steps per rotation.
  • threads.per.cm: a standard M8 threaded rod will have 10 threads per centimetre, other rods may vary.
  • L: this is the length of the base board between the hinge and the centre of the threaded rod. This has to be precisely measured after construction is complete
  • siderealtime: 23 hours, 56 minutes, 4.0916 seconds, or more simply 86164.0419 seconds

This formula could be executed directly on the Arduino board, but a sine calculation is somewhat heavy for the microcontroller. Realistically the mount isn’t going to be doing exposures of longer than 2-3 hours. It is fairly trivial to thus this formula and calculate the required number of rotations for each minute of each hours and produce a 180 entry table. The Arduino then merely has to keep track of time and do a trivial table lookup to determine the rotation rate. An algorithm for doing this will be the subject of a later blog post.

Now read: part 3, drive control software

Building a barn door mount, part 1: arduino stepper motor control

Serious astronomical imaging requires an equatorial mount for the camera / telescope, which tracks the rotation of the earth for anywhere between 5 minutes and several hours. Commercially available mount options have a starting price of several hundred pounds and range up to thousands. As a result many amateur astro-photographers choose the DIY option, building what’s commonly known as a “barn door mount“. At their simplest, they consist of two parallel planks of wood hinged at one side, with a threaded rod which is manually turned once a minute to gradually open the hinge at a rate which matches the speed of rotation of the Earth.

They are very simple to build, but the pain point should be clear from the end of the previous sentence – you need to control the dimensions such that one rotation of the threaded rod, causes the hinge to open at precisely the right rate. This isn’t as hard as it sounds for short exposures (10-15 minutes) but as the desired exposure time goes up the errors quickly spiral out of control. Some of the error is caused by construction inaccuracies but the bigger part is due to the inherent design decision to produce angular motion (opening hinge) from linear motion (rotating threaded rod). The latter is commonly referred to as the tangent error.

There are various more complicated barn door designs which use 3 pieces of wood to eliminate the tangent errors. Sadly the more complicated designs also increase the mechanical errors due to construction inaccuracies. The easy solution to this problem is to use a programmable microcontroller to drive the mount, allowing arbitrary errors to be corrected in software. When you need a cheap, low power microcontroller, the first option that comes to mind is an Arduino. A little bit of searching on google revealed someone who had built a barn door controlled by an Arduino Uno and a stepper motor. Even better, they provided a sketch of their circuit diagram for wiring it up.

Cost being king, I headed over to eBay to source the big ticket parts, and a maplin store for a few odds & ends I wanted to see in person before purchase. On the list were

Thus the total cost for the electronics was £46.21, a little bit higher than I was originally hoping for. I could have reduced it by going for one of the lower spec stepper motors which are bundled with a driver circuit board. This would have cut approx £12.00 off the cost, but I was not confident it would have sufficient torque for direct drive of the threaded rod, so I went for the sure bet. A pound or two could have been shaved off the cost of switches / power jack too, by sourcing from eBay instead of maplin. IOW it is probably possible to get the parts for about £30-35 if you really find the bargains. Before assembly the parts are laid out

Barndoor electronic parts

In addition to the project parts, you’ll need a few workshop items including a multi-meter, soldering iron, helping hands, wire cutters/strippers and 3A x 12v regulated bench power supply.

After looking at the previously mentioned circuit diagram, I decided to make one slight variation in the use of switches. I discarded the separate power switch, and used all three prongs from one of the switches to toggle between forward/stopped/backward. Thus the aim was to construct the following circuit diagram from the parts:

Barndoor circuit

The Arduino is capable of being powered from the USB port, the on board DC jack, or the VIN pin. While the EasyDriver can take a 5v line from the Arduino board, this is only suitable for driving the electronics, not the stepper motor which needs much higher current than the Arduino is capable of supplying. Thus the decision was made to take a 12V supply from a off-board 2.1mmx5mm DC jack, to the VIN pin on the Arduino and M+ pin on the EasyDriver. The DC jack size was chosen to match that used on the Celestron NexStar telescope mounts, and so was wired center-positive.

The EasyDriver needs a minimum of two control signals, one to trigger a motor step and the other to set the direction of rotation. Thus the Step and Dir pins on the EasyDriver board were connected to the digital pins 8 and 9 on the Arduino. The EasyDriver defaults to 8-point microstepping. If use of full steps were required, the MS1 and MS2 pins could be connected to further digital pins on the Arduino. For the barn door mount though, the rate of rotation is so slow that 8-point microstepping is more than OK.

The two switches are going to be used to provide control parameters to the software running on the Arduino. The ON/OFF/ON switch is going to be used to switch the motion of the motor between clockwise, stopped and anti-clockwise. The ON/ON switch is going to be used to switch between automatic sidereal matched speed control and manual fast speed. For wiring, we effectively have a 1K Ohm resistor between the 5V output pin and an analogue pin. The switch is used to short this link out to ground. Toggling the switch thus toggles the analogue pin high/low.

The final piece of wiring is connecting the stepper motor wires to the EasyDriver. The ordering of the wires is absolutely critical. The stepper motor has two separate coils / phases, and 4 coloured wires coming out of it. Each pair of wires corresponds to one of the phases. The key is determining which wires match which phase and the polarity. Fortunately the stepper motor had a model number on it, allowing the data sheet to be located via google. The data sheet shows that one phase is connected to the black + green wires, while the other phase is connected to the red + blue wires. So the EasyDriver motor pins are wired up in the order black, green, red, blue. Again, this order is absolutely critical to get right – mixing up the polarity between the two coils will result in a motor which won’t turn. Likewise, not matching up wires within a phase will result in a motor which won’t turn. It is also NOT SAFE to use trial and error to test the motor while the EasyDriver is active. Detaching the motor wires while the EasyDriver is active will likely result in a burnt-out EasyDriver. Find the data sheet and get it right first time.

After a hour or two cutting and soldering wires the circuit was complete. To test it requires creation of a simple test program in the Arduino IDE. For this test I’d used the AccelStepper library instead of the Stepper library that is normally used, because the AccelStepper is more flexible to use.

#include <AccelStepper.h>

int debug = 0;

int dgPinStep = 8;
int dgPinDirection = 9;

int anPinForeward = 4;
int anPinBackward = 5;
int anPinSpeed = 3;

AccelStepper stepper(AccelStepper::DRIVER, dgPinStep, dgPinDirection);

void setup() {
  pinMode(anPinForeward,  OUTPUT);
  pinMode(anPinBackward,  OUTPUT);  
  pinMode(anPinSpeed,  OUTPUT);  

  stepper.setMaxSpeed(3000);

  if (debug) {
    Serial.begin(9600);
  }
}

void loop() {
  int valForeward = analogRead(anPinForeward);
  int valBackward = analogRead(anPinBackward);
  int valSpeed = analogRead(anPinSpeed);
  int run = 0;

  if (debug) {
    Serial.print("Foreward: ");
    Serial.print(valForeward);
    Serial.print(" Backward: ");
    Serial.print(valBackward);
    Serial.print(" Speed: ");
    Serial.println(valSpeed);
  }
  if (valForeward < 5) {
    if (valSpeed < 5) {
      stepper.setSpeed(200);
    } else {
      stepper.setSpeed(2000);
    }
    run = 1;
  } else if (valBackward < 5) {
    if (valSpeed < 5) {
      stepper.setSpeed(-200);
    } else {
      stepper.setSpeed(-2000);
    }
    run = 1;
  } else {
    run = 0;
  }

  if (run) {
    stepper.runSpeed();
  } else {
    stepper.stop();
  }
}

After compiling and uploading to the Arduino over USB, the program will start running immediately. If you’re not confident that the switch pins are connected in the right order the “debug” variable can be set to 1, which will let you watch the levels via the IDE’s serial console as the switches are toggled. Just remember to turn off debugging again afterwards because the println calls seriously slow down the program to the point that it is unusable in the real world. The video shows toggling the motion switch between forward/off/backward and the speed switch between slow/fast (sidereal rate is not implemented in the test program)

With everything working, all the remains is to house it in the plastic case. This required drilling a few holes for the switches and DC hack, and carving out a hole with a file for the USB port and carving a channel for the motor wires. With the electronics complete, the next phases are to build the mechanical side of the mount and then do the maths calculations and software programming necessary to track the earth’s rotation accurately. These will follow as separate blog posts in the coming days or weeks.

Now read: part 2, calculating mount movements

Constructing a filter for solar imaging with a DSLR

In recent months I’ve had an increasing interest in astronomy and astrophotography, to my surprise discovering the Baker Street Irregular Astronomers who hold monthly observing sessions in Regent’s Park – I never imagined it was practical todo astronomy in London’s light polluted sky. I’ve not got as far as purchasing a telescope yet, instead deciding to learn a bit more about the topic first, and experiment to see what I can do with just a DSLR camera. With a Nikkor 180mm prime lens and 2x teleconvertor I was able to produce this image of the Moon

The Moon

The 180mm lens + 2x teleconvertor on the D90’s 1.5 crop factor sensor gives an full frame equivalent of 540mm. This is really the bare minimum acceptable reach for getting images of the moon, with the image above being a pretty aggressive crop down. There are enough pixels for publishing online, but not really sufficient for printing out at any reasonable resolution.

As most people know, by a stroke of good fortune, the Sun and the Moon have the same apparent size when viewed from the Earth (this is how the moon can precisely block out the Sun during an eclipse). Naturally, since I was able to get a nice image of the Moon with the setup described above, I could expect to get a similar sized image of the Sun. Of course looking at, or pointing your camera at, the Sun is an incredibly dangerous thing to do. You absolutely must take care to protect both the camera optics and your eyes if you are going to try solar imaging. There are a variety of solar filters available in the astronomy market with varying characteristics, but for basic full spectrum DSLR imaging, what you want is a filter built with a piece of Baader AstroSolar Safety Film. This is available in A4 sheets from any decent astronomy store, in my case The Widescreen Center, near Baker St.

Baader AstroSolar Safety Film

Baader AstroSolar Safety Film

The pack just contains one fine sheet of film, around which you need to built a mount to hold it in place in front of the lens. This involves a bit of fun with cardboard, scissors, sellotape and a craft knife. The mount will consist of two flat pieces of card with discs cut out to sandwich the film between, and a tube that will fit snugly around the lens barrel. The basic cut out shapes used to construct the mount can be seen in the image below:

The cut-out parts

The cut-out parts

For the front sandwich I decided to use 4mm poster board to get rigidity. The centre cut outs are just a few mm smaller than the lens diameter ensuring the lens front will not be pressing on the relatively delicate solar film. I decided to cut a 3rd piece to act as a front flap cover to protect the film when not in use too. For the tube, I decided to use thin cardboard – something little thicker / stiffer than than commonly used for cereal packets. The first two strips of it are 2 inches wide, while the third has an extra 3/4 of an inch, which is then cut into a series of little flaps. These flaps will be used to attach the collar to the front sandwich.

The first step was forming the tube / collar around the lens. I placed double sided sticky tape along the two strips of cardboard without the flaps. I fastened the first strip snugly around the lens:

Forming the collar

The next two strips of card simply wrap around the first, reinforcing its shape. Finally the outer layer is wrapped in a strip of black duck tape to secure it fully.

With construction of the tube out of the way, we can move onto construction of the front sandwich. The key thing to remember at this step is that we do not want to place the safety film under tension – it is actually desirable if it is a slightly loose / slack and this will not affect the image quality at all. The Baader instructions recommend laying the film on a sheet of tissue paper to protect it from any roughness on your work surface.

The Safety Film

The film is actually highly reflective & silvery – the yellowish colour seen above is caused by the reflection of light from the walls in my house. The two plasterboard pieces need to have one side each, covered in double sided sticky tape. Gently place one piece face down onto the safety film, lightly pressing around the edges to get good contact. Then flip the board over so the safety film is facing up again and place the second piece of board to complete the sandwich. Now bind the whole lot together by wrapping more tape around all the edges, taking care not to touch the area of film visible through the cut out disc. The 3rd piece of poster board for the protective cover can now also be attached with a few more pieces of tape.

The last stage is to attach the lens collar to the front board, with yet more double sided sticky tape. For added strength, I finished it off by adding strips of duck tape along the join between the collar and front boards. If all went the plan, then the result should look something like this

Finished filter

Finished filter

With the camera attached to a tripod, and the filter in place on the front of the lens, the complete setup looks like:

Filter attached to the camera

The weather was looking kind of dicey while I was constructing the filter, with pretty heavy cloud. By the time I had taken a break to eat lunch though, the cloud had cleared enough that the Sun was visible for a few minutes at a time. This allowed an opportunity to try out the newly constructed filter. Before using the filter though, it is essential to verify that the safety film was not damaged during construction. The instructions that come with the film describe the kind of defects to look out for, basically tears, scratches, holes, etc. The check for damage should be repeated again every time you go to use the filter. You cannot be too paranoid when imaging the Sun. For additional safety it is advisable to not directly look through the camera view finder, even when the filter is in place. Instead either use the live view from the LCD screen on the camera, or better yet, tether the camera to a laptop using a USB cable. I chose the latter approach, controlling the camera from a laptop using Entangle.

Actually attempting to take a photo though highlights another challenge – that of lining up the camera so that it points at the Sun, without actually looking at the Sun. To get the initial rough alignment, I adjusted the tripod head so that the camera lens was parallel to one of the tripod legs, then shifted the entire tripod around until the shadow cast by that tripod leg disappeared. With rough alignment achieved, I then enabled “live view” in Entangle and made minor changes to the tripod head until the Sun appeared in the centre of the screen.

Aside from the safety benefit, one of the key reasons to tether the camera to a laptop is that it makes focusing much simpler. The laptop screen can zoom the preview image until it shows pixels at 1-1 size. Very small tweaks of the lens focusing ring can then bring focus into the sweat spot. The result of all this work, was the following image

The Sun

Click on the image above to be taken across to flickr where it can be viewed full size. The white colour is the result of the of the Baader film doing its job. If a traditional “yellow” image is desired, it is a simple matter of adding colourization when post-processing the image. The handful of dark smudges in the bottom left quarter of the image are sunspots.

Overall the construction of the filter took somewhere between 1+1/2  and 2 hours (I wasn’t timing it so don’t know the exact time). When viewed with normal full spectrum light, the Sun does not produce anywhere near as interesting an image as the Moon. It was none-the-less satisfying to be able to capture the sunspots. The limiting factor to producing a better image at this point is likely the need to get a longer focal length lens. As mentioned earlier the setup used for this image, was equivalent to about 540mm. If I can switch the Nikkor 180mm lens out for something like the Sigma 150-500mm lens, it would be able to get to 1500mm full frame equivalence. Of course, first I’ll have to buy the Sigma, and then go through the process of building another filter to fit that lens, since its diameter is no doubt different to that of the Nikkor 180mm. Those who really get addicted to solar imaging will end up buying dedicated scopes with Hydrogen-Alpha or Calcium K-Line filters, which produce some really stunning images.