Autofocus to far out to find focus

I am having problems with autofocus algorithms. The problem is when stars are too big, I get a FWHM reading of zero. Yet I know I am heading in the right direction to obtain focus. The zero reading throws of the routine and it wants to move beyond the current focus. thus resulting in never finding focus. So my request is I want to ignore any FWHM rating below a certain number. As an example, I know when I am in focus I get around 1.4 FWHM. So I want to ignore any reading below that. Let me set the that threshold… I have this problem in spades when there are wide temperature swings. Thanks for considering… Bruce

You should move your focuser to around the “in focus” position and only then run the AF.

1 Like

Of course I do this, but when walking into the focus point which changes from one night to the next from temp swings, it becomes a trial an error exercise. I am not in the observatory. to manually move the focus.

And, if the temp changes enough during automated runs , It will walk out of focus.

Sounds like a couple things could help out here :

  • Step size may be too big, or too many autofocus points being used. Seems like perhaps the initial move of the autofocus routine takes you too far away from “close enough to get some HFR readings”.
  • If temp changes are throwing you that far out, then you may want to adjust the frequency you run autofocus. In the AF settings, you can tell SGP to autofocus every N° temp change. Perhaps something as low as 1° might be called for here.
  • Set the starting point (for each filter, if you’re doing mono imaging) to something reasonable. For example, perhaps some evening at around the time you normally begin a session, find a good focus point for say, Lum, and store that in the equipment profile. Then, each night before starting a session, go to the focus tab of control panel and “Focus for Lum” to begin at that point. Wile it won’t be perfect, it should certainly be close enough to serve as a suitable starting point for AF, given attention to the things above.

If all of these things still don’t resolve it, you may have some backlash or slippage that needs to be dealt with. Quick way to find out is to get to focus, move the focuser out some “largeish” number of steps, and then back in the same number of steps. (Or in, and back out, whichever). It SHOULD return back to focus, where it started. If it does not, there’s a mechanical issue to be dealt with.

There is no manual intervention required… unless mechanical issues are the cause.

You should have an absolute focuser, you need to send it to a ball park position, even a 15C delta will not break the AF system if calibrated correctly in terms of step size, data points and capture settings.

I recommend 3sec bin 2x2 for wideband filters and 6sec bin 2x2 for narrowband.

This is a common request, especially for SCTs where once the stars start becoming rings it likes to choose noise as stars instead. It’s frustrating that it appears that no progress has yet been made here and even more frustrating to see replies that it “should work and you must be doing something wrong.” I agree that it should work, but it doesn’t with the current state of SGP and it’s not user error. While I understand that finding an algorithm that’s smart enough to handle large out of focus stars may be problematic, SGP could easily use temperature to set a default starting point if a sensor is available and temperature training has been done. But as yet I haven’t seen that request met either. So give bmorelltx a break. He’s describing a legitimate problem that you’ll find on a number of threads here. Saying to manually adjust before you start automation kind of defeats the point of having automation!


@bmorrelltx, are you using temperature compensation? This is the real key to avoiding the problems you are having with wide temperature swings. If your rig is mechanically sound, you should be able to set the starting focus position very close to correct focus by simply reading off the correct focus position based on the starting temperature. Refer to this great thread by @mikaelA which details the latest version of SGP AutoFocus LogViewer which will let you easily compute your temperature equation. You will want to average many nights results from this tool to get a good value for the slope and intercept of the temperature profile.

There is a wonderful potential enhancement to the Autofocus routine that would automate this which I will be formally proposing to the developers after the more critical enhancements are implemented. If the Autofocus routine accepted the slope and intercept of the user’s temperature compensation profile, it could automatically guarantee that a focus run always starts from a close to ideal starting position. This position would be either the current position, if that were close to the line, or a position determined by the line.

Thank you for chiming in. Yes I have a 11 inch SCT. The only thing I do that may be pushing things is 9 points instead of 7. I set the step size so that the first and last FWHM is 3 times the minimum so that I get well defined v. C11 goes out of focus with temp very quickly. I did not want to turn this thread into a discussion of how to autofocus.

I am requesting a feature that allows me to reject false readings. SCT stars become donuts and I get false readings on hot pixels or a zero reading…

This feature was requested a year ago ( Minor feature request for when you run out of other ideas ), but unfortunately without response from the developers. Again I support this idea.



So we are talking about the same thing, manual intervention is required to get a proper focus. In the event that temp compensation was not being used, or inaccurate, eliminating false readings would probably work. When a observatory is unmanned, the issue becomes even more critical…

Everybody’s set-up is different. I have never had to do manual intervention to get good focus and SGP’s routine works fine for me every night. (I image via a refractor and although my focus start point might not be on the button…it still works for me without any drama.)
Having said that - if people need improvement to what is presently on offer - then I am all for it. I just wanted to throw a positive comment into the mix - SGP AutoFocus does work well for some!


Yeah it works but there a few quirks, clusters sometimes got flagged as a unique stars as an example. I don’t see why SGP would refuse to calculate the HFR for a doughnut… is it related with the “open” middle region ?

I have also encountered this issue with 9 points. I am very close to focus, but apparently SGP requires at least 3 points to the right side of the V-curve. If it only has two, it moves all the way out where it gets inconsistent readings for the first three or four tries (e.g. 9, 9.6, 7, 5– and instead of continuing in the right direction it stops and moves out again, at which point there’s no saving it.
Note that I can be farther from focus and succeed, as long as there’s three consecutive improving points, for SGP will add more points as needed. But it doesn’t intelligently utilize the first V-curve attempt if there are two or fewer points.

The problem that the star size algorithm doesn’t cope with large stars, and particularly large stars with an obstructed scope, is IMO the main reason for people to have problems with the SGP autofocus.

Obviously starting in focus isn’t a solution.

As I see it the problem is that stars stop looking like a spot that’s brighter in the centre, they look more like a uniform disc, or doughnut for an obstructed scope. People can see these easily and, because the size reduces as the focus position is approached, can easily focus the scope. The software can’t, probably because it’s looking for a dot with size and will tend to use part of the star image or noise, such as a galaxy.

There is a lot of information about finding circles in images, much of it mentions the circular Hough Transform. Unfortunately most of this is interested in determining the position of the circles, not their size. I don’t really have the time or enthuiasm to do the coding and testing required to test this but perhaps there’s someone around who could.

I agree entirely with this. My suggestion for a very simple, and simple to implement fix, is for the routine to just ignore all the large stars. Obviously when very out of focus, all stars will be on the large size. An easy way to implement this and deal with this problem is to just use the smallest half of the stars. Or maybe the smallest 30%, if throwing away 50% is not adequate. Another major benefit of doing this is it will eliminate most, if not all of the large stars which are actually groups of two or more stars. Including these only serves to make the average focus value less reliable and closer to noise.

I have never gotten any feedback from the developers on this.

Yes, SGP does calculate HFR for donut sized stars. At least it does for me. A couple of years ago Ken put in a lot of effort to get it to do this. From that point forward it has been much more successful in this regard. Its success will of course diminish the larger the stars get, partly because the larger (more out of focus) they are, the dimmer they are.

The best hope for this may be to implement using the temperature profile of your rig to set the starting point for a focus run much closer to best focus. This has been suggested many times.

The problem of star clusters treated as single stars is a known issue. I believe Ken has a version of the routine that detects these but is very cpu intensive so has not been used.

Are you saying there is no problem with determining the star size for out of focus images? That the people in this thread and others reporting that their out of focus images don’t give correct star sizes are wrong?

So far the only solution I’ve seen is to start with a nearly focused star image and that doesn’t solve anything.

Perhaps this is a problem for which the full solution is to hire an observing assistant.

Ok I will take one more pss at this. In order to do this, I need to state, I consider myself an expert in this software and associated systems. With that said, there is lots of evidence on this forum, that some people are having problems.
i am calling a large star as having a FWHM measurement that might be around 7-9. This is not out of the capability of SGPro to measure. I set my step size to give me 7 points with the max reading about 3 times the minimum. So lets not rehash am I doing it right.

It is a fact, SGP returns false readings under certain circumstances. If you are not experiencing this, that is fabulous, but please let those of us who are, have our say…

Chris, if this comment refers to my comment, then NO, I am not saying that. Obviously when enough out of focus, the focus routine cannot find the stars and therefore cannot determine a star size. Obviously lots of people are experiencing difficulty getting usable focus curves. Inability of the focus routine to give meaningful star measurements is a problem we are looking for solutions for.

What I did mean with my comment is that up to a certain size and brightness, it will detect and give correct star sizes for stars that are donuts. I did not say or imply that this would be true for way out of focus situations. Ken did make major improvements in this a couple of years ago. Does it work when badly out of focus. Of course not. Why would we expect it to. The user should try to start as close as possible to good focus.

Clearly, as you say, we must start the focus run as close as possible to correct focus. Assuming no manual intervention, the only way that has been presented so far to do this is to have the routine use the current temperature and make the appropriate temperature compensation before starting the run.

This works well for a fixed installation, assuming you have determined the temperature coefficient for your equipment. For a portable rig, you should be able to manually set the focuser at the optimum starting position based on the current temp.

Yes, I see this often myself. For this reason I have turned off the smart focus procedure so that it does not move a huge distance from where it started. This approach has worked reasonably well for me.

An estimate of how far out of focus a FWHM of 8 pixels would give is 240 microns, 0.24mm, 10 thousands of an inch. I’m assuming a pixel size of 5 microns, an F/6 scope, and geometric optics.

That doesn’t seem like a long way out and I can see why people want a better ability to focus, especially when they can see the stars in the image when it’s a lot more out of focus than that…

It may be that determining the star size when grossly out of focus is too difficult and there’s always going to be a problem when the star image is so big that it vanishes into the noise. But if stars could be detected and sized when say 6 mm out of focus a coarse focus routine could help users get in the ballpack.