Horn USA
Published

Have it Your Way

Confirming initialized conditions ensures that programs will run as expected.

Share

Leaders-In background

Programmers often assume quite a bit about their CNC machines when they execute a program. They may, for example, assume that certain initialized states are still set the same as they were when the machine’s power was turned on. If this is not the case, however, the program will not run as expected. Maybe they assume that the measurement system of choice (imperial or metric) is still selected when the program is run. If it is not, the axes will not move as expected.

To avoid the problems associated with such assumptions, you may be in the habit of including a series of commands at the beginning your programs to ensure that initialized states are still active. You could, for instance, include a G20 (imperial) or G21 (metric) command to ensure that the appropriate measurement system has been selected.

While this is a very good habit, one that I would urge all programmers to consider, including such initializing commands in all of your programs can be cumbersome. And if at some future date you must add another command, you’ll probably have to change a lot of programs.

I suggest you create a user-defined G code (like G100) with which to specify and store your program-initializing commands. If you must eventually add more commands, you can easily do so. (This assumes your machine is equipped with custom macro capability. If not, the same result can be accomplished with a simple sub-program call.)

Just as an inappropriately selected G code will cause your programs to behave poorly, so can inappropriately specified parameters. You can ensure that program-related parameters also are set as they must be when your programs are executed. If a given parameter varies among your programs or machines, you can even specifiy the variables in a user-defined G code. 

Parameter-setting commands would be overly cumbersome to include in all of your CNC programs, but they are quite easy to include in your user-defined initializing G-code (G100) program, and doing so provides a somewhat transparent benefit over including them in your machining program. Since parameter numbers vary among control models, you may require a different initializing program in each machine, and each will appropriately set your chosen parameters. This cannot be accomplished if you elect to include all initializing commands in the machining program and you expect the program to run on different machines.

To create a user-defined G code with a FANUC 0iD control, you can set parameter number 6050 to a value of 100. After that, the control will execute program number O9010 whenever it reads a G100 word. Initializing commands will be included in program O9010.

For example, maybe you have had issues with program format when using multiple repetitive cycles on a turning center. Newer FANUC controls allow both one-line and two-line multiple repetitive cycles. A parameter controls which program format must be used. If this parameter is not appropriately set, the control will generate an alarm when the program is run, and it will take time to diagnose and correct the problem.

Parameters vary among FANUC control models, so you must reference your parameter manual to find program-related parameters in question. With a 0iD control, the first bit number of the parameter specifies the program format used with multiple repetitive cycles. You can include it in your initializing program to ensure that the control is appropriately set to accept programs utilizing your desired program format method.

Truly, any time you find yourself manipulating parameters in order to get programs to run properly is an example of when you should consider adding commands to your initializing program.

Here is an example for a FANUC 0iD control that is being used on a turning center:
O9010

(Normal safety commands)
G18 G20 G23 (XZ plane, imperial measurement system, stored stroke limit off)
G40 G67 G99 (Cancel tool nose radius compensation, cancel modal macro call, per revolution feed rate)
(Parameter settings)
G10 L52 (Select parameter entry mode)
N0000 R110 (Inch, ISO, TV check off)
N0001 R10 (Program format)
N0020 R4 (Output device is memory card)
N3410 R0 (Circular motion tolerance)
N5130 R0 (Thread chamfering amount)
N5133 R300 (Escape amount during multiple G71 and G72)
G11 (Cancel parameter setting mode)
M30

Again, this program will be executed when the control reads a G100 word. The first two commands probably resemble what you currently do in all your CNC programs. They simply ensure that all initialized states are still in effect. The G10 L52 command tells the control to instate the parameter entry mode, and each subsequent command specifies a parameter setting. The N word specifies the parameter number and the R word specifies the setting value. G11 cancels the parameter setting mode.

Note that you can even include parameter settings that may not be directly related to the way your programs run. In this example, we set the punch code format to ISO and turn off tape vertical (TV) check. If this setting is turned on, loaded programs must include the same number of characters in every command (which is never the case). We also set the output device to the memory card. 

Horn USA
Sumitomo
Kyocera SGS
Master Fluids Free Trial
Iscar
GWS Tool Group
Ingersoll Cutting Tools
Carbide cutting tools: make chips, finish jobs
Tungaloy-NTK
Metal Forming Complex Parts
Have it all with Mazak Ez Series Machines
Starrett W9400 Touch Screen Indicator

Related Content

CNC Tech Talks

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
CNC Tech Talks

Strange But True: Odd Things That Happen With CNCs

These oddities in the way a CNC naturally behaves can help explain some rather unusual situations that may occur during machining.

Read More

Tips for Designing CNC Programs That Help Operators

The way a G-code program is formatted directly affects the productivity of the CNC people who use them. Design CNC programs that make CNC setup people and operators’ jobs easier.

Read More
Basics

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

Read Next

Workforce Development

Building Out a Foundation for Student Machinists

Autodesk and Haas have teamed up to produce an introductory course for students that covers the basics of CAD, CAM and CNC while providing them with a portfolio part.

Read More

5 Rules of Thumb for Buying CNC Machine Tools

Use these tips to carefully plan your machine tool purchases and to avoid regretting your decision later.

Read More

Registration Now Open for the Precision Machining Technology Show (PMTS) 2025

The precision machining industry’s premier event returns to Cleveland, OH, April 1-3.   

Read More
Iscar