' Maxim DL Script to take a sequence of CCD images ' with binning and filter wheel control ' J C Moore ' Last Update 07 May 2008 ' NB VBS Strings are 1 based, but Arrays 0 based! ' Note the path needs to be set absolutely otherwise it sometimes fails: Root = "d:\Scripts\" Telescope = "105SDHF" wsv = WScript.Version ' Needed for sleep function Dim cam ' Camera object Set cam = CreateObject("MaxIm.CCDCamera") cam.DisableAutoShutdown = True cam.LinkEnabled = True If Not cam.LinkEnabled Then MsgBox "Can't connect to camera!", vbCritical+vbOK, Camera_Name wscript.Quit End If cam.ShowWindow(True) Camera_Name = cam.CameraName Dim fso ' File System Object Set fso = CreateObject("Scripting.FileSystemObject") ObjectName = InputBox("Object Name (e.g. m51)", Camera_Name) If ObjectName = "" Then wscript.Quit End If Path = Root & ObjectName & "\" If Not fso.FolderExists(Path) Then fso.CreateFolder(Path) End If MsgBox "Saving in " & Path, vbOK, Camera_Name ' Discover how many filters are fitted and in which positions: Dim Filter_Letter(10) Dim Exposures(10) Dim Binnings(10) Filter_Names = cam.FilterNames NFilters = UBound(Filter_Names) FNames = "" For i = 0 to NFilters-1 FL = Left(Filter_Names(i), 1) If FL <> "F" Then Filter_Letter(i) = FL FNames = FNames + Filter_letter(i) End If Next MsgBox "Available Filters are " & FNames, vbOK, Camera_Name ' Get required sequence of exposures and check it: Done = False Do Until Done Used_Filters = "" Sequence = InputBox("Filter Sequence (e.g. LLRGB)", Camera_Name) Done = True If Sequence = "" Then wscript.Quit End If Sequence = UCase(Sequence) For i = 1 To Len(Sequence) F = Mid(Sequence,i,1) ' Required Filter Letter If InStr(FNames, F) = 0 Then MsgBox "Filter " & F & " Not Available!", vbOK, Camera_Name Done = False End If If InStr(Used_Filters, F) = 0 Then Used_Filters = Used_Filters + F End If Next Loop ' Create sub directories for each filter used: For i = 1 to Len(Used_Filters) F = Mid(Used_Filters,i,1) FPath = Path & F If Not fso.FolderExists(FPath) Then fso.CreateFolder(FPath) End If Next ' Get Exposure details for each filter required: For i = 0 To Len(Sequence)-1 F = Mid(Sequence,i+1,1) Exposures(i) = InputBox("Exposure for " & F & " filter (seconds)", Camera_Name) If Exposures(i) = "" Then wscript.Quit End If Binnings(i) = InputBox(" Binning for " & F & " filter (1,2 or 3)", Camera_Name) If Binnings(i) = "" Then wscript.Quit End If Next NLoops = InputBox("Number of iterations ",Camera_Name) If MsgBox("Start Sequence?",vbQuestion+vbOKCancel,Camera_Name) <> vbOK Then wscript.Quit End If Dim Serial(10) For i = 0 to 9 Serial(i) = 1 ' 1 for each used filter Next ' Now take the exposures and save each image in its appropriate directory: For i = 1 To Nloops For j = 0 To len(Sequence)-1 Required_Filter_Letter = Mid(Sequence,j+1,1) For k = 0 to NFilters-1 If Required_Filter_Letter = Filter_Letter(k) Then Filter_Number = k End If Next Index = InStr(Used_Filters, Required_Filter_Letter)-1 SNum = Serial(Index) Serial(Index) = SNum + 1 Binning = Binnings(j) Exposure= Exposures(j) cam.BinX = Binning cam.BinY = Binning ' not all cameras need this cam.SetFullFrame ' undocumented bug needs this cam.Expose Exposure, 1, Filter_Number ' Light Frame NS = CStr(SNum) ' Serial Number FileName = ObjectName & "_" & Required_Filter_Letter & "_" & Left("000",3-Len(NS)) & NS & ".fit" Do While Not cam.ImageReady If wsv >= "5.1" Then wscript.sleep 100 ' release CPU for 100mS End If Loop cam.Document.DisplayName = FileName cam.SetFITSKey "OBJECT", ObjectName cam.SetFITSKey "TELESCOP", Telescope If Not (cam.SaveImage(Path & Required_Filter_Letter & "\" & FileName)) Then wscript.echo "Failed to save image." End If Next Next