-- Mach4Turn Ratcheting Tool Turret function m6() inst = mc.mcGetInstance() selectedtool = mc.mcToolGetSelected(inst) currenttool = mc.mcToolGetCurrent(inst) turret = mc.mcAxisGetMachinePos(inst, 5) Ulock = 10 -- ' Sets the Unlock Movement in Degrees Value Rlock = 5 -- ' Sets the Relock Movement in Degrees Value T1SafePosX = 2 T1SafePosZ = 1.5 if (selectedtool > 8) or (selectedtool < 1) then --DoButton(3) --'Stop Program Run mc.mcCntlSetLastError(inst,"Program Stopped due to Tool Number Out of Range") do return end end if (selectedtool == currenttool) then mc.mcCntlSetLastError(inst,"Tool is the same NO tool change needed") do return end end local Tp = 0 --' Zero's the Tool Positon values DO NOT CHANGE --'------------------- Move to Safe Tool Position ----------- mc.mcCntlSetLastError(inst," Move to Tool Safe Pos") mc.mcCntlGcodeExecuteWait(inst, "G53 X" .. T1SafePosX); mc.mcCntlGcodeExecuteWait(inst, "G53 Z" .. T1SafePosZ); mc.mcCntlSetLastError(inst,"Safe XZ Move Completed") --'------ Select Tool ------------------------------------ if (selectedtool < currenttool) then Turns = ((8 - currenttool) + selectedtool) Moves = turret + Ulock + (Turns * 45) mc.mcCntlGcodeExecuteWait(inst, " G53 C " ..Moves); end if (selectedtool > currenttool) then Turns = (selectedtool - currenttool) Moves = turret + Ulock + (Turns * 45) mc.mcCntlGcodeExecuteWait(inst, " G53 C" ..Moves); end if (selectedtool == 1) then mc.mcCntlSetLastError(inst, "Tool#1 Loaded") elseif (selectedtool == 2) then mc.mcCntlSetLastError(inst, "Tool#2 Loaded") elseif (selectedtool == 3) then mc.mcCntlSetLastError(inst, "Tool#3 Loaded") elseif (selectedtool == 4) then mc.mcCntlSetLastError(inst, "Tool#4 Loaded") elseif (selectedtool == 5) then mc.mcCntlSetLastError(inst, "Tool#5 Loaded") elseif (selectedtool == 6) then mc.mcCntlSetLastError(inst, "Tool#6 Loaded") elseif (selectedtool == 7) then mc.mcCntlSetLastError(inst, "Tool#7 Loaded") elseif (selectedtool == 8) then mc.mcCntlSetLastError(inst, "Tool#8 Loaded") end --'------------ end Tool Change ------------------------ mc.mcCntlSetLastError(inst," Tool Turret LOCKING ") mc.mcCntlGcodeExecuteWait(inst, " G52 C0" ); mc.mcCntlGcodeExecuteWait(inst, " G00 H-" ..Rlock ); -- ' Lock Turret --,----------------------------------------------------- tool = selectedtool mc.mcToolSetCurrent(inst, selectedtool) if (mc.mcInEditor() == 1) then m6() end end