Why Focus Is Everything
If there is one thing that can ruin an otherwise perfect imaging session, it is poor focus. You can have the best mount tracking, the darkest skies, and hours of integration time, but if your stars are even slightly out of focus, your final image will look soft and unremarkable. Sharp focus is what separates a snapshot from a photograph.
The challenge is that focus does not stay put. As the temperature drops through the night, your telescope tube contracts and shifts the focal point. When you switch between filters, each one sits at a slightly different depth in the optical path. Even humidity changes can nudge your focuser position. On a typical night, you might need to refocus every 30 to 60 minutes, and certainly every time you change filters.
Doing this manually with a Bahtinov mask works, but it means walking to the telescope, swapping the mask in and out, checking the star pattern on screen, and adjusting the focuser by hand. It is slow, it interrupts your imaging, and in the middle of winter it means leaving a warm house. N.I.N.A.’s autofocus system handles all of this automatically.
What You Need
Before setting up autofocus in N.I.N.A., make sure you have the right hardware connected and configured:
- A motorized focuser with absolute positioning. This is usually an ASCOM-compatible focuser like the ZWO EAF, Pegasus FocusCube, PrimaluceLab SESTO SENSO, or a motorized focuser built into your telescope. It needs to report its exact position and move to precise positions on command. Manual focus knobs with a digital readout will not work.
- Backlash compensation set correctly. Most focusers have some mechanical slack or “play” in the gears. If you move the focuser outward by 100 steps and then inward by 100 steps, you may not end up back at the same position. This backlash must be compensated either in the ASCOM driver settings or in N.I.N.A.’s focuser settings. Without it, autofocus results will be inconsistent.
- A camera connected in N.I.N.A. Autofocus takes test exposures through your imaging camera, so it needs to be connected and configured with the correct gain and offset settings.
- Reasonably dark skies with stars visible. The autofocus routine needs stars in the field of view to measure focus quality. If you are imaging from a very light-polluted area, you may need longer autofocus exposure times.
How N.I.N.A. Autofocus Works
N.I.N.A. offers two methods for measuring focus quality: Star HFR (Half Flux Radius) and Contrast Detection. Each has its strengths.
Star HFR Method
This is the primary and most commonly used method. Here is what happens during a Star HFR autofocus run:
- Benchmark exposure. N.I.N.A. takes an exposure at your current focuser position and calculates the average Half Flux Radius of all detected stars. HFR is a measure of star size — smaller HFR means tighter, better-focused stars. This benchmark will be used later to verify that autofocus actually improved things.
- Move outward. The focuser moves outward (away from focus) by the Initial Offset Steps multiplied by the Step Size. This places the focuser well into the out-of-focus zone on one side of the V-curve.
- Sweep inward. N.I.N.A. moves the focuser inward one step at a time, taking an exposure and measuring HFR at each position. As it passes through best focus, the HFR drops to a minimum and then rises again on the other side. This creates the classic V-shaped focus curve.
- Curve fitting. Once enough data points are collected on both sides of the minimum, N.I.N.A. fits a mathematical curve (you can choose between trend lines, parabolic, or hyperbolic fitting) to find the exact focuser position of minimum HFR.
- Move to best focus. The focuser moves to the calculated best position.
- Verification. A final exposure is taken and its HFR is compared to the benchmark from step 1. If the new HFR is not at least 15% better than the starting value, the autofocus run is considered a failure and the focuser returns to its original position or retries.
The beauty of this method is its built-in error handling. Wind gusts, passing clouds, or a satellite trail might produce a bad data point, but the curve fitting algorithm weights each point by its measurement error. Points with large error bars have less influence on the final result.
Contrast Detection Method
This is a newer, experimental method that works more like the autofocus in your phone camera. Instead of detecting individual stars, it measures the overall contrast in the image. At best focus, fine details are sharpest and overall image contrast is highest.
The advantages are that it can work with very short exposures and does not need detectable stars. This makes it potentially useful for focusing on the Moon, planets, or even terrestrial objects. However, the contrast peak is narrower than the HFR valley, making it easier to miss entirely if your step size is too large. For most deep sky imagers, the Star HFR method is the better choice.
Key Settings Explained
The main autofocus settings are found under Options, Equipment, Focuser in N.I.N.A. Getting these right is the difference between reliable autofocus and constant frustration.
Auto Focus Step Size
This is the number of focuser steps the focuser moves between each measurement point. It is the single most important setting to get right.
If the step size is too small, the autofocus run will take forever and the HFR changes between steps may be lost in noise. If it is too large, you will not have enough data points near best focus to accurately determine the minimum. You want the V-curve to have roughly 8 to 12 data points total, with about 4 to 6 points on each side of the minimum.
How to find your ideal step size:
- Focus manually using a Bahtinov mask or by eye.
- Note the focuser position.
- Move the focuser outward until stars are noticeably defocused (they look like small doughnuts).
- Note the new focuser position.
- Divide the difference by about 5. That is your starting step size.
For example, if best focus is at focuser position 10,000 and noticeably out of focus at 10,500, the difference is 500 steps. Divided by 5 gives a step size of 100. Try 100 and adjust from there based on your V-curves.
Auto Focus Exposure Time
This is the exposure time used for each focus measurement image. It needs to be long enough to detect stars but short enough that the autofocus run does not waste too much imaging time.
For broadband imaging (no filter or LRGB), 1 to 3 seconds is usually sufficient. For narrowband filters (Ha, OIII, SII), you will need much longer exposures, typically 5 to 10 seconds, because these filters pass much less light.
If you have a filter wheel connected in N.I.N.A., you can set per-filter autofocus exposure times in the filter wheel settings. This is extremely useful if you switch between broadband and narrowband during a session.
Auto Focus Initial Offset Steps
This determines how far out of focus N.I.N.A. moves before starting its inward sweep. It is measured in units of your Auto Focus Step Size, not raw focuser steps. The default is usually around 5, meaning N.I.N.A. starts 5 steps away from your current position.
If autofocus frequently fails because it cannot find a clear minimum, try increasing this value to 8 or 10. If autofocus takes too long, try reducing it to 3 or 4.
Curve Fitting Method
N.I.N.A. lets you choose how it fits the focus curve:
- Trendlines — fits straight lines to each side of the V. Simple and robust but less precise.
- Parabolic — fits a parabola to the data points. Good balance of accuracy and noise resistance.
- Hyperbolic — fits a hyperbola, which is the theoretical shape of a real focus curve. Can be more accurate but may be sensitive to noisy data.
For most setups, parabolic fitting is a great starting point. If you get consistently good V-curves with clean data, try hyperbolic for potentially more precise results.
Tips for Reliable Autofocus
Use Overshoot
Most focusers have some backlash in their gears. When N.I.N.A. reverses the focuser direction during its sweep, the first few steps might not actually move the focuser because the gear slack is being taken up. This can produce flat or misleading data points at the turn-around point.
The solution is to always approach best focus from the same direction. N.I.N.A. can be configured to overshoot the target position and then approach from one side. In practice, this means the final move is always inward (or always outward), eliminating backlash from the critical measurement.
Focus Before You Start
N.I.N.A.’s autofocus works best when you start reasonably close to focus. If you are way off, the stars will be large doughnuts that are hard to measure accurately. Before starting your imaging sequence, do a rough manual focus or use a Bahtinov mask to get close. Then let autofocus refine from there.
Focus on Bright Nights
Autofocus needs stars to detect. If you are imaging a sparse field with few stars, or if transparency is poor, the routine may struggle. N.I.N.A. lets you set a minimum number of stars required for a valid autofocus measurement. If you frequently image sparse fields, consider lowering this threshold, but be aware that fewer stars means noisier HFR measurements.
Temperature Compensation
Some ASCOM focusers support temperature sensing. N.I.N.A. can use this to automatically adjust focus position as the temperature changes throughout the night, reducing the frequency of full autofocus runs. Check your focuser’s documentation to see if it has a temperature sensor and enable this feature if available.
Filter Offsets
If you use a filter wheel, each filter may sit at a slightly different depth in the optical path, shifting focus by a small amount. N.I.N.A. lets you define per-filter focus offsets. Once you determine the offset for each filter (by focusing with one filter, then measuring the focus shift when you switch to another), you can enter these values and N.I.N.A. will automatically adjust the focuser when changing filters. This is much faster than running a full autofocus after every filter change.
Adding Autofocus to Your Sequencer
Once your autofocus settings are dialed in, you can add autofocus steps to your N.I.N.A. sequencer. Here are the common patterns:
- Start of sequence autofocus. Add an Autofocus instruction at the very beginning of your sequence to ensure you start sharp.
- After filter change. If you do not have filter offsets configured, add an Autofocus instruction after any filter change instruction.
- Periodic refocus. Use the “Autofocus after elapsed time” condition or add a timed loop that includes periodic autofocus every 30 to 60 minutes to compensate for temperature drift.
- Smart refocus. N.I.N.A. can trigger autofocus when the temperature changes by more than a set amount, rather than on a fixed timer. This is more efficient because you only refocus when you actually need to.
Real-World Example
Let me walk through a typical autofocus setup using the equipment I use for my own imaging. My primary rig uses an Orion 8-inch f/4.9 Newtonian with a Gemini focuser, Canon T3i camera, and an Orion Atlas EQ-G mount.
After manually focusing with a Bahtinov mask, my focuser reads around position 5,200. I move outward until stars are noticeably doughnut-shaped, which happens at around position 5,700. The difference is 500 steps. Dividing by 5 gives me a step size of 100.
My settings look like this:
- Auto Focus Step Size: 100
- Auto Focus Exposure Time: 2 seconds (no filter) or 8 seconds (with narrowband)
- Initial Offset Steps: 5
- Curve Fitting: Parabolic
With these settings, an autofocus run takes about 60 to 90 seconds and consistently nails focus. Here is a globular cluster, M53, captured with this setup — tight, round stars across the entire frame, thanks to reliable autofocus keeping things sharp throughout the session:
M53 globular cluster in Coma Berenices. 44 x 180 second exposures captured in N.I.N.A. 3 and stacked in Siril 1.4. Sharp focus across thousands of stars is what autofocus delivers.
Troubleshooting Common Issues
Autofocus fails every time
Check these things first:
- Is your step size correct? Too large or too small will both cause failures.
- Is your exposure time long enough to detect stars?
- Is backlash compensation set up in your focuser driver?
- Are you starting too far from focus? Get close manually first.
V-curve looks messy with scattered points
This usually means one of the following:
- Your mount tracking is poor, causing star trailing during focus exposures. Improve your guiding or shorten the focus exposure time.
- Wind is shaking the telescope during exposures. Try focusing between gusts or add a wind delay condition.
- Your focuser has excessive backlash or mechanical slop. Tighten the focuser mechanism or enable backlash compensation.
Autofocus succeeds but images are still soft
If the autofocus routine reports success but your images are not sharp:
- Check that your focuser is not slipping under the weight of the camera. Tighten any set screws or locking mechanisms.
- Verify that your mirror is not shifting (common with SCT telescopes). Lock the mirror if possible.
- Make sure your autofocus region of interest is not picking up hot pixels instead of real stars. Enable star filtering in the autofocus settings.
The Bottom Line
Autofocus is one of those features that, once you set it up and get it working reliably, you will wonder how you ever imaged without it. It frees you from manual focus checks, maintains sharp images through temperature changes and filter swaps, and lets you sleep through the night while your rig takes care of itself.
Take the time to dial in your settings on a clear night. Start with the Star HFR method, find your ideal step size and exposure time, and verify the results by checking your star shapes in a few test frames. Once it is working, add it to your sequencer and enjoy consistently sharp images session after session.
Happy imaging, and may your stars always be tight.
Have questions about autofocus or your N.I.N.A. setup? Check out the other tutorials in the blog or browse the image gallery to see what is possible with automated imaging.
