! EncZoomArtifTest.scr ! Encoded Zoom Artifact Test ! Measures the Zoom Calibrate Artifact to assess accuracy and repeatability of magnifications. ! ----------------------------------------------------------------------------------------------- loadsub "EncZoomGlob.scr" loadsub "EncZoomSdoGlob.scr" loadsub "EncZoomArtifGlob.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$ & " Artifact Test \n\n" msg$ = msg$ & " This will test calibration by measuring the artifact. \n\n" msg$ = msg$ & " Requires the following: \n" msg$ = msg$ & " Interference cavity with centered artifact and TF \n" msg$ = msg$ & " Minimized tilt fringes \n" msg$ = msg$ & " Good focus \n\n" msg$ = msg$ & " Requires these 11 mask files set to fit the corresponding zones: \n" msg$ = msg$ & " EncZoomArtifZ01.mas \n" msg$ = msg$ & " ... \n" msg$ = msg$ & " EncZoomArtifZ11.mas \n\n" msg$ = msg$ & " The following control must be set: \n" msg$ = msg$ & " Artif Test Iterations \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$ = "Artifact Test" gosub SET_STATUS_MSG_1 gosub LOG_DATE_TIME_MSG ! ----------------------------------------------------------------------------------------------- gosub GET_ARTIF_TEST_NUM_ITERATIONS ! Sets var TestIterations% if TestIterations% <= 0 then msg$ = " The Artif Test Num Iterations control value must be >= 1 " gosub SHOW_ERROR_DIALOG stop endif ! ----------------------------------------------------------------------------------------------- SettlingTimeWait = 1.0 ! seconds ! ----------------------------------------------------------------------------------------------- NumSweepSteps% = (2 * NumArtifZones%) - 1 ! ----------------------------------------------------------------------------------------------- dim OutputFn$[999] OutputFn$ = DataFolder$ & "\\" & "ArtifTest.csv" if WarnBeforeOverwritingFiles% = 1 then fn$ = OutputFn$ gosub DOES_FILE_EXIST ! Uses var fn$, sets var fileExists% if fileExists% <> 0 then msg$ = " OK to 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" line$ = "Encoded Zoom Artifact Calibration Test" output @OutputFp; line$ ! Column Headings ! Column values will come from these vars: ! TimeStamp, TargMag, ActZoomMag, ZoomMagErr, ZoomMagDir%, OuterDiam, ZonePoints% line$ = "" line$ = line$ & "Time (sec)" line$ = line$ & ", Target Zoom Mag" line$ = line$ & ", Actual Zoom Mag" line$ = line$ & ", Zoom Mag Error" line$ = line$ & ", Zoom Mag Dir" line$ = line$ & ", Outer Diam (pix)" line$ = line$ & ", Region Points" output @OutputFp; line$ ! ----------------------------------------------------------------------------------------------- OuterDiamSum = 0 OuterDiamCount% = 0 OuterDiamMax = -99999 OuterDiamMin = 99999 ! ----------------------------------------------------------------------------------------------- dim LightLevelPctAry(NumArtifZones%) for ArtifZone% = 1 to NumArtifZones% LightLevelPctAry(ArtifZone%) = 0 next ArtifZone% ! ----------------------------------------------------------------------------------------------- StartTime = timedate ! ----------------------------------------------------------------------------------------------- gosub OPEN_MODULATION_MAP_WINDOW gosub SET_CONTROLS_FOR_TEST ! ----------------------------------------------------------------------------------------------- for IterIndex% = 1 to TestIterations% if (IterIndex% mod 2) = 1 then gosub ZOOM_MAG_SWEEP_INCREASING else gosub ZOOM_MAG_SWEEP_DECREASING endif next IterIndex% ! ----------------------------------------------------------------------------------------------- gosub SET_CONTROLS_BACK_TO_NORMAL ! ----------------------------------------------------------------------------------------------- if OuterDiamCount% > 0 then line$ = "" output @OutputFp; line$ OuterDiamMean = OuterDiamSum / OuterDiamCount% OuterDiamRange = OuterDiamMax - OuterDiamMin OuterDiamError = 100.0 * OuterDiamRange / OuterDiamMean ofmtr("%9.3f") line$ = "" line$ = line$ & "OuterDiamMean = " & val$(OuterDiamMean) & " pix\n" line$ = line$ & "OuterDiamMax = " & val$(OuterDiamMax) & " pix\n" line$ = line$ & "OuterDiamMin = " & val$(OuterDiamMin) & " pix\n" line$ = line$ & "OuterDiamRange = " & val$(OuterDiamRange) & " pix\n" line$ = line$ & "OuterDiamError = " & val$(OuterDiamError) & "%\n" output @OutputFp; line$ endif ! ----------------------------------------------------------------------------------------------- assign @OutputFp to "" ! ----------------------------------------------------------------------------------------------- ofmtr("%.2f") msg$ = "Artifact Test done, R = " & val$(OuterDiamError) & "%, details in file " & OutputFn$ gosub SET_STATUS_MSG_2 gosub LOG_DATE_TIME_MSG ! ----------------------------------------------------------------------------------------------- if quietFlag% = 0 then msg$ = " Artifact Test done \n" ofmtr("%.2f") msg$ = msg$ & " R = " & val$(OuterDiamError) & "% \n" msg$ = msg$ & " Details in file " & OutputFn$ & " \n" gosub SHOW_MESSAGE_DIALOG endif ! ----------------------------------------------------------------------------------------------- gosub SET_SCRIPT_STATUS_PASS ! ----------------------------------------------------------------------------------------------- end ! ----------------------------------------------------------------------------------------------- ZOOM_MAG_SWEEP_INCREASING: ZoomMagDir% = 1 for ArtifZone% = 1 to NumArtifZones% TargMag = ArtifZoneZoomMag(ArtifZone%) gosub SETUP_AND_MEASURE next ArtifZone% return ! ----------------------------------------------------------------------------------------------- ZOOM_MAG_SWEEP_DECREASING: ZoomMagDir% = -1 for ArtifZone% = NumArtifZones% to 1 step -1 TargMag = ArtifZoneZoomMag(ArtifZone%) gosub SETUP_AND_MEASURE next ArtifZone% return ! ----------------------------------------------------------------------------------------------- SETUP_AND_MEASURE: ofmti("%d") ofmtr("%g") msg$ = "Iteration " & val$(IterIndex%) & " of " & val$(TestIterations%) if ZoomMagDir% = 1 then msg$ = msg$ & ", Increasing" else msg$ = msg$ & ", Decreasing" endif msg$ = msg$ & ", Zone " & val$(ArtifZone%) msg$ = msg$ & ", Mag = " & val$(TargMag) gosub SET_STATUS_MSG_2 loadmasks(ArtifZoneMaskFile$(ArtifZone%)) if LightLevelPctAry(ArtifZone%) <> 0 then LightLevelPct = LightLevelPctAry(ArtifZone%) 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_ARTIF_ZONE gosub GET_LIGHT_LEVEL_PCT ! Sets var LightLevelPct LightLevelPctAry(ArtifZone%) = LightLevelPct gosub GET_DATA_ZOOM_MAG ! Sets var DataZoomMag ActZoomMag = DataZoomMag ZoomMagErr = ActZoomMag - TargMag gosub GET_DATA_OUTER_DIAM ! Sets var DataOuterDiam (in pixels) OuterDiam = DataOuterDiam gosub GET_DATA_POINTS ! Sets var DataPoints ZonePoints% = DataPoints TimeStamp = timedate - StartTime line$ = "" ofmtr("%6.0f") line$ = line$ & val$(TimeStamp) 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$(DataOuterDiam) ofmti("%9d") line$ = line$ & ", " & val$(ZonePoints%) output @OutputFp; line$ OuterDiamSum = OuterDiamSum + DataOuterDiam OuterDiamCount% = OuterDiamCount% + 1 if OuterDiam > OuterDiamMax then OuterDiamMax = OuterDiam endif if OuterDiam < OuterDiamMin then OuterDiamMin = OuterDiam endif return ! ----------------------------------------------------------------------------------------------- SET_CONTROLS_FOR_TEST: ! Use a small value for Target Range so that AGC is tight TargetRange = 0.05 gosub SET_TARGET_RANGE ! Sets control using var TargetRange ! Use a large value for Min Area Size to exclude any slivers of adjacent zones MinAreaSize = 5000 gosub SET_MIN_AREA_SIZE ! Sets control using var MinAreaSize return ! ----------------------------------------------------------------------------------------------- SET_CONTROLS_BACK_TO_NORMAL: TargetRange = 0.20 gosub SET_TARGET_RANGE ! Sets control using var TargetRange MinAreaSize = 7 gosub SET_MIN_AREA_SIZE ! Sets control using var MinAreaSize return ! ----------------------------------------------------------------------------------------------- loadsub "EncZoomSubs.scr" loadsub "EncZoomSdoSubs.scr" ! -----------------------------------------------------------------------------------------------