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.https://www.dropbox.com/sh/06ok5l0o8ktuxv3/AAB84A5j_7s-v2tUmRpA6_aza?dl=0
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.
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.
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 188.8.131.525
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.
Old topic, I realize, but I have trouble with AF2 in a very different system. Maybe the suggestions here will help me, though. I’d appreciate your thoughts.
My scope is f/15, 5250mm focal length(!). I have an Optec ThirdLynx, 1.07 microns per step. My focuser has 1.5" travel, approximately 32mm (in rounded numbers), so approximately 32000 steps racked-in to racked-out. The last time I was out I could not achieve focus. I was close enough to focus that stars were round, if bloated a bit. I set movement size anywhere from 100 steps to 1000 steps trying to get focus to converge. I started with 7 points, got up to 13, then started backing down again. I never got a U-shaped curve and autofocus failed every time I tried. Call me frustrated.
I haven’t looked at the ASCOM driver mentioned, unless it’s the driver for my focuser. In that case I’ll double check the maximum position is set for 32000 or there about. Anything else I can check/ change/ do?
I should add, after reading another autofocus post: during the night in question, I never did get a saddle/ U-shaped curve, so I didn’t really have an opportunity to change my best focus point and movement size to keep my focuser in the range where there was a saddle. I’ll look for that next time I go to my observatory.
Dialing in AutoFocus can be a bit frustrating for sure, but luckily this is typically only a “once per rig” activity (maybe small adjustments through the seasons).
I would recommend sticking with
9 data points (for now). This is a good value for dialing AutoFocus. In terms of the step size:
- Step 1: Enable Image History and then start a Frame and Focus loop using your desired exposure length for AutoFocus. This will display, on each frame, the current HFR. The objective here is, using manual focus adjustments, minimize the HFR. This focus doesn’t need to be perfect.
- Step 2: Note the current position of the focus controller and note the HFR at this point
- Step 3: Once you have approximate focus, making sure to move the focuser in the SAME direction as the last movement you used to achieve this manual focus (eliminate backlash as a variable), move the focuser slowly until HFR is about 3 time larger than the “in focus” HFR above. It doesn’t matter if you rack out or in, just that you move in the same direction as the last focus movement in Step 1.Once here note the focus controller’s reported position.
- Step 4: Find the delta (absolute value) of the starting focuser position and the focuser position that yielded 3x HFR. This value is approximately half of the distance a focus run should move. With that in mind, go ahead and double this value and then divide by
9. This should be your starting step size (not necessarily your final one though).
- Step 5: Setup AutoFocus with the new values and run it. As long as you start AutoFocus from a position of focus, you should observe a “U” and, notably, the tips of said “U” should be approximately 3x of your in focus HFR. If they are not, this points to a different problem (focus movement issues… backlash, binding, slipping, etc).
If you still have issues after following this min guide, write back and we can move to the next step.
Thank you, Ken. In my previous attempts I started with a less rigorous version of Steps 1 and 2, then tried autofocus. The frustrating thing is, it’s worked in the past, just not last weekend. I’ll try Steps 1-5…
If it’s worked in the past, maybe you can derive a list of variables that may have changed between then and now:
- New drivers?
- Different target? More or less star dense, etc.
- Different orientation of mount? Fighting gravity, etc
- Different loadout on tube (weight changes, etc)
- Different weather (extreme cold can cause binding)
- Accidental removal of required settings (like backlash)
Thanks again, Ken. Clouds stayed away this weekend so I made an after-work trip to my observatory. Autofocus still didn’t work last night, but this time the cause was obvious: wind. Very frustrating to see a nice saddle forming only to have a puff of wind cause my stars to streak to 3x their previous size.
To respond to some of your questions: no new drivers, hardware is fully consistent, and other than being pointed to different targets, my mount and scope orientation has also been consistent (no changes to polar alignment, no shifting of my scope to rebalance, etc.). Cold hasn’t been a factor with my hardware, either, though if could have been. We’ve had our annual freeze south of I-10 so us southerners have been whining enough to make Yankees laugh.
Funny you should mention lost settings: when I was working to get plate solving working my friend and I discovered my camera data had disappeared from my configuration. Once that was fixed plate solving started to work.
Here’s hoping for no breeze next weekend…
A fresh attempt this weekend without success. I don’t think wind was the problem this time, I think seeing was. During my various autofocus attempts I would watch the HFD numbers for one of the stars in the preview window. The HFD values for one attempt I remember varied between 4.2 and 10.6, randomly.
At various times I tried changing my Settings (one at a time). Exposure length between 1s-4s (hoping to either “beat” the seeing, or average it out), 7 points/ 9 points/ 13 points per run (trying to make outliers less important, move sizes between 125 and 1000 steps. I never did get a saddle to form. Lots of scattered data points making saw-tooth patterns as the star images “boiled”.
I did use Step 1 above to get close to focus. Then I used the autofocus algorithm “manually”: I set my manual focus step to 250, then took 3-4 frame-and-focus images to get an average HFD value. Then I moved one move (250 steps) in one direction, 3-4 F-F frames and compared the average HFD value. If the trend was decreasing HFD, I continued in that direction until HFD started increasing. Whatever position my focuser was in when I found my minimum HFD was my best focus point. I then repeated the procedure using 125 steps per movement. I think I was within 0.2mm of best focus when I stopped focusing.
I did take some pictures, but haven’t even preprocessed the data yet.
That’s a pretty wild fluctuation without any kind of movement. Keep in mind that this metric is a “whole image HFR” that can be heavily influenced in star-poor regions. How many stars does SGPro say it finds? Are you using long FL or super fast gear?