¸ßÅâÂÊÁùºÏ²Ê

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. 

Related Content

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

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

4 Reasons to Use Safety Commands

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

Read More
CNC Tech Talks

4 Commonly Misapplied CNC Features

Misapplication of these important CNC features will result in wasted time, wasted or duplicated effort and/or wasted material.

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 ¸ßÅâÂÊÁùºÏ²Ê 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