Understanding g-code

Good morning,

I’m curious, is there an easy way or place to learn or understand g-code?

The reason I’m asking is because I was cutting a project last night, there was a circle cut all the way through the board in the center of the project. I was using masking tape/crazy glue as the hold down method. Well, the circle that was cut loose didn’t get caught very well by the tape, so it broke free and bound up the bit.

I think if I understood the g-code, I could have sorted out which line things went awry, and I could of started the job after that point.

there’s really complicated stuff. but most of it is simple

G code has some boilerplate stuff, but everything else is basically a series of X Y and Z moves
generally all coordinates are relative to your zero, and in metric (you can have imperial gcode but it’s rare)
There’s 2 speeds, G0 (rapids) and G1 (normal cutting).

A line can look like

G1X400Y300Z200F5000

which means "Go at cutting speed to X coordinate +400mm, Y +300mm and Z+200 at speed 5000 mm/min)

All of these are sticky, which means that if the line after it says
Y500
all the not mentioned elements are kept from the previous line, and only the Y coordinate is changing.

… and that’s basically it.

you can use a tool like ncviewer in your browser to even get a visual of the result, and walk through your gcode line by line to see the where in the design the line is that you highlight

1 Like

Thank you for the explanation. I had looked through it, and figured it was an x,y,z point, but then didn’t know know it goes from point a, to point b, to point c, etc.

I thought about starting to cut over from the beginning, (it was about halfway through), so I know it would have just cut air up to the point where things went wrong…but I threw in the towel.

Thank you

I’ve just started diving into GCode myself and this has been great stepping through the code line by line and visually seeing what it’s doing. So take the file you want to look at closer and step through it in NCViewer and Google search a description of the command on that line (ie. G0, G1, G91,…). You’ll find a site fairly quickly that has all the commands explained.

Thank you!

This stuff is making me break out my high school geometry

so if you want to start at some “random” point you need to be careful about 2 things

  1. where the spindle is when it starts, since the moves are “from wherever you are go HERE”… if it’s in a bad spot, it will still just go there… it could go through all your material :wink:
    Best way to deal with this is to go back a little to the last time the cutter was above the material (positive Z) and start there… much safer that way
  2. since all the G/X/Y/Z/F are sticky, make sure the first line you restart at has all of those on it…
    you don;t want to run a line with unknown “inherited” values from some previous thing
1 Like

Okay. That definitely makes sense.

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