Talk:G-code

From Wikipedia, the free encyclopedia

G-code and Gerber File articles seem to describe the same file format. At least googling for cnc "gerber" g00 g01 g02 and cnc "g-code" g00 g01 g02 gaves pages with similar lists. However I have little CNC experience to confirm this. --195.113.20.80 16:08, 26 Apr 2005 (UTC)

[edit] Units

What about the units used in the G-code? I mean, where is it defined whether one uses inches, or centimeters, or some other unit? 134.58.253.114 10:53, 19 December 2005 (UTC)

As far as I know units are not defined - user has to supply it externally. Milimeters or (fractions of) inches are used. --Alvin-cs 18:37, 12 February 2006 (UTC)
I'm in my 3rd year at Deakin Uni Australia learning robotic engineering. All international specialists (except for a US specialist) that visited our division said it's best to design and program NC hardware to the world standards(ISO) which is Metric. I do recall one of the Italian lecturers from BLM Group stating it's ignorant and unprofessional to design NC equipment to anything other than ISO standards. So it's probably best for US engineers to stay in the imperial rutt.

There is a pair of G codes to switch between "inch" and metric. All CNCs have some way to switch between the two systems.

In general, G-codes are a simplistic progamming language. There are G code pairs to switch between not only inch and metric, but absolute and incremental coordinate designation. G codes are put into groups. The "motion" group includes G01 to denote linear departures, G02 to denote clockwise arc paths and G03 to denote counterclockwise arc motions.

There is only one CNC manufacturer that continues to use the EIA RS-274D standard for G code programming. All other manufacturers have adopted the international ISO standard. The two systems, while not identical, have significant overlap and commonality in how the G codes are used.

Just for clarity, G20 and G21 are the standard codes to specify units in inches or millimeters, respectively. Most machines will have a set of system variables accessible from both machine setup and parametric programs to permanently alter system defaults, one of which is inch/millimeter mode.
Inches vs. Metric: Almost all the large machine tools, both under manual and NC control, are still in inches. Example: The shipyard lathes used to turn driveshafts on large seagoing vessels, such as nuclear aircraft carriers. Many large floor and planing mills are still inches, as well. At least in the United States economy, these tools play a role in keeping some industries in inches. Why would you buy a 600 foot between center CNC lathe to replace the perfectly functional manual/NC one you already have, just to get millimeters? More importantly, where are you going to get it from in the first place? A floor mill with an 8'x8' table and 18' of pendant travel? Or a 15'x15' vertical boring lathe? Very few manufacturers are making equipment this large, and it is expensive to commission and transport. Lathes and mills that size were built in the 1920s and '30s, and are still alive and maintaining accuracy. No one wants to shell out the money for a new one just so they can switch over to metric. Some machines get converted to CNC. Even so, conversion is still an ineffective option for some of the larger tools, or smaller shops that work on big jobs. Or the machine design might prohibit it.
Outside very-large-job shops, automatic screw machines are another bit of old equipment many production shops use in quantity. Most of those are still in inches. A fancy CNC lathe or turning center isn't going to beat a screw machine in productivity, no matter how hard the lathe manufacturers try. They just can't get four second part cycles with one spindle and a turret yet. Screw machines are cheaper and produce more parts per hour. Some shops can afford to switch to CNC screw machines or rotary transfers, but that isn't common yet. So if the machines that are going to produce the part the cheapest are imperial, do you want to design in metric and have to submit a second set of weird/non-standard imperial drawings? Or are you just going to design your part in inches in the first place?
I really wish we'd just switch and use metric, because it would mean I don't have to stock and track of two sets of tools plus spares. But, in the end, it doesn't matter to the person making the parts if it's inches or metric - it matters to the machines. - Toastydeath 07:31, 26 November 2006 (UTC)

[edit] Tool Changes

While the examples are interesting, they all lack one rather important thing: They never actually execute a tool change. T-- prepares the tool changer for the next tool swap, in the event the changer has such capability (most lower-end machines do not). M06 swaps the tool out. I have a few other concerns in this same area, and I'm going to pick on one program in particular. All suffer problems.

It begins like so: N1 X0 Y0 T01. This either goes to WCS 0,0 or doesn't move at all. We can't be sure, as the program isn't setting default modes. Then, it prepares the tool changer for a tool swap, but doesn't do anything. If the tool change DID execute via M06, the X and Y don't matter in the slightest, as the spindle on vertical machines needs only travel upwards to meet the changer. Both horizontal and vertical machines will move themselves to the tool changer in the event of a tool change, as absolute 0,0 can be anywhere on the bloody table. On top of this, no movement modes have been entered. So, even in the instance above, the machine doesn't have any of the information it needs to go anywhere (unless the machine enters a movement mode on startup, or you were running a program that actually did something beforehand). This program does nothing, moves the tool changer, and then does nothing again.

One generic, thoroughly explained program aught to be enough. Moreover, it should actually run on a machine if an example is to be included at all. Reducing complexity is necessary teaching new concepts, but not to the point where the information doesn't actually help anyone.

- Toastydeath 06:26, 29 November 2006 (UTC)