! EncZoomSetWL.scr ! Set Wand Limits ! Measures wand over-travel relative to soft limit ! then calculates wand limit values relative to prog limits. ! ----------------------------------------------------------------------------------------------- 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$ & " Set Wand Limits \n\n" msg$ = msg$ & " This will set limits for wand moves. \n\n" msg$ = msg$ & " No interference cavity is required. \n\n" msg$ = msg$ & " The following controls must be set correctly: \n" msg$ = msg$ & " Lower Prog Limit \n" msg$ = msg$ & " Upper Prog Limit \n" msg$ = msg$ & " 1X Pos \n\n" msg$ = msg$ & " The following controls will be set: \n" msg$ = msg$ & " Lower Wand Limit \n" msg$ = msg$ & " Upper Wand Limit \n\n" msg$ = msg$ & " This will take about 2 minutes. \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$ = "Set Wand Limits" gosub SET_STATUS_MSG_1 gosub LOG_DATE_TIME_MSG ! ----------------------------------------------------------------------------------------------- StartTime = timedate ! ----------------------------------------------------------------------------------------------- ! NumIter% is the number of iterations. ! One iteration consists of: ! Move DOWNARD to hit lower soft limit and get over-travel. ! Move UPWARD to hit upper soft limit and get over-travel. NumIter% = 10 ! ----------------------------------------------------------------------------------------------- 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 ! ----------------------------------------------------------------------------------------------- dim OutputFn$[999] OutputFn$ = DataFolder$ & "\\" & "WandLimits.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" ! ----------------------------------------------------------------------------------------------- ! Save the old control values gosub GET_LOWER_WAND_LIMIT ! Gets control value into var LowerWandLimit gosub GET_UPPER_WAND_LIMIT ! Gets control value into var UpperWandLimit OldLowerWandLimit = LowerWandLimit OldUpperWandLimit = UpperWandLimit ! Reset the controls to zero LowerWandLimit = 0 UpperWandLimit = 0 gosub SET_LOWER_WAND_LIMIT ! Sets control using var LowerWandLimit gosub SET_UPPER_WAND_LIMIT ! Sets control using var UpperWandLimit ! ----------------------------------------------------------------------------------------------- ! Disable firmware backlash compensation gosub SDO_DISABLE_BACKLASH_COMP ! ----------------------------------------------------------------------------------------------- ! Disable internal program move limits gosub CLEAR_PROG_LIMITS_CALINFO ! ----------------------------------------------------------------------------------------------- ! Disable firmware soft limits gosub SDO_DISABLE_SOFT_LIMITS ! ----------------------------------------------------------------------------------------------- ! Use program move to start at approx middle position TargPos = MidPos msg$ = "Moving to approx middle position" gosub SET_STATUS_MSG_2 gosub SET_ZOOM_POS_AND_IGNORE_ERRORS ! Uses var TargPos ! ----------------------------------------------------------------------------------------------- ! Set firmware soft limits inside of program limit positions LowerSoftLimit% = LowerProgLimit + 2000 UpperSoftLimit% = UpperProgLimit - 2000 gosub SDO_SET_LOWER_SOFT_LIMIT ! Uses var LowerSoftLimit% gosub SDO_SET_UPPER_SOFT_LIMIT ! Uses var UpperSoftLimit% ! ----------------------------------------------------------------------------------------------- line$ = "Measurements of wand over-travel when hitting soft limits" output @OutputFp; line$ ! ----------------------------------------------------------------------------------------------- ofmtr("%.0f") line$ = "LowerProgLimit = " & val$(LowerProgLimit) output @OutputFp; line$ line$ = "UpperProgLimit = " & val$(UpperProgLimit) output @OutputFp; line$ ofmti("%d") line$ = "LowerSoftLimit = " & val$(LowerSoftLimit%) output @OutputFp; line$ line$ = "UpperSoftLimit = " & val$(UpperSoftLimit%) output @OutputFp; line$ ! ----------------------------------------------------------------------------------------------- ! Column Headings ! Column values will come from these vars: ! IterIndex%, LowerOT(), UpperOT line$ = "" line$ = line$ & "Index" line$ = line$ & ", Lower End Pos" line$ = line$ & ", Lower OT" line$ = line$ & ", Upper End Pos" line$ = line$ & ", Upper OT" output @OutputFp; line$ ! ----------------------------------------------------------------------------------------------- dim LowerEndPos%(NumIter%) dim LowerOT%(NumIter%) dim UpperEndPos%(NumIter%) dim UpperOT%(NumIter%) ! ----------------------------------------------------------------------------------------------- for IterIndex% = 1 to NumIter% ofmti("%d") msg$ = "Iteration " & val$(IterIndex%) & " of " & val$(NumIter%) msg$ = msg$ & ", moving to lower soft limit" gosub SET_STATUS_MSG_2 gosub SDO_WAND_ZOOM_DOWN_TO_LIMIT gosub GET_CUR_POS_AVG ! Sets var CurPos LowerEndPos%(IterIndex%) = CurPos LowerOT%(IterIndex%) = LowerSoftLimit% - CurPos ofmti("%d") msg$ = "Iteration " & val$(IterIndex%) & " of " & val$(NumIter%) msg$ = msg$ & ", moving to upper soft limit" gosub SET_STATUS_MSG_2 gosub SDO_WAND_ZOOM_UP_TO_LIMIT gosub GET_CUR_POS_AVG ! Sets var CurPos UpperEndPos%(IterIndex%) = CurPos UpperOT%(IterIndex%) = CurPos - UpperSoftLimit% ofmti("%d") line$ = val$(IterIndex%) line$ = line$ & ", " & val$(LowerEndPos%(IterIndex%)) line$ = line$ & ", " & val$(LowerOT%(IterIndex%)) line$ = line$ & ", " & val$(UpperEndPos%(IterIndex%)) line$ = line$ & ", " & val$(UpperOT%(IterIndex%)) output @OutputFp; line$ next IterIndex% ! ----------------------------------------------------------------------------------------------- MaxLowerOT% = 0 MaxUpperOT% = 0 for IterIndex% = 1 to NumIter% OT% = LowerOT%(IterIndex%) if OT% > MaxLowerOT% then MaxLowerOT% = OT% endif OT% = UpperOT%(IterIndex%) if OT% > MaxUpperOT% then MaxUpperOT% = OT% endif next IterIndex% ! ----------------------------------------------------------------------------------------------- ofmtr("%d") line$ = "Max lower over-travel = " & val$(MaxLowerOT%) output @OutputFp; line$ line$ = "Max upper over-travel = " & val$(MaxUpperOT%) output @OutputFp; line$ ! ----------------------------------------------------------------------------------------------- LowerWandLimit = LowerProgLimit + MaxLowerOT% if LowerWandLimit > OneXPos then LowerWandLimit = OneXPos endif UpperWandLimit = UpperProgLimit - MaxUpperOT% ! ----------------------------------------------------------------------------------------------- ofmtr("%.0f") line$ = "Lower Wand Limit = " & val$(LowerWandLimit) output @OutputFp; line$ line$ = "Upper Wand Limit = " & val$(UpperWandLimit) output @OutputFp; line$ ! ----------------------------------------------------------------------------------------------- assign @OutputFp to "" ! ----------------------------------------------------------------------------------------------- ! Set the controls gosub SET_LOWER_WAND_LIMIT ! Uses var LowerWandLimit gosub SET_UPPER_WAND_LIMIT ! Uses var UpperWandLimit ! ----------------------------------------------------------------------------------------------- ! Disable the firmware soft limits gosub SDO_DISABLE_SOFT_LIMITS ! ----------------------------------------------------------------------------------------------- ofmtr("%.0f") msg$ = "Set Wand Limits done" msg$ = msg$ & ", old = [" & val$(OldLowerWandLimit) & "," & val$(OldUpperWandLimit) & "]" msg$ = msg$ & ", new = [" & val$(LowerWandLimit) & "," & val$(UpperWandLimit) & "]" gosub SET_STATUS_MSG_2 gosub LOG_DATE_TIME_MSG ! ----------------------------------------------------------------------------------------------- ElapsedTime = timedate - StartTime ! ----------------------------------------------------------------------------------------------- if quietFlag% = 0 then msg$ = " Set Wand Limits done \n" ofmtr("%5.0f") msg$ = msg$ & " Old = [" & val$(OldLowerWandLimit) & "," & val$(OldUpperWandLimit) & "] \n" msg$ = msg$ & " New = [" & val$(LowerWandLimit) & "," & val$(UpperWandLimit) & "] \n" ofmtr("%.1f") msg$ = msg$ & " Elapsed time = " & val$(ElapsedTime/60) & " min " gosub SHOW_MESSAGE_DIALOG endif ! ----------------------------------------------------------------------------------------------- gosub SET_SCRIPT_STATUS_PASS ! ----------------------------------------------------------------------------------------------- end ! ----------------------------------------------------------------------------------------------- loadsub "EncZoomSubs.scr" loadsub "EncZoomSdoSubs.scr" ! -----------------------------------------------------------------------------------------------