Skip to content

Clarification to G38 commands - #4868

Open
dirkx wants to merge 2 commits into
LinuxCNC:masterfrom
dirkx:feat_g38_docs
Open

dirkx wants to merge 2 commits into
LinuxCNC:masterfrom
dirkx:feat_g38_docs

Conversation

@dirkx

@dirkx dirkx commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Clarification to G38 commands; especially to what happens if things are already in the state the g-code should be waiting for.

See

if (probeval != probe_whenclears) {
for the actual logic.

…re already in the state the g-code should be waiting for
Comment thread docs/src/gcode/g-code.adoc Resolved
Comment thread docs/src/gcode/g-code.adoc Resolved
@grandixximo

grandixximo commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

The new paragraph says G38.3 and G38.5 also abort when the probe is already in the target state; they don't. Only G38.2 and G38.4 abort. G38.3 and G38.5 end at once at the start point and set #5070 to 1, as if the probe had tripped there. The error message naming G38.3 is wrong, which is easy to be misled by; I opened a PR to fix it.

That also covers the G38.7 and G38.9 you proposed in #4874: a check of the probe before the move, plus #5070 after G38.3 or G38.5, already tells the three outcomes apart without a new G-code. Could you add these to the docs in this PR? Read the pin after an M66 E0 L0, so the value is current rather than read ahead of the motion before it.

G38.3:

M66 E0 L0 (wait for motion so the probe pin is current)
o<probe-to-contact> if [#<_hal[motion.probe-input]> eq 1]
    (the probe is already tripped: G38.3 would end at once without moving)
o<probe-to-contact> else
    G38.3 Z-10 F100
    o<probe-to-contact-result> if [#5070 eq 0]
        (no contact: the move reached Z-10)
    o<probe-to-contact-result> else
        (contact: the trip position is in #5061 to #5069)
    o<probe-to-contact-result> endif
o<probe-to-contact> endif

G38.5:

M66 E0 L0 (wait for motion so the probe pin is current)
o<probe-to-loss> if [#<_hal[motion.probe-input]> eq 0]
    (the probe is already clear: G38.5 would end at once without moving)
o<probe-to-loss> else
    G38.5 Z10 F100
    o<probe-to-loss-result> if [#5070 eq 0]
        (still in contact: the move reached Z10)
    o<probe-to-loss-result> else
        (contact lost: the position is in #5061 to #5069)
    o<probe-to-loss-result> endif
o<probe-to-loss> endif

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants