Guiding: PHD2 attempts to use the same guide star after a slew
Posted: Thu Sep 12, 2024 3:41 am
I have noticed some odd guide star selection problems in SharpCap when guiding with PHD2. The more I have automated image capture using sequences, the more noticeable the problems have become.
My scope is an 11" Celestron with an off axis guider. I always run the scope at F10, so the guide field is pretty small. Here is the sequence code that I usually use to start guiding, including error handling when guiding fails to start the fist time. Not sure why this occasionally happens, but a retry seems to do the trick unless something has really gone wrong (hardware connections, etc). Note that it doesn't try to launch PHD2 unless the initial guiding connect fails, which almost always means PHD2 is not running yet. It seems that the GUIDING CONNECT operation will cause PHD2 to connect to the last hardware it used (camera and mount), which is convenient.
# if it connect fails, it tries a second time after launching PHD2
# if PHD2 is already running this will result in an error dialog from PHD2,
# but at least we gave it a shot
DEF SUB RetryConnectAfterStartingPHD2
RUN "C:\Program Files (x86)\PHDGuiding2\phd2.exe" WITH PARAMS "" WAIT False
COUNTDOWN FOR 5 SHOWING "Waiting for PHD2 to connect to mount and camera..."
RETRY ERRORS UP TO 4 TIMES
GUIDING CONNECT ABORT False
END RETRY ERRORS
END SUB
DEF SUB GuidingConnectandStart
IGNORE ERRORS FROM ONERROR RUN RetryConnectAfterStartingPHD2
GUIDING CONNECT ABORT False
END IGNORE ERRORS
GOSUB GuidingStart
END SUB
# Start guiding:
# This will get automatically PHD2 to also automatically connect to the mount and guide camera
# if they aren't already.
DEF SUB GuidingStart
SET PLATESOLVE/FOCUS SETTINGS EXPOSURE 6
SHOW NOTIFICATION "Waiting for guiding to be active..." COLOUR Amber DURATION 30
IGNORE ERRORS FROM ONERROR RUN \"GuidingStartFailure\"
GUIDING START
GUIDING WAIT
SHOW NOTIFICATION "Waiting for guiding to be active...guiding is now active with no errors" COLOUR Green DURATION 30
END IGNORE ERRORS
WAIT FOR FRAME
END SET
END SUB
#begin guiding:
GOSUB GuidingConnectandStart
Note that the GuidingStartFailure subroutine called if guiding doesn't start is omitted here as it rarely gets called. Its only activated if I am unlucky enough that the guiding field is in a star desert where there are no stars bright enough for guiding.
Now all this works reliably for the first target of the night. After I do a meridian flip in my automation or go to another completely new target and my sequence automation starts guiding gaain, I would expect PHD2 to pick a new guide star with a high SNR. Instead, I see that PHD2 will do one of two things:
1) Report star lost and it selects a new guide star with a good SNR.
2) Selects a guide star in the guide field close to where the previous imaging target's guide star was located in the previous guide field. If this star has an SNR below the minimum I have set in PHD2, it selects it anyway. I have to intervene and manually select a new star when this occurs due to PHD2 frequently losing its chosen dim star when it attempts to guide on it. This makes automation not so automated, so I can't nap through a meridian flip.
BOTTOM LINE:
My interpretation of these observed behaviors is that after a slew, the previous guide star is not cleared in PHD2. It looks like the PHD2 server API does have support for forcing PHD2 to deselect the current guide star. I don't know if this PHD2 function is not reliable, or if SharpCap is not using it. It seems that if SharpCap detects a new target, or the same target, but finds that the scope is now pointing at it from the opposite side of the pier, it should tell PHD2 to clear the previous guide star.
I understand that deciding when there is a "new target" and PHD2 needs to select a new guide star may be a bit challenging to implement. The whole point of using the PHD Server is to allow SharpCap to be agnostic about how guiding is performed. SharpCap has no idea how big a slew will result in a new guide field. I guess PHD2 itself is in a similar predicament as to when the target has changed. However, unlike SharpCap, it knows how big the guide field is, so it should know when there is a whole new guide field, or a meridian flip has occurred, and thus the previous guide star is gone for good.
If it is difficult for SharpCap to detect when the old guide star should be deselected, maybe you could add a sequencer command that sends the "Clear guide star" command to the guiding application.
An extra note: PHD2 docs says "Stop Guiding when mount slews" should always be checked, but it was unchecked in my PHD2 config for some reason. I thought this might be causing the problems I was observing, so I turned it on. Unfortunately, this didn't seem to help at all.
My scope is an 11" Celestron with an off axis guider. I always run the scope at F10, so the guide field is pretty small. Here is the sequence code that I usually use to start guiding, including error handling when guiding fails to start the fist time. Not sure why this occasionally happens, but a retry seems to do the trick unless something has really gone wrong (hardware connections, etc). Note that it doesn't try to launch PHD2 unless the initial guiding connect fails, which almost always means PHD2 is not running yet. It seems that the GUIDING CONNECT operation will cause PHD2 to connect to the last hardware it used (camera and mount), which is convenient.
# if it connect fails, it tries a second time after launching PHD2
# if PHD2 is already running this will result in an error dialog from PHD2,
# but at least we gave it a shot
DEF SUB RetryConnectAfterStartingPHD2
RUN "C:\Program Files (x86)\PHDGuiding2\phd2.exe" WITH PARAMS "" WAIT False
COUNTDOWN FOR 5 SHOWING "Waiting for PHD2 to connect to mount and camera..."
RETRY ERRORS UP TO 4 TIMES
GUIDING CONNECT ABORT False
END RETRY ERRORS
END SUB
DEF SUB GuidingConnectandStart
IGNORE ERRORS FROM ONERROR RUN RetryConnectAfterStartingPHD2
GUIDING CONNECT ABORT False
END IGNORE ERRORS
GOSUB GuidingStart
END SUB
# Start guiding:
# This will get automatically PHD2 to also automatically connect to the mount and guide camera
# if they aren't already.
DEF SUB GuidingStart
SET PLATESOLVE/FOCUS SETTINGS EXPOSURE 6
SHOW NOTIFICATION "Waiting for guiding to be active..." COLOUR Amber DURATION 30
IGNORE ERRORS FROM ONERROR RUN \"GuidingStartFailure\"
GUIDING START
GUIDING WAIT
SHOW NOTIFICATION "Waiting for guiding to be active...guiding is now active with no errors" COLOUR Green DURATION 30
END IGNORE ERRORS
WAIT FOR FRAME
END SET
END SUB
#begin guiding:
GOSUB GuidingConnectandStart
Note that the GuidingStartFailure subroutine called if guiding doesn't start is omitted here as it rarely gets called. Its only activated if I am unlucky enough that the guiding field is in a star desert where there are no stars bright enough for guiding.
Now all this works reliably for the first target of the night. After I do a meridian flip in my automation or go to another completely new target and my sequence automation starts guiding gaain, I would expect PHD2 to pick a new guide star with a high SNR. Instead, I see that PHD2 will do one of two things:
1) Report star lost and it selects a new guide star with a good SNR.
2) Selects a guide star in the guide field close to where the previous imaging target's guide star was located in the previous guide field. If this star has an SNR below the minimum I have set in PHD2, it selects it anyway. I have to intervene and manually select a new star when this occurs due to PHD2 frequently losing its chosen dim star when it attempts to guide on it. This makes automation not so automated, so I can't nap through a meridian flip.
BOTTOM LINE:
My interpretation of these observed behaviors is that after a slew, the previous guide star is not cleared in PHD2. It looks like the PHD2 server API does have support for forcing PHD2 to deselect the current guide star. I don't know if this PHD2 function is not reliable, or if SharpCap is not using it. It seems that if SharpCap detects a new target, or the same target, but finds that the scope is now pointing at it from the opposite side of the pier, it should tell PHD2 to clear the previous guide star.
I understand that deciding when there is a "new target" and PHD2 needs to select a new guide star may be a bit challenging to implement. The whole point of using the PHD Server is to allow SharpCap to be agnostic about how guiding is performed. SharpCap has no idea how big a slew will result in a new guide field. I guess PHD2 itself is in a similar predicament as to when the target has changed. However, unlike SharpCap, it knows how big the guide field is, so it should know when there is a whole new guide field, or a meridian flip has occurred, and thus the previous guide star is gone for good.
If it is difficult for SharpCap to detect when the old guide star should be deselected, maybe you could add a sequencer command that sends the "Clear guide star" command to the guiding application.
An extra note: PHD2 docs says "Stop Guiding when mount slews" should always be checked, but it was unchecked in my PHD2 config for some reason. I thought this might be causing the problems I was observing, so I turned it on. Unfortunately, this didn't seem to help at all.