TL;DR I have just written a new focus algorithm that I hope can improve autofocus for some people with AF issues. I need your help in testing it out, especially if you are experienced, comfortable running the bleeding-edge software, and having AF issues. However, whoever you are if you do test this, please send me feedback.
This new code was just submitted tonight, so it will be in the next nightly build, or, if you compile from source you could git pull it now. To see if your new code has it, go to the Focus tab, find the "Process" tab near the middle-left of the page, and in there, under the "Algorithm" drop down, select "Linear (Experimental)". If you don't see "Linear (Experimental)" in the Algorithm drop-down menu, then you don't have the software you need to test this (the other choices in the drop-down are Iterative and Polynomial).
Here's how I recommend you use it.
Choose the following in the Focus Tab:
- Process sub-tab: Algorithm: Linear (Experimental)
- Process sub-tab: I'd recommend Detection: SEP and Tolerance 5%, or perhaps a little higher
- Settings sub-tab: Full Frame (definitely recommend this)
- Settings sub-tab: I'd recommend Annulus to 25% 75%
- Mechanics sub-tab: Choose Initial Step Size and MaxTravel as described below.
- Exposure: this is up to you, but for my f/5.6 refractor and an ASI1600mm, I'm successfully using 5s for RGB and 10 for Narrow Band filters. I have not tested with a DSLR.
- Set up your system so you have rough focus. If you are far out of focus, it won't work. - Click AutoFocus and watch it (hopefully) work!
Please turn on verbose focus logging: In the main Ekos tab (on the left) click on logs, then in the logging page, check verbose, and focus, and file output. When you send me a note, please include the log.
Note: this will fail if you are not "near focus". I define that by being within 5 Steps (InitialStepSize) of the minimum-HFR position.
The way the algorithm works is: after you click AutoFocus, it moves from the current focus position to a new position that is 7 steps outward (the camera is moved further away from the telescope). It then samples HFR, moving inward by InitialStepSize, looking for a minimum HFR. If it doesn't find a minimum within 20 steps or so, it will fail. If/once it finds the minimum, it moves outward to 2 steps past the minimum position, and then re-samples back inward, but moving by half-steps, until it measures a HFR within tolerance of the best measured HFR in the first pass. When it finds that, it's done.
My theory is that current failures may be due to too-much changing of direction, and I'm hoping this more steady "always in" approach will improve things.
You may have to experiment, but, I roughly focus, and set initial step-size to something like 1/3 the distance between Red and Green Focus in my refractor (or perhaps a little larger).
MaxTravel won't have much impact unless you set it too small. I start with something like 4x the distance between my Red and Green focus.
This algorithm will no doubt be slower (more iterations) that the existing ones. If the other ones work for you, great, use them. The goal here is to get something that works for more people, and once we have that, then to try and speed things up and make it more tolerant of starting position, without losing reliability.
This is not the end, but rather the start of the process, so please be gentle
Please let me know how it goes,
Hy
PS It is certainly the case that autofocus can be affected by star detection and by HFR calculation. This change does not address that. Star detection and HFR calculation may be the next things to look into, but I believe it makes sense to start this way.