Trigger Auto Focus on HFR Increase => BETA Docs

Hey folks,

We typically don’t formalize docs until just before release, but some things need a rough draft to go out alongside the beta. This applies to the SGPro 4.2 beta which, as of this writing, it not yet available, but early feedback is welcome. In all honesty, this process helps me to ensure that all of the use cases are well thought through. You are welcome to skip down to the actual “docs” part if you’re not interested in the sausage factory.

What is it?

A fairly popular request over the years has been to support an auto focus trigger based on the quality of light frames during the sequence. In other words, track your light frame HFR and when it increases by some amount trigger focus.


  • Trigger: A condition, that, if true, will cause auto focus to run prior to the next light frame
  • Focus Metric: Specific to SGPro, we we reference a Focus Metric, we are referring to 2 different values: HFR and the number of stars detected.
  • Focus Baseline: After any auto focus runs, the next captured frame will be used as the numbers to which all subsequence frames will be compared against.
  • AF: Auto Focus


There is complexity hidden in this request that has prevented us from implementing it in the past. Nothing we can’t overcome, but we felt (and still do to some degree) that other triggers provided negated the need for this trigger so we didn’t add it. Our users continually swear that existing triggers are not sufficient because they are not reliable enough for their rig. We don’t claim to know it all and if enough folks tell us something is true, we’ll certainly listen.

Here are the problems we are attempting to solve in order to release this feature:

  • A sequence can contain many different events and the metrics for an event may or may not be compatible with your last baseline. Without careful management of metrics we run the chance of comparing incompatible metrics against one another.
  • How do we handle Sequence Event and Sequence Target changes when using this trigger?
  • How do we calculate meaningful change in focus metrics when so little data is available to us?
  • The largest problem to solve is a little difficult to explain, but an example is probably best… The degree to which the following is true depends on gear, location and target. Say you are pointing at your favorite target and your focus is 100% perfect. The target currently has an altitude of 25 deg above the horizon. The lowest attainable HFR is currently 1.5. The next light frame is captured (after an AF run) and 1.5 HFR is used as the baseline and the trigger requires HFR to increase to 1.7 in order to start AF. **** Time goes on **** The target is now at an altitude of 40 deg and, without any movement of the focuser, your HFR is now 1.25 (because your previous focus was coincidentally perfect even beyond its ability to measure… aka “luck”) and because the higher altitude allow for more precision in focus. Comparing the trigger threshold (1.7) to the new HFR (1.25) you can see that we are now in a position where our focus would need to degrade significantly to trigger focus. It is true that the current focus won’t be worse than the “acceptable” value we had at 25 deg, but, in this case, we are failing to trigger when focus could be better. In this case, we have chosen to address this problem by having every frame, be a candidate for the baseline and not just the frame after the last focus run. At this moment, we are still unsure if there are any pitfalls with this method. The one we are most concerned with is the opposite of the scenario above where, high on the East side, an HFR of 1.25 is captured and used as the baseline. As the target gets lower, even perfect focus may start to show as a false degradation in focus. This is when temperature seems like a more attractive metric. There is no good way to address this issue directly, but one may want to consider minimizing its effect by supplementing it with another trigger like time or temperature.


Here is the new trigger…


Checking this box will cause the sequence to run auto focus when an average deviation from focus is higher than some percentage (that you define). In the example above we would focus when the average of the last 3 metrics increases by at least 15%. The calculation used for interpreting deviation is a simple average using the number of images specified for both HFR and number of stars. Both metrics must meet the deviation threshold to activate the trigger. The trigger will never activate until the sequence has the required number of frames to perform the calculation. In the example above, there is no possibility that the auto focus will trigger until just after the 3rd frame.

The checkbox located below this trigger that reads “Trigger focus when baseline is missing” defines a behavior of this trigger when moving from one Sequence Event to another. Consider 2 consecutive events where Auto Focus is run at the end of the first event and the current baseline metrics are specific to the first event. Upon starting the second event, there is currently no valid baseline to use for comparison (because the last baseline we captured is not compatible). If this box is checked, the lack of a baseline will automatically trigger focus (and produce a baseline after the first image in the second event). If the box is not checked, the new baseline will be collected only when a different trigger cause auto focus to run.

The current baseline for the current event is displayed in the Auto Focus module and in the Control Panel Focus Tab with text like 1.5 (654) where the first number is HFR and the second is number of stars.

Lastly, this isn’t specific to the new trigger, but it is related in that we now collect this information and, in some cases, it might be helpful to display it. Since events now have their own histories and individual baseline markers, you can now see them in event options.


The current event’s baseline can be reset (or invalidated) in the following situations:

  • When the sequence detects that a compatible event has produced a “better” metric. See “Background” above for more info here.
  • When the current baseline is older than 8 hours old (because it is likely from a different imaging session). This means that your event baseline markers will, in most cases persist through same session (starts, stops, pauses, aborts, etc).

Is there something that can be leveraged from PHD2? Changes in guiding performance would be great feedback in deciding if the increasing focus metrics are environmental or focus related.


If someone is imaging with a OSC camera then the issue of a filter change triggering an AF is not an issue but for monochrome cameras, it is likely every filter change will trigger an AF. I personally use filter offsets to avoid an AF on filter change. This is very useful when shooting filters in round robin mode.

In addition to altitude changes triggering an AF, there are things like a drop in seeing conditions triggering an AF, which won’t result in a better focus metric.

Perhaps the biggest challenge is how to avoid all the “false positives” that trigger an AF that does not result in any improvement but consumes valuable time. We need to also be careful that we aren’t pursuing “robotic” imaging rather than just automated imagining. Robotic imaging is a bottomless pit of options.

It can also be a challenge to ask software to make up for poor equipment. If someone is not using a high quality focuser with built-in temperature compensation, then acquiring one will be the best solution to maintaining good focus during an imaging run.