' Expose.vbs ' ' (c) 2002 John C. Smith ' ' This script allows a sequence of exposures to be specified and expanded as needed. ' ' Due to possible focus positions as a function of filters, provision is made to ' change the focus position via RoboFocus to a given filter's optimum position. It ' is assumed a temperature compensation curve has been initialized and the correction ' has been set to relative and manual. The routine will update the focus position ' prior to each exposure. ' ' The exposure sequence followed shutting down the guider, safely parking the telescope ' and then acquiring a programmable number of bias and dark frames. Once this is completed, ' the cooler is adjusted close to ambient and then shut off. This script works with ' both CCDSoft and MaximDL/CCD acquisition programs. ' ' 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. The Park routine moves the telescope east two hours ' so that parking doesn't try to go under the mount. ' ' This script uses TheSky, Orchestrate, MaximDL/CCDSoft RoboFocus ' Version numbers used 5.00.014 1.00.011 3.xx/5.xx 3.13 ' Also requires the ASCOM platform for the timing loop. ' ' v 1.01 11/20/01 ' Corrects binning errors by adding "objCam.LinkEnabled = True" and "objCam.SetFullFrame()" ' to Sub SubExposure ' ' v1.02 12/11/01 ' Added RoboFocus object and commands to manually adjust focus according to temperature ' compensation. RoboFocus control program must be run and temperature compensation file ' loaded before script is run. Set RoboFocus update to manual mode. I generally focus ' using FocusMax at an elevation that is representative of where my target will be in the ' middle of the exposure sequence. This is usually near the meridian. ' ' v1.03 12/17/01 ' Added code to support CCDSoft v3 via an option switch Option Explicit Dim L_Welcome_Text Dim L_Welcome_MsgBox_Title_Text Dim L1, L2 Dim CRLF CRLF = Chr(13) & Chr(10) L1 = "This script does exposure and dark sequence and then parks the telescope." L1 = L1 + CRLF + CRLF L2 = L1 + "Using CCDSoft v5 - John Smith, 12/17/01" L1 = L1 + "using MaximDL/CCD v3 - John Smith, 12/17/01" L_Welcome_MsgBox_Title_Text = "Expose and Park Script v1.03" 'Global Objects Dim objTheSky Dim objTele Dim objCam Dim objFilter Dim u Dim RF 'Global variables Dim bIgnoreErrors Dim bErrorOccurred Dim NumberSets Dim NumberDarks Dim ExposureDelay Dim g_Object Dim StartDelay Dim g_ImageCount Dim Index Dim Maxim ' ******************************************************************************** ' * ' * User Initialization ' * ' 'If you want your script to run all night regardless of errors, 'set bIgnoreErrors = True ' bIgnoreErrors = False ' ' *** Select acquisition program *** ' Maxim = False 'True if using Maxim v3, False if using CCDSoft v5 ' ' *** Set up exposure parameters *** ' g_ImageCount = 1 'Starting count for Image File Name Numbersets = 8 'Number of image sets NumberDarks = 9 'Number of dark sets ExposureDelay = 24 'seconds - set at 3 times guide exposure If Maxim Then g_Object = "D:\Astronomy\MaximData\HH" 'Maxim object path and name Else g_Object = "HH" 'CCDSoft object name End If StartDelay = 0 'number of hours to delay exposure start ' ' *** 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 Expose() 'Do light exposures If Maxim Then objCam.GuiderStop() 'Stop guiding Call Park() 'Safely 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 red, green, blue, clear ' Describe Luminance, Red, Green, Blue, Dark, Bias, etc. ' SubExposure (Series,ExpTime,FrameMode,ExpDelay,Resolution,Filter,Describe) Dim n For n = 1 to NumberSets 'SubExposure 1, 300, 1, ExposureDelay, 1, 3, "LUM" SubExposure 2, 300, 1, ExposureDelay, 1, 0, "RLUM" SubExposure 1, 300, 1, ExposureDelay, 2, 0, "RED" SubExposure 1, 300, 1, ExposureDelay, 2, 1, "GRN" SubExposure 1, 300, 1, ExposureDelay, 2, 2, "BLU" Next End Sub Sub Dark() Dim n For n = 1 to NumberDarks 'SubExposure 1, 300, 1, 2, 2, 0, "LightR2x2" SubExposure 1, 300, 0, 2, 1, 0, "Dark300s" SubExposure 1, 300, 0, 2, 2, 0, "Dark300s2x2" 'SubExposure 1, 0.1, 0, 2, 1, 2, "Bias" 'SubExposure 1, 0.1, 0, 2, 2, 2, "Bias2x2" Next End Sub Sub Welcome() Dim intDoIt If Maxim Then L_Welcome_Text = L1 Else L_Welcome_Text = L2 intDoIt = MsgBox(L_Welcome_Text, _ vbOKCancel + vbInformation, _ L_Welcome_MsgBox_Title_Text ) If intDoIt = vbCancel Then WScript.Quit End If End Sub Sub PromptOnError(bErrorOccurred) Dim bExitScript 'Debugging-remove the single quote from the line below 'Exit Sub bErrorOccurred = False bExitScript = False if (bIgnoreErrors = 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 bErrorOccurred = True bExitScript = MsgBox ("An error has occurred running this script. Error # " & CStr(Hex(Err.Number)) & " " & Err.Description + CRLF + CRLF + "Exit Script?", vbYesNo + vbInformation) end if If bExitScript = vbYes Then WScript.Quit End if End Sub Sub CreateObjects() Set objTheSky = WScript.CreateObject("RASCOM.RASCOMTheSky.1") Set objTele = WScript.CreateObject("RASCOM.RASCOMTele.1") If Maxim Then Set objCam = WScript.CreateObject("MaxIm.CCDCamera") Else Set objCam = WScript.CreateObject("RASCOM.RASCOMCam.1") Set objFilter = WScript.CreateObject("RASCOM.RASCOMFilter.1") End If Set u = CreateObject("DriverHelper.Util") Set RF = CreateObject("RoboFocus.FocusControl") End Sub Sub ConnectObjects() objTheSky.Connect() objTele.Connect() If Maxim Then objcam.LinkEnabled = True If Not objCam.LinkEnabled Then wscript.echo "Failed to start camera." WScript.Quit End If Else objFilter.Connect() objCam.Connect() End If RF.actOpenComm() u.WaitForMilliseconds(3000) If RF.getFirmwareVersion() = "Not Connected" Then wscript.echo "RoboFocus not active." WScript.Quit End If End Sub Sub SubExposure (Series,ExpTime,FrameMode,ExpDelay,Resolution,Filter,Describe) Dim i, Filename, delta, position For i = 1 to Series RF.actTempCompManual() 'Adjust basic focus point for any temperature change If Filter = 0 Then delta = 0 'Assumes initial manual focusing with red filter If Filter = 1 Then delta = -9 'offsets derived from focal point differences... If filter = 2 Then delta = -2 ' ... with various filters. If filter = 3 Then delta = -3 'RGBL = 0,1,2,3 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 If Maxim Then u.WaitForMilliseconds(ExpDelay*1000) objCam.LinkEnabled = True objCam.SetFullFrame() objCam.Binx = Cint(Resolution) FrameMode = Cint(FrameMode) Filter = Cint(Filter) objCam.Expose ExpTime, FrameMode, Filter Do While Not objCam.ImageReady Loop FileName = g_Object + Describe + String((4-Len(Cstr(g_ImageCount))),"0") FileName = FileName + Cstr(g_ImageCount) + ".fit" objCam.SaveImage FileName Else objcam.dExposureTime = ExpTime If FrameMode = 0 Then FrameMode = 2 objcam.FrameMode = FrameMode objcam.lExposureDelay = ExpDelay objcam.Resolution = Resolution - 1 objFilter.MoveTo(Filter + 1) FileName = g_Object + "_" + Describe objCam.SetObjectName(FileName) objCam.TakePicture() End If g_ImageCount = g_ImageCount + 1 If delta <> 0 Then If delta < 0 Then RF.actOut Else RF.actIn End If End If Call PromptOnError(bErrorOccurred) Next End Sub Sub Park Dim RA, DEC objTele.GetRaDec() RA = objTele.dRa DEC = objTele.dDec objTele.SlewToRaDec RA + 2, DEC, "" u.WaitForMilliseconds 10000 objTele.Park() 'Park the telescope End Sub Sub CoolerOff If Maxim Then objCam.TemperatureSetpoint = 20 Else objCam.dTemperatureSetpoint = 20 Index = timer u.WaitForMilliseconds 60000 If Maxim Then objCam.CoolerOn = False Else objcam.TemperatureRegulation = 0 End Sub Sub DisconnectObjects() objTheSky.Disconnect() objTele.Disconnect() If Not Maxim Then objCam.SetObjectName("") 'Clear CCDSoft filename assignment objCam.Disconnect() objFilter.Disconnect() End If End Sub Sub DeleteObjects() Set objTheSky = Nothing Set objTele = Nothing Set objCam = Nothing If Not Maxim Then Set objFilter = Nothing Set u = Nothing Set RF = Nothing End Sub