The code was more for a outline but will work.
I have a message popup for "YEP" to verify that the code is working but left this for you to decide what to do...just comment out "PRINT "YEP" and/or add a result.
Let me know what part isn’t working right and I can modify it:
I'll break it down here with description ...
1. Move Z to toolchange position:
'////MOVE THE MACHINE FOR TOOLCHANGE////
Code ("G53 G00 Z-0.200")'Move Z to position
2. Wait for Z to get to position:
While IsMoving() ' Wait for machine to stop
SLEEP(250)'Slow down cycle time for CPU resources
Wend
3. Get requested tool and activate turret with Brain:
'//GET SET TOOL////
tool = GetSelectedTool() 'Gettool
SetCurrentTool( tool )'Set tool
4. Wait 4 seconds and then Check to see if Input 1
*****************************Rather then waiting 4 seconds why dont we loop and check for INPUT1 to be active....if after 4 seonds it is not active popup message to user?
SLEEP(500)'Wait to see if input becomes active
5. If Input doesn't activate popup message:
'////CHECK INPUT/////
If Not(IsActive(INPUT1)) Then 'Is the imput active
Message box settings:
'///Message box////
msg = "Please reseat tool and continue?" ' Define message
title = "Tool Changer" ' Define title
buttons = 1
response = MsgBox(msg,buttons, title)
***6. If the user is finished resetting and presses the "OK" button then do this(HEre you can comment out ("Print"yep"):
'///Responce was YES
If response = 1 Then ' User chose Yes.
' Perform recheck issue has been fixed.
Print"yep"
7. The user pressed "Cancel" you should estop the sytem and turn things off:
'///Responce was NO
Else
' Estop system ecit.
Print"nope"
End If'exit message
8. Input was active and just continue running tool changer:
End If 'Input was active exit