Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: pmageau on May 14, 2024, 04:24:53 PM

Title: mc.mcToolGetSelected not tracking tool setting(e.g. T1 M6, T2 M4, ...) !!!!
Post by: pmageau on May 14, 2024, 04:24:53 PM
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

Title: Re: mc.mcToolGetSelected not tracking tool setting(e.g. T1 M6, T2 M4, ...) !!!!
Post by: SwiftyJ on May 15, 2024, 06:59:33 AM
Go to Configure>Control and on the Tools tab make sure “T on m6 line is tool to use”
Title: Re: mc.mcToolGetSelected not tracking tool setting(e.g. T1 M6, T2 M4, ...) !!!!
Post by: pmageau on May 15, 2024, 03:21:01 PM
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 ?
Title: Re: mc.mcToolGetSelected not tracking tool setting(e.g. T1 M6, T2 M4, ...) !!!!
Post by: SwiftyJ on May 16, 2024, 05:07:10 AM
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
Title: Re: mc.mcToolGetSelected not tracking tool setting(e.g. T1 M6, T2 M4, ...) !!!!
Post by: pmageau on May 16, 2024, 12:19:00 PM
Thanks, that fixed it !