Introduction1

https://farm6.staticflickr.com/5653/22253919670\_b4f8b8c985.jpg

Limited depth of field is a very serious issue for macro photography. Focus stacking is a powerful technique used by macro photographers as a workaround for the limited DoF problem. It consists of taking a few macro photographs of your subject with gradually shifting focus - sort of "scanning microscope" approach - and then using focus stacking software to merge these multiple slices into a single photograph with a much deeper synthetic DoF.

When dealing with modest macro magnifications (around 1:1 - this is considered to be "standard" macro), focus stacking can be quite easily accomplished manually: as at these magnification only a handful of photos are required to create a decent DoF, all you need is a good quality manual focusing rail, something like Velbon Super Mag Slider. Then one can manually move the camera using the rail's focusing knob from one shot position to the next one, and manually trigger the camera's shutter.

At much larger, "super macro" magnifications (around 5:1 or more), the situation becomes unmanageable: due to the extremely narrow DoF at such magnification (around 50 μm at 3:1; becomes ~2 μm at 20:1), one often needs to shoot hundreds of photographs in a single stacking sequence to achieve the desired DoF. Doing it manually is no longer a practical option.

The solution: fully automated focus stacking rails, which would both move the camera (or the subject) between the shots, and trigger the camera's shutter to take the shots. The problem with this solution is that it is a fairly limited use gadget which can be very expensive. Likely the cheapest commercial product available, Cognysis StackShot, will run you $727 with the camera cable and optional battery.

So I decided to design / build / program such an automated stacking rail myself, with the following three main goals:

* I wanted it to be as cheap as possible (much cheaper than the Cognysis).
* I wanted it be as fast as possible, both in terms of the time it takes to set it up and start shooting, and in terms of frames per second speed attained. (The hope was to make it fast enough that potentially even live insects could be photographed, in the wild.)
* I wanted it to be light and portable, to be usable for outdoor shooting.

I believe I succeeded with all the three goals, and then some more. My DIY automated focus stacking rail was built very cheaply from the parts I ordered on ebay from China, with the total costs around $150 ($110 for the manual focusing rail Velbon Super Mag Slider + ~$40 for all the rest).

It was designed as a professional tool, not as a gadget, with the speed and efficiency in mind. As a consequence it doesn't use any menus or a touch screen for operation; all the functions it supports (45 at this point, not including the telescope focuser mode functions) are directly accessible via one or two-key commands, using its 16-keys keypad. The 6 lines x 14 characters LCD display is densely packed with all the information you'd need to know when doing focus stacking. It takes less than a second from powering up the device to starting shooting (by pressing a single key).

The rail I built is very accurate - one motor step is only 1.25 μm, and the built-in full backlash compensation allows for (almost) perfect repeatability of stacking sequences. I am using different acceleration/decelerations for the rail movements which allows both highly accurate positioning of the camera and fast travel time. The device is fairly small and light (1.36 kg including batteries), and can be powered by both AC adapter and eight rechargeable AA batteries. This makes it very usable for outdoor shooting, with live insects.

The device should be able to control any camera which has a socket for a wired remote shutter control (most DSLRs, some mirrorless and perhaps some prosumer point-and-shoot cameras; if your camera only has a wireless remote shutter control, it is still possible to use it with my rail - it is a matter of a simple hack of the camera's remote control). It has a few adjustable software parameters which can be tuned to achieve the best possible performance out of your camera. For example, my fairly old Canon 50D can do at least 30 (likely more) shots in RAW format at 4 frames/second, when operated by my rail. This is sufficient to do a quick stacking of some live insects.

The rail supports two major modes of operation:

* **Single-point stacking**. ("Outdoor mode"). Press a single key, and the rail will take a predefined number of shots, with given μm/frame and frames/second parameters. (The first parameter is determined by your lens' depth of field which in turn depends on the magnification and aperture, and the second - by the abilities of your camera and flash to shoot batches of shots in a rapid sequence.) One has to use a flash as the main light, to eliminate the blur due to the rail's motion.
* **Two-point stacking**. ("Studio mode"). Fine-tune the two positions of the camera (foreground and background points), press a single key, and the camera will travel to the foreground point and will shoot a stacking sequence while moving to the background point. Again the μm/frame and frames/second parameters are used. Flash is needed to freeze the camera's motion. Alternatively, one can press another key to do a slower "move - stop - wait - take\_a\_shot - wait\_more - move\_again" style of stacking, which is the one to use when flash lighting is not possible or desirable. In studio mode one can also use electronic shutter ("Full Resolution Silent Picture" feature of Magic Lantern alternative firmware for Canon cameras), with or without an external flash.

For the studio mode, there is an option to repeat stacks multiple times with a given time interval between stacks (so called **timelapse mode**). This for example can be used to create a timelapse video for a slowly changing macro object (like a flower bud opening).

When compared to a commercial solution (Cognysis StackShot), my rail has the following advantages:

* **Price:** It is much cheaper (by a factor of 5).
* The same controller can operate both macro rail and a telescope motorized focuser. (Only relevant if you have a telescope of course.)
* **Hardware:**
	+ It is smaller and lighter, and uses standard AA NiMh batteries - meaning it is better suited for outdoor applications.
	+ Camera shutter cable is connected to the rail in my design (and only one cable connects the controller unit to the rail), which is more convenient and safer than the Cognysis' approach (the controller unit is connected to the camera and to the rail, using two separate cables).
	+ It looks like the Cognysis gadget controls only the camera's shutter. My rail independently controls camera shutter and autofocus, which allows one to achieve the best possible performance (frames per second) out of your camera. It also allows my rail to control independently camera's shutter and external flash, which makes it possible to use external flash with electronic shutter (under Magic Lantern; only Canon cameras).
	+ From the Cognysis description, it appears that its limiting switches are triggered every time you move the rail to one or the other ends. In my design, the rail always stops by itself right before hitting one of the two limiting switches, which I think makes much more sense.
	+ The Cognysis doesn't have a manual left<->right camera movement knob, whereas the Velbon Super Mag Slider (and hence my design) has such a module, which is very convenient for framing your macro shots.
* **User Interface:**
	+ The Cognysis doesn't have the **"Pause"** feature, while my rail does. For example, if something goes wrong (e.g. flash or camera battery dies) in the middle of a lengthy (hundreds of shots) focus stacking, the Cognysis will only let you abort stacking and restart the stacking from the beginning, potentially wasting hundreds of shots. In my rail, pressing any key during a two-point stacking (and more generally, in timelapse stacking) will merely pause stacking, with the ability to travel back and fourth to any particular frame position, and then resume stacking from that position by pressing a single key.
	+ My rail is **much faster to operate** than the Cognysis. All functions in my design are one click (with either one or two key bindings) away. In Cognysis, most functions (including the ones you use all the time: start stacking, setting foreground/background points, using memory registers) require a large number (5..10 or even more) of key clicks.
	+ Cognysis doesn't have a very convenient stacking mode, Continuous Two-point stacking in my rail, where one specifies starting and ending points and uses the continuous stacking approach. The two-points modes the Cognysis does have are all non-continuous (much slower). Instead, the Cognysis has a bunch of modes which I consider to be not useful (Automated Step, Total Travel Distance etc.). Why would anyone let the distance between frames to be a free parameter? This parameter should be totally determined by the DoF of the lens you are using, so normally needs to be changed only when you change the lens. Overall, the Cognysis' user interface looks like it was designed by engineers, not by photographers.
	+ The Cognysis gadget is not convenient for fast stacking (when you are pushing your camera/flash to its limits, in terms of frames per second). In my design, one can find and use the highest FPS parameter the camera/flash can sustain, as a single input parameter. In Cognysis, the fps of your continuous stacking is determined by two separate parameters - Toff and Tpulse, which makes things complicated.
	+ In the Cognysis, shots are taken at equal time intervals, which is wrong - they should be taken at equal distances between frames, as is the case in my design. As a consequence, continuous stacking with the Cognysis will have too many shots at the beginning and at the end of stacking, where the rail accelerates and decelerates. My rail will always produce correct (equidistant) stacks, regardless of the acceleration/deceleration used.
	+ The software I wrote for the rail is available as Open Source: meaning you can do any modifications you want, add any features you need.

Of course, there is always a catch - there is a price to pay for having a lighter and more portable macro rail. The notable advantages of Cognysis StackShot over my design are:

* The Cognysis rail does appear to be more durable and sturdy than the Velbon Super Mag Slider I am using, but perhaps that is an overkill; my Velbon has been performing well so far. You can always use a different, more durable rail with my controller and my software.
* The Cognysis gadget's maximum travel speed is 2x larger than mine (5 mm/s versus 2.5 mm/s). This doesn't really affect shooting, just the time it takes to prepare for one.
* The Cognysis allows for longer (100 mm or 200 mm, depending on the model, versus my 55 mm) maximum stacking length. I haven't found this to be a limiting factor yet - perhaps because my focus is on super macro (magnifications 2:1 ... 10:1).