Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: FiveO on April 18, 2026, 08:03:03 AM
-
Hello!
Using Mach 4 4809 and ESS v285. Probing new tool with m200, also using same kind for m6 for tool change height. Problem is jerk/jitter after probing slow. Added two videos to bottom of this post that show the problem. What's the problem and how to get rid of it? Here is my m200 code:
function M200()
local inst = mc.mcGetInstance()
--------------------------------------------------------------------
-- CONFIG
--------------------------------------------------------------------
local ToolSetterHeight = -40.425 -- distance from toolsetter surface to real workpiece surface
local FastProbeFeed = 200
local SlowProbeFeed = 20
local BackoffDistance = 1 -- retract between probes
local ProbeClearance = 1 -- safety backoff after slow probe
mc.mcCntlSetLastError(inst, "M200: Tool zeroing start")
--------------------------------------------------------------------
-- REQUIRE ACTIVE TOOL (no offsets applied)
--------------------------------------------------------------------
local tool = mc.mcToolGetCurrent(inst)
if tool < 1 then
wx.wxMessageBox("No active tool selected. Set Tool DRO first.", "M200 ERROR")
return
end
--------------------------------------------------------------------
-- Ensure absolute distance & feed mode
--------------------------------------------------------------------
mc.mcCntlGcodeExecuteWait(inst, "G90")
mc.mcCntlGcodeExecuteWait(inst, "G94")
--------------------------------------------------------------------
-- Start probing DOWN from current Z (NO upward move!)
--------------------------------------------------------------------
mc.mcCntlSetLastError(inst, "M200: Fast probe")
mc.mcCntlGcodeExecuteWait(inst,
string.format("G31 Z-9999 F%d", FastProbeFeed))
--------------------------------------------------------------------
-- Backoff before slow probe
--------------------------------------------------------------------
mc.mcCntlGcodeExecuteWait(inst,
string.format("G91 G0 Z%.3f", BackoffDistance))
mc.mcCntlGcodeExecuteWait(inst, "G90")
--------------------------------------------------------------------
-- Slow probe
--------------------------------------------------------------------
mc.mcCntlSetLastError(inst, "M200: Slow probe")
mc.mcCntlGcodeExecuteWait(inst,
string.format("G31 Z-9999 F%d", SlowProbeFeed))
--------------------------------------------------------------------
-- Read probed position
--------------------------------------------------------------------
local probedZ = mc.mcCntlGetPoundVar(inst, mc.SV_PROBE_POS_Z)
if probedZ == nil then
wx.wxMessageBox("Probe never triggered. Check wiring and position.", "M200 ERROR")
return
end
--------------------------------------------------------------------
-- Final retract after probing
--------------------------------------------------------------------
mc.mcCntlGcodeExecuteWait(inst,
string.format("G91 G0 Z%.3f", ProbeClearance))
mc.mcCntlGcodeExecuteWait(inst, "G90")
--------------------------------------------------------------------
-- CALCULATE NEW WORK OFFSET ZERO
--------------------------------------------------------------------
local newWorkOffsetZ = probedZ + ToolSetterHeight
-- Set Z0 on currently active work offset
mc.mcCntlSetPoundVar(inst, 5223, newWorkOffsetZ) -- 5223 = G54 Z, 5243 = G55, etc., Mach4 handles active WCS
mc.mcCntlSetLastError(inst,
string.format("M200: New WCS Z0 set to %.4f", newWorkOffsetZ))
--------------------------------------------------------------------
-- MOVE UP TO MACHINE Z-HOME (YOUR REQUEST)
--------------------------------------------------------------------
mc.mcCntlGcodeExecuteWait(inst, "G53 G0 Z0")
--------------------------------------------------------------------
-- DONE
--------------------------------------------------------------------
wx.wxMessageBox(
string.format("M200 Complete:\n\nProbe Hit @ Z = %.4f\nNew WCS Z0 = %.4f",
probedZ, newWorkOffsetZ),
"M200 DONE")
end
if (mc.mcInEditor() == 1) then
M200()
end
Videos: https://limewire.com/?referrer=pq7i8xx7p2 (https://limewire.com/?referrer=pq7i8xx7p2) , videos was to big to upload here.
-
if the upper link does not work for videos, use this: https://limewire.com/d/2c3Jx#pvVPYoUWnE (https://limewire.com/d/2c3Jx#pvVPYoUWnE)