Autofocus sometimes goes awry


#1

With refractors the autofocus routine works amazingly well – most of the time.
Here is a sample of the focus curve I get almost every time with my Stellarvue 102mm refractor:

This scope has a very predictable focus relationship with temperature, as illustrated by this linear regression plot of focus position vs temperature.

The resulting formula that yields the focus position is:
FocusPos = 17591 + 10.1 * F (this is an average of 3 separate nights of focus positions)
This yields a focus position that is usually + or - 10 units from the ideal value. Quite close to excellent focus since my step for the autofocus routine is 70 units. When I use the formula to set the initial focuser position when I start imaging, then run the autofocus routine, it usually is within 10 units of my calculated value.

However, the problem is that twice in the last 5 full nights of imaging with ver 2.5.0.17 at some point during the night the routine went haywire. Autofocus runs were done every hour.
Here is the http://adgsoftware.com/misc/sgfocus/ extract of the focus positions:

Temp Position HFR
47.3 18079 2.2
47.3 18081 2.05
45.5 18056 2.38
41.9 18019 2.11
39.2 17988 2.19
36.5 17983 2.37
34.7 17921 2.43
28.4 17119 1.82 ###
27.5 17884 2.52

Note that the next to last entry is badly out of whack. I set the focus routine to do its focus once per hour, so for the hour it was imaging at pos = 17119 all my images were badly out of focus.

What has caused this I am not sure of. I suspect it is probably a light cloud came over, or perhaps a brief spell of strong wind. Whatever caused it, my thought is that the autofocus routine ought to be able to cope with this and never produce this failure.

There are several ways the routine can avoid this problem:

  1. support a new feature that accepts the focus parameters for the focus formula as a function of temperature. One additional parameter the user should provide is a maximum focus position variance. If the focus position the routine comes up with differs from the projected value from the formula by more than the variance, the routine would throw its value away and calculate a new position as an offset from the prior position using the differential value.
    Example from above: last good position was at 17921 for 34.7. Current temp is 28.4, so 17921+(28.4-34.7)10.1 = 17857.
    Just using the formula directly gives 17591+(10.1
    28.4) = 17878, an even better value in this case.
    In fact, ideally the routine would compute its own linear regression for this evenings run and use it.

This approach has the additional advantage that when the focuser is intially connected SGP would immediately move the focuser to the posisiton given by the formula. My standard procedure now is to compute the formula value in a calculator, then manually move the focuser to that position, then run the initial focus run. This makes the initial focus run quicker because to already has the best possible starting focus position.

  1. The simplest quick and dirty approach is to just support the maximum focus position variance parameter. The focus routine would compute its own temp offset if the user has not included one in the focus setup.

  2. The third possibility would implement a suggestion I made several months ago to compute a quality factor for the run and the user would provide the minimum quality allowable, otherwise the focus result would be discarded. A simple quality factor would measure the least square fit of the data points on each side of the curve. I’m sure this would have prevented these failures for me, since that data points where it failed were very irregular.

I should add that for the past 5 or 6 full nights of imaging unattended with 2.5.0.17 it has otherwise run flawlessly without a single crash.
Great work Ken and Jared!!


#2

Thanks… glad things are smoothing out…

Good idea… not sure I like the idea of forcing users to temperature profile their scope for proper use of AF, but we’ll think about this.

Maybe. What is the baseline for this variance? What if the “bad” focus had been used in the sequence as the first AF run? Not sure how to guard against this (especially since user AF positions, even at the same temperature, are not guaranteed to be near each other for focus).

Pobably the most promising suggestion (IMO). Coupling this with the minimum star star size filter in arcsec (suggested by @freestar8n) would probably be quite effective.

Also… noticed this was run with a DSLR. Are you using soft binning for the AF runs (something we should log, but failed to)?


#3

I would really like to see the suggestions above being implemented, I have had the issue that somehow overnight the focus results drifted lower and lower, and more and more out of focus, I have both refractors and reflectors and especially the reflectors are error prone, I know donuts can be though …

So I really would like to see a hard focus range with optimal focus point as a hint …
So thumbs up for the suggestions made above.

/Yves


#4

I would not make this a mandatory feature. Just like the current optional temperature compensation (which by the way, works wonderfully well) this could be optional.

The variance I am suggesting is simply a maximum difference from the autofocus run value. For my SV102 I would pick a value of say 20. For any autofocus run that gives a value more than 20 units off the formula computed value, I would want the routine to set the focuser to the formula computed value. So the baseline for this would be the formula.
SGP could accumulate this data automatically and use the last X nights of data to create an up-to-date formula the evolves over time.

I would definitely NOT use an offset from the prior position as I suggested in my prior post. Much better to always use the formula.

So I guess what I am saying here is that approach #2 really needs to be #1, use the formula.

Here is a much better plot of 7 nights of imaging from Mar 2 to Mar 8. This plot includes all focus data points, including the bad ones.

When I eliminated all data points that were clear outliers, we get a much more reliable plot yielding the formula
Position = 17600 + 9.94 * F

Alcula.com BTW is an excellent site for doing these plots. It lets you paste in the entire set of data in one step.

The correlation coefficient for this plot is .992, which is excellent and implies using the formula is very reliable in predicting the optimum focus position.

Right on here. I think this is essential and should be fairly easy for you to implement, since you are already calculating the linear regressions for the 2 sides of the curve.

However, I am really rooting for doing both, since the temperature formula gives such good results. In fact, I have been using the temperature formula approach for my RC12 since it gives me such erratic results. It has some very decent V curves and many useless V curves, all without the donuts coming into play, since I am always running it manually in the near vicinity of good focus.


#5

No, I always use full res with my DSLR.

@Yves suggestion of a hard focus range with an optimal focus point hint ties in very well with the focus formula. The focus point hint would be provided by the formula, which would also define the range. If the user does not have a temp sensor or no formula has been developed, a simple Min and Max range would certainly prevent the worst failures.

Quite frankly, I am thinking that with my SV102 I could just use the formula exclusively and not do any autofocus runs, the same way I am now running with my RC12. I might get just as good results. I will give it a try. The optimal formula may have different parameters for different temp ranges. When summer gets here I will be able to check that out.


#6

You might want to try soft binning for AF. Sometimes the bayer artifacts interfere with metrics and cause irregular behavior. Soft binning removes the bayer artifacts (mostly).


#7

Thanks Ken, I’ll give it a try.


www.mainsequencesoftware.com