Build 375 - Autofocus Fails - RedCat51

I am having some trouble with autofocus and looking for some help. I am using SGP beta 375. I have been using SGP for three years now and am very happy with the software. During this three year period I have been using autofocus on my Celestron Edge HD 800 with much success. I just received my William Optics RedCat51 and just set this up in SGP. I also have an AF3 automatic focuser from DeepSkyDad attached to the Redcat. The AF3 focuser seems to work just great when manually adjusting focus. The problem I am having is the autofocus routine never successfully completes although the curves look great. I use 10 data points and a step size of 15. I start with the Redcat in really good focus with stars at HFR 1.2 range. I have put a link to my dropbox which contains an SGP log file and several folders of the Autofocus packs. If you look at the SGP log file at 21:12:40, the first data point has an HFR value at 4.54. The HFRs that follow are 3.51, 2.37, 1.60, 1.28, (then back up) 1.40, 2.04, 3.00. Even though I have 10 data points setup, the autofocus never gets past 8 points. It just fails and restarts another autofocus try with the exact same results. I tried different number of data points and step size but the problem persists. What I dont understand is why at data point 8 the autofocus fails? The curve looks great to me. Any ideas of what might be happening or anything different to try? I have only tried this on Build 375, no other Builds or Versions.

Indeed looks like something isn’t working properly here. I used the logviewer to extract some of the failed runs, and they pretty much all look like this (the red curve is the SGP quadratic fit function):


I don’t think this is a problem with your settings, the data looks good. The problem appears to be in the quadratic fit of the data, which results in a poor quality factor causing an abort. @jmacon ad @Ken should have a look at this.


@mikaelA, @Ken, @mexbound the problem here is the actual focus positions:
499754 4.54 61
499739 3.4 100
499724 2.36 148
499709 1.6 243
499694 1.32 267
499679 1.42 237
499664 2.05 176
499649 3.01 105

It looks like they are biased up by 499000 or thereabouts. Percentage wise they are almost all identical. An increment of 15 around a position of 499600 is a very tiny percentage. This actually busts the current release of our Quadratic code because the long reals overflow with such a big number. This number is taken to the 4th power, which badly overflows a long real numeric storage. We have already dealt with this by internally dividing the position values by 1000, which so far has worked fine for position values as large as 100000. However, that adjustment does not seem to be enough to deal with position values of 500,000.

I will see what needs to be done to the routine to deal with this. mexbound, do you have a way to change the range of position values you are using? That would solve this immediately.

When I change all these to look like this:
I get Quality factors of 99% for all your runs.

In the ASCOM driver for the AF3 there is a value called “Maximum Position = 1000000”. If the clouds go away tonight, I can try to set this to 100000 and see if the focus position values get reduced. Thanks for looking at this for me.

I would suggest changing it to 10000. that is plenty is your step is only 15. But you really should check and see what range is really required to move the focuser through its entire range, or at least a fair part of its range. That should correlate with your max value.

Ok, I will try using “Maximum Position = 10000” and runs tests to make sure I have full range with this number. I will post back with hopefully a success story or different results. Again, I really appreciate the help.

Just to improve on an already perfect solution:

As an alternative to the division by 1000 - wich, depending on implementation might loose information - you may substract an offset of let’s say (MinValue - 100) from all focuser positions, do the fitting and at the end add it back to all the relevant positions.

Kind regards,

I was able to set the “Maximum Position = 10000” in the ASCOM driver and run some tests with manually moving the focus position. My best focus will now be around “6000” with plenty of room for moving in or out. If the clouds move out, I will try autofocus tonight with these new settings. Thanks again.

Could we not just reduce the position to a reasonable value, store that offset, perform AF, then apply the offset back for any positional movements?

This is definitely the best way to handle this situation. Why didn’t you suggest this to me a month ago? He He.

Same suggestion, we should do this.

This should be fully resolved in

Thanks about resolving this. I am away from home for a month so I won’t be able to test this right now. But I feel good about the resolution.