' Expose202.vbs ' ' (c) 2002 John C. Smith ' ' This script allows a sequence of exposures to be specified and expanded as needed. Due to ' possible focus position changes as a function of filters or optical path temperature ' coefficient, two focusing alternatives are provided: ' Closed loop: Refocus the system via FocusMax prior to each filter exposure sequence ' Open loop: Use Robofocus to adjust focus for different temperatures and/or filters. ' ' The exposure sequence is followed by safely parking the telescope and then acquiring ' a programmable number of bias and dark frames. Once this is completed, the cooler setting ' is adjusted close to ambient and then shut off. ' ' There is a programmable delay that can be used to allow the target to get to a desired ' altitude before starting the exposure. Note that this delay must be carefully chosen ' so that the telescope doesn't run into the mount if you pass the meridian too far. ' ' This script uses TheSky, Orchestrate, MaximDL FocusMax ' Version numbers used 5.00.014 1.00.011 3.xx 2.2 ' Also requires the ASCOM developer platform for some utility routines. ' ' v2.00 3/30/2002 ' Initial release ' ' v2.01 4/1/2002 ' Add logic to prevent FocusMax running on dark frames (stupid error). ' ' v2.02 9/7/2002 ' Added RA, DEC, Alt, Az to FITS header to emulate CCDSoft data format for astrometry. ' Restored Robofocus code and added switches for Robofocus and Focusmax. Option Explicit Dim TitleText TitleText = "Expose and Park Script v2.02" 'Global Objects Dim TheSky 'Requires TheSky, Orchestrate (RASCOM.DLL) Dim Tele 'Requires TheSky, Orchestrate (RASCOM.DLL) Dim Cam 'Requires Maxim Dim FM 'Requires Focusmax Dim RF 'Requires Robofocus Dim u 'Requires ASCOM development platform 'Global variables Dim IgnoreErrors Dim ErrorOccurred Dim MaximSavePath Dim Object Dim Telescope Dim Origin Dim NumberSets Dim NumberDarks Dim ExposureDelay Dim GuideExposure Dim StartDelay Dim ImageCount Dim Index Dim Maxim, Focusmax, Robofocus ' ******************************************************************************** ' * ' * User Initialization ' * ' 'If you want your script to run all night regardless of errors, 'set IgnoreErrors = True ' IgnoreErrors = True ' ' ' ' *** Application Switches *** ' Focusmax = False 'Set to True for Focusmax autofocusing Robofocus = False 'Set to True for Robofocus temperature control 'Be sure to set filter offsets, if needed, 'in Sub subexpose ' ' *** Set up exposure parameters *** ' ImageCount = 1 'Starting count for Image File Name Numbersets = 4 'Number of image sets NumberDarks = 12 'Number of dark sets GuideExposure = 0 'Set guide exposure ExposureDelay = 2 * GuideExposure Origin = "Hidden Loft Observatory" 'Imaging location Telescope = "RCF7" 'For FITS header Object = "NGC253" 'File object name, also placed in FITS header StartDelay = 0 'number of hours to delay exposure start MaximSavePath = "D:\Astronomy\MaximData\" ' ' *** Set parameters in Sub Expose and Sub Dark. Comment unneeded calls *** ' ' ******************************************************************************** ' * ' * Main Program Flow ' * Call CreateObjects() Call ConnectObjects() Call Welcome() u.WaitForMilliseconds (StartDelay*1000*3600) 'Call Dark() 'Do dark and bias exposures Call Expose() 'Do light exposures Tele.Park() 'Park the telescope Call Dark() 'Do dark and bias exposures Call CoolerOff 'shut down camera cooler Call DisconnectObjects() Call DeleteObjects() Wscript.echo "Script ended normally at", Time ' ******************************************************************************** ' * ' * Subroutines ' * Sub Expose() ' Debugging-add a single quote before line below On Error Resume Next ' Series Number of exposures in a series ' ExpTime Exposure time in seconds ' FrameMode 0,1 Dark, Light ' Resolution 1,2,3 1x1, 2x2, 3x3 ' Filter 0,1,2,3,4 red, green, blue, clear, Halpha ' Describe Lum, Red, Green, Blue, Dark, Bias, etc. ' SubExposure (Series,ExpTime,FrameMode,ExpDelay,Resolution,Filter,Describe) Dim n For n = 1 to NumberSets 'SubExposure 1, 1200, 1, ExposureDelay, 1, 4, "Ha" SubExposure 2, 600, 1, ExposureDelay, 1, 3, "Lum" SubExposure 1, 420, 1, ExposureDelay, 2, 0, "Red" SubExposure 1, 420, 1, ExposureDelay, 2, 1, "Grn" SubExposure 1, 600, 1, ExposureDelay, 2, 2, "Blu" 'SubExposure 2, 600, 1, ExposureDelay, 1, 0, "RLum" 'SubExposure 3, 300, 1, ExposureDelay, 1, 2, "Blum" Next End Sub Sub Dark() SubExposure 3, 1, 0, 0, 1, 4, "Flush" 'SubExposure NumberDarks, 1200, 0, 0, 1, 4, "Dark20m" SubExposure NumberDarks, 600, 0, 0, 1, 4, "Dark10m" SubExposure NumberDarks, 600, 0, 0, 2, 4, "Dark10m2x2" SubExposure NumberDarks, 0.11, 0, 0, 1, 4, "Bias" SubExposure NumberDarks, 0.11, 0, 0, 1, 4, "Bias" 'SubExposure NumberDarks, 1200, 0, 0, 1, 4, "Dark20m" SubExposure NumberDarks, 0.11, 0, 0, 2, 4, "Bias2x2" SubExposure NumberDarks, 0.11, 0, 0, 2, 4, "Bias2x2" 'SubExposure NumberDarks, 10, 0, 0, 1, 4, "Dark10s" 'SubExposure NumberDarks, 20, 0, 0, 1, 4, "Dark20s" 'SubExposure NumberDarks, 2.2, 0, 2, 1, 2, "FlatDarkG1x" 'SubExposure NumberDarks, 9.3, 0, 2, 1, 2, "FlatDarkB1x" End Sub Sub SubExposure (Series,ExpTime,FrameMode,ExpDelay,Resolution,Filter,Describe) Dim i, Filename, s, delta Cam.filter = Filter If Focusmax = true and FrameMode = 1 then 'Don't run FocusMax with dark frames FM.DimStarDetectionEnable = True Cam.Binx=3 Cam.SetFullFrame() FM.Focus End If If Robofocus = true and FrameMode = 1 Then 'Don't run Robofocus with dark frames RF.actTempCompManual() 'Adjust basic focus point for any temperature change u.WaitForMilliseconds(3000) If Filter = 0 Then delta = 0 'Assumes initial manual focusing with red filter If Filter = 1 Then delta = 0 'offsets derived from focal point differences... If Filter = 2 Then delta = 0 ' ... from red for various filters. If Filter = 3 Then delta = 0 'R,G,B,L,Ha = 0,1,2,3,4 If Filter = 4 Then delta = 0 If delta <> 0 Then If delta < 0 then u.WaitForMilliseconds(2000) RF.setDelta(-delta) u.WaitForMilliseconds(2000) RF.actIn Else u.WaitForMilliseconds(2000) RF.setDelta(delta) u.WaitForMilliseconds(2000) RF.actOut End If End If End If For i = 1 to Series u.WaitForMilliseconds(ExpDelay*1000) Cam.Binx = Resolution Cam.SetFullFrame() Cam.Expose ExpTime, FrameMode, Filter Do While Not Cam.ImageReady Loop FileName = MaximSavePath + String((4-Len(Cstr(ImageCount))),"0") + Cstr(ImageCount) FileName = FileName + "." + Object + "." + Describe + ".fit" Cam.SetFITSKey "OBJECT", Object Cam.SetFITSKey "ORIGIN", Origin Cam.SetFITSKey "NOTES", "Acquired by " + TitleText Cam.SetFITSKey "EXPOSURE", Cdbl(ExpTime) Cam.SetFITSKey "TEMPERAT", Cam.Temperature Cam.SetFITSKey "TELESCOP", Telescope If FrameMode = 1 Then Tele.GetRaDec() Cam.SetFITSKey "OBJCTRA", u.HoursToHMS(Tele.dRa, " ", " ",,3) If Sgn(Tele.dDec) >= 0 Then s = "+" Else s = "" Cam.SetFITSKey "OBJCTDEC", s + u.DegreesToDMS(Tele.dDec," "," "," ",2) Tele.GetAzAlt() Cam.SetFITSKey "CENTAZ", Tele.dAz Cam.SetFITSKey "CENTALT", Tele.dAlt End If Cam.SaveImage FileName ImageCount = ImageCount + 1 Call PromptOnError(ErrorOccurred) Next If Robofocus and FrameMode = 1 Then If delta <> 0 Then If delta < 0 Then RF.actOut Else RF.actIn End If End If End If End Sub Sub Welcome() Dim WelcomeText Dim L1 Dim CRLF CRLF = Chr(13) & Chr(10) L1 = "This script does a programmable exposure sequence, parks the telescope," L1 = L1 + CRLF L1 = L1 + "does a programmable dark and bias sequence and shuts down the cooler." L1 = L1 + CRLF L1 = L1 + "Applications used: Maxim, TheSky, RASCOM.DLL, " If Robofocus Then L1 = L1 + "RoboFocus, " If Focusmax Then L1 = L1 + "FocusMax, " L1 = L1 + "The ASCOM platform." L1 = L1 + CRLF + CRLF L1 = L1 + " John Smith, Hidden Loft Observatory, Tucson, AZ." Dim intDoIt WelcomeText = L1 intDoIt = MsgBox(WelcomeText, vbOKCancel + vbInformation, TitleText) If intDoIt = vbCancel Then Cam.DisableAutoShutdown = True WScript.Quit End If If StartDelay > 0 Then WelcomeText = "Start delay is " + Cstr(StartDelay) + " hour(s)" intDoIt = MsgBox(WelcomeText, vbOKCancel + vbInformation, "Script Start Delay") If intDoIt = vbCancel Then Cam.DisableAutoShutdown = True WScript.Quit End If End If End Sub Sub PromptOnError(ErrorOccurred) Dim ExitScript 'Debugging-remove the single quote from the line below Exit Sub ErrorOccurred = False ExitScript = False if (IgnoreErrors = True) then 'Ignore all errors except when the user Aborts if (CStr(Hex(Err.Number)) = "800404BC") then 'Do nothing and let the user abort else Err.Clear end if end if if (Err.Number) then ErrorOccurred = True ExitScript = MsgBox ("An error has occurred running this script. Error # " & CStr(Hex(Err.Number)) & " " & Err.Description + CRLF + CRLF + "Exit Script?", vbYesNo + vbInformation) end if If ExitScript = vbYes Then Cam.DisableAutoShutdown = True WScript.Quit End if End Sub Sub CreateObjects() Set TheSky = WScript.CreateObject("RASCOM.RASCOMTheSky.1") Set Tele = WScript.CreateObject("RASCOM.RASCOMTele.1") Set Cam = WScript.CreateObject("MaxIm.CCDCamera") If Focusmax Then Set FM = CreateObject("FocusMax.FocusControl") If Robofocus Then Set RF = CreateObject("RoboFocus.FocusControl") Set u = CreateObject("DriverHelper.Util") End Sub Sub ConnectObjects() TheSky.Connect() Tele.Connect() Cam.LinkEnabled = True If Not Cam.LinkEnabled Then wscript.echo "Failed to start camera." WScript.Quit End If If Robofocus Then RF.actOpenComm() u.WaitForMilliseconds(3000) If RF.getFirmwareVersion() = "Not Connected" Then wscript.echo "RoboFocus not active." WScript.Quit End If End If End Sub Sub CoolerOff Cam.TemperatureSetpoint = 20 u.WaitForMilliseconds 60000 Cam.CoolerOn = False u.WaitForMilliseconds 2000 Cam.DisableAutoShutdown = True End Sub Sub DisconnectObjects() TheSky.Disconnect() Tele.Disconnect() End Sub Sub DeleteObjects() Set TheSky = Nothing Set Tele = Nothing Set Cam = Nothing Set u = Nothing If Focusmax then Set FM = nothing If Robofocus then Set RF = Nothing End Sub