YCM Alliance
Published

Identifying Machines from Within CNC Programs

The technique outlined here offers a seamless way for a single CNC program to be used when a job is run across different machines.

Share

Leaders-In background

It is sometimes necessary to run a given job across several, possibly different, CNC machine tools. For instance, the required number of workpieces may be greater than what can be produced on a single machine. Or maybe a shop has multiple machines with similar attributes, and a given job may be run on whichever machine becomes available first.

When multiple (and especially different) CNC machines are involved in running a single job, multiple CNC programs normally are required. This is because there may be machine-specific commands within each program, such as M-code usage and tool-change position. Creating, storing and maintaining a separate program for each machine is cumbersome, and if a design engineering or process change is required, all of the related programs will have to be changed as well.

Let me begin by saying thank you to John Romero for the following suggestion. He came up with this seamless way to ensure that one program could be run among different machines. His particular application had to do with ensuring that work coordinate system offsets are appropriately set, but this technique also can be helpful for many other applications. However, I must point out one important limitation: This method requires similar CNC controls that allow access to parameter settings. (The example we provide below is for FANUC CNCs.)

The first step is to choose a CNC parameter that is available on all of the related machines but that has a different value in each case. Once this parameter is determined, make note of that value. John chose a parameter related to axis stroke limits, and our example will do the same. After confirming that this parameter is set differently on each machine, the next step is to test against this parameter setting (from within the program) whenever a machine-specific programming command is required. The third and final step is to specify the series of commands that vary from one machine to the other.

Here is our specific example: Say that for one machine (we’ll call it machine A), the CNC word to turn on through-the-spindle coolant is M49. For another (machine B), it is M65. In both cases, an M09 command turns off the coolant. When the through-the-spindle coolant must be turned on, our universal program must be able to specify the appropriate M code, regardless of which machine is currently running it.

We’ll use the X-axis stroke limit, like John did, to determine which machine is currently being used. The X-axis stroke limit for a current-model FANUC CNC is stored in register number 1 (the X register) of parameter 1321. The FANUC function that provides access to parameter settings is PRM. Its syntax for this function when accessing parameters that have multiple registers is PRM[num] / [reg]. The label “num” represents the parameter number and the label “reg” represents the register number. 

Here is a command that will access the X register (register number 1) for parameter number 1321 and store the result in common variable #100:
#100 = PRM[1321] / [1]

If you elect to use this parameter for testing, of course, you must first make note of its value on each machine and then also make sure that it is different for each machine. For machine A, say we find the X register of parameter 1321 to be a value of 15.375. For machine B, this value is 17.436. Sure enough, they are different, so we make note of each of them.

Now a simple test can be made using a conditional branching command (IF statement) to determine which machine is being used. Here is a sample program that shows how:
O0001 (Program number)
G91 G28 Z0 M19
T01 M06
G90 G54 S1500 M03
G00 X1.0 Y1.0
IF [PRM[1321] / [1] EQ 15.375] GOTO 1
IF [PRM[1321] / [1] EQ 17.436] GOTO 2
#3000 = 100 (Machine is not recognized)
N1 M49
GOTO 3
N2 M65
N3 … (Program continues)

Admittedly, our example application of this technique is pretty simple, and you may be able to come up with other ways to deal with this particular issue. Our more important point, however, is that you can make a program access unique parameter settings to discover which machine is being used. This has tremendous implications for unifying programs, regardless of application complexity. 

YCM Alliance
MMS Made in the USA
Hurco
Koma Precision
To any Measurement Question there is an Answer
VERISURF
DANOBAT
Innovative Manufacturing for the Medical Industry
Paperless Parts
Pat Mooney Saws
High Accuracy Linear Encoders
JTEKT

Related Content

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

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

2 Secondary Coordinate Systems You Should Know

Coordinate systems tell a CNC machine where to position the cutting tool during the program’s execution for any purpose that requires the cutting tool to move.

Read More

Read Next

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

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
YCM Alliance