323
« on: August 24, 2021, 08:58:44 PM »
You could try this macro, I have no idea if its any good to you.
No warranty given or implied.
-- Mach4Turn 8 position tool Turret
function m6()
inst = mc.mcGetInstance()
selectedtool = 5 -- mc.mcToolGetSelected(inst)
currenttool = 1 -- mc.mcToolGetCurrent(inst)
Rlock = 1 -- ' Sets the Relock Movement in Degrees Value
if (selectedtool > 8) or (selectedtool < 1) then
mc.mcCntlSetLastError(inst,"Tool Number Out of Range.")
do return end
end
if (selectedtool == currenttool) then
mc.mcCntlSetLastError(inst,"No tool change needed.")
do return end
end
--'------ Select Tool ------------------------------------
mc.mcCntlSetLastError(inst,"Moving to Tool " ..selectedtool )
if (selectedtool > currenttool) then
Moves = selectedtool - currenttool
Moves = (Moves * 45) + 1
mc.mcCntlSetLastError(" G00 A" ..Moves);
end
if (selectedtool < currenttool) then
Moves = ((8 - currenttool) + selectedtool)
Moves = (Moves * 45) + 1
mc.mcCntlSetLastError(" G00 A " ..Moves);
end
mc.mcCntlSetLastError(inst,"Tool Loaded")
--'------------ end Tool Change ------------------------
mc.mcCntlSetLastError(inst," Turret Locking ")
mc.mcCntlGcodeExecuteWait(inst, "G52 A-" ..Moves);
mc.mcCntlGcodeExecuteWait(inst, "G00 G90 A0");
mc.mcCntlGcodeExecuteWait(inst, "G00 G91 A-" ..Rlock ); -- ' Lock Turret
mc.mcCntlGcodeExecuteWait(inst, "G52 A0");
mc.mcCntlGcodeExecuteWait(inst, "G90"); --' Reset to ABS
tool = selectedtool
mc.mcToolSetCurrent(inst, selectedtool)
if (mc.mcInEditor() == 1) then
m6()
end
end