This is how I do CNC tool break detection and tool management on a Haas machine with the Next Gen controller. And it is not by simply touching the tool to a tool setter and calling it good. That only checks the tool. I want to know what happened to the part, so I measure the cut.
After the tool makes the cut, I call the probe, measure the feature, and use macro logic to decide what happens next. If the tool overcuts, the machine alarms out and stops. If the tool undercuts, I update the wear offset, recut the feature, and measure it again. If it checks good, the machine moves on to the next operation.
That is why I call this tool management, not just tool break detection. For shops trying to improve in-process probing, CNC automation, lights-out machining, or tool wear compensation, this is a better way to control the process because the program reacts to the actual cut, not just the tool.
Start With a Simple CNC Program
Here is the basic code I use on a Haas VF6 with the Next Gen controller.
I’ll write some sample code and then build on it. Don’t judge the CAM path, the rough formatting, or the fact that this is not production-ready code. I’m keeping it basic so the probing logic is easy to see.
The goal is to show how CNC macro programming can use an in-process inspection macro and a Renishaw probe macro to measure the feature, adjust the tool wear, and decide whether the machine should stop, recut, or move on.
G17 G40 G49 G80
G90 G0 X0. Y0.
T1M6
S5500 M3
M8
(MAKE SOME CUT)
G90 G0 Z1.0 M9
G91 G28 Z0. M5
M1
Ok, not much in that, but it gets the idea out there.
Add a Sequence Number
First, I add a sequence number. Usually, I try to make it match the tool number if I can.
N1
G17 G40 G49 G80
G90 G0 X0. Y0.
T1M6
S5500 M3
M8
(MAKE SOME CUT)
G90 G0 Z1.0 M9
G91 G28 Z0. M5
M1
Call the In-Line Inspection Macro
Then at the end I call my probe macro to measure the feature. We’ll assume that the feature is a 5.0-inch diameter blind bore with a .5-inch-deep floor. This way I can show how to check both the diameter and the tool length management.
N1
G17 G40 G49 G80
G90 G0 X0. Y0.
T1M6
S5500 M3
M8
(MAKE SOME CUT)
G90 G0 Z1.0 M9
G91 G28 Z0. M5
G65 P9300 A1. T1.
M1
I write my in-line inspection macro so it can cover more than one operation. The A1 in the macro call points to sequence N1. Inside the macro, I use GOTO#1 to jump to the right section of probe code for that feature.
Build the Renishaw Probe Macro
So, I will build the macro too. I’ll truncate the code for speed and clarity like I am doing with the main.
O9300(IN-LINE INSPECTION)
GOTO#1
IF[#20 NE20] THEN #3000 = 9300(TOOL FEATURE MISMATCH)
N1
T20M6(THE PROBE)
G90 G0 X0. Y0.
G43 H20 Z5.0
G65 P9832
G65 P9810 Z1. F120.
G65 P9811 Z-.5 T#20. (THIS WILL UPDATE THE T1 TOOL HEIGHT WEAR)
(THE MAGIC)
#30=#148 (#198 FOR THE HAAS)
G65 P9810 Z-.25
G65 P9814 D5.0 T#20 (THIS WILL UPDATE THE TOOL DIAMETER WEAR)
#31 = #148 ( AGAIN #198 FOR HAAS)
G65 P9810 Z2.0 F300.
G65 P9833
G53 Z0.
M99
Save the Probe Results into Macro Variables
“I grabbed the probe result and move it into my own variable so I can use it later in the main program.”
Ok I didn’t truncate much but here it is. The Renishaw probing cycle knows whether it is dealing with a height move or a diameter check based on the move and the value being evaluated. The adjustment is the difference between the target “Z” and the probe location when the G31 inside the P9811 macro triggers. This difference is applied to the tool number we passed into the O9300 macro above. Which in this case is tool “T1” that made the cut.
Now I passed the delta(deviation) value to #30 for the depth and the delta value for the diameter. Again, that is taken care of in the Renishaw macro for you. Now I pass the values into my #900 for the height and #901 for the Diameter variable and run that back into the main program. Now I have control of what I can do with the program.
N1
T20M6(THE PROBE)
G90 G0 X0. Y0.
G43 H20 Z5.0
G65 P9832
G65 P9810 Z1. F120.
G65 P9811 Z-.5 T#20. (THIS WILL UPDATE THE T1 TOOL HEIGHT WEAR)
(THE MAGIC)
#30=#148 (#198 FOR THE HAAS)
G65 P9810 Z-.25
G65 P9814 D5.0 T#20 (THIS WILL UPDATE THE TOOL DIAMETER WEAR)
#31 = #148 ( AGAIN #198 FOR HAAS)
G65 P9810 Z2.0 F300.
G65 P9833
G53 Z0.
IF[#30 GT .005] THEN #900 =1(TOO DEEP)
IF[#31 GT .005] THEN #901 =1(TOO BIG)
IF[#30 LT -.005] THEN #900 =2(TOO SHALLOW)
IF[#31 LT -.005] THEN #901 =2(TOO SMALL)
M99
“In my example, #900 is my depth status and #901 is my diameter status. A value of 1 means the feature went too far or too big and I want to stop. A value of 2 means it is undersize or shallow enough that I can update the offset and recut.”
Use IF Statements to Stop, Recut, or Continue
So back to the main program.
N1
G17 G40 G49 G80
G90 G0 X0. Y0.
T1M6
S5500 M3
M8
(MAKE SOME CUT)
G90 G0 Z1.0 M9
G91 G28 Z0. M5
G65 P9300 A1. T1.
IF[[#900 EQ 1] OR [#901 EQ 1]] THEN #3000 = 9301(ABORT: CHECK T1)
IF[[#900 EQ 2] OR [#901 EQ 2]] GOTO1
M1
And there it is. The tool adjusted automatically when the probe measured the feature. The first check handled the tool height wear, and the second check handled the tool diameter wear. Then the IF statements decided what happened next. If it was overcut, the machine aborted. If it was undercut, the program went back and recut the feature with the updated offset. If it passed, it moved on and kept making money.
Skip Probing Every Part During Lights-Out Machining
We can add a bonus feature because this is for lights out automation manufacturers we know that a feature like this does not need constant probing every time. We can add a gate to see if it should take the time to measure or skip a round.
So, I add this bit before the probe macro call.
N1
G17 G40 G49 G80
G90 G0 X0. Y0.
T1M6
S5500 M3
M8
(MAKE SOME CUT)
G90 G0 Z1.0 M9
G91 G28 Z0. M5
IF[[#800MOD5] NE 0] GOTO11
G65 P9300 A1. T1.
IF[[#900 EQ 1] OR [#901 EQ 1]] THEN #3000 = 9301(ABORT: CHECK T1)
IF[[#900 EQ 2] OR [#901 EQ 2]] GOTO1
N11
M1
#800 is my part counter. #800 MOD 5 is the math nerd way of saying “only do this every fifth part.” If the part count is 5, 10, 15, and so on, #800 MOD 5 equals zero. That makes the NE 0 statement false, so the program does not jump to N11. It keeps going and runs the probe check. On the other parts, the value is not zero, so the program jumps to N11 and skips the check.
Final Thoughts From the Shop Floor
That’s it. This is the kind of real CNC tool management I wish more shops were using. Not another recycled AI summary of somebody else’s blog post. This is how I actually think through it as a machinist/programmer who has been doing this since 1989. Use the machine, use the probe, use the macro logic, and make the process react to the part.


