' Expose104.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 "Cam.LinkEnabled = True" and "Cam.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 v5 via an option switch ' ' v1.04 3/23/2002 ' Consistent file names for Maxim and CCDSoft, some clean-up. Option Explicit Dim WelcomeText Dim TitleText Dim L1, L2 Dim CRLF CRLF = Chr(13) & Chr(10) L1 = "This script does a programmable exposure sequence, parks the telescope, then" L1 = L1 + CRLF + CRLF L1 = L1 + "does a programmable dark sequence " L2 = L1 + "using CCDSoft v5 - John Smith, 3/23/2002" L1 = L1 + "using MaximDL/CCD v3 - John Smith, 3/23/2002" TitleText = "Expose and Park Script v1.04" 'Global Objects Dim TheSky Dim Tele Dim Cam Dim Filter Dim u Dim RF 'Global variables Dim IgnoreErrors Dim ErrorOccurred Dim MaximSavePath Dim Object Dim NumberSets Dim NumberDarks Dim ExposureDelay Dim StartDelay Dim ImageCount Dim Index Dim Maxim ' ******************************************************************************** ' * ' * User Initialization ' * ' 'If you want your script to run all night regardless of errors, 'set IgnoreErrors = True ' IgnoreErrors = False ' ' *** Select acquisition program *** ' Maxim = True 'True if using Maxim v3, False if using CCDSoft v5 MaximSavePath = "D:\Astronomy\MaximData\" ' ' *** Set up exposure parameters *** ' ImageCount = 1 'Starting count for Image File Name Numbersets = 8 'Number of image sets NumberDarks = 7 'Number of dark sets ExposureDelay = 1 'seconds - set at 3 times guide exposure Object = "M97" 'File object name 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 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, 2, 0, "Red" SubExposure 1, 300, 1, ExposureDelay, 2, 1, "Grn" SubExposure 1, 480, 1, ExposureDelay, 2, 2, "Blu" SubExposure 3, 300, 1, ExposureDelay, 1, 3, "Lum" 'SubExposure 2, 300, 1, ExposureDelay, 1, 0, "RLum" Next End Sub Sub Dark() Dim n For n = 1 to NumberDarks SubExposure 1, 300, 0, 2, 1, 2, "Dark300s" SubExposure 1, 300, 0, 2, 2, 2, "Dark300s2x2" SubExposure 1, 480, 0, 2, 2, 2, "Dark480s2x2" 'SubExposure 1, 600, 0, 2, 2, 2, "Dark600s2x2" 'SubExposure 1, 0.9, 0, 2, 1, 2, "FlatDarkL1x" 'SubExposure 1, 3.4, 0, 2, 2, 2, "FlatDarkR2x" 'SubExposure 1, 13.5, 0, 2, 2, 2, "FlatDarkG2x" 'SubExposure 1, 65, 0, 2, 2, 2, "FlatDarkB2x" Next End Sub Sub Welcome() Dim intDoIt If Maxim Then WelcomeText = L1 Else WelcomeText = L2 intDoIt = MsgBox(WelcomeText, _ vbOKCancel + vbInformation, _ TitleText ) If intDoIt = vbCancel Then WScript.Quit 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 WScript.Quit End if End Sub Sub CreateObjects() Set TheSky = WScript.CreateObject("RASCOM.RASCOMTheSky.1") Set Tele = WScript.CreateObject("RASCOM.RASCOMTele.1") If Maxim Then Set Cam = WScript.CreateObject("MaxIm.CCDCamera") Else Set Cam = WScript.CreateObject("RASCOM.RASCOMCam.1") Set Filter = WScript.CreateObject("RASCOM.RASCOMFilter.1") End If Set u = CreateObject("DriverHelper.Util") Set RF = CreateObject("RoboFocus.FocusControl") End Sub Sub ConnectObjects() TheSky.Connect() Tele.Connect() If Maxim Then Cam.LinkEnabled = True If Not Cam.LinkEnabled Then wscript.echo "Failed to start camera." WScript.Quit End If Else Filter.Connect() Cam.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 = 0 'offsets derived from focal point differences... If filter = 2 Then delta = 0 ' ... with various filters. If filter = 3 Then delta = 0 '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) Cam.LinkEnabled = True Cam.SetFullFrame() Cam.Binx = Cint(Resolution) FrameMode = Cint(FrameMode) Filter = Cint(Filter) 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 "NOTES", TitleText Cam.SaveImage FileName Else Cam.dExposureTime = ExpTime If FrameMode = 0 Then FrameMode = 2 Cam.FrameMode = FrameMode Cam.lExposureDelay = ExpDelay Cam.Resolution = Resolution - 1 Filter.MoveTo(Filter + 1) FileName = Object + "_" + Describe Cam.SetObjectName(FileName) Cam.TakePicture() End If ImageCount = ImageCount + 1 If delta <> 0 Then If delta < 0 Then RF.actOut Else RF.actIn End If End If Call PromptOnError(ErrorOccurred) Next End Sub Sub Park Dim RA, DEC Tele.GetRaDec() RA = Tele.dRa DEC = Tele.dDec Tele.SlewToRaDec RA + 2, DEC, "" u.WaitForMilliseconds 10000 Tele.Park() 'Park the telescope End Sub Sub CoolerOff If Maxim Then Cam.TemperatureSetpoint = 20 Else Cam.dTemperatureSetpoint = 20 Index = timer u.WaitForMilliseconds 60000 If Maxim Then Cam.CoolerOn = False Else Cam.TemperatureRegulation = 0 End Sub Sub DisconnectObjects() TheSky.Disconnect() Tele.Disconnect() If Not Maxim Then Cam.SetObjectName("") 'Clear CCDSoft filename assignment Cam.Disconnect() Filter.Disconnect() End If End Sub Sub DeleteObjects() Set TheSky = Nothing Set Tele = Nothing Set Cam = Nothing If Not Maxim Then Set Filter = Nothing Set u = Nothing Set RF = Nothing End Sub