1456
« on: February 17, 2015, 03:54:08 AM »
This should at least get you moving with a tool change. I fixed the errors that prevented the M6Start from running.
Sub Main() 'Define variables
OldTool = GetOEMDRO (1200)
x = GetToolChangeStart( 0 )
y = GetToolChangeStart( 1 )
z = GetToolChangeStart( 2 )
tool = GetSelectedTool()
xpos1 = GetOEMDRO (1205)
ypos1 = GetOEMDRO (1206)
xpos2 = GetOEMDRO (1207)
ypos2 = GetOEMDRO (1208)
xpos3 = GetOEMDRO (1209)
ypos3 = 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
If NewTool > MaxToolNum Then
NewTool = Question ("Place valid tool number (between 1 y 3)")
Else
End If
CODE "G90" 'Makes sure you are not in INC mode
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" & xpos1 ' YOU may want to do combined moves of XY
Code "G00 G53 y" & ypos1 ' Code"G00 G53 X" &xpos1 &"Y"&ypos1
Case Is = 2
Code "G00 G53 x" & xpos2 'Same here
Code "G00 G53 y" & ypos2
Case Is = 3
Code "G00 G53 x" & xpos3 'Same Here
Code "G00 G53 y" & ypos3
End Select
End Sub
Main