I'm finally getting around to finishing of my cyclone, but during testing various things, I've discovered an issue with selecting tools.
If I issue a full tool change command i.e.T0101, things work fine, however if I command an abreviated version i.e. T01, then it requests tool 0 which is invalid (it has also highlighted an issue with my PLC logic, but that's another issue).
Is this how Mach turn usually works?
Or have I missed something?
Here's my toolchange macro-
oldtool = GetUserDRO(1202) 'Get the current tool position (we could use GetCurrentTool, but UserDRO1202 is updated directly from KFLOP via the macropump)
newtool = GetSelectedTool() 'Get the new tool position
if oldtool = newtool Then 'if we've already got the requested tool loaded
End 'then we can quit this macro without doing anything
End If
ActivateSignal(Output10) 'this activates the tool change allowed signal from the KFlop to PLC (KFlop bit 144 - Port2Pin16)
SetOEMDRO(1006,newtool) 'transfer the new tool position to the OEMDRO (transfers to KFlop persist, where it gets transferred via MODbus to the PLC)
NotifyPlugins(19006)
While Isactive(Input1) 'wait for tool changer OK signal to turn of (this is so we know the new tool position has been transfered)
Wend
While not Isactive(Input1) 'then wait for tool change ok signal to turn back on - KFlop bit 141/port2pin13
Wend
DeactivateSignal(Output10) 'turn of tool change allowed signal
SetCurrentTool(newtool)
End
I'm using a KFlop, which communicates with a PLC via modbus to control the toolchanger.
I've checked and the KFlop is being sent a request for position 0, so I'm sure this is something Mach is doing.
One other quick question while I'm here.
If I add code into the Macro to check for a valid position, what code is needed to halt the current program if an invalid position is requested?
i.e.
If newtool < 1 or newtool > 6 Then
What goes here to bring everything to a halt?
End If