When Programmers Should Know G Code


Facebook Share Icon LinkedIn Share Icon Twitter Share Icon Share by EMail icon Print Icon


The majority of programmers use some kind of CAM system to prepare their CNC programs. The product of any CAM system is a G-code program from which the CNC machine will run. While CAM systems simplify programming, most programmers have to know something about G code. How much they must know depends upon five factors.
• How often are program modifications required at the CNC machine?
The more varieties of work a company takes on, the more often it has to handle new and unfamiliar processes. This often equates to imperfect CNC programs that must be optimized at the CNC machine, at the very least. More likely, unfamiliar processes will require more substantial program modifications once the job hits the machine.
Another condition that requires at-the-machine program changes is variation from one time a job is run to the next. Variations in material hardness, raw material, cutting tool selection and workholding setup will cause a program that ran well in the past to fail in the future. The long-term solution is to eliminate the variations, but if they occur, programs have to be changed at the machine.
Program modifications required at the machine must be done at G-code level. A programmer shouldn’t have to go back to the CAM system for every minor program edit. At the very least, programmers must be able to change cutting conditions such as speeds, feeds and depths of cut. With processing mistakes, programmers may also have to change the machining sequence— as in running one tool before another. They should also be able to catch and eliminate wasteful motions.
• How well optimized is the CAM system?
Most CAM systems allow users to fine-tune almost every aspect of CNC program creation. Doing so enhances efficiency and requires a good understanding of G code. Once the CAM system is optimized, a person with lesser G-code skills can use it. 
CAM systems vary with regard to how well optimized they are when they are first purchased. Some users set the defaults for worst case scenarios. While this may make them safer to use, especially for beginning CAM system programmers, the G-code programs they output will not be very efficient.
A programmer must be able to recognize wasteful G code. Programmers can watch a program run and notice obvious wasteful functions. These include wasted rapid motions such as approaching and retracting in one axis at a time as well as independently activated functions that could be activated simultaneously (such as spindle start within an approach motion).
Less obvious functions for machining centers include readying the next tool while the current tool is machining as well as orienting the spindle during the cutting tool’s retract to the tool-change position. Less obvious functions for turning centers include inappropriate use of constant surface speed, which can lead to wasted time; undue wear-and-tear on the spindle drive system; wasted electricity; and the absence of spindle range changes that can keep the spindle running at the appropriate speed for rough-machining operations.
There are many ways to improve the efficiency of G-code level CNC programs. In order to incorporate any of them into the G-code programs created by CAM systems, the programmer must understand the related G code.
• How complex is your work?
While CAM systems are great for simplifying complex work, they don’t tend to be as helpful with simple work. Generally speaking, many of the same tasks required to generate the program for a complex workpiece must also be done to create the program for a simple workpiece. For simple work, writing the program at G-code level (manual programming) may be easier than using the CAM system.
• How often are process changes made?
The more work you do of a similar nature, the more likely you are to use the same cutting tools for a variety of different jobs. If a process change is made that requires a change in cutting tools, it is probable that all of the programs that used the old cutting tool will need to be changed. The more programs you have, the more daunting this task will be. Depending on the complexity of the required changes, it may be faster and easier to make the changes at G-code level than from within the CAM system.
• Do you ever get program alarms when running new programs?
If a CNC machine sees a command it cannot execute, it will generate an alarm—regardless of whether the program was created manually or with a CAM system. The programmer must be able to diagnose and correct the problem that caused the alarm. While the alarms are pretty specific, it can still be a challenge to fix the program once the reason for the alarm is understood. A good understanding of G code will be required to do so.