Adjusting Z-axis zero "on the fly"

Hey all,

I’ve been doing some scratch engraving lately, where the tool bit is only 0.005 or so into the workpiece, so you just have a thin line left on the surface.

As you might imagine, unless your workpiece is nearly perfectly flat, you will have some variation in the depth of the scratch, and might end up with a much more noticeable groove, or the tool might not even tough the surface.

My workaround up until now has been to scratch engrave at a depth that seems right, and if it’s going too deep, pausing the work, re-zeroing up or down a few 0.001’s, and resuming the work.
This still leaves me with some portions that are un-cut unless i’m redoing this every move. This is very labor and coding intensive since I have to manually go in and cut out parts of the gcode that don’t need to be run again, hoping that I don’t delete the wrong part or end up with a G0 command left un-specified (potentially running a scratch across the whole surface while traversing).

My “attempt” at rezeroing on the fly has been to write a bit of code for a macro:
G01 z0.001 G38.2 Z0.000 G01 Z-0.005 macro1: “up 0.001”
G01 -z0.001 G38.2 Z0.000 G01 Z-0.005 macro1: “down 0.001”

which pulls it up to 0.001 above (or below) zero, rezeros there, and returns it back to required cutting depth of 0.005 (for my scratch engraving).

As you might imagine this is very slow, moving the cutting head off and onto the surface.
And this only works for fixed-depth cutting, where it’s only ever supposed to cut at 0.005.
What would be ideal for my circumstance is to be able to incrementally adjust z-axis zero “on the fly” without the motion. That way when I start V-carving, where Z is always going in and out, and not always cutting at a fixed depth, I can similarly monitor the cut, and fine-tune the depth as it goes.

Is there a way to do just declare “z axis zero is now + 0.001 relative to where it is now, for the rest of the cut” or “…-0.001…”?

I looked into using G38.2 in relative (G91) mode, but apparently G38.2 ignores that and just assumes you are in absolute mode (G90).

Is there a way to do it with WCS or something?



There isn’t an easy way to this right now, but it might be a nice feature to add. Your macros are really nice.

What would the ideal feature look like? A slider? A button to shift the z-home by some amount?

I think a pair of buttons: up and down.
you could make it a user adjustable amount +/-, be that by the 0.001th inch or the 0.01 mm or whatever.

I think to use the G38.2 function, one would need to know the existing Z depth, so you could return it to that depth. I’m not sure you can write a macro with a variable in it.

Since the arduino is counting encoder steps on the stepper motors, maybe it would have to be a function that works at that level…takes the saved “zero” encoder position and adds some user defined number of steps and resaves it as the new encoder position for “zero”.

Can the macro even access functions at that level (outside the “G-code” world and onto the arduino board’s level of counting steps)?


1 Like

Yeah I don’t think you can, but it could be done in the firmware. I’m going to look into adding something like that to the next version.

I think that’s exactly how it would work.

Unfortunatly not :confused: