Mach3 ATC Macro
Mach3 ATC Macro
m1s
'M6 start macro with auto tool touch off
'M6Start.m1s
'Check all axes referenced
If (GetOemLed(807) Or GetOemLed(808) Or GetOemLed(809)) Then
Message(" Please Home Machine before Tool Change")
'Cycle Stop
' Button 3 - select Toolpath screen
DoButton(3)
Exit Sub
End If
'--------------- CONFIGURATION
' the X+y+z position of tool #0 is stored in DRO 1200, 1201, 1202
' THESE USER-DEFINED DROS MUST BE DEFINED IN THE SCREEN SET
' distance of tools inside the magazine along the Y axis
TOOLDISTANCE = 33.5
TOOLDISTANCE_Z = (33.5-36.5)/5
TOOLCHANGE_FEEDRATE = 150
tool = GetselectedTool()
oldTool = GetCurrentTool() 'GetOEMDRO(1212)
If oldTool = tool Then
Answer = MsgBox("old tool and new tool are identical", 0 + 16 )
Exit Sub
End If
Answer = MsgBox("experimental tool change from tool " & oldTool & " to new tool "
& tool, 0)
DoSpinStop()
While IsMoving ()
Wend
'===== DEBUG====
Response = MsgBox ( "moving to Zsafe=" & SafeZ & " quickly", 1 )
If Response = 2 Then ' Cancel pressed
End
End If
'===== DEBUG====
'===== DEBUG====
Response = MsgBox ( "moving to y_oldtool=" & ChangeYold & " quickly", 1 )
If Response = 2 Then ' Cancel pressed
Response = MsgBox ( "Aborting" , 1 + 16 )
End
End If
'===== DEBUG====
Else
'===== DEBUG====
Response = MsgBox ( "moving to y_oldtool=" & ChangeYold & " quickly", 1 )
If Response = 2 Then ' Cancel pressed
Response = MsgBox ( "Aborting" , 1 + 16 )
End
End If
'===== DEBUG====
'===== DEBUG====
Response = MsgBox ( "moving to SafeX=" & SafeX & " quickly", 1 )
If Response = 2 Then ' Cancel pressed
Response = MsgBox ( "Aborting" , 1 + 16 )
End
End If
'===== DEBUG====
'===== DEBUG====
Response = MsgBox ( "Moving down to ChangeZold=" & ChangeZold & " quickly" , 1 )
If Response = 2 Then ' Cancel pressed
End
End If
'===== DEBUG====
'===== DEBUG====
Response = MsgBox ( "Placing tool in X=" & ChangeX & " slowly" , 1 )
If Response = 2 Then ' Cancel pressed
End
End If
'===== DEBUG====
'===== DEBUG====
Response = MsgBox ( "releasing the old tool" , 1 )
If Response = 2 Then ' Cancel pressed
End
End If
'===== DEBUG====
'===== DEBUG====
Response = MsgBox ( "moving up to SafeZ slowly" , 1 )
If Response = 2 Then ' Cancel pressed
End
End If
'===== DEBUG====
' move up
Code("G01 G53 Z" & SafeZ & " F" & TOOLCHANGE_FEEDRATE)
While IsMoving ()
Wend
'===== DEBUG====
Response = MsgBox ( "moving over to y=" & ChangeYnew & " quick", 1 )
If Response = 2 Then ' Cancel pressed
End
End If
'===== DEBUG====
'===== DEBUG====
Response = MsgBox ( "lowering to Znew" & ChangeZnew & " slowly", 1 )
If Response = 2 Then ' Cancel pressed
End
End If
'===== DEBUG====
' move up
Code("G01 G53 Z" & ChangeZnew & " F" & TOOLCHANGE_FEEDRATE)
While IsMoving ()
Wend
'===== DEBUG====
Response = MsgBox ( "grabbing the new tool" , 1 )
If Response = 2 Then ' Cancel pressed
End
End If
'===== DEBUG====
'===== DEBUG====
Response = MsgBox ( "moving to SafeX=" & SafeX & " slowly", 1 )
If Response = 2 Then ' Cancel pressed
End
End If
'===== DEBUG====
ZProbePos = GetVar(2002)
' go up again
Code "G00 G53 Z" & SafeZ
While IsMoving ()
Wend
SetCurrentTool( tool )
'===== DEBUG====
'Response = MsgBox ( "moving to back to " & CurrentPosX & " - " & CurrentPosY &" ,
then Z=" & CurrentPosZ , 1 )
'If Response = 0 Then ' Cancel pressed
' End
'End If
'===== DEBUG====
M6End.m1s
'M6End.m1s
tool = GetDRO(24)
oldTool = GetOEMDRO(1212)
Kita versija:
Sub Main()
OldTool = GetOEMDRO (1200) 'Tool In spindle DRO You must add this to your settings
screen
x = GetToolChangeStart( 0 )
y = GetToolChangeStart( 1 )
z = GetToolChangeStart( 2 )
tool = GetSelectedTool()
NewTool = tool
End Select
Code "G53 X" & XPos & " Y" & YPos
End Sub
Main