Hello Guest it is April 25, 2024, 10:21:41 PM

Author Topic: Crash after tool change  (Read 2003 times)

0 Members and 1 Guest are viewing this topic.

Offline Azalin

*
  •  181 181
    • View Profile
Re: Crash after tool change
« Reply #20 on: April 15, 2022, 11:29:19 AM »
In the meantime Rob send me an email with an M6 function. I tested it and it worked fine too. Only difference from the stock M6 is it has an extra line which is:
mc.mcMotionSync(inst)

Since it is official I prefer this one.

Thanks Rob


function m6()

   local inst = mc.mcGetInstance()
   local selectedTool = mc.mcToolGetSelected(inst)
   selectedTool = math.tointeger(selectedTool)
   local currentTool = mc.mcToolGetCurrent(inst)
   currentTool = math.tointeger(currentTool)
   
   if selectedTool == currentTool then
      mc.mcCntlSetLastError(inst, "Current tool == Selected tool so there is nothing to do")
   else
      --Remove this line if you would not like the Z axis to move
      --mc.mcCntlGcodeExecute(inst, "G90 G53 G0 Z0.0");--Move the Z axis all the way up
      mc.mcCntlSetLastError(inst, "Change to tool " .. tostring(selectedTool) .. " and press start to continue") --Message at beginning of tool change
      mc.mcCntlToolChangeManual(inst, true) --This will pause the tool change here and wait for a press of cycle start to continue
      mc.mcCntlSetLastError(inst, "Current tool == " .. tostring(selectedTool) .. "   Previous Tool == " .. tostring(currentTool)) --Message that shows after Cycle Start
      mc.mcToolSetCurrent(inst, selectedTool)
      mc.mcMotionSync(inst)
   end
end

if (mc.mcInEditor() == 1) then
   m6()
end