A Little G-Code Help

Been working on learning G Code and have a fairly basic question. Below is a piece of code (part of Phil’s keyhole code) and just wanting to know about first and last line. Is there a rule for when the “0” is needed before the decimal point? In line one there isn’t one before the .15000 but in line four there is one before .37500. Running a test I added on in the first line and it seemed to go OK but just wondering if it makes a difference?

G0Z.15000
G0X0.0000Y0.0000S12000M3
G0X0.0000Y0.0000Z0.2000
G1Z-0.37500F5.0

The leading zero makes no difference with any of the software I am using.

Thanks, I appreciate the answers.

1 Like

The leading zero before the decimal is optional. Some post-processors will omit it to reduce file size. It’s quite possible that if the negative sign is present, it’s no longer optional, which would explain the difference between the two in this case. I’m surprised that the X0.0000 and Y0.0000 aren’t just X0 Y0 as trailing zeros are optional too.

Here are some links to Gcode info.

Hope this helps.

I usually like just messing with something to see how it works BUT I just learned more in 15 minutes than in 3 hrs of playing around with g code! Thanks for the information and links. Stephen, the three links were good but last one was especially helpful!

@RayMacke It is great that you are diving deep into gcode. It is always helpful to know how things work at the lowest levels.

My favorite gcode reference is the one for Linux CNC. Linux CNC and Grbl are pretty strict about following proper gcode rules.

With regards to what can be put on a single line, you should read the reference about gcode modal groups.

Glad the links helped.
:slight_smile: