Hello Guest it is March 28, 2024, 03:30:17 PM

Author Topic: Prevent spindle from starting when touch probe is in spindle  (Read 530 times)

0 Members and 1 Guest are viewing this topic.

I'm having a wired 3D-touch probe in my linear ATC system. The plug for the wire is automatically connected as the spindle picks the tool holder for the probe. The same plug also keeps the probe from rotating (no encoder or brake on the spindle).

However, if the spindle is started while the probe is in there, the wire will get ripped off and the probe will get damaged. Any best practice for preventing Mach4 to start the spindle as long as a specific tool number is in the spindle?
Re: Prevent spindle from starting when touch probe is in spindle
« Reply #1 on: May 31, 2022, 12:08:27 PM »
You could replace your SpinCW and your SpinCCW functions in the screen load script with this.
Also, make a new m3 and m4 macro and save them into your profile's macro folder as m3 and m4 and it will overwrite the stock m3 and m4.  Code below as well.
You would have to replace the tool number to suit your needs.  I have it set to 30 in all of these scripts.  I would also thoroughly test this in all instances. 
---------------------------------------------------------------
-- Spin CW function.
---------------------------------------------------------------
function SpinCW()
    local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON);
    local sigState = mc.mcSignalGetState(sigh);
   local Tool = mc.mcToolGetCurrent(inst)
    
    if Tool == 30 then
      mc.mcCntlSetLastError(inst, "Cannot run spindle with tool probe.")
    else
       if (sigState == 1) then
          mc.mcSpindleSetDirection(inst, 0);
       else
          mc.mcSpindleSetDirection(inst, 1);
       end
    end
end
---------------------------------------------------------------
-- Spin CCW function.
---------------------------------------------------------------
function SpinCCW()
    local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON);
    local sigState = mc.mcSignalGetState(sigh);
   local Tool = mc.mcToolGetCurrent(inst)
   
    if Tool == 30 then
      mc.mcCntlSetLastError(inst, "Cannot run spindle with tool probe.")
    else
   
       if (sigState == 1) then
          mc.mcSpindleSetDirection(inst, 0);
       else
          mc.mcSpindleSetDirection(inst, -1);
       end
    end
end
---------------------------------------------------------------

function m3()
local inst = mc.mcGetInstance()
local Tool = mc.mcToolGetCurrent(inst)

if Tool == 30 then
    mc.mcCntlSetLastError(inst, "Cannot run spindle with tool probe.")
else
    mc.mcSpindleSetDirection(inst, 1);
end--If Tool == 30


end--m3

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

function m4()
local inst = mc.mcGetInstance()
local Tool = mc.mcToolGetCurrent(inst)

if Tool == 30 then
    mc.mcCntlSetLastError(inst, "Cannot run spindle with tool probe.")
else
    mc.mcSpindleSetDirection(inst, -1);
end--If Tool == 30


end--m4

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


Chad Byrd