#! /usr/bin/perl -w use strict; use warnings; use OLE; use Win32; use Win32::OLE; use Win32::OLE::Variant; BEGIN { push @INC, 'D:\\MyDocuments\\Development\\Libraries\\Perl' }; # A script to drive Maxim DL blurred guiding. # When doing photometry with a short focal length scope the star images are not adequately sampled. # By continually shifting the guide star the stars in the image can be blurred. # assume the user has already chosen a guide star and started guiding. # Versioning # 2.0 updated to warn user if guider not running # shortened the period between nudges to 2s to better distribute flux in shorter exposures use constant CAMERADRIVER => "Maxim.CCDCamera"; use constant FL => 405; # main scope focal length use constant fl => 200; # guide scope focal length use constant PX => 5.4; # imaging camera pixel size in microns use constant px => 5.4; # guider camera pixel size in microns use constant BLUR => 1.5; # desired FWHM of stars in imaging camera use constant FREQ => 5000; # interval in ms between guider movements use constant TRUE => 1; use constant FALSE => 0; # Variables my ( $camera ); # calculate the required guider movement to give desired blur my $scale = BLUR * (PX/px) * (fl/FL) / 2; printf "Main Scope FL: %5.3fmm\n Main Camera Pixel Size: %5.2fmicrons\n Guidescope FL: %5.3fmm\n Guide Camera Pixel Size: %5.2fmicrons\n\n Blur ratio: %5.2f\n\n Corrections every: %5.2fs\n", FL, PX, fl, px, $scale, FREQ/1000; # test array - to ensure guider responds correctly to movements and doesn't correct them out # my @posns = ([0,0], [5,0], [5,5], [0,5]); # in case I need absolute positions # my @moves = ([5,0], [0,-5], [-5,0], [0,5]); # in case I need differential positions # 3x3 array # my @posns = ([0,0], [-1,1], [0,1], [1,1], [1,0], [1,-1], [0,-1], [-1,-1], [-1,0], [0,0]); # my @moves = ([-1,1], [1,0], [1,0], [0,-1], [0,-1], [-1,0], [-1,0], [0,1], [1,0]) # 5x5 array $scale /= 2; # need to reduce scale by 50% to account for 5x5 array is twice as large # my @posns = ([0,0], [0,1], [1,1], [1,0], [1,-1], [0,-1], [-1,-1], [-1,0], [-1,1], [-1,2], [0,2], [1,2], [2,1], [2,0], [2,-1], [1,-2], [0,-2], [-1,-2], [-2,-1], [-2,0], [-2,1], [0,0]); my @moves = ([0,1], [1,0], [0,-1], [0,-1], [-1,0], [-1,0], [1,0], [1,0], [1,0], [0,1], [0,1], [1,-1], [0,-1], [0,-1], [-1,-1], [-1,0], [-1,0], [-1,1], [0,1], [0,1], [2,-1]); # initialize the camera object &CameraInit; printf "Camera initialization completed.\n"; my $index = 0; # index into the moves or posns array my $posnCount = @moves; # check that Maxim is autoguiding if(!$camera->GuiderRunning()){ printf("\aMaxim autoguiding is not running! Start autoguiding with Maxim and restart this script.\n\a"); Win32::MsgBox("Autoguider not running!", MB_ICONSTOP, "Restart"); exit; } while($camera->GuiderRunning()){ pause(FREQ); printf "Index: %2i %2i %2i\n", $index, $moves[$index][0], $moves[$index][1]; my $x = $camera->GuiderXStarPosition() + $scale * $moves[$index][0]; my $y = $camera->GuiderYStarPosition() + $scale * $moves[$index][1]; $camera->GuiderMoveStar( $x,$y ); printf "Moving to %8.3f,%8.3f\n", $x, $y; $index++; $index %= $posnCount; } ############################################################################### sub CameraInit{ # initialize the camera - windows specific functions isolated to a function print "Initializing the Camera\n"; $camera = CreateObject OLE CAMERADRIVER or die "Unable to create camera object: $!"; $camera->{DisableAutoShutdown} = TRUE; $camera->{LinkEnabled} = TRUE; pause(2000); if( ! $camera->LinkEnabled ) { Win32::MsgBox( "Camera link failed.", 0 ,"CCD Camera Test Script" ); } # pause to allow Maxim to initialize fully pause(1000); } ############################################################################### sub pause { # small function to isolate the windows sleep function my $duration = shift; # in millisec Win32::Sleep( $duration ); }