×

INDI Library v2.0.7 is Released (01 Apr 2024)

Bi-monthly release with minor bug fixes and improvements

For those with focus issues

  • Posts: 1119
  • Thank you received: 182
Hy,
The latest focuser algorithm (v3.2) works GREAT with my analog 3D printed focuser based on the Shoestring Astronomy FCUSB focuser.
This is what I get with a 135mm Nikkor lens attached to a cooled ASI183MM. I have a deep red filter in the lightpath, which includes Ha, S2 and extends into the infrared.



This is what my rig looks like (taken this morning after a night of imaging using a 55mm Nikkor Macro lens).



Simple solutions, great results.

Happy to share the STL files for the 3D printed rig, if anyone is interested.

Jo

PS: Here another image of the Linear focus routine, v3.2, this time using SEP, not Centroid.

The following user(s) said Thank You: Jim
Last edit: 4 years 2 months ago by Jose Corazon.
4 years 2 months ago #48845
Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 182
Thanks for writing this code, Hy!
It is very fast and works great with such a simple focuser. Takes care of common backlash issues.
Jo
4 years 2 months ago #48846

Please Log in or Create an account to join the conversation.

  • Posts: 1222
  • Thank you received: 565
Thanks Jo.

For everyone:  I'm happy to continue iterating and improving this scheme, but at this point have implemented most of what I planned. If anyone has autofocus issue with this algorithm, please send debug logs my way. Please also let me know if it does improve AF where previous focus algorithms didn't perform well.

FYI, the way I've been using autofocus (4" WO f/5.6 refractor with moonlight 2.5" focuser stepper motor and V2 controller) is:
  • Step size of 25 (that's definitely focuser dependent)
  • SEP detection algorithm (haven't carefully compared, but the HFR computation looks better to me this way)
  • Full Field HFR measure with annulus of 20% & 75%.
  • 5% tolerance
  • Max Travel of 400 (probably irrelevant, but don't make it too small)
  • no backlash compensation (the moonlight focuser driver doesn't support that anyway.
  • 2x2 binning and 3s exposures for RGB and 6s for narrowband gain 200 for my zwo ASI 1600mm

Make sure you have logging set to: Verbose, File, and have at least Focus and Capture set.
Hy
The following user(s) said Thank You: Jose Corazon
4 years 2 months ago #48876

Please Log in or Create an account to join the conversation.

  • Posts: 554
  • Thank you received: 138
A quick (I hope) question.
The name implies that the focus algorithm is linear but the display seems to show that the points are fitted to a curve. That looks more like the polynomial method to me.
I'm not objecting, some sort of curve fitting seems better to me because it uses more information.

Chris
4 years 2 months ago #48935

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 182
I intuitively had the same thought initially. I believe the curve is naturally hyperbolic, but can be fitted near its minimum with good approximation using a polynomial algorithm. To obtain that curve and thus the calculated minimum, Hy’s algorithm will first focus out from a position near optimal focus by 10 steps, then move in by 5 steps (to fully engage the gears and removing backlash), then move past the starting point by 5 steps. The HFR values measured at each step are then used to calculate the curve (from watching it perform, I think that calculation is done after each step move). Then the algorithm will move back OUT past the minimum again and then move IN again using smaller steps toward the calculated minimum.

So the movement during which HFR measurements are taken always proceed in only one DIRECTION.
The advantage is, that this minimizes backlash error, as the gears are always fully engaged. By contrast, the “polynomial” method uses movements in AND out once it has calculated the minimum, which would yield the same result, IF there is no backlash.

So, I think you are correct, both methods use polynomial fitting to a hyperbolic curve, but the original “polynomial “ method uses a bidirectional iteration towards the minimum, while Hy’s method uses a UNIDIRECTIONAL linear iteration which eliminates backlash as a variable.

Perhaps the algorithm should be renamed to ‘Unidirectional’ to avoid this confusion, but Hy should weigh in on that one (and also on whether my account of how I think his algorithm performs is factually correct).

Jo
4 years 2 months ago #48941

Please Log in or Create an account to join the conversation.

  • Posts: 554
  • Thank you received: 138
Thanks Jo.

I agree that the curve is close to a hyperbola but close to the minumum a polynomial, presumably of degree two seems OK.

Part of the reason I hadn't tried it was the linear name. I don't have a lot of backlash so the current polynomial method works well for me. I didn't want to loose that.

For mounts which can reach a reproducible position but have backlash the second phase could be reduced to a single move out, then a single move to the position calculated in the first phase.

Chris
The following user(s) said Thank You: Jose Corazon
4 years 2 months ago #48943

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 182
Yes, Chris, that would work with stepper motors, but not so well with analog motors which are less precise.
One reason why Hy has designed the algorithm the way he did was to help people like me who are using self-built, primitive analog-based autofocusers. Very adaptable to a wide range of telescopes and cost next to nothing.
That algorithm works REMARKABLY well with the simple 6V micromotor from uxcell I used in the focuser shown in the picture above.

www.amazon.com/30RPM-Shaft-Metal-Gearwhe...7YTWJ364CVV8N9PA3YPE

One can't argue with a $ 7 price tag....
4 years 2 months ago #48947

Please Log in or Create an account to join the conversation.

  • Posts: 1222
  • Thank you received: 565
Chris.

Perhaps I named it poorly, I would be open to renaming it when I remove the "experimental" in the name--so suggestions are welcome. I called it linear, I guess to contrast it to the polynomial algorithm.

The main characteristics of the algorithm (mirroring much of what Jo said) are:
  • It takes regularly sampled HFR values, i.e. (mostly) moving the position inward by a fixed amount--step size in the 1st pass of the algorithm, and 1/2 step size in the 2nd pass. The polynomial algorithm varies the change in position.
  • It hardly ever changes direction, and mostly moves inward. It takes a number of samples inward to establish an approximate minimum-HFR position, then makes a 2nd inward pass looking for that minimum. The polynomial algorithm can move in and out often.
  • It only samples the HFR after an inward move. When it needs to move outward, e.g. in between the the 1st and 2nd passes, it moves outward much further than needed, and then back in before capturing an image. Polynomial has no such constraint.
I like to think of this algorithm as "slow and steady". It will hopefully be less sensitive to backlash and measurement noise, but will likely take more samples to achieve its minimum HFR than a successful polynomial search.

The polynomial that is displayed is used to help find the minimum position, and stopping position, and, for example, as a check to see if there will be a minimum at all for the current sampling plan. A red polynomial means a failure (no minimum, just a maximum). The polynomial is only computed after several samples.

There are some details that may violate the above principles (e.g. it may skip some samples if it thinks it's far from the minimum), but in general that's the way it works.

Hy
4 years 2 months ago #48967

Please Log in or Create an account to join the conversation.

  • Posts: 554
  • Thank you received: 138
Hy and Jo,
I really wasn't attacking what you have done. I think it's great. In fact, now I know it does a polynomial fit I'm tempted to use it because I think that moving in one direction will give better data, even with minimal backlash.

It's just that with an absolute focuser once the best focus position has been found using the polynomial I'd like to move straight there. It's not critical though, I could live with it as is or stay with the current polynomial.

Chris
4 years 2 months ago #48984

Please Log in or Create an account to join the conversation.

  • Posts: 1222
  • Thank you received: 565
Chris,
I absolutely didn't take your comments as an attack, quite the opposite. Sorry if my response sounded like that.
I agree that if polynomial gives you good results, it should be quicker so you'd be well served using it.
It was my understanding that there were some people that were having issues with the current AF algorithms, especially SCT owners,
(though quite honestly my configuration also sometime seemed sub-optimal) so I targeted a "slow and steady" approach for those folks.
The following user(s) said Thank You: Jose Corazon
4 years 2 months ago #48985

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 182
I also did not read this as undue criticism of Hy's great contribution at all! On the contrary, we all need constructive criticism if we want to improve. Seeing a way for someone to improve and not telling defeats the purpose.

Keep it coming, Chris!

Best

Jo
4 years 2 months ago #48992

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 182
I have now had the chance to use Hy's Linear v3.2 algorithm for several nights and I am pleased to report that it performs flawlessly with my simple analog FCUSB driven home-built focuser in a heavily light-polluted area, so under the worst possible conditions.
It finds the optimal focus every time and the U-curve that is being displayed gives me visual confirmation that the focuser has indeed found the minimum.
I definitely will use this method as my standard focusing method from now on.
Chris, you may want to try this, too. It is definitely better and more consistent than the "polynomial" back and forth method.
4 years 2 months ago #49165

Please Log in or Create an account to join the conversation.

Time to create page: 0.768 seconds