Becoming Familiar With Code

Author James Harvey
Published
October 01, 2016 - 02:45pm

With the advent of CAM software, generating G code is no longer the big deal it was a few decades ago. A CAM system will generate all the G code you need in a matter of seconds. Presented here is the first part of a multiple-part series of columns on the subject.

An adapter plate can be machined using manually written code. Image courtesy J. Harvey.
An adapter plate can be machined using manually written code. Image courtesy J. Harvey.

“G code” is an all-encompassing, informal term used when referring to CNC programming code. For example, when troubleshooting, you may hear someone say, “The drawing is correct; the problem must be in the G code.” This means the problem is in the CNC program. Not all controllers use the same G code, but, generally, there are many similarities.

Learning G code may seem tedious at times, but becoming familiar with it is necessary to edit programs at the machine. As good as CAM systems are at spitting out G code, if you don’t know the functions of the code and how to edit it, you will be at a disadvantage in terms of making adjustments at the machine. Many unproven programs have issues that must be fixed or fine-tuned.

The majority of machining operations can be undertaken with just a handful of G and M codes. G codes can loosely be described as tool-positioning codes, and M codes as switches for actuating mechanisms, such as the toolchanger, the chip auger and valves that open and close to allow and restrict coolant or air flow. M codes have other functions as well. If you’re new to CNC programming, it may look complicated. However, simple patterns will soon emerge that appear over and over again.

Now that machining operations are created with CAD/CAM applications, G code can be output for a specific machine using the appropriate post-processor, which is just a computer file. With the correct post-processor, incompatibility is not that much of a problem anymore, at least not for computers. Operators may still have issues with variations in G code as they move from one machine to another.

Writing programs manually is a good way to become familiar with G code. I have always preferred learning something by doing a project, so that’s how I’m going to present the material for this series of columns. Specifically, in the December issue of CTE, I will present a manually written program for machining an adapter plate. The adapter plate is similar to one I made for a hydraulic valve for an existing molding machine.

Related Glossary Terms

  • computer numerical control ( CNC)

    computer numerical control ( CNC)

    Microprocessor-based controller dedicated to a machine tool that permits the creation or modification of parts. Programmed numerical control activates the machine’s servos and spindle drives and controls the various machining operations. See DNC, direct numerical control; NC, numerical control.

  • computer-aided manufacturing ( CAM)

    computer-aided manufacturing ( CAM)

    Use of computers to control machining and manufacturing processes.

  • coolant

    coolant

    Fluid that reduces temperature buildup at the tool/workpiece interface during machining. Normally takes the form of a liquid such as soluble or chemical mixtures (semisynthetic, synthetic) but can be pressurized air or other gas. Because of water’s ability to absorb great quantities of heat, it is widely used as a coolant and vehicle for various cutting compounds, with the water-to-compound ratio varying with the machining task. See cutting fluid; semisynthetic cutting fluid; soluble-oil cutting fluid; synthetic cutting fluid.

  • toolchanger

    toolchanger

    Carriage or drum attached to a machining center that holds tools until needed; when a tool is needed, the toolchanger inserts the tool into the machine spindle. See automatic toolchanger.

Author

Shop Operations Columnist

James A. Harvey is a machinist and moldmaker who has worked in shops across the U.S. for nearly 40 years. Harvey’s Shop Operations column for Cutting Tool Engineering magazine is adapted from information in his book “CNC Trade Secrets: A Guide to CNC Machine Shop Practices,” published by Industrial Press Inc., South Norwalk, Conn. The publisher can be reached by calling (888) 528-7852 or visiting www.industrialpress.com. By indicating the code CTE20OFF when ordering, CTE readers will receive a 20 percent discount off the book’s list price of $29.95.