Autofocus help

I think your idea of fitting a quadratic makes sense but in your example you are choosing three arbitrary points around the minimum thus not taking advantage of the other data. I suggest using a least-squares fit such as given here http://mathforum.org/library/drmath/view/72047.html That would use all the data points. Since the data curve is quite flat, curve fitting has the potential of giving a better result than trying to do a linear fit of the sides of the curve. In my own experience, I often find that there are one or more clear outlier points. Perhaps an approach that does two curve fits would work better. The first attempt would use all the data and the second attempt would remove data points that are off the curve by some amount. If there are too many divergent points that would be a clue that the process is failing.

Also, the idea of selecting a subset of stars makes sense to reduce the computation. I assume that giving preference to stars near the center of the image would give a better result. Perhaps using some sort of weighting approach where stars near the center contribute more to the result.

Lastly, as was pointed out by another poster, when you start getting donuts the star diameters are clearly increasing. So perhaps a hybrid algorithm that looks at HFR and star diameter would be the way to go. The current algorithm starts off by moving the focuser to one end of the curve as defined by the user. Perhaps a better approach would be to take one image it the current focuser position to establish a baseline. If the star diameters are getting much larger than the baseline you know there is a problem. The current algorithm is predicated on the idea that the focus is near the ideal so why not take advantage of that fact. Moving the focuser in steps away from the current position (rather than moving to the curve edge) would give feedback about whether you are getting into large diameters. Of course, backlash has to be taken into account.

1 Like

Hi Frank,

I’m happy to take up your offer of help! :slight_smile: I have a standard C11 and my SXVR-H694 and reducer gives a field of about 22x28 arcmin. With that FOV, there’s a bit of distortion, though nothing like what I got with my old QHY8. Do you think I’m better off with full FOV/more stars or subframe/fewer stars? I don’t have much trouble with focusing, but better is always good. And I’m collimated with Metaguide, of course!

Kevin

Per my previous post, I tried the data that buzz provided with a least squares fit. The resulting graph shows a very nice correlation between the actual and calculated curve. However, for this particular data there is not a lot of difference between the least squares calculation and the SGP or 3 points calculations for the actual focus position. Nevertheless, the least squares calculation is on better theoretical footing than doing linear fits of the sides of the curve.

Here is a DropBox link to the Excel sheet. https://www.dropbox.com/s/8l6ajegsnks2hbs/SGP%20Focus%20least%20squares.xlsx?dl=0

Hi-

When I said “the focus should be found based on the parabolic shape” - what I meant was to use a curve fit rather than the two straight-line fits. I have my own focus code but it doesn’t integrate well with SGP and I think the sgp approach should work fine. In my own code, for an sct I found that quadratic isn’t adequate to describe the shape of the curve and it needs at least a cubic fit.

I don’t know how people are currently doing focus runs with sgp, but if they are getting big donuts with an sct, it sounds like they are thinking of focusmax with one bright star rather than sgp with many stars - so you don’t need to go so far from focus. In my case I used a fairly dense star field with uniform star brightness and then a 50% crop mainly to speed the process. The seeing was fairly good so the curve was well shaped - but it should still be ok with imperfect seeing.

I haven’t used this enough to know that it is robust in an unattended imaging session, but it seems promising so far - as long as you start near focus.

And for focusing an sct with the primary focuser - make sure backlash is handled and goes the right direction. In my case I use a full turn of backlash compensation - which takes about 45 seconds and adds a lot of time to the process. But it only gets invoked at the start of autofocus and when it completes.

Frank

Of course, all our ‘help’ is interesting but not the entire story. It is easy for us to sit back and say ’ off you go Ken, here is an equation, what is the problem? Can I have it for 2.5?". Finding an algorithm that Ken and Jared can code and for it to work robustly in hundreds of different cases is a completely different matter. With the diverse range of equipment, it does seem more likely there may need to be alternatives to suit wide-range and close-range focusing. Clearly FM does wide range with linear regression - I’ll have to dig it out and try it with ahem, Maxim, to see how it copes with my RCT!

So, off you go Ken. Can I have it for a beta for next week? :wink:

My main point is that the existing code appears to work well well for an sct when used in this way. The line intersection routine isn’t ideal here - but it is essentially perfect focus for my setup because the horizontal scale is so fine.

By capturing the minimum of the focus curve in detail with multiple stars, there is no need to go far from focus where donuts and other algorithms are required.

For an sct and some other setups - it does require backlash to be handled properly, and it does require starting from near focus in the first place.

I used focusmax with maxim and I didn’t find it worked well - and I didn’t like the idea of using only one star for all the information - and extrapolating far from focus. The sgp implementation captures the main aspects that I would want in an autofocus routine.

I’m not sure if the approach I describe here will give a nice curve for everyone as it did for me - but my setup is relatively challenging, being an sct with robofocus on the primary focuser. So if it works for me - it seems like it should work for others - and for those who are having trouble with the existing routine.

Frank

an sct is not a fast newtonian, and the results on my fast obstructed ota are pretty
strange and time consuming, i found focusing completly non repetable, position differs with filters, exposure duration
star distribution and numbers, and so on.
I did try to implement offsets, and wasn’t able to have something reproductible.
So far, focumax stay the gold standard for focusing (at least in my opinion for my particular setup…).

I have to go back on this when possible. and make more tests to find out what i missed.

Hello freestar8n,
I am new here and have a small question. I typical download of the whole image lasts 30s with my STL11k and 15-20s with my Moravian CCD. Than with medium or bad seeing the FHWM values change much without any focus change, so there is the need to sum more images per step. I would take very long. Is it possible to define an ROI for autofocus?
Thomas

Hi-

I believe this issue came up earlier and there is currently no way to crop on download. All you can do to reduce download time is bin.

You can restrict the area used for measuring stars - and I do that to improve the measurement and avoid the edges.

I want to save time everywhere when I am not exposing an image - and autofocus takes a long time due to backlash unwinding and image download. So I agree that you should be able to use a cropped region of interest. There already is a setting to limit the region used for autofocus analysis - and I think it should also be used to crop the actual image download - to save time.

I am using an 8300 sensor and when using binx2 the focus time is mainly limited by backlash unwinding on an sct - but if I could crop the images, I would.

As for the question prior to yours - there is a mistaken impression that focusing an sct is equivalent to “focusing at f/10” - but that isn’t true when you focus with the primary. When you focus with the primary you are effectively moving an f/2 (very fast - much faster than a Newtonian) optic - and the rest of the imaging system simply magnifies the resulting view of focus. This is very different from using a crayford and moving a sensor back and forth in a stationary f/10 cone to focus.

So when I focus using the primary of an sct - I am doing something much more critical than focusing an f/4 Newtonian with a crayford. Yet this method of focusing an sct, with autofocus software and backlash compensation, does work well - and it simplifies the imaging train.

Frank

Slated for 2.5:

While this discussion is concentrating on the methodology of auto focus routines, let’s not lose sight of the need to tie the OTA temperature to every aspect of automated focusing. In “SCT” style OTA’s, the amplifying secondary requires temperature compensation to be taken into account when implementing focusing routines since the effect of the change in OTA length is also amplified by the secondary.

According to Roland Christen of Astro-Physics, short focus APO refractors with aluminum tubes have a nearly zero temperature coefficient since the APO lens changes focal length with temperature change almost identically with aluminum. This is why AP does not sell refractors with carbon fiber tubes.

My system may have good focus with the luminance filter with the focuser at position 22550 when the temperature of the OTA is 20.4 degrees Celsius but it will need to be at 23200 when the temperature drops to 19.4 degrees Celsius – a change of 650 steps.

So when designing the system to support preset focus positions, such as for changing filters, those recorded focuser positions must also have the matching OTA termperature recorded. This permits temperature compensation to be taken into account when actually moving the focuser to a new filter position.

cm

While I understand what you are saying, this does not seem to be entirely necessary if you record your focus positions within a reasonable period of time. Originally, SGPro had this functionality, but added a complexity we didn’t feel was entirely necessary. This is in the docs… if you are recording your filter offsets at random times over different nights, you are not going to be happy. Trying to walk the line between usable and powerful is sometimes a tricky problem.

1 Like

Ken:

I certainly understand the desire to keep features as simple as possible. However, with my setup the issue is that there is no such thing as “where does the Red filter focus” that does not include a corresponding temperature reading. The Optec Gemini focuser on my 12" Meade LX850 OTA has a temperature coefficient of 650 steps / degree C.

  1. At 10PM the temperature is 20 C and the Red filter focuses at position 22000.
  2. At 3AM the temperature is 15 C and the Red filter now focuses at position 25250.

I would prefer that SGP not do a full auto focus routine on a filter change – it takes too long. I am suggesting a method whereby SGP could “adjust” the focus position based on a temperature calculation. Since an initial focus calibration routine could span several minutes, you could have a temperature change during the session. So the filter table might look similar to:

Lum: 21850 @ 21.3 C
Red: 22000 @ 20.0 C
Grn: 22115 @ 19.9 C
Blu: 21930 @ 19.7 C

My goal would be to perform a full auto focus routine for each filter at the beginning of the evening and then rely on “focus adjustments” for the remainder of the night.

Charlie

With an sct I found no clear correlation with temperature that could be used to help focusing. I just want to focus periodically and do it well and as quickly as possible - so I agree with the SGP approach to do accurate focusing with many stars and without switching to a bright star for focus - in which case you don’t need to include temp. as a factor except perhaps as a guide to when you need to change focus.

The filter offsets should be constant with temperature - if not that is pretty strange. So you should be able to focus relatively quickly with L and then know the focus accurately for the other filters using their offsets - until the next time you need to refocus.

Frank

Charlie,

In a certain sense SGPro already allows for this. Set your filter offset positions within a reasonable time period… positions within a degree or two will likely not lead you out of the CFZ. Then run AF on you favorite filter (lum usually). In the sequence uncheck “use AF” option. Turn on temperature compensation. Filter changes will change the focuser pos by the delta of the current and new filter offsets and temperature compensation will help adjust them in real time.

We’re probably not looking to change the AF methodology anytime soon (with the exception of better algorithms for secondary obstructions).

Ken:

I would be very happy with just the new auto focus algorithms for SCT style scopes and rely on SGP’s temperature compensation routines for holding focus between auto focus steps.

Charlie

sorry, but this is optically non sens at all… your critical focus zone is for F/10 not F/2.

No - it is optically correct. The typical cfz calculations show a fixed setup and an image plane moving through it. That is not what is happening when you focus an sct by moving the primary. You are not moving the image plane - you are moving an f/2 optic - and resulting size of the star spot will change dramatically as you move it. Very slight movement of the primary will result in large changes of the star spot - just as when you focus with a fixed f/2 primary by moving the sensor.

It is optically correct to view it as I describe - because that is how it works. It is incorrect to view it as a crayford moving a sensor in and out of an f/10 cone - because that is not how it works.

The main point is - focusing an f/10 sct or f/2 hyperstar by moving the primary - does work well. They both rely on critical positioning of an f/2 optic with a fixed sensor - and they both work well with the multistar focusing of sgp - as long as backlash is handled properly.

Frank

You should already be able to do this:

  1. Turn on temp compensation in SGP or use the temperature compensation built into your focuser (it sounds like you currently are).
  2. Setup focus positions (which will be treated as offsets) in the filter setup.
  3. Turn on “Auto adjust focus per filter”
  4. Disable auto focus if you don’t want it, or set it to run AF between targets, or whatever.

Now focus your scope and run the sequence.

In between frames (or even during if it’s setup in your focuser) the temp compensation will keep you focused. When you change filters the focus position will be updated using the data setup in step 2, keeping you in focus.

I think this is what you’re looking for? The only “gotcha” is that backlash compensation may not be invoked if you need it (or it may, I can’t recall 100% here).

(Just realized this is the same that Ken recommended above…which should do exactly what you’re after)

Thanks,
Jared

Jared:

Thanks for these suggestions. I will give them a try on my next imaging run.

Charlie