What's new
What's new

G Code Demystified

Jaden

Aluminum
Joined
Jan 31, 2015
Location
Calgary
Does G Code vary from machine to machine? Older Ncs compared to newer ones? Or is it the same programming language and commands throughout the CNC world?
 
I think most of them are the same. I think some of the newest controls probably have a bit more variety. There was a post recently about someone using a brother (I think anyways) and it had different M codes, all unfamiliar to me, for surfacing accuracy. Haas uses a G187 and P value to define 3 different presets on accuracy, I think that is exclusive to them, although other mtb may have their own G and/or M codes to do the same.
G-code - Wikipedia, the free encyclopedia
 
Different brands use different codes for the most part,but there are a lot of common ones that are the same.
 
X2.

Anyone here ever run a wire EDM? Very few G-Codes are the same.

Good point, I was thinking milling, not every type of machine that uses g code. The Charmilles (mid to late nineties vintage anyhow) has it's own programming system entirely. It had 3 files used in conjunction to run a program typically. Although I have seen the techs use just the .cmd and .tec to run test programs. You could program shapes inside the .cmd using the command words if you wanted, cta, ctr and x/y coordinates...
 
Wow you guys are all over the map. Which is it? Listening to the comments the standard seems to be diminishing due to proprietary reasons. As time goes on, there's less standardization? Sounds like there's a marketing opportunity here, make a program that takes your language of choice and coverts it into the machine language you are using.
In this day and age it doesn't have to be this way! lol
 
Wow you guys are all over the map. Which is it? Listening to the comments the standard seems to be diminishing due to proprietary reasons. As time goes on, there's less standardization? Sounds like there's a marketing opportunity here, make a program that takes your language of choice and coverts it into the machine language you are using.
In this day and age it doesn't have to be this way! lol

The situation is a little complicated due to evolution as time went by. Back in the day, artwork for printed circuit boards was created by photo plotters using Gerber code which also was used for some other simple machines.
In the case of photo plots the machine was similar to a CNC router except that it had a light source instead of a spindle. Mechanical apertures were placed in front of the light to create the shapes. Pads for devices were "flashed" similar to drilling. Traces were routed by leaving the light on while the head was moved along similar to milling. The apertures were changed the same as tools in a CNC mill.

A different part of the Gerber file specified drill sizes and locations. There were also solder mask layers created in a manner very similar to the copper layers.

As time went by more sophisticated machines than plotters and 2-axis milling and or drilling machines were developed. The code had to be stretched and adapted to these new machines. This is a simplified explanation of a complex subject but once the basics of G code are learned it becomes a matter of learning the additional codes (or other functions of the same code) for other machines
 
Wow you guys are all over the map. Which is it? Listening to the comments the standard seems to be diminishing due to proprietary reasons. As time goes on, there's less standardization? Sounds like there's a marketing opportunity here, make a program that takes your language of choice and coverts it into the machine language you are using.
In this day and age it doesn't have to be this way! lol

G-Code was designed as a "user defined" language - for a reason. There are thousands upon thousands of machines out there that utilize G-code that ARE NOT a standard 3-axis mill or 2-axis lathe. The language was designed to be adaptable for all machine tools and it is very good at that. The ones listed by Joe quickly became very standardized because of industry. Past those, most of the rest are "user defined" - meaning the Machine Tool Builder or Control Builder decide what action those codes actually perform.
 
Which brings us to another key point - it is not hard to define a universal language that could translate into G-code (and ADT may have done it.) It is not structurally hard to account for all of the variations seen so far, though keeping up with them all could be quite a pain.

It is, however, pointless.

Because a great deal of what is in a post, of what is machine specific in a program, is actually *peculiar* to a particular machine. As in, this exact model of machine from this exact vendor has a hydraulic whisk broom used to automatically clean vises. Or this machine is an EDM and so spindle rotation means nothing, but electrical parameters mean quite a lot. So your 5-axis mill program was never going to run on your 4-axis EDM regardless of what language is used. Your 3-axis mill program will either have to change, or really need to change, unless the new target machine has the exact same set of spindle speeds, and the like.

So what does "g-code compatible" really mean? It's a kind of market speak for "Your technical staff will be able to grok this quickly - they already know it's basic structure, they already know how to write a general class of program, all they have to spend time on learning is the special things which are in this manual I've just handed to you". This means it's generally easier to absorb than if somebody says "here's our new 5-axis dematerializer, you program using a set of primitives we make available in brainfuck[1]"

That's really the only advantage of G-code - it doesn't have most of the advantage of detailed and complete compatibility for things like PC programs, or socket wrenches. It was never intended to, and covers a field of activity where that wouldn't work well anyway.

By the way, the heidenhain H language (they call "conversational") is semantically equivalent - if you you know how to write G-code programs, you know how to write .H programs, it's just nicer keywords.

[1] - brainfuck is a real programming language (which why I repeat the uncivil name) which is provably Touring complete - meaning you could indeed write machine tool programs using it.
Brainfuck - Wikipedia, the free encyclopedia
 
By the way, the heidenhain H language (they call "conversational") is semantically equivalent - if you you know how to write G-code programs, you know how to write .H programs, it's just nicer keywords.
The H language is much more consistent over time and controls as well. You could say they have the advantage of building the controls that use it, but certainly Fanuc has not capitalized on the same situation.
 








 
Back
Top