Hi, all
I'm studying auto tool changer macro.
I have 3 tools, now it is setted the position of each tool in m6start.m1s like below code.
Select Case ToolNumber 'Here set the position of each tool.
Case Is = 1
Xpos = 12.00
YPos = 2.00
Case Is = 2
Xpos = 14.00
YPos = 2.00
Case Is = 3
Xpos = 16.00
YPos = 2.00
End Select
I would like to input coord's of tools location in Mach3 screen not in m6start.m1s.
So I created userDRO to input coord's at Screen4, and edited m6start.m1s like below codes.
But It ignores m6start.m1s and performs next code.
I don't know what's wrong.
Please anybody let me know what's wrong, or is there a better way to do this?
I'm sorry for bad english.
Thank you.
Sub Main() 'Define variables
OldTool = GetOEMDRO (1200)
x = GetToolChangeStart( 0 )
y = GetToolChangeStart( 1 )
z = GetToolChangeStart( 2 )
tool = GetSelectedTool()
1xpos = GetOEMDRO (1205)
1ypos = GetOEMDRO (1206)
2xpos = GetOEMDRO (1207)
2ypos = GetOEMDRO (1208)
3xpos = GetOEMDRO (1209)
3ypos = GetOEMDRO (1210)
NewTool = tool
MaxToolNum = 3 'Maximum number of tools to use.
ToolDown = -50 'Height for the tool change.
ToolUp = 0.0 'Height the Z-axis for the tool change.
PosSec = 50.0 'Safe Position.
If NewTool = OldTool Then
Exit Sub
End If
While NewTool > MaxToolNum
NewTool = Question ("Place valid tool number (between 1 y 3)")
Wend
Code "G00 G53 Z" & ToolUp 'The z-axis is going to "machine zero"
While IsMoving()
Wend
Code "G53 y" & PosSec 'Going to safe position.
While IsMoving()
Wend
Code "G53 Z" & ToolDown 'Down to the height of tools
While IsMoving()
Wend
Call MovePos(OldTool) 'Going to the last position to relase the old tool.
While IsMoving()
Wend
ActivateSignal(Output1) 'Relase the tool.
Code "G4 P1.0"
Code "G53 Z" & ToolUp
While IsMoving()
Wend
Call MovePos(NewTool) 'Go to the new tool position.
While IsMoving()
Wend
Code "G53 Z" & ToolDown 'down the z-axis to hold the tool.
While IsMoving()
Wend
DeActivateSignal(Output1) 'hold the new tool.
Code "G4 P1.0"
Code "G53 y" & PosSec 'Returns to the safe position.
While IsMoving()
Wend
Code "G53 Z" & ToolUp 'Returns z-axis to "machine zero".
Call SetUserDRO (1200,NewTool)
SetCurrentTool( NewTool )
End Sub
Sub MovePos(ByVal ToolNumber As Integer)
Select Case ToolNumber 'Here set the position of each tool.
Case Is = 1
Code "G00 G53 x" & 1xpos
Code "G00 G53 y" & 1ypos
Case Is = 2
Code "G00 G53 x" & 2xpos
Code "G00 G53 y" & 2ypos
Case Is = 3
Code "G00 G53 x" & 3xpos
Code "G00 G53 y" & 3ypos
End Select
End Sub
Main