'Toolchanger Macro For the M6Start Macro:
'Input1 == Tool #1
'Input2 == Tool #2
'Input3 == Tool #3
'Input4 == Tool #4
'Output4 raise/rotate turret
'Output5 rotate/Lock turret
'OEMDRO(1111) is utilized to store the last used tool (OldTool) and is updated
OldTool = GetOEMDRO (1111)
Tool = GetSelectedTool()
MaxToolNum = 4 'Max number of tools for the changer
If OldTool = Tool Then
Message ("Selected Tool already loaded")
Exit Sub
End If
While Tool > 4
Tool = Question ("Tool Error, Tool number to large Enter new tool number")
Wend
Call StartTool
While NewTool <> Tool
Call CheckPins
While IsMoving()
Sleep(10)
Wend
Wend
Call StopTool
Call SetUserDRO (1200, NewTool)
SetCurrentTool(NewTool)
'//// Subroutines /////////
Sub StartTool
ActivateSignal(Output3)
While IsMoving()
Sleep(10)
Wend
End Sub
Sub CheckPins
If IsActive(Input1) Then
NewTool = 1
End If
If IsActive(Input2) Then
NewTool = 2
End If
If IsActive(Input3) Then
NewTool = 3
End If
If IsActive(Input4) Then
NewTool = 4
End If
End Sub
Sub Stoptool
DeActivateSignal(Output3)
ActivateSignal(Output5)
Code "G4 P2.0"
While IsMoving()
Sleep(5)
Wend
DeActivateSignal(Output5)
While IsMoving()
Sleep(5)
Wend
End Sub |