! EncZoomPMTest.scr ! Program Move Calibration Test ! Measures program move repeatability. ! Sweeps zoom mag over the calibrated range using program moves. ! Measures interferogram to assess accuracy/repeatability of magnifications. ! Length of test is controlled by the Prog Move Test Iterations custom control. ! ! Pseudo-code description of process: ! FOR IterIndex = 1 to NumIter ! Set zoom mags from low to high and back, ! measure at each zoom mag, ! and log results ! NEXT I ! ! Set up a plano cavity. ! Set a circular acquisition mask to be just inside fringe pattern boundary at zoom lower limit. ! Perform lateral calibration. ! Adjust tilt for lots of fringes - at zoom lower limit the PV should measure about 150 fringes. ! ----------------------------------------------------------------------------------------------- loadsub "EncZoomGlob.scr" loadsub "EncZoomSdoGlob.scr" ! ----------------------------------------------------------------------------------------------- gosub GET_QUIET_FLAG ! Sets var quietFlag% ! ----------------------------------------------------------------------------------------------- gosub CLR_STATUS_MSG_ALL gosub SET_SCRIPT_STATUS_FAIL ! ----------------------------------------------------------------------------------------------- if quietFlag% = 0 then msg$ = "" msg$ = msg$ & " Prog Move Test \n\n" msg$ = msg$ & " This will test the calibration of program moves. \n\n" msg$ = msg$ & " Requires the following: \n" msg$ = msg$ & " Plano interference cavity \n" msg$ = msg$ & " Tilt between " & val$(CalMinTiltPv) & " and " & val$(CalMaxTiltPv) & " fringes at lowest zoom mag \n\n" msg$ = msg$ & " The following controls must be set: \n" msg$ = msg$ & " Apert Diam \n" msg$ = msg$ & " Prog Move Test Iterations (recommended >= 2) \n\n" msg$ = msg$ & " If this is an MST app, the 2S Cav Length Scan control must be Off. \n\n" msg$ = msg$ & " This will take about 10 to 15 minutes per iteration. \n\n" msg$ = msg$ & " Do you want to continue? " msgtype% = 6 gosub SHOW_DIALOG ! Uses vars msg$ and msgtype%, sets var ok% if ok% = 0 then stop endif endif ! ----------------------------------------------------------------------------------------------- msg$ = "Prog Move Test" gosub SET_STATUS_MSG_1 gosub LOG_DATE_TIME_MSG ! ----------------------------------------------------------------------------------------------- gosub GET_APERT_DIAM ! Gets control value into var ApertDiam in millimeters if ApertDiam <= 0 then msg$ = " The Apert Diam control value must be >= 0 " gosub SHOW_ERROR_DIALOG stop endif ! ----------------------------------------------------------------------------------------------- gosub GET_PROG_MOVE_TEST_ITERATIONS ! Gets control value into var TestIterations% if TestIterations% <= 0 then msg$ = " The Prog Move Test Iterations control value must be >= 1 " gosub SHOW_ERROR_DIALOG stop endif ! ----------------------------------------------------------------------------------------------- ! If this is an MST app, verify that the 2S Cav Length Scan control is Off. gosub VERIFY_MST_2S_CAV_LEN_SCAN_OFF ! ----------------------------------------------------------------------------------------------- ! Specify either NumTargMags% OR TargMagStep ! If NumTargMags% > 0, then TargMagStep is calculated instead of using this constant value. NumTargMags% = 50 TargMagStep = 0.5 ! ----------------------------------------------------------------------------------------------- SettlingTimeWait = 1.0 ! seconds ! ----------------------------------------------------------------------------------------------- ! Get the program limit cal values TargMagMin = getgpizoommin(1) if TargMagMin = 0 then msg$ = " The Lower Prog Limit cal value is zero " gosub SHOW_ERROR_DIALOG stop endif TargMagMax = getgpizoommax(1) if TargMagMax = 0 then msg$ = " The Upper Prog Limit cal value is zero " gosub SHOW_ERROR_DIALOG stop endif ! ----------------------------------------------------------------------------------------------- if NumTargMags% > 0 then TargMagStep = (TargMagMax - TargMagMin) / (NumTargMags% - 1) else NumTargMags% = int((TargMagMax - TargMagMin) / TargMagStep) + 1.5 endif ! ----------------------------------------------------------------------------------------------- dim OutputFn$[999] OutputFn$ = DataFolder$ & "\\" & "ProgMoveTest.csv" if WarnBeforeOverwritingFiles% = 1 then fn$ = OutputFn$ gosub DOES_FILE_EXIST ! Uses var fn$, sets var fileExists% if fileExists% <> 0 then msg$ = " Overwrite file " & fn$ & " ? " on error goto DIALOG_ESCAPED ok% = dialog(msg$, 6) off error if ok% = 0 then stop endif endif endif assign @OutputFp to OutputFn$ "w" ! ----------------------------------------------------------------------------------------------- ! Delete any masks, and if this is an MST app, make a cal marker gosub DELETE_MASKS_AND_MAKE_CAL_MARKER_FOR_MST ! ----------------------------------------------------------------------------------------------- msg$ = "Moving to lower prog limit" gosub SET_STATUS_MSG_2 TargMag = TargMagMin gosub SET_ZOOM_MAG_WITH_RETRY ! Uses var TargMag ! ----------------------------------------------------------------------------------------------- VALIDATE_CAVITY_SETUP: msg$ = "Measuring to validate cavity setup" gosub SET_STATUS_MSG_2 gosub MEASURE_WITH_RETRY gosub CLR_STATUS_MSG_2 gosub GET_DATA_PV_TR ! Gets result value into var DataPv (in fringes) if (DataPv < CalMinTiltPv) or (DataPv > CalMaxTiltPv) then msg$ = " Adjust tilt to obtain PV between " ofmtr("%.0f") msg$ = msg$ & val$(CalMinTiltPv) & " and " & val$(CalMaxTiltPv) msg$ = msg$ & " fringes at lowest zoom mag. \n" msg$ = msg$ & " Click YES to retry or NO to stop. \n" msgtype% = 5 gosub SHOW_DIALOG ! Uses vars msg$ and msgtype%, sets var ok% if ok% = 1 then goto VALIDATE_CAVITY_SETUP else stop endif endif ! ----------------------------------------------------------------------------------------------- ! Set camera resolution gosub GET_DATA_OUTER_DIAM ! Gets result value into var DataOuterDiam in pixels GenCamRes = ApertDiam / DataOuterDiam setcamres(GenCamRes, "mm") ! ----------------------------------------------------------------------------------------------- ! Set circular acquisition mask to fit data runscript(0, "EncZoomSetMask.scr") gosub VERIFY_SCRIPT_STATUS_PASS gosub SET_SCRIPT_STATUS_FAIL ! ----------------------------------------------------------------------------------------------- dim TargMagAry(NumTargMags%) dim LightLevelPctAry(NumTargMags%) TargMag = TargMagMin for MagIndex% = 1 to NumTargMags% TargMagAry(MagIndex%) = TargMag LightLevelPctAry(MagIndex%) = 0 TargMag = TargMag + TargMagStep if TargMag > TargMagMax then TargMag = TargMagMax endif next MagIndex% ! ----------------------------------------------------------------------------------------------- NumSweepSteps% = (2 * NumTargMags%) - 1 ! ----------------------------------------------------------------------------------------------- line$ = "Program Move Calibration Test" output @OutputFp; line$ ! Column Headings ! Column values will come from these vars: ! LogIndex%, Date$, Time$, ElapsedTime%, TargMag, ActZoomMag, ZoomMagErr, ZoomMagDir%, TiltMag, DataPv, ScaledPv line$ = "" line$ = line$ & "Index" line$ = line$ & ", Date" line$ = line$ & ", Time" line$ = line$ & ", ET (sec)" line$ = line$ & ", Target Zoom Mag" line$ = line$ & ", Actual Zoom Mag" line$ = line$ & ", Zoom Mag Error" line$ = line$ & ", Zoom Mag Dir" line$ = line$ & ", Tilt Mag (urad)" line$ = line$ & ", PV (fr)" line$ = line$ & ", Scaled PV (fr)" output @OutputFp; line$ ! ----------------------------------------------------------------------------------------------- TiltMagSum = 0 TiltMagCount% = 0 TiltMagMax = -99999 TiltMagMin = 99999 ScaledPvSum = 0 ScaledPvCount% = 0 ScaledPvMax = -99999 ScaledPvMin = 99999 ! ----------------------------------------------------------------------------------------------- ! Set controls to support fitting a zernike plane to current data, then generating that plane gosub SET_ZERNIKE_PLANE_CONTROLS ! Uses var GenCamRes ! ----------------------------------------------------------------------------------------------- StartTime = timedate ! ----------------------------------------------------------------------------------------------- LogIndex% = 0 for IterIndex% = 1 to TestIterations% gosub ZOOM_MAG_SWEEP next IterIndex% ! ----------------------------------------------------------------------------------------------- TiltMagMean = TiltMagSum / TiltMagCount% TiltMagRange = TiltMagMax - TiltMagMin TiltMagError = 100.0 * TiltMagRange / TiltMagMean ofmtr("%9.3f") line$ = "" line$ = line$ & "TiltMagMean = " & val$(TiltMagMean) & " urad\n" line$ = line$ & "TiltMagMax = " & val$(TiltMagMax) & " urad\n" line$ = line$ & "TiltMagMin = " & val$(TiltMagMin) & " urad\n" line$ = line$ & "TiltMagRange = " & val$(TiltMagRange) & " urad\n" line$ = line$ & "TiltMagError = " & val$(TiltMagError) & "%\n" output @OutputFp; line$ ! ----------------------------------------------------------------------------------------------- ScaledPvMean = ScaledPvSum / ScaledPvCount% ScaledPvRange = ScaledPvMax - ScaledPvMin ScaledPvError = 100.0 * ScaledPvRange / ScaledPvMean ofmtr("%9.3f") line$ = "" line$ = line$ & "ScaledPvMean = " & val$(ScaledPvMean) & " fr\n" line$ = line$ & "ScaledPvMax = " & val$(ScaledPvMax) & " fr\n" line$ = line$ & "ScaledPvMin = " & val$(ScaledPvMin) & " fr\n" line$ = line$ & "ScaledPvRange = " & val$(ScaledPvRange) & " fr\n" line$ = line$ & "ScaledPvError = " & val$(ScaledPvError) & "%\n" output @OutputFp; line$ ! ----------------------------------------------------------------------------------------------- assign @OutputFp to "" ! ----------------------------------------------------------------------------------------------- ofmtr("%.2f") msg$ = "Program Move Test done, R = " & val$(TiltMagError) & ", see " & OutputFn$ gosub SET_STATUS_MSG_2 ! ----------------------------------------------------------------------------------------------- msg$ = "Prog Move Test done" gosub LOG_DATE_TIME_MSG ofmtr("%.2f") msg$ = "R = " & val$(TiltMagError) & "%" gosub LOG_MSG msg$ = "Results in file " & OutputFn$ gosub LOG_MSG ! ----------------------------------------------------------------------------------------------- if quietFlag% = 0 then msg$ = " Prog Move Test Result \n" ofmtr("%.2f") msg$ = msg$ & " R = " & val$(TiltMagError) & "% \n" msg$ = msg$ & " Details in file " & OutputFn$ & " " gosub SHOW_MESSAGE_DIALOG endif ! ----------------------------------------------------------------------------------------------- gosub SET_SCRIPT_STATUS_PASS ! ----------------------------------------------------------------------------------------------- end ! ----------------------------------------------------------------------------------------------- ZOOM_MAG_SWEEP: SweepIndex% = 0 ZoomMagDir% = 0 MagIndex% = 1 ZOOM_MAG_SWEEP_INCREASING_LOOP: TargMag = TargMagAry(MagIndex%) SweepIndex% = SweepIndex% + 1 gosub SET_ZOOM_AND_MEASURE MagIndex% = MagIndex% + 1 ZoomMagDir% = 1 if MagIndex% <= NumTargMags% then goto ZOOM_MAG_SWEEP_INCREASING_LOOP endif MagIndex% = NumTargMags% ZoomMagDir% = 0 ZOOM_MAG_SWEEP_DECREASING_LOOP: TargMag = TargMagAry(MagIndex%) SweepIndex% = SweepIndex% + 1 gosub SET_ZOOM_AND_MEASURE MagIndex% = MagIndex% - 1 ZoomMagDir% = -1 if MagIndex% >= 1 then goto ZOOM_MAG_SWEEP_DECREASING_LOOP endif return ! ----------------------------------------------------------------------------------------------- SET_ZOOM_AND_MEASURE: ofmti("%d") ofmtr("%g") msg$ = "Iteration " & val$(IterIndex%) & " of " & val$(TestIterations%) msg$ = msg$ & ", Step " & val$(SweepIndex%) & " of " & val$(NumSweepSteps%) msg$ = msg$ & ", Mag = " & val$(TargMag) gosub SET_STATUS_MSG_2 if LightLevelPctAry(MagIndex%) <> 0 then LightLevelPct = LightLevelPctAry(MagIndex%) gosub SET_LIGHT_LEVEL_PCT ! Uses var LightLevelPct endif gosub SET_ZOOM_MAG_WITH_RETRY ! Uses var TargMag if SettlingTimeWait > 0 then wait SettlingTimeWait endif gosub MEASURE_WITH_RETRY gosub GET_LIGHT_LEVEL_PCT ! Gets control value into var LightLevelPct LightLevelPctAry(MagIndex%) = LightLevelPct gosub GET_DATA_ZOOM_MAG ! Gets attribute value into var DataZoomMag ActZoomMag = DataZoomMag ZoomMagErr = ActZoomMag - TargMag ! Get TltMag result from Test+Ref Map gosub GET_DATA_TILT_MAG_TR ! Gets result value into var DataTiltMag (in urad) TiltMag = DataTiltMag gosub GENERATE_ZERNIKE_PLANE ! Get PV result from Test+Ref Map gosub GET_DATA_PV_TR ! Gets result value into var DataPv (in fr) ScaledPv = TargMag * DataPv LogIndex% = LogIndex% + 1 t = timedate Date$ = date$(t) Time$ = time$(t) ElapsedTime% = t - StartTime line$ = "" ofmti("%d") line$ = line$ & val$(LogIndex%) line$ = line$ & ", " & Date$ line$ = line$ & ", " & Time$ line$ = line$ & ", " & val$(ElapsedTime%) ofmtr("%9.6f") line$ = line$ & ", " & val$(TargMag) line$ = line$ & ", " & val$(ActZoomMag) line$ = line$ & ", " & val$(ZoomMagErr) ofmti("%2d") line$ = line$ & ", " & val$(ZoomMagDir%) ofmtr("%9.3f") line$ = line$ & ", " & val$(TiltMag) line$ = line$ & ", " & val$(DataPv) line$ = line$ & ", " & val$(ScaledPv) output @OutputFp; line$ TiltMagSum = TiltMagSum + TiltMag TiltMagCount% = TiltMagCount% + 1 if TiltMag > TiltMagMax then TiltMagMax = TiltMag endif if TiltMag < TiltMagMin then TiltMagMin = TiltMag endif ScaledPvSum = ScaledPvSum + ScaledPv ScaledPvCount% = ScaledPvCount% + 1 if ScaledPv > ScaledPvMax then ScaledPvMax = ScaledPv endif if ScaledPv < ScaledPvMin then ScaledPvMin = ScaledPv endif return ! ----------------------------------------------------------------------------------------------- loadsub "EncZoomSubs.scr" loadsub "EncZoomSdoSubs.scr" ! -----------------------------------------------------------------------------------------------