Power control at beginning and end of sequence

I have just written an ASCOM switch driver for a 4-way relay and I am thinking of deploying it before and after a sequence. I can see in the sequence options that I can potentially run an end of sequence script to remove power (I assume the script is executed after any disconnect devices action) but I was wondering of the possibility of executing a power-on script before SGP tries to connect all the devices, and in the case of a timed sequence start, only powering up and connecting say 10 minutes say ahead of the sequence kicking off in earnest.

I don’t think that possibility exists at the moment, hence posting it under feature requests. What do you think?

I think that’s a great idea. I’ve been contemplating an auto boot up sequence for a while, but cannot write scripts, so a little stumped.


I have enquired about the end of sequence script, and I’m sure Ken/Jared said this script is run prior to the disconnect (maybe even prior to end of sequence options?).

W10 scheduler enables you to run a script at a set time and this is what I have done to date to run my power off script ( I have non-ascom IP controlled power sockets).

I and @gnomus are just in the final stages of testing for a remote set up and are using the excellent Lunatico Astronomia Dragonfly, this too can run scripts and does so with W10’s scheduler and is ascom compliant.

It would be great to have the script option in SGP run after End of Sequence options and equipment disconnect have completed. There are a number of products available now for remote power control and having this linked to SGP would be a real boon.


1 Like

Yes, you are correct Barry, the script is executed before it disconnects.

Steve - if you have an ASCOM switch device, a script to turn a relay on and off can be very simple

set c = CreateObject(“ASCOM.Utilities.Chooser”)
id = c.Choose(”")
set sw = CreateObject(id)
sw.Connected = true
sw.SetSwitch x, y
sw.Connected = false
msgBox “Press OK to continue”

x is the switch number and y is true or false. If you know the device name beforehand, you do not need the prompt to choose it and simply write the name of the ASCOM switch device in the place of id and cut out the ASCOM.chooser line.
Of course you can make it more fancy too. I bought a USB-controlled 4-way relay module from KMTronic. It is controlled with serial commands. I wrote a simple ASCOM driver for it. I can help you with further details if you want. I have this module switching 12V supplies to mount, fans, focuser and camera. To reset the PC, I need something that is independent, for which I use a KMTronic Web relay, that connects to my LAN. In this way, I can cycle the power to the PC and USB hub from any device.

Hi Buzz,

Sorry for the long delay. I must have missed your reply. I have now set up a 2nd Velleman K8055N bord together with the Vellemam VM129 8 channel relay board to run my equipment. These I manually switch on and off through the Levesdome software. I would like to automate this sequence to start up and shut down my equipment. But I don’t know if this can be done with this hard/software and if it can. I do not have the skills to complete it.


Does the relay board have some form of serial protocol? They are normally fairly simple. If that is the case, I wrote ASCOM drivers for my 4-way relay and the source code is on my website. It should be possible to keep the program as it is but change a few lines to alter the command protocol between the hardware and the PC.
If you have some kind of datasheet, I could take a look.

Hi Buzz,

I am currently searching for the CD that came with the boards. I’ve had a quick look on the Velleman forum. The boards are usb - serial. They can be scripted, C++ or VB / DLL scripting. Totally over my head. I’ll post again once I find the CD.

Kind regards


Steve, they are likely to be on line. Which board would you want to control with ASCOM?

Hi Buzz,

The first board controls the Observatory and is controlled by ASCOM in
SGPro. Although I have an issue with it syncing with my Dome, but that’s
another issue entirely. The second board is manually controlled by, what
looks like a VB compiled, pull down menu. I have to manually connect my
equipment by selecting each “button”. This, in turn, switches the mating
relays. I have 3 scopes set up via the eight relays - 3 permutations. I
would like to be able to select on of the 3 permutations, which will, in
turn, open the second board menu and select the necessary equipment. Also
to implement the reversal procedure to power down.
I’m certainly open to options and suggestions. However, I don’t want to go
too deep as I am secretly waiting for SGpro’s release of dual scope
Due to the “conflict” I have SGPro and my Dome sync. I run my 2nd scope &
Dome automation through MaximDL and the Main scope sequence and guiding via
SGPro & PHD2.

BTW I have found the disc. All it contains is the Manual, various examples
of VB script and the K8055N DLL.

Kindest regards


I just wondered if I could simply modify my own ASCOM driver. You appear to looking at something more bespoke. VBS is not too difficult and if you have some worked examples already - it may be possible for you to work out some logic around the basic controls. Can you run two SGP windows at the same time?

Hi Buzz,

Thanks for replying. Yes I’m able to run two instances of SGPro.


Any new detail on this? I just wrote an ASCOM driver for my RF remote switches to be able to automate most of the startup and shutdown sequences only to discover that SGP doesn’t support switches. I would have thought that injecting ASCOM switches, sensors, and the like into an SGP sequence would be a pretty important part of observatory automation. Having to write a bunch of scripting code just to load the ASCOM diver kind of makes it a waste of time having written an ASCOM interface vs. just having a command line option for my existing GUI components.




I am also interested in this topic. Apologies if this is hijacking Beo’s question but I think it’s relevant.
I have installed a Devantech ds378 8-channel Ethernet switch to control startup/shutdown of various observatory equipment. I would very much appreciate it if anyone could point me at any examples of vb.net being used to control things via an ethernet link. I am not up to writing my own but I’m happy to have a go at modifying some existing code.
The blurb for the ds378 says:

Right out of the box -
Simple configuration and setup from your web browser.
Control it from a web page, or select tcp/ip control with an option of ASCII, Binary or Modbus protocols.
Send email notifications on selected events.
Optional AES encryption for totally secure control using binary tcp/ip mode.
Add simple relay automation, for automatic relay control.
Create Peer to Peer control in a few clicks.
Up to eight 32-bit counters with capture and reset, 20 counts/second on inputs.
Event schedules for timed events daily or weekly.

Regards, Hugh

Hi Hugh,

Give the capabilities they’re describing, you’d think they’d have some sample code available that would give you a starting point. Might not be VB, but given Visual Studio Community is free, if you can hack VB, you can probably hack C# code too.

Regarding the scripting in general, the one big problem I see with instantiating ASCOM drivers from a script as done in the example is that for something like my RF switch driver, where the actual state is unknown and can only be inferred from the last state of the driver setting, the constant re-instantiation of the driver for each script is undesirable. More importantly, for the Arduino controlled relay that happens to control ALL my equipment, opening the COM port resets the Arduino, so every time the driver would be brought up to open the port, BOOM, all the equipment shuts off! That won’t work!

The problem also goes beyond just switches as there are other things that are missing. I got to looking at the observatory interface in SGP and it looks like that’s ONLY for domes. So the only way to open/close my roll-off is through a script. Likewise, before ANY of the other equipment drivers that it actually does support can be connected, the startup needs to turn it on. So a camera can’t be connected to cool down until a dedicated “run once” script were to execute. Of course given I haven’t found a software hibernation solution for NexRemote, the telescope still has to be started up manually after the system power starts, and the power can’t be turned off until it’s hibernated manually.

At this point it looks like I’m headed back towards developing a single application console to aggregate all of the functions of the various individual programs I use now. That was my plan prior to starting to use SGP. The only question is whether or not to go through the added trouble of using the ASCOM layer in between that and my hardware. It adds more work, but would make some of the stuff I’m developing accessible to others. By adding the console, it would make it straightforward to write scripts that would send commands directly to the console without all the added initialization steps for each ASCOM driver.


Beo - not so. I wrote my own ASCOM driver for a RoR and SGP operates it just fine. You need to set it up in the slave settings - has two options, one for domes, one for RoR. SGP parks the mount and then closes the roof quite happily (and the reverse, at beginning of sequence). The think what some are missing is a method to do something after a sequence has completely finished, as the end of sequence script is executed before the end of sequence options are done.

Just set the “Observatory Type” to Roll Off Roof and you get settings that make sense to a RoR.