Hello Guest it is June 09, 2024, 08:23:31 PM

Author Topic: mc.mcToolGetSelected not tracking tool setting(e.g. T1 M6, T2 M4, ...) !!!!  (Read 857 times)

0 Members and 1 Guest are viewing this topic.

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

Go to Configure>Control and on the Tools tab make sure “T on m6 line is tool to use”
Thanks Swifty. I found the setting but for some reason it won't stick. When I set it, close the config dialog. Open it again, the setting is stuck on "Tool is the Next Tool". Any thoughts ?
That means your parameters.ini file in C:\Mach4hobby\profiles\<your profile> folder is corrupt. You can normally copy the file from another profile e.g the router or mill profile, and it will be ok
Thanks, that fixed it !