91ÊÓÆµÍøÕ¾ÎÛ

Published

4 Reasons to Use Safety Commands

Safety commands help safeguard CNC applications from common programming or operation errors.

Share

Leaders-In background
Source: Getty Images

I have received numerous questions about CNC over the years, many having to do with problems or issues with machine usage. Often, these issues have been presented as machine or control malfunctions, but were actually caused by programming or operation errors. Some resulted in rather odd machine behavior and were quite difficult to diagnose. Others involved somewhat hidden or unknown CNC features that users were unaware of.

The examples I show fall into the category of changed initialized states. You probably know that a CNC machine will automatically select certain modes when powered up. Many programmers depend on the machine retaining these modes, so they do not include related G codes, commonly called safety commands, in their programs. This can be a terrible mistake, as you are about to see.

One phone call I have received multiple times was about ridiculously slow feed rates on a turning center. The position displays showed evidence of movement (the one-ten-thousandths register incremented every second or so), but motion was undetectable. The reason was related to an incorrect subprogram calling command. Instead of specifying the subprogram call with M98, they used G98. They found the mistake, of course, and changed the G98 to M98. What they didn’t realize, however, is that they had inadvertently placed the lathe in per-minute feedrate mode. The intended per-revolution feedrate of 0.010-inches per revolution (ipr) was being taken 0.010-inches per minute (ipm). This is, indeed, a very slow feed rate!

One user complained that motions the machine was making were much smaller than they should be. It appeared to them that a tiny workpiece was being machined very close to the machine’s starting position. This turned out to be a mistyped G-code problem. They had intended to instate cutter compensation with G41, but did so with G21. Again, they quickly discovered and corrected the problem, but did not realize that they had placed the machine in metric mode. Instead of taking programmed coordinates in inches, the machine was moving in millimeters. So the machine was trying to make a “workpiece” 25.4 times smaller than it should be.

The two odd issues just described probably occurred many times more than I ever heard about. They are examples of issues that would go away if the user simply cycled the power. After restarting the machine and the initialized states were reselected, the problem would disappear. But this must be disconcerting to the user, since they would be left wondering what caused the problem in the first place. It also gives way to users incorrectly thinking that a machine could just go haywire and do unexpected things for no reason.

Another common phone call is related to an X- or Y-axis overtravel on a machining center during the program’s first motion command. Motion commands in the program appeared (and were) correct, but every time the operator started the cycle, the machine would go the wrong way and overtravel. After much discussion the first time I received this call, it was determined that the user had been using X- or Y-axis mirror image for the previous program. The setup person had turned it on manually, using the “Handy Settings” display screen. Since the previous program was written accordingly, it worked fine. But the current program was not set up to run with mirror image. Turning off mirror image, either manually or commanding the mirror image cancellation G code (G50.1 with current FANUC CNCs), solved the problem.

Yet another odd, motion-related machining center problem involved drilling a series of holes after a milling operation. The drilled holes were all out of location. We confirmed that programmed coordinates were correct, but none of the holes were where they were supposed to be. We eventually discovered that the previous tool, a milling cutter, was programmed using cutter radius compensation (G41 or G42), but the programmer did not cancel it (with G40) when the tool was finished. Since none of the drill’s motions broke any rules of cutter radius compensation, all subsequent X- and Y-axis motions it made were being modified by the previously used cutter-radius compensation offset.

It is for these reasons that you should include a series of G codes in your programs to ensure that initialized states are still in effect. The first two of these problems would not have occurred if the programmer had placed safety commands at the beginning of each program. The last two problems mentioned would have required the safety commands to be at the beginning of each cutting tool.

Older FANUC CNCs allow just three compatible G-codes per command, meaning you must provide multiple safety commands. Newer CNCs have no such limitation, but you should still break them up if your programs must run on older and newer machines.

Recommended safety commands for machining centers:

  • N005 G99 G50.1 G20 (inches per revolution mode, cancel mirror image, inch mode)
  • N010 G40 G15 G17 (cancel cutter comp, cancel polar coordinates, XY plane selection)
  • N015 G23 G50 G54 (cancel stored stroke limit, cancel scaling mode, normal cutting mode)
  • N020 G67 G69 G89 (cancel modal custom macro call, cancel coordinate rotation, cancel canned cycle)

Recommended safety commands for turning centers:

  • N005 G99 G20 G18 (inches per revolution mode, inch mode, XZ plane selection)
  • N010 G23 G40 G50.1 (cancel stored stroke limit, cancel cutter comp, cancel mirror image)
  • N015 G64 G67 (normal cutting mode, cancel custom macro modal call)

FANUC considers some of the features specified above as optional. Invoking the related G code(s) will generate an alarm if the machine does not have them.

Related Content

CNC Tech Talks

6 Variations That Kill Productivity

The act of qualifying CNC programs is largely related to eliminating variations, which can be a daunting task when you consider how many things can change from one time a job is run to the next.

Read More
CNC Tech Talks

A Higbee Thread Milling Custom Macro

Higbee threads provide a full thread form at the very start of the thread. The sharp edge is removed during the machining process.

Read More
CNC Tech Talks

Troubleshooting Differences in Programming Methods, Machine Usage

Regardless of the level of consistency among machines owned by your company, you probably have experienced consistency-related issues. Here are some tips to help solve them.

Read More

5 Reasons Why You Should Know How to Write Custom Macros

Custom macros enhance what can be done in G-code programs, giving users the ability to code operations that were previously not possible.

Read More

Read Next

Automation

AMRs Are Moving Into Manufacturing: 4 Considerations for Implementation

AMRs can provide a flexible, easy-to-use automation platform so long as manufacturers choose a suitable task and prepare their facilities.

Read More
Basics

Machine Shop MBA

  Making Chips and 91ÊÓÆµÍøÕ¾ÎÛ are teaming up for a new podcast series called Machine Shop MBA—designed to help manufacturers measure their success against the industry’s best. Through the lens of the Top Shops benchmarking program, the series explores the KPIs that set high-performing shops apart, from machine utilization and first-pass yield to employee engagement and revenue per employee.  

Read More
Top Shops

Last Chance! 2025 Top Shops Benchmarking Survey Still Open Through April 30

Don’t miss out! 91ÊÓÆµÍøÕ¾ÎÛ's Top Shops Benchmarking Survey is still open — but not for long. This is your last chance to a receive free, customized benchmarking report that includes actionable feedback across several shopfloor and business metrics. 

Read More