A test protocol to get the best NINA autofocus routine your motorized focuser can handle

N.I.N.A. Users 5 replies46 views
Frédéric Ruciak avatar

Hi,

I went a long path down to achieve the best focus I can get from my setups with various rack and pinion focusers equiped with lacerta MFOC or Primaluce Sestosenso electronic step motors in combination with NINA autofocus. As I found that there was a lot of beliefs that were not consistent with real numbers I thought it was worth to share what I found to be true and the way I take into account the various parameters (namely backlash in, BLI, backlash out BLO, step in and step out) to get the best reproductible autofocus routine in NINA down to less than a few microns (and most of the time around 1) from start position to last position assuming that start position was at the best focus point.

This post is a long one to share good explanations, I hope. There is a little spreadsheet attached that is described in the post. It helps to run the measurement phase and compute the right value and to check the consistency of the result with NINA and tune if eventually.

Looking for best focus position is worth the effort as the critical focus zone can be very tiny (see https://www.innovationsforesight.com/how-much-focus-error-is-too-much/) especially for fast scope ≤F4.

What I was looking for was a NINA autofocus sequence with physical positions of the focuser consistent with the step position reported by NINA during an autofocus sequence starting from the initial “near to focus position” and finishing to the optimized focus position close to the start position.

My problem started when I recognized that all the focusers I had on my scopes in tandem with either Lacerta MFOC or Sesto senso from Primaluce were not mechanically perfect, with the step inward (displacement when moving in resp. out) not exactly identical to step outward, and BLI different from BLO. If you are sure (with data) that you have a perfect focuser stop reading ;-).

One often read that the best way to tune Autofocus in NINA is to use “overshoot mode” with a large number of steps and forget it. Yes, this is simple and it works but if and only if BLI=BLO and step in = step out. Otherwise there is a drift taking place that can give you less than optimal autofocus final position. With my 3 tested setups this equality assumption is wrong and using overshoot mode led to focusing error that is getting close to the CFZ and I can avoid it so why not?.

In absolute backlash compensention mode you need to tune BLin and BLout to avoid that the NINA autofocus sequence finishes with the focuser moving to a step position, computed by the fitting curve that is 10, 15 microns away from the same step position when the measure was taken at that exact position. This is deterministic and is based on the difference between BLI and BLO (and also step in to step out, we’ll speak about it later).

When you put the numbers in a spreadsheet and mimik the way NINA is working you can demonstrate it easily and measure it. By the way in absolute mode NINA is keeping track of an offset (see AbsoluteBacklashCompensationDecorator.cs in the NINA repository on Githup, it is simple and easy to understand without being a developer that I am not ;-))

To get the best that you can following my path, you need a dial indicator, preferably to the micron, at least to the 100th of millimiter or 10 micron precision.

You need to fix the dial indicator to a fixed part of your setup and to have the tip of the needle of the indicator leaning on a moving part of the imaging train while the needle stays parallel to the optical axis of the focuser ie the indicator will show in microns or 10 microns how much the focuser moved after each “move to” order. Check that the moving needle of the dial indicator will never touch anything else or be jammed in its travel.

You start at the last best focus position you were at (better because the mechanical behaviour is not always the same regarding the position of the focuser).

Then you run two series of measurements and fill the little spreadsheet attached.

The first run of measurement will give you stepin, stepout, Blin and Blout. You either use the app of your focuser without any backlash settings or NINA but you need to have no backlash parameters configured otherwise it doesn’t work. You start from the start position (= last best focus position) with the backlash out cleared and you move outwards by a large amount, once or twice. You then reverse to move in and you move in a second time then you reverse by a larger amount and so on. You use a large amount to get a precise measurement even more if you use a dial indicator with 10 microns precision. You need a move of ~300 microns to get an error of ½ a graduation 5/300=1.7%, if you go for 600 microns you get a 0.8% error. When you reverse, it is more precise to estimate the backlash with a large move too with a little formula (in the spreadsheet) rather than moving step by step waiting for the indicator to move. Each time you move you capture in the spreadsheet the position in steps and the position in microns (pay attention to start from a medium position to avoid your dial indicator reaching the end). The spreadsheep computes and averages the 4 parameters. You will notice that it is not exactly the same each time because perfect mechanics is extremely expensive and I cannot afford thousands plus euros in a focuser ;-).

Now that you have BLin and Blout, and Stepin and Stepout. If BLin=Blout you just use overshoot mode with a value a little bit larger. If not or if you prefer to check for real during an autofocus, you choose absolute mode and you put the average of your measurement for Blin and Blout in NINA. And you start the last measurement sequence. You start from the best focus position having cleared the backash out (coming from a previous inner position). You move out the number of measurement points x the value of autofocus steps (5×40 for me), you measure the position, you then move in repeatedly 10 times (for me) x 40 steps and you measure the position at each autofocus steps with the dial indicator and then you come back to the original position in steps and you measure again.

As you populate the spreadsheet, you will see if the dial indicator is giving you symetric measurements around the best focus position, or not, and what is the delta. You can also easily check if BLin ou BLout have to be adjusted: if you detect that the step just after reversal is too large (backlash overshoot => should be decreased) or too low (backlash undershoot => should be increase). If you’ve done a good job during the measurement sequence, an ajdustment of 1 or 2 steps in the BL parameters is most probably sufficient to optimize the behavior down to 1 micron (in my case). If your dial show only 10 microns graduation you will have to estimate at least a quarter of a graduation but the MOST important is that you come back to the same position (you can take a picture) when you pass again at the starting position during the inward travel and when you come back to the starting position at the end of the autofocus sequence. If you have this behaviour you easily understand that whenever NINA computes an optimized best focus position il will move the focuser to the right place and not a shifted one.

We haven’t spoken yet of stepin and stepout. Overshoot and absolute backlash compensation are standard features of NINA and everything above can be done with the standard version. Clearly if stepin is too different from stepout (as it is the case for one of my setup), moving inward 10×50 steps will trigger a shift in physical position not seen by NINA that was too large according to my expectations and the CFZ. To take this into account I modified the AbsoluteBacklashCompensationDecorator.cs as it is the decorator keeping track during a NINA session of the offset between what shows NINA and the real step count of the focuser. I have a clone version of NINA on my computer, changed the decorator and rebuild a version of NINA that includes the ratio of stepin/stepout effect in the decorator. It works especially well on cumulative moves as one cannot move a focuser by decimal steps so it works well on autofocus sequence for my setup having a significant difference between stepin and stepout. I know that a lot of people do not like to use a non official version and you need to play a little bit to be able to build on your computer this specific version of NINA tuned to your setup. If there are some people interested I can easily explain what I did and share the decorator (mainly following step by step what is described on the github repository of NINA to build a clone).

Sorry for the long post but I prefer to give real step by step sequence to make it efficient if you are interested.

At the end in my case I have now consistent autofocus sequences with a measured precision down to the micron. If I change the imaging train and the best focus position changes I most probably will check again but once you have done it it is a matter of ½ hour during day time to check so it’s transparent regading imaging session.

I hope it can help some of you willing to get the best of their setup.

CS Frédéric

NINA Autofocus optimization.xlsx

Helpful Engaging
Rick Krejci avatar

I guess I don’t undetstand how you determined that Backlash In and Out need to be the same for overshoot assuming the overshoot value is only set in one direction (the other zero) and are much larger than either in or out backlash.

As long as there is no slipping in the system, the purpose of overshoot is to always approach the focus from a single direction. And of your overshoot is, say, more than 4x of either backlash, the focuser will always be at the same focal distance for a given focuser index number. If it’s not, you are slipping somewhere and no backlash settings can fix that.

I do agree that backlash is a complex subject since some focusers shift the image and some have zones of backlash that are non-linear such that, even if the focuser started to move after backlash is “taken up”, it may start out slightly slower until truly all backlash is removed and gets into the 1 EAF index = 1 linear physical distance zone. This may be double or triple of the traditional “when it starts to move” way of determining backlash depending on the focuser

That’s why I set overshoot really high and always have it end on the focusing towards the scope direction (working against gravity)

Now if you use traditional backlash compensation, I agree BLIn must = BLOut, but overshoot (again set in only one direction) it does not. Just set it to 4-5x what you’d normally measure as backlash (starting to move index count after switching direction) and forget it.

Helpful
Alex Nicholas avatar

Rick Krejci · Apr 23, 2026, 11:53 PM

That’s why I set overshoot really high and always have it end on the focusing towards the scope direction (working against gravity)

Yep… My step sizes for my f/2.8 newtonian is 40, the actual backlash is about 35~36 steps, I overshoot by 160 steps… AF gets me HFR’s of ~1.59 for SII and Ha, ~1.64 for OIII and 1.67 for L R G B respectively - every time… I then used the Filter Offset calculator plugin to measure the offset between each filter (relative mode, using L as the baseline) and I run my sequences shooting 3xL 1xR 1xG 1xB then dither on a loop, autofocusing the system once every 5°C of temperature shift or a 10% increase in HFR (consistent after 10 subs), and this results in sharp images…

You can absolutely prematurely optimise, over-optimise and over-engineer these things as the level of detail you can delve into is extreme - in most cases, it simply isn’t necessary to do so.

Helpful Engaging
Frédéric Ruciak avatar

This is a very interesting subject :-) and it’s true that it is optimization. The question is is this optimization worth it or not? The paper I shared from a PHD in optics (not me ;-) ) is stating that the CFZ to get no more than the effect of lambda/10 effect on the focus for a F3 telescope is 4 microns. If your focuser step is around 1.5 microns, a 4 steps shift between what Nina reports and the physical position of the focuser is above the CFZ. You might still get good results but not as good as if your were within the interval.

Now let’s look at what is happening with overshoot mode always finishing inwards. You just put a number larger than the backlashin and backlashout, suppose you put 40 steps with your BLin=35 and Blout=30. Each time you move out, NINA adds 40 steps out and then moves in by 40 steps. The first move to reach the position “start+delta” out gives a physical position of start+delta+40-30 (as the focuser stays at the same position during the backlash out) and then the second move in with overshoot finishes at start+delat+40-30-(40-35) as the focuser stays still during 35 steps for BLin. At the end the final position is start+delta+40-30-(40-35)=start+delta+5 steps compared to what NINA is reporting start+delta. Now put this in an autofocus sequence with the assumption that the physical start position was the best focus and look at the physical position of start, supposed to be the best one. When NINA moves back the focuser to what is computed as the optimized focus position (let’s assume it is again the same physical position) it is shifted by 5 steps inwards as seen from nina, due to the first overshoot. The computation compensates the first shift but the second overshoot ends with a shift of 5 steps. The remaining shift is independent of the value of the overshoot itself. It is the difference between Blind and Blout. This is demonstrated in a small spreadsheet attached. The only way to end with no shift is to have BLin=Blout or to use absolute backlash compensation. If you have blin=blout, fantastic you end with no shift, but if your system is showing a difference in backlash larger than the CFZ at lambda/10, you end at a focus position that is out of the CFZ.

It is factual, one can argue that it is useless and it is useless if you have Fratio of 5 and more or if you have a very good mechanical system either by chance or because of the money you spend on it and that ‘s good. On the other hand it is simple to optimize your system if you want to spend some times during the day to do it :-)

CS Frédéric

overshoot mode simulation.xlsx

Respectful
Rick Krejci avatar

If your physical focus position changes every time you go out and then in, then you have a slippage somewhere. Your ideal focus position will change over time. I’ve never experienced that with a variety of eafs, particularly with rack and pinion focusers. If you’re slipping, then I wouldn’t imagine that would be a constant over time and temperature and pointing attitude so would be virtually impossible to accurately compensate. I would find the source of slippage and address that or you’ll be chasing a ghost

Helpful
Frédéric Ruciak avatar

hi Rick, my system is not slipping. It has a difference between Backlash in and backlash out. This difference is inducing a shift when you run an autofocus sequence with overshoot. If you look at the spreadsheet describing what NINA does in overshoot mode it is a very simple arithmetic consequence of this difference. Overshoot ignores what Blint and Blout are but they are still there. I spent a long time playing with the system and measuring with a dial indicator. In absolute backlash mode once tuned as I describe I have no more difference over several autofocus runs, my system is not slipping. Math simply demonstrates that overshoot is not the solution if you have a difference between BLin and BLout: you end the sequence with a difference between the position where NINA sends the focuser and where the focuser is physically.

CS Frédéric

Helpful Concise