9 Drift

Example 9. Drift

 
MacroName Drift
####################################################################
# Drift.txt
# by Chen Xu at 10/11/2011
# Update @ 2014-10-22 10:33:17
# Modified from the original code by David M
####################################################################
#
# A macro to measure drift rate, if good, skip to the end of loop. 
# Otherwise, exit execution -- i.e. skip the point. 

Echo ===> Running Drift ...

#=============
# parameters 
#=============
## drift rate threshold
# crit = 2
# set these above from centralized macro - Parameters 
Call Parameters
shot = F
interval = 15
times = 10

period = $interval + 1
#SuppressReports
#ResetClock 

$shot
Delay $interval
Loop $times index
$shot
AlignTo B
ReportAlignShift
ClearAlignment
dx = $reportedValue3
dy = $reportedValue4
dist = sqrt $dx * $dx + $dy * $dy
rate = $dist / $period * 10	
#ReportClock
echo Rate = $rate A/sec
echo ----------------

If $rate < $crit
    echo Drift is low enough after shot $index      
    break
Elseif  $index < $times
    Delay $interval
Else
    echo Drift never got below $crit: Skipping ...
    exit   
Endif
EndLoop

This macro is modified from David's original macro "drift control". I made it to output drifting rate as angstrom instead of nanometer. And I use "exit" in the loop.

This macro can be used as standalone or be called from main macro. It measures drifting rate, when the threshold is reached, it jumps to the end of this macro using "break". If the threshold can be reached for number of times, it exits this macro to end or if being called from main macro it exits to the end of the main macro - skip this point.

This macro is to be called right before final exposure. It is also useful with direct detector camera. We use higher threshold to avoid initial drifting is too big, even with movie mode.