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?

Thanks!

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

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

G0 Z10;
G10L20Z16;

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?

G10L2Z6
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.

code:
T1
G17
G20
G0Z0.8000
G0X0.0000Y0.0000S12000M3
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"
G0X0.2202Y-0.2771Z0.5000
G0Z0.2000
G1Z0.0000F10.0
G1X-0.2202F25.0
G1X-0.2510Y-0.2510
G1X-0.2889Y-0.2063
**** 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***
G1X0.0493Y0.3717
G1X0.0000Y0.3750
G0Z0.5000
G0Z0.8000
G0X0.0000Y0.0000
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
G0Z0.8000
G0X0.0000Y0.0000S12000M3
G0X0.2202Y-0.2771Z0.5000
G0Z0.2000
G1Z0.0000F10.0
G1X-0.2202F25.0
G1X-0.2510Y-0.2510
G1X-0.2889Y-0.2063
**** goes off and cuts second circle *****

TIA!

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?

2 Likes

@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.