G-Code Standards and Dialects: Skill Guide
There Are Many Dialects of G-Code
There are Many Dialects of GCode…
Some wag once joked that the great thing about standards is there are so many to choose from. So it is from G-Code. While much of it remains the same from controller to controller (setting aside alternatives to G-Code from things like Mazatrol, Heidenhain’s Conversational CNC language, and others), there are important details and defaults you need to be aware of to understand the particular dialect of g-code your controller needs to be happy.
In terms of sheer numbers of users, the Fanuc dialects of G-Code are probably the most common among professionals and Mach3 among hobbyists. This is not to say they are better than other G-Code dialects, just that they are more common and so if you’re going to talk to other machinists or move around from job to job and machine to machine, it may be helpful if you’re familiar with those dialects and how they differ if your machine doesn’t use one of these two controllers.
G-Code has an extremely long history. The first attempts at standardizing it came out of the Electronics Industry Association’s RS-274 standard which has evolved to NIST’s RS-274NGC standard. The original EIA standards work was begun in the 1960’s but the first standard wasn’t released until 1980. Even though there are now standards (ISO has one too that is nearly the same as RS-274), it isn’t clear how many controllers out there are purely standards based. Indeed, many controls will claim to be some standard or other, but when you look closely at the details they’re pretty non-standard.
How Are the Dialects Different?
G-Code dialects differ in a variety of ways. Most manufacturers have added their own little bells and whistles to make their dialect better for competitive and marketing reasons. For example, Haas has a series of special g-codes for pocket milling, as well as some special parameters and capabilities on some standard G-Codes. It pays to understand the special capabilities of your machine because they were probably put there to save time based on feedback the manufacturer got from its customers.
In general, we see the following categories of differences between G-Code dialects:
– Which G-Codes are Supported. Not all controllers support all G-Codes. For example, many early lathe controls do not support the G71 and similar roughing cycles.
– G-Code mappings. Sometimes the same function will be supported by different g-code numbers on different controls.
– Parameters and Macro Programming. Parametric programming with macros is something that emerged after the basic standards were in place. Fanuc Macro B is probably the most common standard for it. Many controls are very limited in their capabilities around Macro Programming and there are a lot of detail differences around exactly how Macros work.
– Parameters. Many G-Codes need additional information to do their job, so they use other words (letters) to collect that information. Exactly which words collect which information can vary from one control to the next.
– Formatting. Some controls allow G0 or G00. Some insist on G00. Some allow numbers with no decimal, others insist on a decimal or even a trailing zero. “1”, “1.”, and “1.0” are all variations that may be accepted, rejected, or required when specifying the number 1.
We’ll talk more shortly about what all of this means, but for now, be aware that these differences exist. For simple programs and MDI use, obviously a lot of this won’t matter. But, for writing complex hand-written G-Code or trying to understand why the G-Code your CAM program emits isn’t quite right, you’ll need to be aware of the dialect issues.
For purposes of this tutorial, unless we specifically say something different, we’re going to assume you’re running a Fanuc controller. If you follow along with our exercises with G-Wizard Editor, you should run a Machine Profile for the Fanuc Controller, preferably by downloading our canned profile. When you go to program for your machine, you’ll need a profile properly set up for your machine!
1. Look up what g-code dialect your CNC machines use. Are they Fanuc? Mach3? LinuxCNC? Or something else? Does the manufacturer claim compatibility with a standard?