My astronomy project:
7: Find best focus point, polynomial fit
Maybe you have already read about my new Excel sheet, it's a calculation to find the best focus position by a second degree polynomial fit. With that you can find where the focus point is even if your test focus point are outside the perfect focus point. It's not very complicated, it just find where the derivate of the polynomial is equal to zero.
I did a test under real condition, a night when the sky was partly clouded and not useful for photographing. But good enough to do this test. I use the APT software to control my camera, and APT can also over ASCOM control my focus unit. You don't need this software exactly, just a software that control the motor and give you the position and some value over the FWHM, HFD or just some value that tell you how good the focus is.
In a gearbox there is almost always some backlash, to get rid of this problem you shall only run the focus motor in one direction. You start with one position a couple of hundred steps outside where you believe you have your optimal focus position. If you have temperature compensation of the focus position, disable it now.
You need about 15 to 20 different focus test points. In my case I have them 100 steps apart, it doesn't matter if you have different length of step numbers, the calculation take care of that. Later if you need better precision you can decrease the step number. In my case I started the motor in the outward position and drove it inwards. If you are still are to close to the best focus point on the other side you can ad more points until you are well outside the best focus point.
Here how it looked after my test, I have inserted new rows between the first and last row (I shall clean up the text in the Excel sheet later):
The green line is the best fit polynomial and at the bottom point you have the derivate equal to zero, set Y' to zero and solve for x, that's where the best focus point shall be. Even if you have high noise level it should not disturb much if you have enough number of test points. It had of course been better with some extra focus test point to the left, but clouds came in and destroyed my evening.
If the outdoor temperature have changed much then there could be a problem. The telescope shall be at it's equilibrium temperature before you start doing this, at least one hour outdoors.
Here I have used the HFD numbers as the quality of the focus at different points. FWHM are more sensitive to stars that are oversaturated and then give bad quality numbers. That can easily happens when the focus is at its best. Of course you should try to avoid that strong stars in the first case.
The best focus point is calculated to be at position 14557, drive the focus motor to at least 500 steps to the other side of that position, the side where you started, even more if your backlash is big. In your case it will of course be other numbers. Then move back to where the calculated best focus point is. If needed you can narrow in the test range and do a new run with smaller steps. My focus motor moves the focus by 1.7 my per step.