! EncZoomMeasRaw.scr ! Measure raw data used to calibrate magnifications ! ----------------------------------------------------------------------------------------------- loadsub "EncZoomGlob.scr" loadsub "EncZoomSdoGlob.scr" ! ----------------------------------------------------------------------------------------------- gosub CLR_STATUS_MSG_2 gosub SET_SCRIPT_STATUS_FAIL ! ----------------------------------------------------------------------------------------------- gosub GET_LOWER_PROG_LIMIT ! Gets control value into var LowerProgLimit gosub GET_UPPER_PROG_LIMIT ! Gets control value into var UpperProgLimit if UpperProgLimit <= LowerProgLimit then msg$ = " Incorrect Lower Prog Limit and/or Upper Prog Limit control values. " gosub SHOW_ERROR_DIALOG stop endif ! ----------------------------------------------------------------------------------------------- gosub GET_1X_POS ! Gets 1X Pos control value into var OneXPos if OneXPos <= 0 then msg$ = " The 1X Pos control has not been set. " gosub SHOW_ERROR_DIALOG stop endif ! ----------------------------------------------------------------------------------------------- ! NumCalPos% is the number of positions we will measure NumCalPos% = 50 ! ----------------------------------------------------------------------------------------------- ! Erase contents of existing raw cal data file (and make sure file is writable) assign @fp to RawCalDataFile$ "w" assign @fp to "" ! ----------------------------------------------------------------------------------------------- ! Disable firmware backlash compensation gosub SDO_DISABLE_BACKLASH_COMP ! ----------------------------------------------------------------------------------------------- ! Disable internal program move limits gosub CLEAR_PROG_LIMITS_CALINFO ! ----------------------------------------------------------------------------------------------- ! Find lower limit msg$ = "Finding lower limit" gosub SET_STATUS_MSG_2 TargPos = 0 gosub SET_ZOOM_POS_AND_IGNORE_ERRORS ! Uses var TargPos gosub GET_CUR_POS_AVG ! Sets var CurPos LowerHardLimit = CurPos ! ----------------------------------------------------------------------------------------------- ! Delete any masks, and if this is an MST app, make a cal marker gosub DELETE_MASKS_AND_MAKE_CAL_MARKER_FOR_MST ! ----------------------------------------------------------------------------------------------- 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 circular acquisition mask to fit data runscript(0, "EncZoomSetMask.scr") gosub VERIFY_SCRIPT_STATUS_PASS gosub SET_SCRIPT_STATUS_FAIL ! ----------------------------------------------------------------------------------------------- ! Set first and last positions ! Want the first move to take up any backlash FirstPos = LowerHardLimit + BacklashCompMax ! But FirstPos must be below OneXPos OneXPosEpsilon = 100 if FirstPos > (OneXPos - OneXPosEpsilon) then FirstPos = OneXPos - OneXPosEpsilon endif LastPos = UpperProgLimit ! ----------------------------------------------------------------------------------------------- ! Calculate position step PosStep = (LastPos - FirstPos) / (NumCalPos% - 1) ! ----------------------------------------------------------------------------------------------- ! Set dimensions of arrays dim TargPosAry(NumCalPos%) dim ActualPosAry(NumCalPos%) dim PosErrorAry(NumCalPos%) dim MeasPvAry(NumCalPos%) dim GenPvAry(NumCalPos%) ! ----------------------------------------------------------------------------------------------- ! Prepare array of target positions TargPos = FirstPos for PosIndex% = 1 to NumCalPos% TargPosAry(PosIndex%) = TargPos TargPos = TargPos + PosStep next PosIndex% ! ----------------------------------------------------------------------------------------------- gosub MEASURE_RAW_CAL_DATA ! Uses vars NumCalPos%, TargPosAry() ! Sets vars ActualPosAry(), PosErrorAry(), MeasPvAry() and GenPvAry() ! ----------------------------------------------------------------------------------------------- gosub SAVE_RAW_CAL_DATA ! Uses vars RawCalDataFile$, NumCalPos%, TargPosAry(), ! ActualPosAry(), PosErrorAry(), MeasPvAry() and GenPvAry() ! ----------------------------------------------------------------------------------------------- msg$ = "Saved file " & RawCalDataFile$ gosub SET_STATUS_MSG_2 ! ----------------------------------------------------------------------------------------------- gosub SET_SCRIPT_STATUS_PASS ! ----------------------------------------------------------------------------------------------- end ! ----------------------------------------------------------------------------------------------- MEASURE_RAW_CAL_DATA: ! Uses vars NumCalPos%, TargPosAry() ! Sets vars ActualPosAry(), PosErrorAry(), MeasPvAry() and GenPvAry() ! Set controls to support fitting a zernike plane to current data, then generating that plane GenCamRes = 0 gosub SET_ZERNIKE_PLANE_CONTROLS ! Uses var GenCamRes for PosIndex% = 1 to NumCalPos% ofmti("%d") msg$ = "Measuring raw cal data, position " & val$(PosIndex%) & " of " & val$(NumCalPos%) gosub SET_STATUS_MSG_2 TargPos = TargPosAry(PosIndex%) gosub MOVE_AND_CHECK_POS_ERROR ! Uses vars TargPos and PosErrorTol, sets vars CurPos and PosError ActualPos = CurPos ActualPosAry(PosIndex%) = ActualPos PosErrorAry(PosIndex%) = PosError gosub MEASURE_WITH_RETRY gosub GET_DATA_PV_TR ! Gets result value into var DataPv (in fr) MeasPvAry(PosIndex%) = DataPv gosub GENERATE_ZERNIKE_PLANE gosub GET_DATA_PV_TR ! Gets result value into var DataPv GenPvAry(PosIndex%) = DataPv next PosIndex% return ! ----------------------------------------------------------------------------------------------- loadsub "EncZoomSubs.scr" loadsub "EncZoomSdoSubs.scr" ! -----------------------------------------------------------------------------------------------