Fast Stacker (Arduino based automated focus stacking rail)

Have questions about the equipment used for macro- or micro- photography? Post those questions in this forum.

Moderators: rjlittlefield, ChrisR, Chris S., Pau

pulsar123
Posts: 146
Joined: Fri Jun 12, 2015 12:36 pm

Post by pulsar123 »

ChrisR wrote:¶Speeds - imagine a rig surrounded by lights and reflectors. You want to change an objective, so you want to withdraw perhaps 100mm or more.
Then you need to approach the focus point to find it - slowly.

¶Remove Toff after last shutter operation:
Using mirror lock, 2 shutter operations may be needed, hence:

Move rail
Settle
First shutter
Toff 1
Second Shutter
Toff 2
Move rail
etc.

Toff 2 is redundant but can't be set separately or removed.
600 shots at 2 seconds wasted = 20 minutes wasted.

You can work around it by adding an extra, single, manual shutter press so the first exposure is made after "settle", then you don't need any Toff, but it's easy to mess it up.

¶Various inputs and output connections:
Focus lights on/off, flash trigger, vibration sensor, flash sensor, alarm....
I see - thanks for the explanations. I am not sure how it is done by Cognisys, but my simple setup seems to work perfectly fine. I have a similar maximum speed (5 mm/s), and my acceleration/deceleration limiter is such that it takes 0.8s to get to the full speed. The rail only moves when you press a button (two buttons for <- and -> movements). In my experience, even at the highest practical magnification 5:1, this works well: a sequence of a few quick key presses/releases allows me to find the starting point with the um accuracy. The time to make a full rail rewind is 12.4s. So it is both fast and accurate.

Regarding the mirror lock, settle time etc - my whole idea was to ignore all this so I can create a super-fast stacker (up to 4 fps with my camera; for live subjects) - as long as my main source of light is a flash used at a fraction of its full power, resulting in such short impulses (100 us or less) that everything is effectively frozen - motion blur (camera moves continuously; of course in reality it moves by microsteps of 2.5 um, but the combination of the rail/camera inertia plus backlash should turn this into pretty much smooth continuous camera motion), rail vibrations, mirror lock etc. I don't see any evidence of these motion artifacts in my 5:1 shots - everything appears to be sharp down to the theoretical diffraction limit. But I am sure some people will have strong and differing opinions on this matter.

It should not be too hard to add another, non-continuous mode of rail operation to my code, but so far I am not convinced it would justify the efforts.

ChrisR
Site Admin
Posts: 8668
Joined: Sat Mar 14, 2009 3:58 am
Location: Near London, UK

Post by ChrisR »

I use fast speed and long ramp, but trying to move a few microns means "stabbing" the button. Needs a logarithmic ramp!
Yes I'm sure that having a working system, you could adapt it to whatever application you choose.

pulsar123
Posts: 146
Joined: Fri Jun 12, 2015 12:36 pm

Post by pulsar123 »

ChrisR wrote:I use fast speed and long ramp, but trying to move a few microns means "stabbing" the button. Needs a logarithmic ramp!
Yes I'm sure that having a working system, you could adapt it to whatever application you choose.
Or just fix the third time derivative of the coordinate - so the initial acceleration would be zero and then gradually increase to the limiting acceleration. (Probably not needed for the deceleration part?) I think this would be easier to implement than logarithmic one, but still achieve the effect you want - very slow and accurate with short presses, significantly faster with longer presses.

Still, rather tricky. It would require messing up with the low level motor driving function, and from my experience that takes time (as you tend to create many hard to catch bugs). But it will be on my to-do list.

pulsar123
Posts: 146
Joined: Fri Jun 12, 2015 12:36 pm

Post by pulsar123 »

I've already added the pause function to my rail. The way it works is:

- Only during the 2-point stacking, hitting any key will put the rail into the new "paused" mode. (In the past, it would just abort the stacking. It is still the case in the other, 1-point shooting mode, which is for outdoor/live insect setting, where pause would not make much sense as it would just slow down things.) This is indicated by displaying "P" symbol in the status letter field (bottom left corner).
- Only a few keys would work in the paused mode, some would change their meaning:
** #1 / #A would still do the same - move one frame to fore/background
** 1 / A now would do large move - 10 frames (in non-paused mode they rewind the rail)
** #4, #7 would work as before (backlighting / trigger shutter manually)
** New meaning of B / #B : now either of them would completely abort stacking (exit the paused mode)
** 0 would resume stacking from the current position/frame, in the original direction.

The paused mode can be exited in three ways: by pressing B or #B (abort stacking), by pressing 0 (resume stacking), or by turning off the power (paused state is not stored in the permanent memory).

I will work now on backlash compensation feature - should be fairly easy to implement. As I wrote before backlash doesn't seem to be a big issue with my rail, but it would still be nice to compensate for it - for the most critical applications (e.g., when you want to do sharpness tests for different apertures, under exactly the same conditions), and also if software is used with other rails with larger backlash. The backlash amount will be a macro constant in the software.

Already one person approached me asking if I can make a replica of my rail for money. I don't have time for that (I have three kids and a well-paying full-time job in IT), but it made me thinking about possible commercialization of this device. What do you think would be the fair market price for the device, say comparing to the existing well established Cognysis product? In some important aspects my device is inferior (in particular, the maximum load/torque factor, the length of the rail), in other respects apparently superior (open source software; already has features lacking in Cognysis - like pause; display with 50% more lines; has a sideways motion knob; extremely fast to set up and use; somewhat lighter; other custom features can be added by anyone, and most likely will be added by me soon - e.g. "logarithmic" ramping).

My guess is it would sell for 300-350$ as a complete device, and perhaps for 100-150$ as a kit (the kit would exclude the Velbon Mag Slider rail). The actual cost would be 110$ for the rail + 40$ for the parts I purchased + ? (likely 10-20$) for the parts I made myself (steel brackets, aluminum enclosure).

Anyone interested in trying to commercialize this device? I would only take part by continuing to develop my open source software.

TheLostVertex
Posts: 317
Joined: Thu Sep 22, 2011 9:55 am
Location: Florida

Post by TheLostVertex »

pulsar123 wrote:The more I look into the Cognisys device, the more ideal my own design looks :)
That is the good thing about building your own devices. You get to work on the things that are important to you and what you need. You also get to make it as complex or as simple as you want. Your project looks well written too (though I havent had time to read through it completely yet).

Chris, for your list of wants, the only thing that I can not do in some capacity with what I currently use is half shutter press. It would take some electronics redesign for that, and i have no case usage for it. I do not have a pause button, but the stack can be stopped at any point and restarted for its current position in multiple different ways. An actual pause is some where on the todo list for when ever I am feeling un-lazy ;)

TheLostVertex
Posts: 317
Joined: Thu Sep 22, 2011 9:55 am
Location: Florida

Post by TheLostVertex »

pulsar123 wrote:(With my 5:1 magnification setup, DoF is 50 um, and no point to go beyond 5:1 as I am hitting the theoretical diffraction limit for optical photography, with one pixel ~ 1um)
I am sorry, but this does not make sense to me. One can very easily go above 5:1. What is it about your set up that makes you think that you should not go above 5:1?

Also, theoretical diffraction limit isnt a sharp cut off. With digital processing, I do not think its something to be heavily worried about often times.

pulsar123
Posts: 146
Joined: Fri Jun 12, 2015 12:36 pm

Post by pulsar123 »

TheLostVertex wrote:
pulsar123 wrote:(With my 5:1 magnification setup, DoF is 50 um, and no point to go beyond 5:1 as I am hitting the theoretical diffraction limit for optical photography, with one pixel ~ 1um)
I am sorry, but this does not make sense to me. One can very easily go above 5:1. What is it about your set up that makes you think that you should not go above 5:1?

Also, theoretical diffraction limit isnt a sharp cut off. With digital processing, I do not think its something to be heavily worried about often times.
From the real life tests I've seen (see the extensive macro lens testing site on coinimaging.com) going beyond 5:1 doesn't reveal new details, so is kind of pointless - you just end up having a smaller field of view, compared to 5:1 lenses. And that agrees with the theoretical diffraction limit argument. You might as well just use 5:1 and then crop - should be a comparable result at much less trouble and cost.

Pau
Site Admin
Posts: 6051
Joined: Wed Jan 20, 2010 8:57 am
Location: Valencia, Spain

Post by Pau »

pulsar123 wrote:...going beyond 5:1 doesn't reveal new details, so is kind of pointless - you just end up having a smaller field of view, compared to 5:1 lenses. And that agrees with the theoretical diffraction limit argument...
As general assessment this makes no sense. Could be true for some lens/camera combos but many people go much beyond this with the adequate optics -mainly microscope objectives- , this forum is plenty of samples and discussions about it. What matters is the effective aperture provided by the objective numerical aperture.
The optical resolution limit with visible light generally accepted is 0.2 micron with immersion oil microscope objectives (in fact it has been exceeded with confocal super resolution advanced techniques, well outside this discussion)
Pau

pulsar123
Posts: 146
Joined: Fri Jun 12, 2015 12:36 pm

Post by pulsar123 »

Pau wrote:
pulsar123 wrote:...going beyond 5:1 doesn't reveal new details, so is kind of pointless - you just end up having a smaller field of view, compared to 5:1 lenses. And that agrees with the theoretical diffraction limit argument...
As general assessment this makes no sense. Could be true for some lens/camera combos but many people go much beyond this with the adequate optics -mainly microscope objectives- , this forum is plenty of samples and discussions about it. What matters is the effective aperture provided by the objective numerical aperture.
The optical resolution limit with visible light generally accepted is 0.2 micron with immersion oil microscope objectives (in fact it has been exceeded with confocal super resolution advanced techniques, well outside this discussion)
Sure, I don't claim to be an expert in this, so I might very well be wrong. I think I should re-phrase myself: going beyond 5:1 is the path of diminishing returns, because of the diffraction limit, and also the path which produces images with fewer resolved lines across the whole frame, resulting in less sharp looking images. (Unless one uses stitching technique.)

rjlittlefield
Site Admin
Posts: 23561
Joined: Tue Aug 01, 2006 8:34 am
Location: Richland, Washington State, USA
Contact:

Post by rjlittlefield »

pulsar123 wrote:Sure, I don't claim to be an expert in this, so I might very well be wrong. I think I should re-phrase myself: going beyond 5:1 is the path of diminishing returns, because of the diffraction limit, and also the path which produces images with fewer resolved lines across the whole frame, resulting in less sharp looking images.
Let me try to clarify.

There is a diffraction limit, and with conventional macro lenses, re-purposed enlarger lenses, and reversed normal lenses, that limit is indeed reached someplace around 5:1 with current sensors.

However, those lenses are all designed to cover a large field using a relatively narrow aperture.

To productively reach beyond 5:1, what you do is to switch optics, using instead lenses that are designed to cover a small field using a much wider aperture. Those lenses are designed and sold as microscope objectives.

We can put some numbers on this. A good macro lens set on f/2.8 and 5X will be running at an effective aperture of f/17, which is right at the diffraction limit for a typical 4 micron pixel assuming Nyquist sampling. On the subject side, that setup has a Numerical Aperture (NA) of 0.15, which is about the same as a good 5X microscope objective. From there, it's no problem to go to 10X at NA 0.30, which doubles the resolution on subject and has the same sharpness in the image plane. Beyond that, the usual progression involves numbers like 20X NA 0.42 and 50X NA 0.55 for long working distance objectives. At these magnifications, diffraction is again reducing sharpness in the image plane, while continuing to increase resolution on subject. The 20X NA 0.42 has almost 3 times higher resolution on subject than 5X NA 0.15, but looks a little less sharp because it's 4 times higher magnification.

So, it matters a lot whether you're concerned with sharpness in the image plane, or resolution on subject. For sharpness in the image plane, the practical limit (meaning lenses that most people might pay for) may be around 10X. For resolution on subject, it's much higher than that.

--Rik

pulsar123
Posts: 146
Joined: Fri Jun 12, 2015 12:36 pm

Post by pulsar123 »

rjlittlefield wrote:
pulsar123 wrote:Sure, I don't claim to be an expert in this, so I might very well be wrong. I think I should re-phrase myself: going beyond 5:1 is the path of diminishing returns, because of the diffraction limit, and also the path which produces images with fewer resolved lines across the whole frame, resulting in less sharp looking images.
Let me try to clarify.

There is a diffraction limit, and with conventional macro lenses, re-purposed enlarger lenses, and reversed normal lenses, that limit is indeed reached someplace around 5:1 with current sensors.

However, those lenses are all designed to cover a large field using a relatively narrow aperture.

To productively reach beyond 5:1, what you do is to switch optics, using instead lenses that are designed to cover a small field using a much wider aperture. Those lenses are designed and sold as microscope objectives.

We can put some numbers on this. A good macro lens set on f/2.8 and 5X will be running at an effective aperture of f/17, which is right at the diffraction limit for a typical 4 micron pixel assuming Nyquist sampling. On the subject side, that setup has a Numerical Aperture (NA) of 0.15, which is about the same as a good 5X microscope objective. From there, it's no problem to go to 10X at NA 0.30, which doubles the resolution on subject and has the same sharpness in the image plane. Beyond that, the usual progression involves numbers like 20X NA 0.42 and 50X NA 0.55 for long working distance objectives. At these magnifications, diffraction is again reducing sharpness in the image plane, while continuing to increase resolution on subject. The 20X NA 0.42 has almost 3 times higher resolution on subject than 5X NA 0.15, but looks a little less sharp because it's 4 times higher magnification.

So, it matters a lot whether you're concerned with sharpness in the image plane, or resolution on subject. For sharpness in the image plane, the practical limit (meaning lenses that most people might pay for) may be around 10X. For resolution on subject, it's much higher than that.

--Rik
Thanks - I wasn't aware of all those details. Thinking in terms of my rail design, it now does look like a sensible thing to think about ways to improve it when operated at < 50um/frame. In particular, the relatively small backlash my rail exhibits (~50 um) can become a serious issue, so my next software improvement will be to introduce a backlash compensation. After that I will try to play with "logarithmic" (likely just fixed third time derivative) ways to accelerate the rail - not really needed at 50 um/frame, but could become essential with much smaller steps.

pulsar123
Posts: 146
Joined: Fri Jun 12, 2015 12:36 pm

Post by pulsar123 »

Another test (89 frames):

ImageWatch by syamastro, on Flickr

ChrisR
Site Admin
Posts: 8668
Joined: Sat Mar 14, 2009 3:58 am
Location: Near London, UK

Post by ChrisR »

Looks good. Reminds me I have a bag of watches to try.

NB did you retouch with Dmap? - may kill the flary highlights.
" play with "logarithmic" (likely just fixed third time derivative) ways to accelerate the rail"
I think on reflection that a (say) 3 stage speed increase may be better. Dead slow for 1 second, slow for another second then flat out.

Or, nested loops in the delay per step, would give you speed = steps_done^n, with n as the number of loops in the nest.
Last edited by ChrisR on Sun Nov 08, 2015 5:57 am, edited 1 time in total.

pulsar123
Posts: 146
Joined: Fri Jun 12, 2015 12:36 pm

Post by pulsar123 »

ChrisR wrote:Looks good. Reminds me I have a bag of watches to try.

NB did you retouch with Dmap? - may kill the flary highlights.
" play with "logarithmic" (likely just fixed third time derivative) ways to accelerate the rail"
I think on reflection than a (say) 3 stage speed increase may be better. Dead slow for 1 second, slow for another second then flat out.

Or, nested loops in the delay per step, would give you speed = steps_done^n, with n as the number of loops in the nest.
Thanks for the Dmap tip - I'll look into that.

Oh no, no loops with delays - this will kill my algorithm! To achieve multitasking (multiple devices - LCD, keypad, motor, relay - working at the same time) - I don't use delays anywhere except in a couple of critical spots (specifically, there is a tiny - 2 us - required minimum delay between writing "1" and then "0" to the stepper motor driver "STEP" pin, to accomplish a single microstep).

I much prefer smooth functions to step functions, as I am solving a differential equation of motion, and the former is much easier to deal with than the latter. We will see.

ChrisR
Site Admin
Posts: 8668
Joined: Sat Mar 14, 2009 3:58 am
Location: Near London, UK

Post by ChrisR »

I assumed you'd set the counter (for an OS clock interrupt to handle), in the loop, so the processor's not doing nothing.
Several ways to skin the cat, I guess.

I find acceleration (ie a ramp) while trying to watch for focus, a bit annoying. Constant speed, perhaps for the first couple of seconds, would be more predictable and perhaps nicer to use.

Post Reply Previous topicNext topic