Hello Guest it is May 25, 2025, 01:42:58 PM

Author Topic: Auto zero freezes Mach4  (Read 3493 times)

0 Members and 1 Guest are viewing this topic.

Auto zero freezes Mach4
« on: October 23, 2024, 05:36:50 PM »
Hi all, I'm new to Mach4, coming from mach3. I have been trying to set up an auto zero button and got as far as putting a button on the screen to start the auto zero script. The problem is when i run the script it freezes when it touches the toolsetter button. I copied an auto zero script from somewhere and when i debug it, it works. Below is a copy of the script. Could someone have a look at it and see what is wrong? BTW I know very little about lua, although I'm working on it.
function autozero()
local inst = mc.mcGetInstance()
local probeHand, rc = mc.mcSignalGetHandle(inst,mc.ISIG_PROBE)
local probeState=mc.mcSignalGetState(probeHand)
if probeState==1 then
    wx.wxMessageBox('Probe already active...cannot proceed')
    return
end
mc.mcCntlGcodeExecuteWait(inst, 'G01 G90 G31 Z-4 F5');
local zProbeStrikePos = mc.mcCntlGetPoundVar(inst, 5063);
mc.mcAxisSetPos(inst, 2, 0.99);
mc.mcCntlGcodeExecuteWait(inst, 'G00 G91 Z1');  --Rapid move to 1 inch above current pos
probeState=mc.mcSignalGetState(probeHand)
if probeState == 1 then
    wx.wxMessageBox("Probe is still activated! Check to make sure probe is not damaged or still contacting strike plate.");
else
    mc.mcCntlSetLastError(inst, "Z Axis now referenced.");
end
 
end

Offline Bill_O

*
  •  598 598
Re: Auto zero freezes Mach4
« Reply #1 on: October 24, 2024, 09:11:21 AM »
Instead of mc.mcCntlGcodeExecuteWait try mc.mcCntlGcodeExecute.
The wait works in some places but not others.