1351
VB and the development of wizards / Re: macro for 4 slot tool change hep
« on: April 24, 2019, 12:18:14 PM »
try this code, now you should see in Status line witch TC place is detected by the Inputs
Code: [Select]
OldTool = GetCurrentTool()
Tool = GetSelectedTool()
MaxToolNum = 4 'Max number of tools for the changer
Message "OldTool: " & OldTool & " NewTool: " & Tool
Sleep(200)
If OldTool = Tool Then
Message ("Selected Tool already loaded")
Exit Sub
End If
While Tool > MaxToolNum
Tool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend
Call StartTool
While NewTool <> Tool
Call CheckPins
While IsMoving()
Wend
Wend
Call StopTool
SetCurrentTool(NewTool)
'//// Subroutines /////////
Sub StartTool
ActivateSignal(Output8)
'Code "G4 P4.0" 'Wait for the tool to rotate past the sensor
While IsMoving()
Wend
End Sub
Sub CheckPins
If IsActive(Input22) Then
NewTool = 1
End If
If IsActive(Input21) Then
NewTool = 2
End If
If IsActive(Input20) Then
NewTool = 3
End If
If IsActive(Input19) Then
NewTool = 4
End If
Message "NewTool= " & NewTool
Sleep(200)
End Sub
Sub Stoptool
DeActivateSignal(Output8)
While IsMoving()
Wend
ActivateSignal(Output9)
Code "G4 P1.0" 'Wait for the tool to rotate onto ratchet stop
While IsMoving()
Wend
DeActivateSignal(Output9)
While IsMoving()
Wend
End Sub