-
Notifications
You must be signed in to change notification settings - Fork 4
/
M200.m1s
136 lines (87 loc) · 3.31 KB
/
M200.m1s
1
'M200 Auto Zero-ing Mach3 Script 'Created: C. Stewart [email protected] 09/01/2017 '24/02/2018 - Corrected zeroing above touch plate, while IsMoving(), Wend'25/02/2018 - Changed so that zeros work co-ordinate not machine co-ordinate'03/06/2018 - Looks up tool length, plunges faster till close to touchplate when tool in library. added commentsPrivate Sub home() Dim ZprobeDepthREL, ZfeedRate, ZsafeABS, XcoordTouchPlateABS, YcoordTouchPlateABS, Ret, CurrentZMachinePos, ZprobCoord Dim isZeroPlateTouched As Boolean Dim toolLen As Integer Dim toolNum As Integer isZeroPlateTouched = false ZprobeDepthREL = -115 'maximum depth the tool can plunge from maximum Z to the touch plate. ZsafeABS = 0 ' ZfeedRatePlunge = 100 ZfeedRatePlungeToolLen = 500 ZfeedRateRetract = 1000 FeedRateJog = 2000 'Set this position to the distance the touch plate is below the spoil board surface ZdepthTouchPlateWCS = -6.75 'Distance from the collet to the zero block Z_TRAVEL = 115 'Distance to keep tool above zero for safety Z_ZERO_CLEARANCE =20 'Location of touchplat in plan XcoordTouchPlateABS = 45 YcoordTouchPlateABS = 95 ' Log code? Code M1003 'Get tool properties toolNum = GetCurrentTool() 'Function GetToolParam(ToolNum As Integer, ParamNum As Integer)' toolLen = GetToolParam(toolNum, 2) Ret = MachMsg("The tool will now touch off on the zeroing plate." & Chr(10) & "Click 'YES' if the tool is at a safe height and clear of all obstructions" & Chr(10) & "If not, click 'NO', jog To safe height then re-run" & Chr(10) & "Click 'CANCEL' if the current tool is zeroed" , "TOOL HEIGHT CALIBRATION", 3) If Ret = 6 Then Message( "Safe Z Confirmed" ) ElseIf Ret = 2 Then Message( "Touch off skipped!" ) End ElseIf Ret = 7 Then 'Abort 'Trigger E-stop DoOemButton(1021) Message( "jog To safe Z Then re-run [CODE: M200]" ) Exit Sub End If 'Move to the touch plate Code "G53 X" & XcoordTouchPlateABS & " Y" & YcoordTouchPlateABS & "F"& FeedRateJog 'Then plunge to toolLen depth ONLY if toolLen != 0 If toolLen <> 0 Then Code "G53 Z" & (-(Z_TRAVEL - toolLen))+Z_ZERO_CLEARANCE & "F" & ZfeedRatePlungeToolLen End If Message( "Auto Tool Zeroing..." ) 'Check if the touch plate has been hit If IsSuchSignal (22) Then 'Call SetUserDRO( 2, 0.00 ) 'Get the current machine Z co-ordinate CurrentZMachinePos = GetABSPosition(2) ZprobCoord = CurrentZMachinePos + ZprobeDepthREL code "G31 Z" & ZprobCoord & " F" & ZfeedRatePlunge While IsMoving() If GetOemLed(825) = -1 Then isZeroPlateTouched = true Else isZeroPlateTouched = false End If Wend CurrentZMachinePos = GetABSPosition(2) code "G53 Z" & CurrentZMachinePos-ZdepthTouchPlateWCS & "F" & ZfeedRatePlunge While IsMoving() Wend 'Call setMachZero(2) 'zero the Z axis SetToolZ (0) Sleep(1000) code "G53 Z" & ZsafeABS & "F" & ZfeedRateRetract End If If (isZeroPlateTouched) Then Message( "Tool Zero-ed: " & isZeroPlateTouched) 'Move back to machine zero X and Y ''Code "G53 X0 Y0" & "F"& FeedRateJog Else Message( "Tool Zeroing failed: " & isZeroPlateTouched ) MachMsg( "The tool failed to zero automatically. Please check and retry", "Tool Zero Failed!", 0) 'Trigger E-stop DoOemButton(1021) Exit Sub End IfEnd Sub