Manually changing Z zero in gcode

Hi all… I want to manually change my Z zero in the gcode after it is created… Is there a command to do that or can I just add a line with something like z0 = z0 + 6 ?

Basically I want to zero on the workpiece but then actually run the program 6mm higher than that. Yes I know I could just zero it then move it 6mm up and zero it again. That’s what I’m doing now and I want to do it in the gcode because I want to end up 1 program with several changes in z zero. Basically manually making depth of cut changes that the software can’t do.

Orrrr do I need to do some kind of find/replace maneuver?


You can’t add quite like that, but it can be done.
Permanent (until you change again) change:
G0 Z10 ;move to safe retract height (assuming mm)
G10L20Z4 ;Set current location to previous -6mm

You can also use G92 in place of G10L20 for offsets that will reset when controller resets.

1 Like

So then this would move it back to the original zero…?

G0 Z10;

What about command L2?

Ansnisnthat order correct? The wiki has it this way: G10 P1 L20 ?

The P word defined the coordinate plane. Unless you’re using multiple in one job, I’d recommend leaving it out.

1 Like

Would this be the same thing, without depending on the actual machine position?

Then G10L2Z-6 to move back?

Thanks a lot for the help!

Sorry, just saw this.

No, I wouldn’t mess with G20L2 as that is an offset to your MACHINE origin. When you send G10L2Z6, you’re setting your Z0 6mm ABOVE your limit switch.

1 Like

@neilferreri So I gave it a try with some practice code and can’t seem to get it right. My code is below. The first time the Z zero ended up 0.64" above the surface (instead of 0.16"). The second time it ran perfect as I wanted. The third time it was back to 0.64" above the surface and the 4th time 1.28" above the surface. Any idea what am I doing wrong? I’m actually in inches, and I wanted the first cut to be 0.16" above the original Z zero, and the second pass back with the original Z zero. Carbide Motion wouldn’t load the file with G10L20 - it spit an error about position so I added in the P1.

G0Z0.2000 --------- I added this line trying to move Z zero up by 0.16"
G10P1L20Z0.0400 --------- I added this line trying to move Z zero up by 0.16"
**** blah blah it goes off and cuts a circle ***
**** picks up when finishing the first circle, I copy pasted the code again for round 2***
G0Z0.2000 ------ I added this line trying to bring Z zero back to original Z zero
G10P1L20Z0.3600------- I added this line trying to bring Z zero back to original Z zero
**** goes off and cuts second circle *****


The G10 commands write to the controller’s EEPROM, or non-volatile memory. That takes time. Add a G4P0.5 before and after the G10 command. That will allow for a half second dwell (delay) to allow the buffer to clear and the EEPROM write to succeed.

EDIT: I knew this sounded familiar:

Now I’m curious…what are you doing?


@neilferreri ok I’ll give that a try tomorrow. This is for a male vcarve inlay. With the start depth and flat depth reversed it will basically ignore the max DOC setting and take the whole cut in one go unless you manually intervene. Allaboardwoodworks on Instagram if you’re interested.

Great work!

I’d love to see a quick write-up on how you do this. I’ve yet to try a v-carved inlay. Actually, I think I glued one up a few years ago, using F-Engrave, and then realized I didn’t have a decent saw to separate the halves…not sure where that is now. My garage has since been buried under toddler toys, but I also have a few more tools.

1 Like

@neilferreri finally got a chance to try the time delay and it worked. I did 5 seconds to be safe. Thank you very much!

Glad it’s working.

Shouldn’t need to be that much…fractions of a second should be enough.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.