Rem HiddenScript.m1s (2021/02/23) Rem programming #7, #16, #17, #27, #37, 100-833 Rem VBScript To center probe inside the edge-finder hole, And On Any edge rem Vancura Innovations 2006/10/30 creation Date; (copyright 2006 - 2020) rem 9010 33rd ST W rem Rock Island, IL 61201 rem (309) 235-1069 rem edgefinder@vancura.biz rem CAUTION: Do Not change Any Line marked With Dim Or REM! rem NOTE: User changable parameters start at Line 105 rem revisions: rem 2020/06/05: Fcn 8 add large hole ZXY rem 2020/05/09: patch To fcn 8 rem 2019/10/18: More Speedy fixup Fcn 7 incorporated Fcn17 & 27 Rem 2019/09/20: Added speedy FCN-17 & FCN-27 setup Rem 2019/09/05: Fixed Z operation On Fcn 7 Rem 2019/06/12: Put feed rate On same Line As G0 And G31 commands; Fixed fcn 6 three Read Rem 2019/06/15: major Mod To Seek edges ' Option Explicit ' this forces programmer to list all variables ' Dim tool_1 As Double ' Favorite tool #1 size Dim tool_2 As Double ' Favorite tool #2 size Dim tool_3 As Double ' Favorite tool #3 size Dim SIDE_X As Double ' finder side width X Dim SIDE_Y As Double ' finder side width Y Dim CENTER_X As Double ' Center of hole offset X Dim CENTER_Y As Double ' Center of hole offset Y Dim CNTR_2_X As Double ' Center of hole offset X Dim CNTR_2_Y As Double ' Center of hole offset Y Dim Z_TOP1 As Double ' Top of edgefinder #1 to workpiece surface Dim Z_TOP2 As Double ' Top of edgefinder #2 to workpiece surface Dim BigMove As Double ' about 1" (25.4mm) move probe this distance looking for edge Dim SmallMove As Double ' about 0.100" (2.54mm) clearance over material Dim FeedSlow As Double ' 4in/min or 100mm/min; Faster sacrifices accuracy, slower increases boredom Dim FeedFast As Double ' 10 x FeedSlow Faster sacrifices accuracy, slower increases boredom Dim safeZ As Double ' === change safe Z height; should clear work-piece ' ==================================================== Dim toolsize As Double ' tool diameter Dim touchoffsetX As Double ' tool + side thickness Dim touchoffsetY As Double ' tool + side thickness Dim FeedCurrent As Double ' feed speed being used Dim Xoffset As Double ' position information Dim Yoffset As Double ' position information Dim XCurrent As Double ' position information Dim YCurrent As Double ' position information Dim ZCurrent As Double ' position information Dim XCenter As Double ' calculated center Dim YCenter As Double ' calculated center Dim ZTOP As Double Dim ZTOP_GOAL As Double ' Desired setting after touch off Dim XNew As Double ' destination of next move Dim YNew As Double ' destination of next move Dim ZNew As Double ' destination of next move Dim XPos1 As Double ' saved temp position Dim YPos1 As Double ' saved temp position Dim ZPos1 As Double ' saved temp position Dim XPos2 As Double ' saved temp position Dim YPos2 As Double ' saved temp position Dim ZPos2 As Double ' saved temp position Dim XAvg As Double ' saved temp value Dim YAvg As Double ' saved temp value Dim ZAvg As Double ' saved temp value Dim XSave As Double ' saved temp value Dim YSave As Double ' saved temp value Dim ZSave As Double ' saved temp value Dim Temp As Double Dim SpeedSetup17_tool As Double Dim SpeedSetup17_finderX As Double Dim SpeedSetup17_finderY As Double Dim SpeedSetup17_top As Double Dim SpeedSetup27_tool As Double Dim SpeedSetup27_finderX As Double Dim SpeedSetup27_finderY As Double Dim SpeedSetup27_top As Double Dim max_error As Double ' allowed max error for a good reading Dim UnitsMode As Double ' 0- Metric, 1 = Inch Dim TopFlag As Double ' 0=Finder 1= Workpiece Dim mymode As Double ' selection: for action; answer to question Dim mytoolsize As Double ' Answer to question Dim myanswer As Double ' Answer to question Dim mySide As Double ' Answer to question Dim toolSelected As Double Dim HoleSelected As Double Dim DefaultTool As Double Dim DefaultHeight As Double Dim DefaultSideX As Double Dim DefaultSideY As Double Dim DefaultHoleX As Double Dim DefaultHoleY As Double Dim Zsel As Double Dim cmd1 As Integer Dim cmd2 As Integer Dim cmd3 As Integer Dim cmd4 As Integer ' Dim RetryLimit As Integer ' Loop retry limit Dim LoopCount As Integer ' Loop retry limit Dim xstr As String ' ' ================================================================= ' ===== CODE STARTS HERE ========================================= ' ================================================================= ' Sub Main ' xstr = " This is a test string." ' Quest(xstr) code "G52 X0.0 Y0.0 Z0.0" UnitsMode = 7 ' === Dummy value to detect a read error === UnitsMode = GetParam("Units") ' === Determine if Metric (0) or English (1) mode RetryLimit = 3 ' === Loop Retry limit === ' If UnitsMode = 0 Then ' === Set Metric Parameters === ' ======================================================= ' ====== CHANGE HERE to set METRIC mode parameters ====== ' ======================================================= Code "(Operating in mm mode.)" tool_1 = 2.380 ' 3/32" = 2.380mm Favorite tool #1 size tool_2 = 3.175 ' 1/8" = 3.175mm Favorite tool #2 size tool_3 = 6.35 ' 1/4" = 6.350mm Favorite tool #3 size SIDE_X = 7.720 ' 0.300" = 7.720mm finder side width both X SIDE_Y = 7.720 ' 0.300" = 7.720mm finder side width both Y CENTER_X = 00.000 ' mm Center of hole offset X CENTER_Y = 00.000 ' mm Center of hole offset Y CNTR_2_X = 12.7 ' mm Center of large hole X CNTR_2_Y = 12.7 ' mm Center of large hole Y Z_TOP1 = 3.81 ' mm Top of edgefinder to workpiece surface Z_TOP2 = 6.35 ' mm Top of edgefinder to workpiece surface BigMove = 24.0 ' mm move probe this distance looking for edge SmallMove = 2.54 ' 0.100" = 2.540mm clearance over material FeedSlow = 100 ' 4in/min or 100mm/min Faster sacrifices accuracy, slower max_error = 0.025 ' 0.001" = 0.025mm ' ElseIf UnitsMode = 1 Then ' === set INCH mode parameters === ' ======================================================= ' ======= CHANGE HERE to set INCH mode parameters ======= ' ======================================================= Code "(Operating in INCH mode.)" tool_1 = 0.0937 ' 3/32" = 2.380mm Favorite tool #1 size tool_2 = 1/8 ' 1/8" = 3.175mm Favorite tool #2 size tool_3 = 1/4 ' 1/4" = 6.350mm Favorite tool #3 size SIDE_X = 0.300 ' 0.300" = 7.720mm finder side width both X SIDE_Y = 0.300 ' 0.300" = 7.720mm finder side width both Y CENTER_X = 0.000 ' inches Center hole offset X CENTER_Y = 0.000 ' inches Center hole offset Y CNTR_2_X = 0.500 ' inches Center of large hole X CNTR_2_Y = 0.500 ' inches Center of large hole Y Z_TOP1 = 0.150 ' inches Top of edgefinder to workpiece surface Z_TOP2 = 0.250 ' inches Top of edgefinder to workpiece surface BigMove = 1.000 ' 1.000" = 25.400mm move probe this distance looking for edge SmallMove = 0.100 ' 0.100" = 2.540mm clearance over material FeedSlow = 4.000 ' 4in/min or 100mm/min Faster sacrifices accuracy, slower max_error = 0.001 ' 0.001" = 0.025mm ' Else Code "(Major Error: Cannot determine if INCH or MM mode.)" Exit Sub ' === if system mode is not zero or one then quit === End If ' ================================================================= While IsMoving() 'Force a display update to show mm/INCH mode Sleep(1) 'Sleep give other processes time to run Wend 'An empty while/wend loop takes almost 100% of computer time ' ' === M Y D E F A U L T I T E M S === DefaultTool = tool_2 DefaultHeight = Z_TOP1 DefaultSideX = SIDE_X DefaultSideY = SIDE_Y HoleSelected = 1 ' 1=Small 2=large hole; (all else)=default DefaultHoleX = CENTER_X DefaultHoleY = CENTER_Y ' ' # 7 & 17 Without finder SpeedSetup17_tool = tool_2 ' speedy setup selector fcn-17 SpeedSetup17_finderX = 0.0 ' speedy setup selector fcn-17 SpeedSetup17_finderY = 0.0 ' speedy setup selector fcn-17 SpeedSetup17_top = 0.0 ' speedy setup selector fcn-17 ' # 7 & 27 With finder SpeedSetup27_tool = tool_2 ' speedy setup selector fcn-27 SpeedSetup27_finderX = SIDE_X ' speedy setup selector fcn-27 SpeedSetup27_finderY = SIDE_Y ' speedy setup selector fcn-27 SpeedSetup27_top = Z_TOP1 ' speedy setup selector fcn-27 safeZ = SmallMove ' === change safe Z height; should clear work-piece FeedFast = FeedSlow * 10 ' === Faster sacrifices accuracy, slower increases boredom ' =============================================================================== ' === P L E A S E D O N O T C H A N G E C O D E B E L O W H E R E === ' =============================================================================== rem rem === program will Not run If probe is shorted === If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty Code "(Probe is grounded, check clearance and try again)" Else ' === module works in only one mode === If GetOemLed (16) <> 0 Then 'Warning Wrong Coordinate system DoOEMButton(107) Code "(Changing to Normal DRO Mode)" Code "G4 P0.25" ' === Pause 1/4 sec === End If DoSpinStop ' === double check motor is not running === Xoffset = SmallMove Yoffset = SmallMove toolsize = (tool_2)/2 ' === 1/8" tool default tool size === ' === ask user to select an operation to perform. === 'mymode = Question ("0=Q 1,8=CTR 2=XL 3=YL 4=XH 5=YH 6=Z 7=XYZ") mymode = Question ("Enter command #, 0 to Quit, or 999 for HELP.") ' Character count 1 ^10 ^20 ^30 ^40 ' If mymode = 0 Then ' === zero quits without doing anything === Code "(0 = Quit)" Exit Sub End If ' === ask more questions if not finding center or Z=0 === If ((mymode = 1) Or (mymode = 8) Or (mymode = 11)) Then ' === do nothing here === ElseIf mymode = 6 Or mymode = 16 Then ' mytoolsize = Question ("Top Offset: 0=None; 1=" & Z_TOP1 &"; 2="& Z_TOP2 &"; 3=More") ' Finder thickness ' If mytoolsize = 0 Then ZTOP_GOAL = 0 ' Find Workpiece Top' ElseIf mytoolsize = 1 Then ZTOP_GOAL = Z_TOP1 ' Find edge finder 1 Top' ElseIf mytoolsize = 2 Then ZTOP_GOAL = Z_TOP2 ' Find edge finder 2 Top' ElseIf mytoolsize = 3 Then ' More Options myanswer = Question ("Enter Finder Thickness: 0=Quit") If (myanswer <=0) Then Exit Sub Else ZTOP_GOAL = (myanswer) End If Else Exit Sub ' QUIT allow only 1, 2, & 3 End If ' ElseIf (((mymode >= 2) And (mymode < 7)) Or (mymode = 12) Or (mymode = 13) Or (mymode = 14) Or (mymode = 15)) Then mytoolsize = Question ("Probe Diam: 0=Quit; 1="& tool_1 & "; 2=" & tool_2 & "; 3=More") If (mytoolsize = 1) Then toolsize = (tool_1) /2 ElseIf (mytoolsize = 2) Then toolsize = (tool_2) /2 ElseIf (mytoolsize = 3) Then myanswer = Question ("Enter Probe Diameter: 0=Quit") If (myanswer <=0) Then Exit Sub Else toolsize = (myanswer) /2 End If Else 'If (mytoolsize <= 0) Then Exit Sub End If ' mySide = Question ("Edge Compensation: 0=quit 1=EdgeFinder 2=None") ' Character count 1 ^10 ^20 ^30 ^40 If mySide = 2 Then touchoffsetX = toolsize ' Touch to work_piece touchoffsetY = toolsize ' Touch to work_piece Code "(Using Offset for Work Piece)" ElseIf mySide = 1 Then touchoffsetX = toolsize + SIDE_X ' Touch to edgefinder touchoffsetY = toolsize + SIDE_Y ' Touch to edgefinder Code "(Using Offset for Edge Finder)" Else Exit Sub End If ElseIf (mymode = 7) Then myanswer = Question ("1=Finder_Fast, 2=Work-piece_Fast, 3=Manual") If (myanswer = 2) Then ' To the work piece touchoffsetX = SpeedSetup17_tool/2 + SpeedSetup17_finderX ' Touch to edgefinder touchoffsetY = SpeedSetup17_tool/2 + SpeedSetup17_finderY ' Touch to edgefinder ZTOP_GOAL = SpeedSetup17_top myanswer = Question ("Ready? 0=NO 1-2=YES") If myanswer <= 0 Then Exit Sub ElseIf (myanswer =1) Then ' To the Edge finder touchoffsetX = SpeedSetup27_tool/2 + SpeedSetup27_finderX ' Touch to edgefinder touchoffsetY = SpeedSetup27_tool/2 + SpeedSetup27_finderY ' Touch to edgefinder ZTOP_GOAL = SpeedSetup27_top myanswer = Question ("Ready? 0=NO 1-2=YES") If myanswer <= 0 Then Exit Sub ElseIf (myanswer = 3) Then ' Custom setup mytoolsize = Question ("Probe Diam: 0=Quit; 1="& tool_1 & "; 2=" & tool_2 & "; 3=More") If (mytoolsize = 1) Then toolsize = (tool_1) /2 ElseIf (mytoolsize = 2) Then toolsize = (tool_2) /2 ElseIf (mytoolsize = 3) Then myanswer = Question ("Enter Probe Diameter: 0=Quit") If (myanswer <=0) Then Exit Sub Else toolsize = (myanswer) /2 End If Else 'If (mytoolsize <= 0) Then Exit Sub End If mytoolsize = Question ("Top Offset: 0=None; 1=" & Z_TOP1 &"; 2="& Z_TOP2 &"; 3=More") ' Finder thickness ' If mytoolsize = 0 Then ZTOP_GOAL = 0 ' Find Workpiece Top' ElseIf mytoolsize = 1 Then ZTOP_GOAL = Z_TOP1 ' Find edge finder 1 Top' ElseIf mytoolsize = 2 Then ZTOP_GOAL = Z_TOP2 ' Find edge finder 2 Top' ElseIf mytoolsize = 3 Then ' More Options myanswer = Question ("Enter Finder Thickness: 0=Quit") If (myanswer <=0) Then Exit Sub Else ZTOP_GOAL = (myanswer) End If Else Exit Sub ' QUIT allow only 1, 2, & 3 End If Else Exit Sub End If ElseIf mymode = 8 Then ' === XYZ with center hole === touchoffsetX = DefaultTool + SIDE_X ' Touch to edgefinder touchoffsetY = DefaultTool + SIDE_Y ' Touch to edgefinder ZTOP_GOAL = Z_TOP1 ElseIf (mymode = 17) Then ' === Without EdgeFinder === touchoffsetX = SpeedSetup17_tool/2 + SpeedSetup17_finderX ' Touch to Surface touchoffsetY = SpeedSetup17_tool/2 + SpeedSetup17_finderY ' Touch to Surface ZTOP_GOAL = SpeedSetup17_top ElseIf (mymode = 27 Or mymode = 37) Then touchoffsetX = SpeedSetup27_tool/2 + SpeedSetup27_finderX ' Touch to edgefinder touchoffsetY = SpeedSetup27_tool/2 + SpeedSetup27_finderY ' Touch to edgefinder ZTOP_GOAL = SpeedSetup27_top ElseIf (Int(mymode/100) <= 0) Or (mymode > 1000) Then Exit Sub Else cmd1 = Int(mymode/100) cmd2 = Int((mymode - cmd1*100)/10) cmd3 = mymode - cmd1*100 - cmd2*10 End If ' FeedCurrent = GetOemDRO(818) 'Get the current settings code "G52 X0 Y0 Z0" XCurrent = GetOEMDRO(800) ' location of tool X position YCurrent = GetOEMDRO(801) ' location of tool Y position ZCurrent = GetOEMDRO(802) ' location of tool Z position Code "G4 P1" 'Pause 1 second to give time to position probe plate '======================================== If (cmd1 > 0) And (cmd1 < 9) Then Go_Mode_100 ' returns with cmd1 End If '=========================================== If (mymode = 1 Or mymode = 11 Or cmd1 = 1) Then ' === FIND CENTER OF HOLE) === ' If (mymode = 1 Or mymode = 8 Or mymode = 11 Or cmd1 = 1) Then ' === FIND CENTER OF HOLE) === Go_Mode_1 '=================================== ElseIf ((mymode = 2) Or (mymode = 12) Or (cmd1 = 2)) Then '=================================== Go_Mode_2 '=================================== ElseIf ((mymode = 3) Or (mymode = 13) Or (cmd1 = 3)) Then Go_Mode_3 '=================================== ElseIf ((mymode = 4) Or (mymode = 14) Or (cmd1 = 4)) Then Go_Mode_4 '=================================== ElseIf ((mymode = 5) Or (mymode = 15) Or (cmd1 = 5)) Then Go_Mode_5 '=================================== ElseIf ((mymode = 6) Or (mymode = 16) Or (cmd1 = 6)) Then '==== Z TOP ==== Go_Mode_6 '=================================== ElseIf mymode=7 Or mymode=17 Or mymode=27 Or cmd1= 7 Then '==== X Y Z ==== Go_Mode_7 '=================================== ElseIf mymode = 8 Or mymode = 37 Or cmd1 = 8 Then ' === XYZ with center hole === Go_Mode_8 '=================================== ElseIf cmd1 = 9 Then ' === Help === Go_Mode_9 '=================================== ElseIf mymode = 9 Then ' === Dummy routine === toolsize = (tool_2) /2 '=================================== '=================================== End If '=================================== Rem: === Restore original feedrate === Code "G01 F" &FeedCurrent ' This does not move but does set the Feedrate back to original While IsMoving() 'Wait for stop signal Sleep(1) Wend If(LoopCount > RetryLimit) Then ' see if process timed out Code "(=== DONE === Caution Retry limit was exceeded ===)" Else Code "(=== SUCCESS DONE ===)" End If End If End Sub ' Sub Main() ' ============================ ' === E N D O F M A I N === ' ============================ ' ' ========================================================= ' ========================================================= ' ========= S T A R T O F S U B R O U T I N E S ========= ' ========================================================= ' ========================================================= Sub Go_Mode_1 ' ========================================================= ' ========================================================= If mymode = 1 Then ' text message on screen Code "(Mode 1: Find Hole Center and SET X and Y DROs to zero.)" Else Code "(Mode 8: Find Hole Center and Show Position)" End If Rem Move Probe X Minus XCurrent = GetOEMDRO(800) ' location of tool X position XPos2 = GetOEMDRO(800) ' get the probe start location LoopCount = 0 ' set retry count to zero ' ===== go in X MINUS direction ===== Do XPos1 = XPos2 XNew = Xcurrent - BigMove 'Move probe (1 inch) MINUS Code "G31 X" &XNew & " F" &FeedSlow 'hunt for touch While IsMoving() 'wait for the move to finish Sleep(1) Wend XPos2 = GetOEMDRO(800) 'get the probe touch location ' XAvg = (Abs(XPos1 - XPos2)) Temp = (XCurrent + XPos2*4)/5 Code "G01 X" &Temp & " F" &FeedFast 'rapid move back to start point LoopCount = LoopCount + 1 'update loop count Loop Until ((XAvg < max_error) Or (LoopCount > RetryLimit)) XSave = ((XPos1 + XPos2) / 2) ' ' ===== go in X PLUS direction ===== Code "G01 X" &XCurrent & " F" &FeedFast 'rapid move back to start point XPos2 = GetOEMDRO(800) ' get the probe Start location LoopCount = 0 ' set retry count to zero Do XPos1 = XPos2 XNew = Xcurrent + BigMove 'Move probe (1 inch) PLUS Code "G31 X" &XNew & " F" &FeedSlow 'hunt for touch While IsMoving() 'wait for the move to finish Sleep(1) Wend XPos2 = GetOEMDRO(800) 'get the probe touch location ' XAvg = Abs(XPos1 - XPos2) Temp = (XCurrent + XPos2*4)/5 Code "G01 X" &Temp & " F" &FeedFast 'rapid move back to start point LoopCount = LoopCount + 1 'update loop count ' Loop Until ((XAvg < max_error) Or (LoopCount > RetryLimit)) ' XCenter = (XSave + ((XPos1 + XPos2) / 2)) / 2 'center is midway between XSave and XPos2 Code "G01 X" &XCenter &" F" &FeedFast 'rapid move to the x center location While IsMoving () 'Wait for stop signal Sleep(1) Wend If (mymode = 1 or cmd1 = 1) Then SetOEMDRO(800,0.000) 'Zero out the location X End If Code "G4 P0.25" 'Pause 1/4 sec ' ====================================== Rem ===== Find Center In Y direction ===== ' ====================================== YCurrent = GetOEMDRO(801) ' location of tool Y position YPos2 = GetOEMDRO(801) ' get the probe start location LoopCount = 0 ' set retry count to zero ' ===== go in Y MINUS direction ===== Do YPos1 = YPos2 ' YNew = Ycurrent - BigMove 'Move probe (1 inch) MINUS Code "G31 Y" &YNew & " F" &FeedSlow 'hunt for touch While IsMoving() 'wait for the move to finish Sleep(1) Wend YPos2 = GetOEMDRO(801) 'get the probe touch location ' YAvg = (Abs(YPos1 - YPos2)) Temp = (YCurrent + YPos2*4)/5 Code "G01 Y" &Temp & " F" &FeedFast 'rapid move back to start point LoopCount = LoopCount + 1 'update loop count Loop Until ((YAvg < max_error) Or (LoopCount > RetryLimit)) YSave = ((YPos1 + YPos2) / 2) ' ' ===== go in Y PLUS direction ===== Code "G01 Y" &YCurrent & " F" &FeedFast 'rapid move back to start point YPos2 = GetOEMDRO(801) ' get the probe Start location LoopCount = 0 ' set retry count to zero Do YPos1 = YPos2 YNew = Ycurrent + BigMove 'Move probe (1 inch) PLUS Code "G31 Y" &YNew & " F" &FeedSlow 'hunt for touch While IsMoving() 'wait for the move to finish Sleep(1) Wend YPos2 = GetOEMDRO(801) 'get the probe touch location ' YAvg = Abs(YPos1 - YPos2) Temp = (YCurrent + YPos2*4)/5 Code "G01 Y" &Temp & " F" &FeedFast 'rapid move back to start point LoopCount = LoopCount + 1 'update loop count Loop Until ((YAvg < max_error) Or (LoopCount > RetryLimit)) ' YCenter = (YSave + ((YPos1 + YPos2) / 2)) / 2 'center is midway between YSave and YPos2 Code "G01 Y" &YCenter &" F" &FeedFast 'rapid move to the Y center location While IsMoving () 'Wait for stop signal Sleep(1) Wend If (mymode = 1 or cmd1 = 1) Then SetOEMDRO(801,0.000) 'Zero out the location Y End If Code "G4 P0.25" 'Pause 1/4 sec ' Rem ================================================== Rem === Do X center again For better accuracy. ======= Rem ================================================== XCurrent = GetOEMDRO(800) ' location of tool X position XPos2 = GetOEMDRO(800) ' get the probe start location LoopCount = 0 ' set retry count to zero ' ===== go in X MINUS direction ===== Do XPos1 = XPos2 'Latest reading is now older reading XNew = Xcurrent - BigMove 'Move probe (1 inch) MINUS Code "G31 X" &XNew & " F" &FeedSlow 'hunt for touch While IsMoving() 'wait for the move to finish Sleep(1) Wend XPos2 = GetOEMDRO(800) 'get the probe touch location ' XAvg = Abs(XPos1 - XPos2) Temp = (XCurrent + XPos2*4)/5 Code "G01 X" &Temp & " F" &FeedFast 'rapid move back to start point LoopCount = LoopCount + 1 'update loop count Loop Until ((XAvg < max_error) Or (LoopCount > RetryLimit)) XSave = ((XPos1 + XPos2) / 2) ' ' ===== go in X PLUS direction ===== Code "G01 X" &XCurrent & " F" &FeedFast 'rapid move back to start point XPos2 = GetOEMDRO(800) ' get the probe Start location LoopCount = 0 ' set retry count to zero Do XPos1 = XPos2 XNew = Xcurrent + BigMove 'Move probe (1 inch) PLUS Code "G31 X" &XNew & " F" &FeedSlow 'hunt for touch While IsMoving() 'wait for the move to finish Sleep(1) Wend XPos2 = GetOEMDRO(800) 'get the probe touch location ' XAvg = Abs(XPos1 - XPos2) Temp = (XCurrent + XPos2*4)/5 Code "G01 X" &Temp & " F" &FeedFast 'rapid move back to start point LoopCount = LoopCount + 1 'update loop count Loop Until ((XAvg < max_error) Or (LoopCount > RetryLimit)) ' XCenter = (XSave + ((XPos1 + XPos2) / 2)) / 2 'center is midway between XSave and XPos2 Code "G01 X" &XCenter &" F" &FeedFast 'rapid move to the x center location While IsMoving () 'Wait for stop signal Sleep(1) Wend If (mymode = 1 or cmd1 = 1) Then SetOEMDRO(800,0.000) 'Zero out the location X End If Code "G4 P0.25" 'Small Pause Rem ======================================================= Rem ===== We are done: Center the tool And Do a dance ===== Rem ======================================================= ZPos1 = GetOEMDRO(802) ' get the probe Z location as current ZNew = ZPos1 + safeZ Code "G01 Z" &ZNew ' Pop Up to indicate done While IsMoving () ' Wait for stop signal Sleep(1) Wend Code "G4 P0.1" 'Small Pause ' Code "G01 Z" &ZPos1 ' Pop back down to indicate done While IsMoving () ' Wait for stop signal Sleep(1) Wend Code "G4 P0.1" 'Small Pause ZNew = ZPos1 + (BigMove/2) Code "G01 Z" &ZNew ' Pop Up to big indicate done While IsMoving () ' Wait for stop signal Sleep(1) Wend Code "G4 P0.1" 'Small Pause Code "(=== DONE ===)" End Sub ' ========================================================= ' ========================================================= Sub Go_Mode_2 ' ========================================================= ' ========================================================= Rem === find the outside edge To minus X === If mymode = 2 Then Code "(Mode 2: Find X Left and set X DRO to zero.)" Else Code "(Mode 12: Find X Left and show position.)" End If Rem Move Probe X Plus XPos1 = 0 XCurrent = GetOEMDRO(800) ' location of tool X position LoopCount = 0 ' set count to zero Do XNew = XCurrent + BigMove 'move probe 1 inch to right Code "G31 X" &XNew &" F" &FeedSlow 'Start hunt for edge While IsMoving() 'Wait for stop signal Sleep(1) Wend XPos2 = GetOEMDRO(800) ' Get the X location ' XCenter = (XPos2) + touchoffsetX 'compensate for tool & finder edge Code "G01 X" &(XPos2-safeZ/4) &" F" &FeedFast 'rapid back away from touched surface While IsMoving() 'Wait for stop signal Sleep(1) Wend ' XAvg = Abs(Xpos1 - XCenter) ' do these positions differ XPos1 = XCenter LoopCount = LoopCount + 1 Loop Until((XAvg < max_error)Or(LoopCount > RetryLimit)) ' ZCurrent = GetOEMDRO(802) ' location of tool Z position Code "G01 Z" &(BigMove + ZCurrent)'rapid move to a safe height While IsMoving() 'Wait for stop signal Sleep(1) Wend Code "G01 X" &XCenter &" F" &FeedFast 'rapid move to the x center location While IsMoving () 'Wait for stop signal Sleep(1) Wend If (mymode = 2 or cmd1 = 2) Then SetOEMDRO(800,0.000) 'Zero the X DRO location End If Code "G4 P0.25" 'Pause 1/4 sec ' ===== End Sub ' ' ========================================================= ' ========================================================= Sub Go_Mode_3 ' ========================================================= ' ========================================================= Rem === find the outside edge To minus Y === If mymode = 3 Then Code "(Mode 3: Find Y Low and set Y DRO to zero.)" Else Code "(Mode 13: Find Y Low and show position.)" End If Rem Move Probe Y Plus YPos1 = 0 YCurrent = GetOEMDRO(801) ' location of tool X position LoopCount = 0 ' set count to zero Do YNew = YCurrent + BigMove 'move probe 1 inch to right Code "G31 Y" &YNew &" F" &FeedSlow 'Start hunt for edge While IsMoving() 'Wait for stop signal Sleep(1) Wend YPos2 = GetOEMDRO(801) 'Get the Y location ' YCenter = (YPos2) + touchoffsetY Code "G01 Y" &(YPos2-safeZ/4) &" F" &FeedFast 'rapid move to the x center location While IsMoving() 'Wait for stop signal Sleep(1) Wend ' YAvg = Abs(Ypos1 - YCenter) ' do these positions differ YPos1 = YCenter LoopCount = LoopCount + 1 Loop Until((YAvg < max_error)Or(LoopCount > RetryLimit)) ' ZCurrent = GetOEMDRO(802) ' location of tool X position Code "G01 Z" &(BigMove + ZCurrent)'rapid move to the x center location While IsMoving() 'Wait for stop signal Sleep(1) Wend Code "G01 Y" &YCenter &" F" &FeedFast 'rapid move to the x center location While IsMoving () 'Wait for stop signal Sleep(1) Wend If (mymode = 3 or cmd1 = 3) Then SetOEMDRO(801,0.000) 'Zero the Y DRO position End If Code "G4 P0.25" 'Pause 1/4 sec ' ===== End Sub ' ========================================================= ' ========================================================= Sub Go_Mode_4 ' ========================================================= ' ========================================================= Rem === find the outside edge To plus X === If mymode = 14 Then Code "(Mode 14: Find Y Max and set Y=0.0.)" Else Code "(Mode 4: Find Y Max and Show location)" End If Rem Move Probe X Minus (Move the probe In the X minus direction Until touch) XPos1 = 0 ' assume last position was zero XCurrent = GetOEMDRO(800) ' location of tool X position LoopCount = 0 ' set count to zero Do XNew = XCurrent - BigMove 'set destination 1 inch minus X Code "G31 X" &XNew &" F" &FeedSlow 'Start hunt for edge While IsMoving() 'Wait for stop signal Sleep(1) Wend XPos2 = GetOEMDRO(800) 'get the touch X location ' XCenter = XPos2 - touchoffsetX 'Calculate the actual work_piece edge location Code "G01 X" &(XPos2+safeZ/4) &" F" &FeedFast 'rapid back away from touched surface While IsMoving() 'Wait for stop signal Sleep(1) 'Allow computer to run other tasks for 1ms Wend ' XAvg = Abs(Xpos1 - XCenter) 'do these positions differ ? XPos1 = XCenter 'update last reading LoopCount = LoopCount + 1 Loop Until((XAvg < max_error)Or(LoopCount > RetryLimit)) ' ZCurrent = GetOEMDRO(802) 'location of tool Z position Code "G01 Z" &(BigMove + ZCurrent) 'rapid move UP to the Z high position While IsMoving() 'Wait for stop signal Sleep(1) Wend Code "G01 X" &XCenter &" F" &FeedFast 'move to the work_piece X edge location While IsMoving () 'Wait for stop signal Sleep(1) Wend If (mymode = 14 Or cmd1 = 14)Then SetOEMDRO(800,0.000) 'Zero the X-DRO to the work_piece edge End If Code "G4 P0.25" 'Pause 1/4 sec ' ===== End Sub ' ========================================================= ' ========================================================= Sub Go_Mode_5 ' ========================================================= ' ========================================================= Rem === find the outside edge To plus Y === If mymode = 15 Then Code "(Mode 15: Find Y Max and set Y=0.0.)" Else Code "(Mode 5: Find Y Max and Show location)" End If Rem Move Probe Y Minus 'Move the probe in the Y minus direction until touch of workPiece YPos1 = 0 ' assume last position was zero YCurrent = GetOEMDRO(801) ' location of tool X position LoopCount = 0 ' set count to zero Do YNew = YCurrent - BigMove 'set destination 1 inch minus Y Code "G31 Y" &YNew &" F" &FeedSlow 'Start hunt for edge While IsMoving() 'Wait for stop signal Sleep(1) Wend YPos2 = GetOEMDRO(801) 'Get the Y touch location ' YCenter = (YPos2) - touchoffsetY 'Calculate the actual work_piece edge location Code "G01 Y" &(YPos2+safeZ/4) &" F" &FeedFast 'rapid move to the x center location While IsMoving() 'Wait for stop signal Sleep(1) Wend ' YAvg = Abs(Ypos1 - YCenter) ' do these positions differ YPos1 = YCenter LoopCount = LoopCount + 1 Loop Until((YAvg < max_error)Or(LoopCount > RetryLimit)) ' ZCurrent = GetOEMDRO(802) ' location of tool Z position Code "G01 Z" &(BigMove + ZCurrent)'rapid move to a safe Z height While IsMoving() 'Wait for stop signal Sleep(1) Wend Code "G01 Y" &YCenter &" F" &FeedFast 'move to the workpiece Y edge location While IsMoving () 'Wait for stop signal Sleep(1) Wend If (mymode = 15 Or cmd1 = 15)Then SetOEMDRO(801,0.000) 'Zero the Y-DRO to the work_piece edge End If Code "G4 P0.25" 'Pause 1/4 sec ' ===== End Sub ' ========================================================= ' ========================================================= Sub Go_Mode_6 ' ========================================================= ' ========================================================= Rem === find the top surface Z = Zero === Code "(Mode 6: Find Z Top and Set Z DRO to zero.)" Rem Assume probe is closer than one inch from finder surface Rem ========================== Rem === Move Probe Z Minus === Rem ========================== ZSave = ZTOP_GOAL ' Preset ideal location LoopCount = 0 ' set retry count to zero Do ' === take a reading === ZNew = (ZCurrent - BigMove) ' set destination -1" (down) Code "G31 Z" &ZNew &" F" &FeedSlow 'Start probe hunt for surface While IsMoving() 'Wait for stop signal Sleep(1) 'While waiting, let other tasks run Wend Code "G4 P0.500" 'Pause 0.5 sec Let user see touch ZAvg = Abs(GetOEMDRO(802) - ZSave) 'compare this reading with desired position ZSave = GetOEMDRO(802) 'save this reading is the new goal (Touching target) ' Code "G01 Z" &(ZSave + (safeZ/4)) &" F" &FeedFast 'rapid move to the (Z + 0.1") location While IsMoving() 'Wait for stop signal Sleep(1) 'While waiting, let other tasks run Wend 'An empty while/wend loop takes 100% of computer time ' LoopCount = LoopCount + 1 'update loop count ' Loop Until((ZAvg <= max_error)Or(LoopCount > RetryLimit)) ' loop again if ZAvg is grater than max_error ' ' or until retry limit is met ' done looping Code "G01 Z" &(ZSave) &" F" &FeedFast 'rapid move to the (Z + 0.75") location While IsMoving() 'Wait for stop signal Sleep(1) 'While waiting, let other tasks run Wend ' If (mymode = 6 Or cmd1 = 6 Or cmd1 = 8 Or mymode = 37 Or mymode = 8) Then SetOEMDRO(802,ZTOP_GOAL) 'Set the DRO display to be the desired Z position Code "G01 Z" &(BigMove*0.50 + ZTOP_GOAL) &" F" &FeedFast 'rapid move to the (Z + 0.75") location While IsMoving() 'Wait for stop signal Sleep(1) 'While waiting, let other tasks run Wend End If ' End Sub ' ========================================================= ' ========================================================= Sub Go_Mode_7 ' ========================================================= ' ========================================================= Rem === find the outside edge minus X, minus Y, And Z = 0 === Code "(Mode 7: Find Edgefinder and set X, Y, and Z DROs to zero.)" ' Must be within 1 inch of the corner over the work XCurrent = GetOEMDRO(800) ' location of tool X position YCurrent = GetOEMDRO(801) ' location of tool X position ZCurrent = GetOEMDRO(802) ' location of tool X position ' ' ======================== ' ===== First find Z ===== ' ======================== LoopCount = 0 ' set retry count to zero Do ' === take a reading === ZNew = ZCurrent - BigMove 'set destination -1" (down) Code "G31 Z" &ZNew &" F" &FeedSlow 'Start probe hunt for surface While IsMoving() 'Wait for stop signal Sleep(1) 'While waiting, let other tasks run Wend Code "G4 P0.200" 'Pause 0.5 sec Let user see touch ZAvg = Abs(GetOEMDRO(802) - ZTOP_GOAL) 'compare this reading with desired position ' SetOEMDRO(802,ZTOP_GOAL) 'Set the DRO display to be the desired Z position ZCurrent = ZTOP_GOAL ' Code "G01 Z" &(ZTOP_GOAL + safeZ/4) &" F" &FeedFast 'rapid move to the (Z + 0.1") location While IsMoving() 'Wait for stop signal Sleep(1) 'While waiting, let other tasks run Wend 'An empty while/wend loop takes 100% of computer time ' LoopCount = LoopCount + 1 'update loop count ' Loop Until((ZAvg <= max_error)Or(LoopCount > RetryLimit)) ' loop again if ZAvg is grater than max_error ' ' or until retry limit is met ' done looping: === ' Code "G01 Z" &(safeZ + ZCurrent) &" F" &FeedFast 'rapid move to safe height While IsMoving() 'Wait for stop signal Sleep(1) Wend ' ======================= ' ===== Then find X ===== ' ======================= Code "G01 Z" &(safeZ + ZCurrent) &" F" &FeedFast 'rapid move to safeZ location While IsMoving() 'Wait for stop signal Sleep(1) Wend XPos1 = 0 ' assume zero is correct XNew = XCurrent - BigMove 'back off X to a reasonable distance ' YNew = YCurrent + SIDE_Y*1.5 YNew = YCurrent Code "G01 X" &XNew &" Y" &YNew &" F" &FeedFast 'rapid move to the x starting location While IsMoving() 'Wait for stop signal Sleep(1) Wend Code "G31 Z" &(ZCurrent - SmallMove) &" F" &FeedSlow*3 'move to starting height While IsMoving() 'Wait for stop signal Sleep(1) Wend ' ' === test for illegal touch === If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty Code "G01 Z" &(SafeZ+ZCurrent) &" F" &FeedFast 'move Z up to clear material While IsMoving() 'Wait for stop signal Sleep(1) Wend Code "G01 X" &(-BigMove * 0.5) &" F" &FeedFast 'rapid move to the y starting location While IsMoving() 'Wait for stop signal Sleep(1) Wend Code "G31 Z" &(ZCurrent-SmallMove) &" F" &FeedFast 'move Z down to starting height While IsMoving() 'Wait for stop signal Sleep(1) Wend End If ' Do XNew = XCurrent 'probe seek 1 inch to right Code "G31 X" &XNew &" F" &FeedSlow 'Start hunt for edge While IsMoving() 'Wait for stop signal Sleep(1) Wend XPos2 = GetOEMDRO(800) ' Get the X location ' XCenter = (XPos2) + touchoffsetX 'compensate for tool & finder edge Code "G01 X" &(XPos2-SmallMove/4) &" F" &FeedFast 'rapid back away from touched surface While IsMoving() 'Wait for stop signal Sleep(1) Wend ' XAvg = Abs(Xpos1 - XCenter) ' do these positions differ XPos1 = XCenter ' update Pos1 for next try LoopCount = LoopCount + 1 Loop Until((XAvg < max_error)Or(LoopCount > RetryLimit)) Code "G01 X" &(XPos2 -(SmallMove)) &" F" &FeedFast 'back off from work. don't scratch it. While IsMoving() 'Wait for stop signal Sleep(1) Wend Code "G01 Z" &(safeZ + ZCurrent) &" F" &FeedFast 'rapid move to the safeZ location While IsMoving() 'Wait for stop signal Sleep(1) Wend Code "G01 X" &XCenter &" F" &FeedFast 'rapid move to the workpiece X Edge location While IsMoving () 'Wait for stop signal Sleep(1) Wend SetOEMDRO(800,0.000) 'Set workpiece X edge to DRO zero XCurrent = 0.000 Code "G4 P0.25" 'Pause 1/4 sec ' ======================= ' ===== Then find Y ===== '======================== Code "G01 Z" &(safeZ+ZCurrent) &" F" &FeedFast 'rapid move to safeZ location While IsMoving() 'Wait for stop signal Sleep(1) Wend ' If mySide = 2 Then TEMP = SIDE_X * 2 Else TEMP = SIDE_X * 1.5 End If Code "G01 X" &(XCurrent+TEMP) &" F" &FeedFast 'rapid move to the x starting location While IsMoving() 'Wait for stop signal Sleep(1) Wend ' Code "G01 Y" &(YCurrent-BigMove) &" F" &FeedFast 'rapid move to the y starting location While IsMoving() 'Wait for stop signal Sleep(1) Wend Code "G31 Z" &(ZCurrent-(SmallMove)) &" F" &FeedSlow*3 'move Z down to starting height While IsMoving() 'Wait for stop signal Sleep(1) Wend ' === test for illegal touch === If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty Code "G01 Z" &(SafeZ) &" F" &FeedFast 'move Z up to clear material While IsMoving() 'Wait for stop signal Sleep(1) Wend Code "G01 Y" &(-BigMove * 0.5) &" F" &FeedFast 'rapid move to the y starting location While IsMoving() 'Wait for stop signal Sleep(1) Wend Code "G31 Z" &(ZCurrent-SmallMove) &" F" &FeedFast 'move Z down to starting height While IsMoving() 'Wait for stop signal Sleep(1) Wend End If ' Ypos1 = 0 LoopCount = 0 ' set count to zero Do YNew = YCurrent ' YCurrent is inside the edgefinder frame Code "G31 Y" &YNew &" F" &FeedSlow 'Start hunt for edge While IsMoving() 'Wait for stop signal Sleep(1) Wend YPos2 = GetOEMDRO(801) 'Get the Y location ' YCenter = YPos2 + touchoffsetY ' correct offset for tool thickness Code "G01 Y" &(YPos2-safeZ/4) &" F" &FeedFast 'rapid move to the x center location While IsMoving() 'Wait for stop signal Sleep(1) Wend ' YAvg = Abs(Ypos1 - YCenter) ' do these positions differ YPos1 = YCenter ' update last position LoopCount = LoopCount + 1 Loop Until((YAvg < max_error)Or(LoopCount > RetryLimit)) ' === we have a decent reading === Code "G01 Y" &(YPos2 -(SmallMove)) &" F" &FeedFast 'back off from work While IsMoving() 'Wait for stop signal Sleep(1) Wend Code "G01 Z" &(ZCurrent+safeZ) &" F" &FeedFast 'rapid move to the safeZ location While IsMoving() 'Wait for stop signal Sleep(1) Wend Code "G01 Y" &YCenter &" F" &FeedFast 'rapid move to the workpiece Y location While IsMoving () 'Wait for stop signal Sleep(1) Wend SetOEMDRO(801,0.000) 'Set Y DRO to zero for workpiece edge Code "G4 P0.25" 'Pause 1/4 sec ' ========================== ' ===== Go to x0,y0,z0 ===== ' ========================== Code "G01 Z" &(ZCurrent+safeZ) &" F" &FeedFast 'rapid move to the safeZ location While IsMoving () 'Wait for stop signal Sleep(1) Wend Code "G01 X" &(0.000) &" F" &FeedFast 'rapid move to the x corner location While IsMoving () 'Wait for stop signal Sleep(1) Wend Code "G01 Y" &(0.000) &" F" &FeedFast 'rapid move to the y corner location While IsMoving () 'Wait for stop signal Sleep(1) Wend Code "G01 Z" &(ZTOP_GOAL) &" F" &FeedFast 'rapid move to the z corner location While IsMoving () 'Wait for stop signal Sleep(1) Wend ' Code "G4 P0.500" 'Pause 1/2 sec Code "G01 Z" &(ZCurrent + safeZ) &" F" &FeedFast 'rapid move to the safeZ location While IsMoving () 'Wait for stop signal Sleep(1) Wend ' ===== Function 7 Done =====End Sub End Sub ' ========================================================= ' ========================================================= Sub Go_Mode_8 ' ========================================================= ' ========================================================= Code "(Mode 8 Find Edgefinder and set X, Y, and Z DROs to zero.)" ' Must be over the hole & within 0.5inch of top XCurrent = GetOEMDRO(800) ' location of tool X position YCurrent = GetOEMDRO(801) ' location of tool Y position ZCurrent = GetOEMDRO(802) ' location of tool Z position ' ' ======================== ' ===== First find Z ===== ' ======================== LoopCount = 0 ' set retry count to zero Code "G31 Z" &(ZCurrent + SmallMove) &" F" &FeedSlow*3 'move to starting height While IsMoving() 'Wait for stop signal Sleep(1) Wend If(HoleSelected < 2) Then Code "G01 X" &(XCurrent + (BigMove/3)) &" F" &FeedFast 'rapid move to the x corner location Else Code "G01 X" &(XCurrent + (BigMove/1.5)) & "G01 Y" &(YCurrent - (BigMove/3)) &" F" &FeedFast 'rapid move to the x corner location End If ' While IsMoving () 'Wait for stop signal Sleep(1) Wend ' Go_Mode_6 '=== Z is zet to work-piece surface === ' Code "G01 X" &(XCurrent) & " Y" &(YCurrent) &" F" &FeedFast 'rapid move to the x corner location While IsMoving () 'Wait for stop signal Sleep(1) Wend ' If ZTOP_GOAL = 0 Then '=== Special case === Code "G31 Z" &(SmallMove/2) &" F" &FeedFast 'move to starting height While IsMoving() 'Wait for stop signal Sleep(1) Wend Code "G31 Z" &(-SmallMove) &" F" &FeedSlow 'move into hole While IsMoving() 'Wait for stop signal Sleep(1) Wend ' Temp = GetOEMDRO(802) ' location of tool Z position ' If (Temp > (-SmallMove*(3/4))) Then If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty code "(No hole in material. Cannot continue.)" Code "G01 Z" &(ZTOP_GOAL + BigMove) &" F" &FeedFast 'rapid move to the (surface of finder) location While IsMoving() 'Wait for stop signal Sleep(1) 'While waiting, let other tasks run Wend 'An empty while/wend loop takes 100% of computer time Exit Sub End If Else ' === Standard case === Code "G31 Z" &(ZTOP_GOAL/5) &" F" &FeedFast 'move to starting height While IsMoving() 'Wait for stop signal Sleep(1) Wend End If ' Go_Mode_1 ' Do a center find; zeros not set ' Code "G01 Z" &(ZTOP_GOAL + safeZ) &" F" &FeedFast 'rapid move to the (surface of finder) location While IsMoving() 'Wait for stop signal Sleep(1) 'While waiting, let other tasks run Wend 'An empty while/wend loop takes 100% of computer time ' If (HoleSelected = 1) Then SetOEMDRO(800,CENTER_X) ' Set X Offset SetOEMDRO(801,CENTER_Y) ' Set Y Offset ElseIf (HoleSelected = 2) Then SetOEMDRO(800,CNTR_2_X) ' Set X Offset SetOEMDRO(801,CNTR_2_Y) ' Set Y Offset Else SetOEMDRO(800,DefaultHoleX) ' Set X Offset SetOEMDRO(801,DefaultHoleY) ' Set Y Offset End If XCurrent = GetOEMDRO(800) ' location of tool X position YCurrent = GetOEMDRO(801) ' location of tool X position ZCurrent = GetOEMDRO(802) ' location of tool X position End Sub ' ' ========================================================= ' ========================================================= Sub Go_Mode_9 ' ========================================================= ' ========================================================= If (cmd2 = 9 And cmd3 = 9) Then HtmlDialog( GetMainFolder()+"Edge-Finder_Options.htm" ) End If End Sub ' ========================================================= ' ========================================================= Sub Go_Mode_100 ' === Three digit commands === ' ========================================================= ' ========================================================= If(cmd1 = 8) Then If(cmd3 <> 0) Then HoleSelected = cmd3 'select either small or large hole; small=0, large=1 End If rem Exit Sub End If ' If(cmd1 = 9) Then If(cmd2 = 9) Then If(cmd3 = 9) Then Exit Sub End If End If End If ' ' === Select the tool to be used === If (((cmd3 <= 0) Or (cmd3 > 4)) And (cmd1 <> 8)) Then toolSelected = DefaultTool/2 '=== Default tool Select === ElseIf (cmd3 = 1) Then toolSelected = tool_1/2 '=== Tool #1 === ElseIf (cmd3 = 2) Then toolSelected = tool_2/2 '=== Tool #2 === ElseIf (cmd3 = 3) Then toolSelected = tool_3/2 '=== Tool #3 === ElseIf (cmd3 = 4) Then myanswer = Question ("Enter Probe Diameter: 0=Default") If (myanswer <=0) Then toolSelected = DefaultTool/2 '=== Default tool Select === Else toolSelected = (myanswer) /2 End If End If ' If cmd2 <= 0 Then '=== D E F A U L T E d g e === touchoffsetX = toolSelected + DefaultSideX ' Touch to edgefinder touchoffsetY = toolSelected + DefaultSideY ' Touch to edgefinder ZTOP_GOAL = DefaultHeight ElseIf cmd2 = 1 Then '=== S U R F A C E === touchoffsetX = toolSelected + 0.0 ' Touch to surface touchoffsetY = toolSelected + 0.0 ' Touch to surface ZTOP_GOAL = 0.000 ElseIf cmd2 = 2 Then '=== E D E G E F I N D E R === L O W T O P === touchoffsetX = toolSelected + SIDE_X ' Touch to edgefinder touchoffsetY = toolSelected + SIDE_Y ' Touch to edgefinder ZTOP_GOAL = Z_TOP1 ElseIf cmd2 = 3 Then '=== H I G H T O P === F C N #6 O N L Y === touchoffsetX = toolSelected + SIDE_X ' Touch to edgefinder touchoffsetY = toolSelected + SIDE_Y ' Touch to edgefinder ZTOP_GOAL = Z_TOP2 ElseIf cmd2 >= 4 Then '=== D E F A U L T E d g e === touchoffsetX = toolSelected + DefaultSideX ' Touch to surface touchoffsetY = toolSelected + DefaultSideY ' Touch to surface ZTOP_GOAL = DefaultHeight End If ' End Sub ' ========================================================= ' ========================================================= ' ' ========================================================= ' ========================================================= ' === E N D ==== E N D ==== E N D ==== E N D ==== E N D === ' ========================================================= ' ========================================================= Rem 2021/02/23 fixes to FCN8 for Z0 depth settings Rem 2020/07/22 added ZTOP_GOAL offse To FCN6 (5 lines from the End) To clear all brands of surface finders Rem 2020/06/20 added local help FCN 999 Rem 2020/04/10 activated 81x Rem 2020/03/31 activated #7, #16, #17, #27, #37, 100-833