• MMS Youtube
  • MMS Facebook
  • MMS Linkedin
  • MMS Twitter
1/15/2009 | 4 MINUTE READ

Confirming That The Right Tool Is In The Spindle

Facebook Share Icon LinkedIn Share Icon Twitter Share Icon Share by EMail icon Print Icon

Regardless of how tool changes are actually made, it is imperative that the cutting tool currently in the spindle matches the program segment that uses the tool. 

During normal operation, a CNC program will cause the machine to make tool changes. With double-arm automatic tool changers, a T word in the program will place the cutting tool in the ready position of the automatic tool changer magazine, and an M06 will actually make the tool change.

With single-arm tool changers, the T word may do everything. Regardless of how tool changes are actually made, it is imperative that the cutting tool currently in the spindle matches the program segment that uses the tool. During normal operation—when the program runs from the first tool to the second, the third and so on—there is little chance of a mismatch. However, when operators must rerun a tool, which is essentially running tools out of sequence, there is a chance that they may not restart the program at the appropriate command. If they start the program from a command after the tool change, and if a different tool is in the spindle, the machine will attempt to run the cutting tool with the wrong series of commands. The results could be disastrous.

Custom macro B tests that the H word of the G43 command matches the tool in the spindle. This test assumes that you always make the tool-length compensation offset number the same as the tool station number and that you never use more than one tool-length compensation offset per tool.

To accomplish this, we must first change the function of G43 so that whenever G43 is executed, a special program is run. A parameter is used for this purpose, but you must reference your programming manual (see the custom macro section) in order to find the parameter. With a 16M control, for example, if we change parameter number 6050 to a value of 43, the machine will run program number O9010 whenever a G43 is executed. Again, you must check your programming manual to find the parameters related to modifying the functions of G codes.

After the parameter change, program O9010 will be executed whenever the machine sees a G43 command. The values within the G43 command (such as H and Z—and possibly even X, Y and M08) will be taken as arguments and passed to program O9010 as local variables. So, program O9010 must reflect the format you use for the G43 commands in your programs.

One more thing before we show an example: We must have a way to determine which tool is currently in the spindle. With single-arm tool changers, it will simply be the value of the last specified T word, which is monitored in custom macro B with system variable #4120. However, if your machine has a double-arm tool changer, you must find the system variable that tracks the spindle tool. You must reference your machine tool builder’s manual (it probably won’t be in the Fanuc manuals) or contact your machine tool builder to find it. For our example, we’ll assume you are using a single-arm tool changer and check against system variable #4120.

Local variable representations within program O9010 include #11 for H, #24 for X, #25 for Y, #26 for Z and #13 for M. Note that if any of these words (especially X, Y or M) are left out of the G43 command, the custom macro will do nothing with them. That is, the custom macro will work properly regardless of whether X, Y and/or M are included in the main program’s G43 commands. The format for the main program could be:

N050 T02 (Place tool number two in the spindle)
N055 G54 G90 S500 M03
N060 G00 X4.0 Y4.0
N065 G43 H02 Z0.1
N070 M08

Or, it could be:

N050 T02 (Place tool number two in the spindle)
N055 G54 G90 S500 M03
N060 G43 H02 X4.0 Y4.0 Z0.1 M08

The custom macro will work in either case.


O9010 (Custom macro program number)
IF [#11 EQ #4120] GOTO 5 (Test if H value matches tool station number)
N5 G43 G00 X #24 Y#25 H#11 Z#26 M#13 (Instate tool length compensation in the normal fashion)
M99 (End of custom macro)


The IF statement tests the value of the H word, making sure it matches the station number of the tool in the spindle. If it does, the control will skip to the G43 command. If not, an alarm will sound, stopping the machine’s execution before making any Z-axis motion.

The G43 command within program O9010 will be executed in the normal fashion for G43. That is, the machine will not try to activate program O9010 again. If the values of #24, #25 and #13 are vacant (they have not been included in the main program’s G43 command), the machine will ignore the related words (X, Y and M).

Custom macro developed with the help of Keith Decker of GMT Corporation.