@A1ex @dmilligan
I am glad you posted this and restarted this topic !
I have been working on the same subject in Lua with lens.focus (open loop, relative focus positioning) and lens.focus_distance.
It would be very useful to be able to work in closed loop with absolute positioning as it would drastically simplify all what I have done so far !
I am very interested in trying to do it but I would need a guidance.
My aims are:
- to implement advanced stack focus after focusing on specific objects to be in sharp focus (or blurry) and after storing their absolute positions;
- to better stack focus in the near infinity range by working in the "nearly linear" image field;
- to position one's lens to hyperfocal distance or to position the lens on specific and previously set "infinity distances".
Those apps may need the use of companion file(s).
Many thanks in advance!
So far, if anybody is interested, I have tried (with incomplete results and success, given the very wide search field) to:
- scan different lenses with step sizes (in domains) 1, 2 and 3 (ex: EF 100mm f/2.8L MACRO IS USM : 4416 steps in domain 1, 396 steps in domain 2, the fp reporting didn't work in domain 3 but lens.focus moved the lens on 55, 56 times, EF 24mm f/1.4L II USM in domains 1, 2 and 3)
- to absolute position a lens in domain 1, after focusing it (automatically (AF) or manually (M)) on an object. The algorithm uses the properties of the step function by translating (projecting) the uncertainty zone to parts of the step function where there is more information in between (and while counting the steps done back and forth as the lens moves); at the beginning, the uncertainty range is the whole lens; with the "step" function, we can know on which "step" the fp lies; then, by using moves in domain 2, the uncertainty range can be divided by 2 at each "larger" step; after domain 2, projecting in domain 1 (still to be better studied), it is then possible to do the same with the finest steps until the uncertainty falls to a few fine steps (the number of moves in a domain is less than the log2 of the uncertainty range measured in steps). The problem is to optimize the algorithm to get the most precision as, in open loop, each move can add a one (or more) step(s) uncertainty.
It requires to store the step function in a file for the lens to be used.
Some primitive tasks :
1) Scan a lens with precision in domains 1 and 2 to get the step function and store the results in a reference file for that lens
2) find the absolute position of a lens using the reference file and store the position in another file for further use (with ancillary tasks : add, remove, clear all,…)
3) use later the positions stored in this last file to position the lens at will as accurately as possible
As said, the caveat is that the stepper motors can loose some steps erratically, so the more you move, the more there can be uncertainty on the positioning.
Research directions:
- Continue to check with different lenses as, until now, I have mostly used fine steps : how can domain 2 and 3 be projected in domain 1 ?
- Work in the « image domain » as the distance of the focal plane is nearly linear in function of the « stepper motor » step number; this can facilitate the use of the near infinity focal positions. Then, translate to « object domain » distance.
- Position uncertainty can be studied : electric power supply; low cost lens vs L lens (better mechanical qualities for moving parts ; perturbation torques; chocs) intervention à la main, frottements...
- measurements in reality : focus on target, measure absolute position, compute (interpolating with step function) a distance: compare computed with measured distance