I have written a M6 manual tool change macro. All the probing operations work as expected. The problem occurs when I run the M6 script more than once. I wrote a test gcode file that does this :
T1 M6
T2 M6
T3 M6
M30
On the first M6 call, the current tool is initially 99, selected tool is 1, then the current tool is set to 1(selected tool)
On the second M6 call, the current tool is initially 1 AND the selected tool is ALSO 1 !!!current tool is set again to 1!
On the third M6 call, the current tool is initially 1 AGAIN !! and the selected tool is 2
T3 is never "selected"
Any ideas why the selected tool does not track the program T* setting ??
---------
This is the simple m6 test
function m6()
local inst = mc.mcGetInstance();
--get current state
mc.mcCntlSetLastError(inst, "M6 Tool Change Test Started!")
local selectedTool = mc.mcToolGetSelected(inst)
selectedTool = math.tointeger(selectedTool)
local currentTool = mc.mcToolGetCurrent(inst)
currentTool = math.tointeger(currentTool)
mc.mcCntlSetLastError(inst, "Starting Current Tool "..tostring(currentTool).." Selected Tool "..tostring(selectedTool))
-- set current tool to new(selected) tool number
mc.mcToolSetCurrent(inst, selectedTool)
currentTool = mc.mcToolGetCurrent(inst)
currentTool = math.tointeger(currentTool)
mc.mcCntlSetLastError(inst, "Ending Current Tool "..tostring(currentTool).." Selected Tool "..tostring(selectedTool))
selectedTool = 0
mc.mcCntlSetLastError(inst, "Tool Change Test Finished\n")
end
if (mc.mcInEditor() == 1) then
m6()
end