G Code Basics

Here are five program-related tasks every operator should know.

If your company is like most, you probably expect a lot from your CNC operators. In addition to loading and unloading workpieces, and activating cycles, operators are commonly expected to measure workpieces, report measured sizes, determine if sizing adjustments are necessary and, if so, adjust offsets accordingly. They may even be expected to perform non-CNC related tasks like cleaning and deburring workpieces, as well as certain preventive maintenance tasks. And to top it all off, operators are often expected to run two or more CNC machines at the same time.

You may be so busy training operators to perform these tasks that you are overlooking some other important program-related information. These are instructions that a programmer or setup person may take for granted, but if you do not include them in your training, the CNC operators may miss out on basic, but needed information.

1. How to find restart commands. It is often necessary to rerun cutting tools in a program. After a program’s execution is stopped and the reason for the stoppage has been addressed, the operator should not rerun the entire program just to get to the cutting tool that was active when the program was halted. Doing so would be a waste of time and could result in additional machining on previously machined surfaces (due to the absence of tool pressure). On most machines, the operator should instead restart the program from the cutting tool that was active at the program stoppage.

In such a case, if an operator is expected to restart the program from the beginning of a given tool, he or she must, of course, be able to find and scan to the restart command. For turning centers, this is commonly the turret index command. For machining centers, it is commonly the tool-changing command (unless the cutting tool is already in the spindle, in which case it is the command after the tool-changing command).

2. How offsets are instated. Most sizing adjustments are made with offsets, and production-run documentation should specify which offsets should be used for each cutting tool. Even better, operators should be shown which offset is involved with machining each workpiece surface. This way, they will know which offset must be modified when a machined surface must be adjusted.

Unfortunately, production-run documentation, if it exists, is rarely detailed enough, and operators often must figure out on their own which offset is being used to machine critical surfaces. Programmers tend to use unwritten rules for selecting offset numbers, like making the offset number correspond in some way to the tool-station number. If you expect your operators to determine on their own the offset numbers for sizing, be sure they know how offsets are instated within the program (with the last two digits of the “T” word on turning centers, and with “H” and “D” words on machining centers).

3. How to determine current modal states. Some odd things can happen if a modal state is inadvertently changed. One classic example is related to subprogramming. Maybe the programmer of a FANUC-controlled turning center specifies a G98 to call the subprogram when, of course, he should specify an M98. Even after diagnosing and correcting this issue, there will still be a problem, however. The machine will be in the feed-per-minute mode, and any feed rate intended to be in feed per revolution (G99) will be taken as feed per minute. Similar problems involve inadvertently activating certain programming features like mirror image, coordinate rotation and scaling. All of these can be difficult problems to diagnose.

Whenever a machine is behaving in an unusual manner, operators should know to check to see which modes are currently active. This means they should know the related G codes. FANUC controls show currently active modal information on the Program Check page. 

4. How to find and alter spindle speed and feed rates. Companies’ approaches vary in terms of how much program control they allow their CNC operators. One of the first freedoms they may allow experienced operators is related to modifying cutting conditions. This is especially true when the company encounters variations in raw materials. Maybe hardness variations are causing cutting tools to wear out faster than they should.

At the very least, operators should know the words related to speed (S) and feed rate (F), and what their values represent. Speed, for example is always specified in revolutions per minute (rpm) for machining center applications but often is specified in surface feet per minute (sfm) for turning center applications. Feed rate could specify feed per revolution or feed per minute, based on the set feed-rate mode. The operators should also know the G codes related to speed and feed-rate mode selection. With this information, they will at least be able to determine what the various speed and feed-rate words in a program represent.

5. How coordinates are calculated. While you probably don’t expect operators to be able to manipulate tool paths, you should want them to understand the positions through which the cutting tools are moving. Be sure they can determine where the program zero point is located (the origin for coordinates). This should be specified in the setup documentation. Point out that almost all X, Y and Z coordinates are specified from this location, and show them how these positions often correspond to workpiece drawing dimensions. With this knowledge, operators will not be working blindly and may be able to spot simple motion mistakes.