Filter Offsets not being applied correctly - V295

sg_logfile_20191013143124.zip (690.3 KB)
sg_logfile_20191013143630.zip (720.1 KB)
Ken, I can post all the focus run images if you need them.

Here are the log files from my AG12 and TV127 from last night using version 295 to test the new quadratic focus routine. There are 160 focus runs in each log file. My three targets for the night each contained the following sequence of events, with auto-focus running for each frame, the frames exposing for only 10 seconds, thus 160 focus runs on each scope. Basically just focusing all night long.
The events run in this order, repeating until end time for target:
L R G B L Ha Sii Oiii

The quadratic focus routine itself ran perfectly. I watched both SGP programs for about 3 hours.

However, there is a very serious failure to move the focuser to the correct new position.

Since I was doing continuous focusing, I turned off temperature compensation of both scopes, wanting to make the night’s runs as simple as possible to analyze.
Both scopes have backlash compensation set to IN 150.
My filter offsets of both scopes are very good, refined over the past 2 years.

Here is the correct sequence of operations when a focus run starts with a new filter, and temperature compensation is turned off: (this is logically what is required, but SGP appropriately combines these operations to minimize movement)

  1. change filter to new requested filter
  2. move focuser in or out to correct for the filter offset delta between the old and the new filter.
  3. take requested number of images to build focus curve
  4. run quadratic fit routine to determine best focus
  5. if quality of run not acceptable, move to new starting position and start over, or quit
  6. move focuser to this best focus position
  7. take image

All focus movements in the above sequence must apply the 150 step backlash for all outward moves.

Here is what happened:

  1. the quadratic focus routine worked perfectly to determine best focus, based on the focus data points
  2. in about 75% of the focus runs, the above sequence was followed perfectly
  3. in the other 25%, after coming up with a good best focus position for a nice centered curve, step two did not work as required, usually moving the focus position to a position that was about 2 or three intervals off. Step 3 then had a very off centered run, giving either a straight line, or only one or two data points above the low point on the low side, thus forcing a rerun.
  4. the final focus position after these reruns was often not correct resulting in the target image being badly out of focus. Here is an example:
    Limages

Unfortunately, I have been unable to determine what set of circumstances is triggering this failure. Filter deltas both + and - both work or not work. Cycling past the first event is not a trigger. The best I can figure for what is causing this is perhaps an uninitialized variable or some random overwriting of a variable this routine depends on. Perhaps the routine does not like performing a focus run on every frame and with a new filter on every frame.

@jmacon

Looks like there is a condition where the end of AF fails to run after the last sample point is analyzed… That seems to jive with being 2 or 3 steps off.

[10/14/19 05:51:45.094][DEBUG] [Camera Thread] Auto focus failed! Index was outside the bounds of the array.

Do you know what array is involved?

Not at the moment… exception logging in that area was weak… we fixed that part. Maybe it’s with one of the sections that “shuffles” array elements? Like…

thing1[i] = thing1[i+1]

Not really sure

I have seen this message too and can confirm focus being off 2-3 steps

I made some very minor changes… will put out another beta that at least has better logging around this event

If you would like to send me your code that calls my routine I will be happy to look it over. I can probably spot the issue fairly quickly.

It looks to me like you have commented out my code that ignores all data points on the long side of an asymmetric curve that are higher than the first higher data point.

All my curves that have only 2 data points higher than the lowest data point are not getting values that my routine would assign. They are much worse values and are contributing to some bogus reruns.

The latest 307 release appears to have solved all the reported issues with the new focus routine and quadratic best fit code. Ken and Jarod fixed a bug in my quadratic routine that was causing some of the runs to not finish correctly.
Already this evening with version 307 I have over 20 focus runs on both scopes. All running perfectly. Looks really great.
Well done Ken and Jarod.

This version does not reflect the conversation we had last night… we will release this soon.

Again, thanks to you guys for all your hard work here…

Focus ran perfectly for the entire night on both scopes. I got 142 runs on the AG12 and 158 runs on the TV127.

One small bug showed up:
End time for the last target on the TV127 was at 6:10am. An autofocus was started just prior to that, and continued for about 10 minutes with several retries because the dome had been shut, the mount parked, and all the power to all devices turned off. The power and dome are controlled independently by my custom dome control software.
It needs code to prevent an auto focus run within X minutes of the end time of the final target. Perhaps X=10?