91ÊÓÆµÍøÕ¾ÎÛ

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. 

MMS Leaders in CNC Machining

Related Content

Computer Programming-Related Features of Custom Macro

Custom macro is an interpreter-based language, meaning that all CNC G code and custom macro commands are executed as the CNC comes across them.

Read More

A Balancing Act for Differential Gaging

Differential gaging measures using two devices, which has advantages over standard, comparative measurements using a single sensing head. These include the ability to measure size without regard to position.

Read More
Basics

Obscure CNC Features That Can Help (or Hurt) You

You cannot begin to take advantage of an available feature if you do not know it exists. Conversely, you will not know how to avoid CNC features that may be detrimental to your process.

Read More

How to Determine the Currently Active Work Offset Number

Determining the currently active work offset number is practical when the program zero point is changing between workpieces in a production run.

Read More

Read Next

Economics

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
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
Top Shops

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