From 86547aaadf5f2f612bd6478a1d8e81c6995032a2 Mon Sep 17 00:00:00 2001 From: Dirk-Willem van Gulik Date: Thu, 19 Nov 2026 22:19:17 +0100 Subject: [PATCH 1/7] Clarification to G38 commands; especially to what happens if things are already in the state the g-code should be waiting for --- docs/src/gcode/g-code.adoc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/src/gcode/g-code.adoc b/docs/src/gcode/g-code.adoc index 20007307b18..1d3c7be417b 100644 --- a/docs/src/gcode/g-code.adoc +++ b/docs/src/gcode/g-code.adoc @@ -1481,10 +1481,9 @@ The axis words are optional, except that at least one of them must be used. The axis words together define the destination point that the probe will move towards, starting from the current location. -If the probe is not tripped before the destination is reached G38.2 and -G38.4 will signal an error. -The tool in the spindle must be a probe or contact a probe switch. +The tool in the spindle must be a probe (e.g. for workpiece touch off) + or contact a probe switch (e.g. for tool lenght or dimenson measurements). In response to this command, the machine moves the controlled point (which should be at the center of the probe ball) in a straight line at @@ -1492,10 +1491,20 @@ the current <> toward the programmed point. In inverse time feed mode, the feed rate is such that the whole motion from the current point to the programmed point would take the specified time. + The move stops (within machine acceleration limits) when the programmed point is reached, or when the requested change in the probe input takes place, whichever occurs first. +If the probe state does not change before the destination is reached +G38.2 and G38.4 will signal an error. G38.3 and G38.5 will set +#5070 to zero to signal this error. + +If the probe is alread tripped when it is expected not to be tripped yet +(G38.2 and G38.3); or when the probe is not yet tripped while it is +expected to (G38.4 and G38.5) - the command will ether exit immediately +and signal an error (G38.2 and G38.4) or set the #5070 to zero. + [[gcode:probing-codes]] .Probing G-Codes [width="90%",options="header"] From 488654195bc47c830e1b1542687c44952efefe04 Mon Sep 17 00:00:00 2001 From: Dirk-Willem van Gulik Date: Sat, 21 Nov 2026 21:45:08 +0100 Subject: [PATCH 2/7] Clarify text; see #4874 discussion --- docs/src/gcode/g-code.adoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/src/gcode/g-code.adoc b/docs/src/gcode/g-code.adoc index 1d3c7be417b..569d4ba6784 100644 --- a/docs/src/gcode/g-code.adoc +++ b/docs/src/gcode/g-code.adoc @@ -1483,7 +1483,7 @@ The axis words together define the destination point that the probe will move towards, starting from the current location. The tool in the spindle must be a probe (e.g. for workpiece touch off) - or contact a probe switch (e.g. for tool lenght or dimenson measurements). + or contact a probe switch (e.g. for tool length or dimension measurements). In response to this command, the machine moves the controlled point (which should be at the center of the probe ball) in a straight line at @@ -1500,10 +1500,10 @@ If the probe state does not change before the destination is reached G38.2 and G38.4 will signal an error. G38.3 and G38.5 will set #5070 to zero to signal this error. -If the probe is alread tripped when it is expected not to be tripped yet -(G38.2 and G38.3); or when the probe is not yet tripped while it is -expected to (G38.4 and G38.5) - the command will ether exit immediately -and signal an error (G38.2 and G38.4) or set the #5070 to zero. +Likewise; if the probe is already tripped when the 'wait for a trip' +command is given (G38.2 and G38.3); or when the probe is no longer +tripped when G38.4 and G38.5 are given -- the command will abort +immediately and signal an error. [[gcode:probing-codes]] .Probing G-Codes From 4040959cd5377e773e17e46545c57b15a18c5b09 Mon Sep 17 00:00:00 2001 From: Dirk-Willem van Gulik Date: Wed, 25 Nov 2026 16:42:02 +0100 Subject: [PATCH 3/7] Add an example & correct 3/5 not aborting on a normal error --- docs/src/gcode/g-code.adoc | 52 +++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/docs/src/gcode/g-code.adoc b/docs/src/gcode/g-code.adoc index 569d4ba6784..8605cc97cb5 100644 --- a/docs/src/gcode/g-code.adoc +++ b/docs/src/gcode/g-code.adoc @@ -1501,9 +1501,55 @@ G38.2 and G38.4 will signal an error. G38.3 and G38.5 will set #5070 to zero to signal this error. Likewise; if the probe is already tripped when the 'wait for a trip' -command is given (G38.2 and G38.3); or when the probe is no longer -tripped when G38.4 and G38.5 are given -- the command will abort -immediately and signal an error. +command is given (G38.2 and G38.3) - then the command wil abort +immediately and singal an error. G38.4 and G38.5 do not abort; but +signal an error via the return value. + +If you need to tell this case (already in the state we are supposed +to wait for) from the case where that state is not reached; then +the following two examples may be of help. + +.G38.3 Example - distinguish between already tripped and no trip +[source,ngc] +---- +M66 E0 L0 (wait for motion so the probe pin is current) +o if [#<_hal[motion.probe-input]> eq 1] + (the probe is already tripped: G38.3 would end at once without moving) +o else + G38.3 Z-10 F100 + o if [#5070 eq 0] + (no contact: the move reached Z-10) + o else + (contact: the trip position is in #5061 to #5069) + o endif +o endif +---- + +.G38.5 Example - distinguish between already lost and not lost +[source,ngc] +---- +M66 E0 L0 (wait for motion so the probe pin is current) +o if [#<_hal[motion.probe-input]> eq 0] + (the probe is already clear: G38.5 would end at once without moving) +o else + G38.5 Z10 F100 + o if [#5070 eq 0] + (still in contact: the move reached Z10) + o else + (contact lost: the position is in #5061 to #5069) + o endif +o endif +---- + +In above; the 'M66 E0 L0' is used to make sure that the value is current, +rather than the value during the read ahead cycle of the moment before. + +Instead of #<_hal[motion.probe-input]>, the probe signal can also be netted to +motion.digital-in-00 and read with M66 P0 L0, which leaves the state in #5399. + +G38.3 and G38.5 still abort, and call on_abort, on a programming error +(zero feed, cutter compensation on, feed per revolution) or a target +outside the soft limits. [[gcode:probing-codes]] .Probing G-Codes From 484f77b90cb5b091a8cf64e5bf473763bababc19 Mon Sep 17 00:00:00 2001 From: Dirk-Willem van Gulik Date: Fri, 27 Nov 2026 13:03:17 +0100 Subject: [PATCH 4/7] Update docs/src/gcode/g-code.adoc Co-authored-by: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> --- docs/src/gcode/g-code.adoc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/src/gcode/g-code.adoc b/docs/src/gcode/g-code.adoc index 8605cc97cb5..2fd6dea563f 100644 --- a/docs/src/gcode/g-code.adoc +++ b/docs/src/gcode/g-code.adoc @@ -1500,10 +1500,11 @@ If the probe state does not change before the destination is reached G38.2 and G38.4 will signal an error. G38.3 and G38.5 will set #5070 to zero to signal this error. -Likewise; if the probe is already tripped when the 'wait for a trip' -command is given (G38.2 and G38.3) - then the command wil abort -immediately and singal an error. G38.4 and G38.5 do not abort; but -signal an error via the return value. +Likewise, if the probe is already in the state the command waits for +when it is given (tripped for G38.2 and G38.3, clear for G38.4 and +G38.5), G38.2 and G38.4 abort immediately and signal an error. G38.3 +and G38.5 do not abort: they end at once without moving and set #5070 +to 1, the same as when the probe changes state during the move. If you need to tell this case (already in the state we are supposed to wait for) from the case where that state is not reached; then From 174f3946e8308f0d7c7d35044f2ea6664733469d Mon Sep 17 00:00:00 2001 From: Dirk-Willem van Gulik Date: Sat, 28 Nov 2026 14:17:43 +0100 Subject: [PATCH 5/7] Update docs/src/gcode/g-code.adoc Co-authored-by: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> --- docs/src/gcode/g-code.adoc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/src/gcode/g-code.adoc b/docs/src/gcode/g-code.adoc index 2fd6dea563f..a10b51c34c8 100644 --- a/docs/src/gcode/g-code.adoc +++ b/docs/src/gcode/g-code.adoc @@ -1542,15 +1542,16 @@ o else o endif ---- -In above; the 'M66 E0 L0' is used to make sure that the value is current, -rather than the value during the read ahead cycle of the moment before. +`M66 E0 L0` makes sure `motion.probe-input` is read at that point in the +program, see <>. -Instead of #<_hal[motion.probe-input]>, the probe signal can also be netted to -motion.digital-in-00 and read with M66 P0 L0, which leaves the state in #5399. +Instead of `#<_hal[motion.probe-input]>`, the probe signal can also be +netted to `motion.digital-in-00` and read with `M66 P0 L0`, which +leaves the state in `#5399`. -G38.3 and G38.5 still abort, and call on_abort, on a programming error -(zero feed, cutter compensation on, feed per revolution) or a target -outside the soft limits. +G38.3 and G38.5 still abort, and call `on_abort`, on a programming +error (zero feed, cutter compensation on, feed per revolution) or a +target outside the soft limits. [[gcode:probing-codes]] .Probing G-Codes From d3a279aa9d869d1f7343d0e901b206c4be4ac3f7 Mon Sep 17 00:00:00 2001 From: Dirk-Willem van Gulik Date: Sat, 28 Nov 2026 14:17:56 +0100 Subject: [PATCH 6/7] Update docs/src/gcode/g-code.adoc Co-authored-by: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> --- docs/src/gcode/g-code.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/gcode/g-code.adoc b/docs/src/gcode/g-code.adoc index a10b51c34c8..61283967fc2 100644 --- a/docs/src/gcode/g-code.adoc +++ b/docs/src/gcode/g-code.adoc @@ -1513,7 +1513,7 @@ the following two examples may be of help. .G38.3 Example - distinguish between already tripped and no trip [source,ngc] ---- -M66 E0 L0 (wait for motion so the probe pin is current) +M66 E0 L0 (dummy read, so motion.probe-input is read here) o if [#<_hal[motion.probe-input]> eq 1] (the probe is already tripped: G38.3 would end at once without moving) o else From 5a6725c249f5a28ff08a340658d7323e60428c5b Mon Sep 17 00:00:00 2001 From: Dirk-Willem van Gulik Date: Sat, 28 Nov 2026 14:18:10 +0100 Subject: [PATCH 7/7] Update docs/src/gcode/g-code.adoc Co-authored-by: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> --- docs/src/gcode/g-code.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/gcode/g-code.adoc b/docs/src/gcode/g-code.adoc index 61283967fc2..c9714a2b288 100644 --- a/docs/src/gcode/g-code.adoc +++ b/docs/src/gcode/g-code.adoc @@ -1529,7 +1529,7 @@ o endif .G38.5 Example - distinguish between already lost and not lost [source,ngc] ---- -M66 E0 L0 (wait for motion so the probe pin is current) +M66 E0 L0 (dummy read, so motion.probe-input is read here) o if [#<_hal[motion.probe-input]> eq 0] (the probe is already clear: G38.5 would end at once without moving) o else