Scripting PHD2

863 views
Skip to first unread message

Igor Bednarek

unread,
Jul 10, 2018, 5:22:41 AM7/10/18
to Open PHD Guiding
Hello,

I am writing some scripts to pilot my telescopes and cameras and I wonder how to execute VBscript instructions to invoke PHD2 properties or methods ? As I did for MaximDl, PinPoint,...

Is there any documentation to learn that ?

Thanks

Igor

Ken Self

unread,
Jul 10, 2018, 7:06:06 AM7/10/18
to Open PHD Guiding
This is probably what you want: https://github.com/OpenPHDGuiding/phd2/wiki/EventMonitoring
Server methods are down near the bottom. 
You need to enable the PHD2 server then open a socket on port 4400

Igor Bednarek

unread,
Jul 10, 2018, 7:35:22 AM7/10/18
to Open PHD Guiding
Thanks Ken.

I just had a quick look but I do not really understand why it is so complex (TCP ? socket ? port 4400 ?) in comparison with other programs such as PinPoint or FocusMax that you can so easily pilot via scripting.

Should I use that or PHD2control that I found elsewhere in the forum ?

Regards

Igor

Igor Bednarek

unread,
Jul 10, 2018, 9:09:11 AM7/10/18
to Open PHD Guiding
To precise my requirements, what I need to do with PHD2 within a VBScript launched from the Autosave sequence of MaximDL is the following (PHD2 is already previously launched manually and guiding) :

     StopGuiding PHD2
     [already developped in my VBscript : Slew to a Focusing Star, Autofocus, PinPoint Solve, Sync, GoBack to the Object]
     AutoSelecting a Guiding Star with PHD2
     ReStartGuiding PHD2

What I do not know how to do in my existing script is StopGuiding PHD2, AutoSelecting a Guiding Star with PHD2, ReStartGuiding PHD2

I hope that this is more clear.

Thanks for your help

Regards
      

Andy Galasso

unread,
Jul 10, 2018, 1:41:55 PM7/10/18
to Open PHD Guiding
On Tue, Jul 10, 2018 at 9:09 AM, Igor Bednarek <igor.b...@gmail.com> wrote:
To precise my requirements, what I need to do with PHD2 within a VBScript launched from the Autosave sequence of MaximDL is the following (PHD2 is already previously launched manually and guiding) :

     StopGuiding PHD2
     [already developped in my VBscript : Slew to a Focusing Star, Autofocus, PinPoint Solve, Sync, GoBack to the Object]
     AutoSelecting a Guiding Star with PHD2
     ReStartGuiding PHD2

What I do not know how to do in my existing script is StopGuiding PHD2, AutoSelecting a Guiding Star with PHD2, ReStartGuiding PHD2

Igor,

phd2control is probably a good solution, easily callable from your VBscript so you won't need to deal with TCP sockets and all that stuff.

Invoke "phd2control.exe stop" to stop guiding
Invoke "phd2control.exe guide 3 10 100" to start guiding (including starting looping, automatic star selection, and starting guiding) and wait for guiding to settle the error below 3 pixels for 10 seconds, or time-out after 100 seconds  (replace 3, 10 , and 100 with values appropriate for your setup).

Andy

bw_msgboard

unread,
Jul 11, 2018, 1:05:28 AM7/11/18
to Igor Bednarek, Open PHD Guiding

Hi Igor.  Just to close the loop on why it’s “so complex.”  PHD2 is a cross-platform application (Windows, Mac, Linux) so it doesn’t rely on COM or other Microsoft-specific technology.  Instead, it uses industry-standard solutions for inter-process communication, things like TCP/IP and JSON.  That approach also supports things like distributed solutions – having an imaging application running on one computer while PHD2 runs on a different computer.  None of that is the case with MaximDL and other imaging apps that are Windows-only.  

 

Cheers,

Bruce

 


--
You received this message because you are subscribed to the Google Groups "Open PHD Guiding" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-phd-guidi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Igor Bednarek

unread,
Jul 11, 2018, 5:22:49 AM7/11/18
to Open PHD Guiding
Hi Andy, Bruce,

Thanks Bruce for your explanation regarding cross-platform and inter-process communication. I understand now better what it means even I do probably do not need that as for now.

Thanks Andy for your reply and examples. I have yet several questions :

1) I understand the arguments "3 10 100" (settle the error below 3 pixels for 10 seconds, or time-out after 100 seconds). Using PHD2 manually when do you configure these arguments ?

2) Within a script when you sequence several commands successively, you have often to wait a command returning a TRUE boolean or 1 value to be sure it finishes correctly, for example with MaximDL :

camera.GuiderExpose(5.0)

while camera.GuiderRunning
  wscript.sleep 1000
wend

camera.GuiderTrack(5.0)

In the case of PHD2 I have the feeling that phd2control.exe does not wait before to finish correctly (the camera should be in an idle state). If I chain several phd2control.exe, they execute one by one without waiting the previous to finish correctly.
Is there any way to wait the and check that phd2control.exe end correctly ?

3) I see that you can dithering using phd2control.exe (phd2control dither 3 1.5 8 300 for example). Is it better to use phd2control or phd_dither.exe developped by Bruce ?

Thanks for your replies.

Regards

Igor

Andy Galasso

unread,
Jul 11, 2018, 3:15:52 PM7/11/18
to Open PHD Guiding
On Wed, Jul 11, 2018 at 5:22 AM, Igor Bednarek <igor.b...@gmail.com> wrote:

1) I understand the arguments "3 10 100" (settle the error below 3 pixels for 10 seconds, or time-out after 100 seconds). Using PHD2 manually when do you configure these arguments ?

There are no corresponding settings in PHD2.  Settling criteria are only relevant for external applications controlling phd2.

2) Within a script when you sequence several commands successively, you have often to wait a command returning a TRUE boolean or 1 value to be sure it finishes correctly, for example with MaximDL :

camera.GuiderExpose(5.0)

while camera.GuiderRunning
  wscript.sleep 1000
wend

camera.GuiderTrack(5.0)

In the case of PHD2 I have the feeling that phd2control.exe does not wait before to finish correctly (the camera should be in an idle state). If I chain several phd2control.exe, they execute one by one without waiting the previous to finish correctly.
Is there any way to wait the and check that phd2control.exe end correctly ?

The guide command is inherently synchronous: it will not return until guiding has settled to within the specified tolerance, or en error or timeout occurs.  The command will return 0 on success (guiding settled successfully), non-zero otherwise.

The stop command returns immediately after requesting the stop, thus the command could return slightly before guiding has actually stopped if phd2 has to wait for a camera exposure in progress to complete.   If this is a problem, I can add an option to phd2control to make it wait synchronously for the stop to complete.


3) I see that you can dithering using phd2control.exe (phd2control dither 3 1.5 8 300 for example). Is it better to use phd2control or phd_dither.exe developped by Bruce ?

They both do exactly the same thing -- sending the dither command to phd2 and waiting for settling to complete.  Use whichever one is most convenient for your application.

Andy

bw_msgboard

unread,
Jul 11, 2018, 5:38:49 PM7/11/18
to Andy Galasso, Open PHD Guiding

Hi Igor.  There’s actually a third option just to confuse things further. J  There’s a “big brother” version of PHD_Dither,  called PHD_Broker,  that supports a larger set of PHD2 commands, certainly the ones you’re asking about.  Andy’s phd2control script is a very lean implementation, does exactly what it’s supposed to do, and is pretty much invisible to the operation.  The PHD_Broker app was developed specifically to let automation apps use PHD2 without having to deal with the TCP/IP and JSON interfaces or really know anything about PHD2.  It includes an app with a UI that acts as a broker sitting between PHD2 and any other app.  It shows the status of commands as they are passed through, writes a log of events, and has a UI for configuring things like the dithering parameters.  Everything is strictly synchronous, so the client app or script will always see the status of whatever command was last issued – and that result will also be shown in the UI.  So it’s a heaver-weight application with its own UI, which may not be what you want.  The documentation for PHD_Broker was written for users of CCDAutoPilot but it will work with pretty much anything.  

 

Since all of these are free options, it probably makes sense to look at all of them and choose the one you like the best.  If you want to try using PHD_Broker, send me a message off-forum and I’ll send you the files you need and a description of what to do.

 

Have fun,

Bruce

 


From: open-phd...@googlegroups.com [mailto:open-phd...@googlegroups.com] On Behalf Of Andy Galasso


Sent: Wednesday, July 11, 2018 12:16 PM
To: Open PHD Guiding

--

Igor Bednarek

unread,
Jul 12, 2018, 10:13:55 AM7/12/18
to Open PHD Guiding
Thanks Andy Ok I will seriously try the phd2control commands and will let you know if I succeeded.

Thanks Bruce I would be interested and will look at PHD_Broker. Are there any other files that the ZIP file on the PHD2 Web Site (https://openphdguiding.org/phd2_broker-package-available/ ) ? I would like to use it with MaximDL.

Regards

Igor

Igor Bednarek

unread,
Jul 16, 2018, 10:46:40 AM7/16/18
to Open PHD Guiding
Hi Andy,

I did some new tests based on PHD2 + Simulators.

When you write : "
The guide command is inherently synchronous: it will not return until guiding has settled to within the specified tolerance, or en error or timeout occurs"
This is not what I see when I run as simple a script as this one :
shell.Exec "phd2control.exe guide 3 10 100"
MsgBox "End of Script"

"End of the Script" displays instantaneoulsy without waiting guiding to start (even if guiding starts correctly after some seconds...).

Furthermore how to test the return of the guide command ?
if shell.Exec "phd2control.exe guide 3 10 100" = 0 Then
[...]
is not accepted by the VBscript compilator.

Thanks for your support.

Igor

Andy Galasso

unread,
Jul 16, 2018, 11:19:19 AM7/16/18
to Open PHD Guiding
Igor,

I don't know much about VBScript, but some internet searching indicates that Exec returns immediately while the command continues to run in the background. You can use the Status property to see when the command has exited, and the ExitCode property gives the exit code of the command.

HTH,
Andy

Igor Bednarek

unread,
Jul 16, 2018, 12:18:22 PM7/16/18
to Open PHD Guiding
Thanks Andy.

Yes exaclty. The Exec command returns immediately while the command continues. But I did not find anywhere how to use the Status and Exitcode properties of the created "shell"...

Could you help me for the syntax ? At least with an example ?

Thanks

Regards

Igor

Andy Galasso

unread,
Jul 16, 2018, 6:26:38 PM7/16/18
to Open PHD Guiding
On Mon, Jul 16, 2018 at 12:18 PM, Igor Bednarek <igor.b...@gmail.com> wrote:

Could you help me for the syntax ? At least with an example ?

Sure, here is an example:

Dim shell
Set shell = CreateObject("WScript.Shell")

' run phd2control to start guiding
Dim oexec
Set oexec = shell.Exec("phd2control.exe guide 3 10 300")

' wait for phd2control to exit
Do While oexec.Status = 0
    WScript.Sleep 100
Loop

' oexec.ExitCode will be 0 if settling succeeded
If oexec.ExitCode = 0 Then
    WScript.Echo "guiding started and settling completed"
Else
    WScript.Echo "guiding failed to start or settling failed"
End If

Igor Bednarek

unread,
Jul 17, 2018, 7:07:54 AM7/17/18
to Open PHD Guiding
Hello Andy,

Thanks a lot. Now it works well. I just missed the Set oexec = shell.Exec("phd2control.exe guide 3 10 300") in order to be able to test the Status and ExitCode.

Now with PHD2Control and PHDBroker sent by Bruce I will deeply look at all these options and choose the one I prefer in my setup.

Best regards

Igor


Reply all
Reply to author
Forward
0 new messages