Paperless Parts
Published

4 Reasons to Use Safety Commands

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

Share

A stock image showing a machine tool with code
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.

Paperless Parts
To any Measurement Question there is an Answer
OASIS Inspection Systems
Koma Precision
DN Solutions
SolidCAM
Kennametal
Hurco
CHIRON Group, one stop solution for manufacturing.
CHIRON Group, one stop solution for manufacturing.
World Machine Tool Survey
Gardner Business Intelligence

Read Next

3 Mistakes That Cause CNC Programs to Fail

Despite enhancements to manufacturing technology, there are still issues today that can cause programs to fail. These failures can cause lost time, scrapped parts, damaged machines and even injured operators.

Read More
Large Part Machining

The Cut Scene: The Finer Details of Large-Format Machining

Small details and features can have an outsized impact on large parts, such as Barbco’s collapsible utility drill head.

Read More
Koma Precision