'===================================================================== '====================Welcome to Maxim DL Script Template============== '===================================================================== 'This form is a template that gives you functions that a script can call 'on to make Maxim DL do things through its ASCOM astronomical scripting. 'It is recommended that you do not change the settings in most sections 'unless you test them afterwards. Settings to leave alone are anything 'that is a "Sub", such as "TakeImage" or "CheckAltitude". Generate your 'script via the web generator or the online instructions, and then paste 'your script between the "--Program--" lines right after the "Startup" 'section ' '--------------------------------------------------------------------- '------------------------------STARTUP------------------------------ 'Don't edit this. '------------------------------STARTUP------------------------------ ' (1) SET UP TELESCOPE Dim scope Set scope = CreateObject("TheSky.Telescope") scope.Connected = True if Not scope.Connected Then wscript.echo "Failed to start telescope." Quit End If scope.SlewSettleTime = 20 ' (2) SET UP CAMERA Dim cam Set cam = CreateObject("MaxIm.CCDCamera") cam.LinkEnabled = True if Not cam.LinkEnabled Then wscript.echo "Failed to start camera." Quit End If ' (3)Create the TheSky object (for loading object coordinates) Dim objTheSky Set objTheSky = WScript.CreateObject("RASCOM.RASCOMTheSky.1") ' (4) Create dome object 'Dim objDome 'Set objDome = WScript.CreateObject("RASCOM.RASCOMDome.1") ' (5) SET UP SCRIPT CONVENTIONS (so no Dim parameters will repeat) ' i is the counter that appears in the file names Dim i i = 1000 ' filename is the name of the saved file. filepath is the directory. Dim filepath Dim filename ' RATarget and DecTarget are recycled in this script so i state them here Dim RATarget, DecTarget Dim AzTarget, AltTarget ' Object is the object name string. This is what you need to type into TheSky's Edit/Find entry in order to load your object. Dim Object 'Set up Altitude check parameter Dim minAlt minAlt = CDbl(20.0000) Dim goAheadAlt goAheadAlt = true 'Set up the Time stamp/check parameter Dim thetime, thehour thetime = Now thehour = Hour(thetime) 'TAKEIMAGE parameters Dim Name, e, f, l '(6) SET UP ACTIVITY LOGFILE Dim fso, f1, log Set fso = CreateObject("Scripting.FileSystemObject") '8 means ForAppending Set log = fso.OpenTextFile("scriptfile.txt", 8) log.writeline("=================================================") log.writeline("=======SCRIPT STARTED " & NOW & "=======") log.writeline("=================================================") '^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_STARTUP_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^ '-----------------------PROGRAM START------------------------ 'on error resume next wscript.echo "starting" ' Please note that for filepath, you need to add a backslash after the name ' or you'll get the wrong names. The reason is that *filepath & filename* is ' the name of the saved files. if you leave out the backslash, you'll be ' looking for the file "C:\IMAGEBOX\foldername1001_NGC3456_red.fits" filepath = "C:\Image Box\JD030527\" object = "NGC 5678" SlewtoObject object if (goaheadalt) then log.WriteLine(Now & " Starting imaging for object " & object) TakeImage object, 90, 0 TakeImage object, 90, 0 TakeImage object, 90, 0 TakeDark 90 end if log.writeline(Now & " done imaging object " & object) 'DomeCheck object = "NGC 6482" SlewtoObject object if (goaheadalt) then log.WriteLine(Now & " Starting imaging for object " & object) TakeImage object, 90, 0 TakeImage object, 90, 0 TakeImage object, 90, 0 TakeDark 90 end if log.writeline(Now & " done imaging object " & object) 'DomeCheck log.writeline(Now & "SCRIPT COMPLETE. CLOSING DOME") Call objDome.Connect() log.writeline(Now & "connected to Automadome") Call objDome.CloseSlit() log.writeline(Now & " Dome should be closed.") wscript.echo "Script Complete" '^_^_^_^_^_^_^_^_^_^_^_^_PROGRAM END_^_^_^_^_^_^_^_^_^_^_^_^_^ '==================================================================================== '==============BELOW ARE ALL THE SUBROUTINES THAT ARE CALLED IN THIS SCRIPT========== '==================================================================================== ' These are listed in the following order: ' ALT CHECK - Check Altitude to see if the telescope will slew to the object ' DOME CHECK - Check the time to see if the sun is up ' SLEW TO OBJECT - Checks with TheSky to see if the object is high enough, then slews. ' TAKE IMAGE - Take an image of the object. ' TAKE DARK - Takes a dark frame ' JOG - Jogs the telescope. Useful for Sky Flats.S ' OFFSET - offsets the target coordinates but doesn't slew. Is called within SlewToObject function. ' FUNCTIONS - RAMove, DecMove, and RARatio. these are used to calculate the Jogs. '------------------------ALT CHECK SUB------------------ ' Check Altitude Sub CheckAltitude(ObjectAlt, AltLow) 'on error resume next If ( ObjectAlt >= AltLow ) Then goAheadAlt = true end if If ( ObjectAlt <= AltLow ) then goAheadAlt = false end if End Sub '^_^_^_^_^_^_^_^_^_^_^_END ALT CHECK SUB_^_^_^_^_^_^_^_^_^ '------------------------DOME CHECK SUB------------------ ' Check time to make sure the sun isn't up Sub DomeCheck 'on error resume next thehour = Hour(now) if (thehour > 18) then log.writeline(Now & " Dome Echo: all is well") end if if (thehour < 06) then log.writeline(Now & " Dome Echo: all is well") end if if (thehour > 05) then if (thehour < 19) then Call objDome.Connect() Call objDome.CloseSlit() log.writeline(Now & " Dome Echo: close the dome!") WScript.Quit end if end if end Sub '^_^_^_^_^_^_^_^_^_^_^_END DOME CHECK SUB_^_^_^_^_^_^_^_^_^ '----------------------SLEW TO OBJECT SUB---------------------- Sub SlewtoObject(Object) 'on error resume next Call objTheSky.Connect() 'Get the object Az and Alt. the altitude is important to make sure the object is above the horizon. 'Note that the function GetObjectAzAlt writes Az to dObjectRa and writes Alt to dObjectDec. 'This can be confusing if you do not keep track of your parameters and do not know whether you have the azalt or radec. objTheSky.GetObjectAzAlt(Object) log.writeline(now & " " & Object & " Az= " & CDbl(objTheSky.dObjectRa)&" Alt="& CDbl(objTheSky.dObjectDec)) AzTarget = CDbl(objTheSky.dObjectRa) AltTarget = CDbl(objTheSky.dObjectDec) 'Get the object RA and Dec. through GetObjectRaDec("[objectname]") objTheSky.GetObjectRaDec(Object) log.writeline(now & " " & Object & " Ra= " & CDbl(objTheSky.dObjectRa)&" Dec="& CDbl(objTheSky.dObjectDec)) RATarget = CDbl(objTheSky.dObjectRa) DecTarget = CDbl(objTheSky.dObjectDec) '|NOTE: YOU MAY NOTICE that I have removed several statements here. The '|reason for this is that the "GetObjectAzAlt" was tested on one computer, '|where it wrote the values to objTheSky.dObjectRA and .dObjectDec. On '|Whitney's computer, though, this does not work. Thus, all things that '|test for AzAlt values, such as "Altitude check" and the below offset for '|different sides of the pier, no longer work. CheckAltitude AltTarget,minAlt If (goAheadAlt) Then log.writeline(now & " Slewing to " & Object & " at RA:" & RATarget & " Dec:" & DecTarget) scope.TargetRightAscension = RATarget scope.TargetDeclination = DecTarget 'sometimes it may be useful to enable an offset on the east or west of the pier If AzTarget > 180 then Offset "east", 0 Offset "north", 0 end If If AzTarget < 180 then Offset "west", 0 Offset "north", 0 end If scope.SlewToTarget() end if If Not (goAheadAlt) then log.writeline(now & " goAheadAlt is false because " & object & " is below " & minAlt & "° Altitude") end if Call objTheSky.Disconnect() End Sub '^_^_^_^_^_^_^_^_^_^_^_^_SLEW TO OBJECT SUB_^_^_^_^_^_^_^_^_^_^_^_^ '--------------------------TAKE IMAGE SUB-------------------------- Sub TakeImage(Name, e, f) 'on error resume next 'Name is the object name 'e is exposure time in seconds given by the user 'f is the filter number given by user log.writeline(now & " Camera is ready, Exposing.") if cam.HasFilterWheel Then cam.Filter = f End If if Not cam.HasFilterWheel Then cam.Filter = 0 End If cam.Expose e, 1, cam.Filter Do While Not cam.ImageReady Loop if cam.HasFilterWheel Then filename = i & "_" & Object & "_" & cam.FilterNames(cam.Filter) & ".fits" cam.setFITSKey "FILTER", cam.FilterNames(cam.Filter) End If if Not cam.HasFilterWheel Then filename = i & "_" & Object & ".fits" cam.setFITSKey "FILTER", "NOFILTER" End If i = i + 1 cam.SetFITSKey "IRAFCODE", "NOCODE" cam.SetFITSKey "OBJECT", Object cam.SaveImage filepath & filename log.writeline(now & " Exposure is done, Image saved as " & filename) End Sub '^_^_^_^_^_^_^_^_^_^_^_^_END TAKE IMAGE SUB_^_^_^_^_^_^_^_^_^_^_^_^_^ '--------------------------TAKE DARK FRAME SUB-------------------------- Sub TakeDark(e) 'on error resume next 'e is exposure time in seconds given by the user log.writeline(now & " Camera is ready, Exposing Dark.") cam.Expose e, 0, 0 Do While Not cam.ImageReady Loop filename = i & "_DARK.fits" cam.setFITSKey "FILTER", "NOFILTER" i = i + 1 cam.SetFITSKey "IRAFCODE", "NOCODE" cam.SetFITSKey "OBJECT", "DARK" cam.SaveImage filepath & filename log.writeline(now & " Exposure is done, Image saved as " & filename) End Sub '^_^_^_^_^_^_^_^_^_^_^_^_END TAKE DARK FRAME SUB_^_^_^_^_^_^_^_^_^_^_^_^_^ '--------------------------TELESCOPE JOG SUB-------------------------- Sub Jog(direction, move) 'on error resume next 'changes coordinates of telescope after slew 'move is in arcminutes, direction is a string "north", "south", "east", or "west". 'This should be placed in the Program section, to be executed only if the slew is successful. dim currentRA, currentDec currentRA = scope.RightAscension currentDec = scope.Declination Select Case direction Case "north" RATarget = currentRA DecTarget = (Currentdec + DecMove(move)) Case "south" RATarget = currentRA DecTarget = (Currentdec - DecMove(move)) Case "east" RATarget = (currentRA + RAMove(move)) DecTarget = currentdec Case "west" RATarget = (currentRA - RAMove(move)) DecTarget = currentdec Case Else RATarget = (currentRA + RAMove(move)) DecTarget = currentdec End Select 'Check for errors resulting from operations if RATarget >= 24 then RATarget = (RATarget - 24) end if if RATarget < 0 then RATarget = (RATarget + 24) end if if DecTarget >= 360 then DecTarget = (DecTarget - 360) end if if DecTarget < 0 then DecTarget = (DecTarget + 360) end if 'write the target coordinates to the telescope object scope.TargetRightAscension(RATarget) scope.TargetDeclination(DecTarget) scope.SlewToTarget() end Sub '^_^_^_^_^_^_^_^_^_^_^_^_END TELESCOPE JOG SUB_^_^_^_^_^_^_^_^_^_^_^_^_^ '---------------------------TARGET OFFSET SUB--------------------------- Sub Offset(direction, move) 'on error resume next 'changes the coordinates of an object before slew 'move is in arcminutes, direction is a string "north", "south", "east", or "west". 'The way to use this is to place the Offset command within the SlewToObject function after the RATarget and DecTarget are given by theSky but before the telescope is slewed. Select Case direction Case "north" RATarget = RATarget DecTarget = (DecTarget + DecMove(move)) Case "south" RATarget = RATarget DecTarget = (DecTarget - DecMove(move)) Case "east" RATarget = (RATarget + RAMove(move)) DecTarget = DecTarget Case "west" RATarget = (RATarget - RAMove(move)) DecTarget = DecTarget Case Else RATarget = (RATarget + RAMove(move)) DecTarget = DecTarget End Select 'Check for errors resulting from operations if RATarget >= 24 then RATarget = (RATarget - 24) end if if RATarget < 0 then RATarget = (RATarget + 24) end if if DecTarget >= 360 then DecTarget = (DecTarget - 360) end if if DecTarget < 0 then DecTarget = (DecTarget + 360) end if 'write the target coordinates to the telescope object scope.TargetRightAscension = RATarget scope.TargetDeclination = DecTarget end Sub '^_^_^_^_^_^_^_^_^_^_^_^_END TARGET OFFSET SUB_^_^_^_^_^_^_^_^_^_^_^_^_^ '-------------------FUNCTIONS USED TO CALCULATE JOG---------------------- function RAMove(move) 'X arcminutes equals how many RA minutes at the equator? RAmove = (move / 60 * 24 / 360) RAmove = (RAmove * RARatio(targetdec)) end function function DecMove(move) DecMove = (move / 60) end function function RARatio(Decvalue) dim pi pi = 3.141592653589793238462643383279 RARatio = (1 / cos(decvalue * pi / 180)) end Function '^_^_^_^_^_^_^_^_^_END FUNCTIONS USED TO CALCULATE JOG_^_^_^_^_^_^_^_^_^