CNC Broach Programming

The Design of CNC Broach Tools and Inserts are Proprietary and Protected by USA Patent #8,622,669,B2


For Informational Purposes Only



The 1 st thing you need to consider is that broaching in a lathe or mill is not a conventional operation. That being said both lathe broaching and mill broaching are perfectly acceptable methods of doing the slotting process and avoiding other expensive CNC Broaching Systems. The common concerns are wear on the slides and “beating” your machine up. But unless you have tens of thousands of parts to cut internal slots into you’re not going to wear your slides. And at an average of .001” Depth of Cut per pass there’s not enough impact to beat on your machine.

This guide will walk you through the basic steps of what it takes to get a CNC machine broaching your parts.

TIP: The code examples used in the guide will be that of FANUC, and YASNAC (Haas). The purpose of the guide is not to give you the codes you need but the concept behind what it takes to program tool path. If your codes are machine specific you will be able to locate and use them following this platform.

1. Locking the tool or material from rotation.
The broach tool does not rotate while being used. This is no ghost to the lathe while the mill on the other hand is accustomed to the tool rotation. The lathe is the opposite and the material must be not rotating to use the broach.


The tool must be lock and not spinning a common way to achieve this is to use orientate spindle “M19” depending on the options your machine has you may change the spindle orientation with a P or R on a Haas, or S on a Fanuc. These letters specify the angle. I.e. 20 deg., 20.5 deg. , and 15 deg. M19 P20. ; or M19 R20.5 ; or M19 S15. ;

TIPS: Some not all mills will alarm out once you try to FEED the tool with the spindle off, most not all have an M code that you can use to disable this safety feature. If no M code is available you can orientate the spindle to lock it in position, then start it again but at 0 RPM I.e. M19; M03 S0 ;


Keyway Broaching on Lathe CNC Broach ToolThe same codes apply for orientating the spindle in the lathe as the above mill. The FEED alarm will not be generated in the lathe however. We still need to feed the while the spindle is off. To do this you must change the FEED units from IPR (inches per revolution) G99 default on a lathe, to IPM (inches per min.) G98 , the concept is the same as if feeding while using a bar feeder.

TIP: make sure you change the FEED units back to IPR G99 after you are done broaching.

2. The cutting motion of the Broaching tool.
Always follow the KEYS TO USING CNC BROACH TOOLS when setting up tool in machine and fundamentals of how the keyway slotting tool should move in and out of material clearances etc.…        Now that the tool or material is locked in position its time to start the cutting motion of the broach.

TIP: There are many ways to make the tool path. the examples below are my favorite easiest to manipulate and least amount of typing.


The example shown is as if the keyway is located in the 12 o’clock position also the program work offset has been set to the centerline of the bore. This is a down and dirty very simple way to write the code for the broach. I will write the code off of the center of the part 0 then I will use a different work offset for the broaching operation only and manipulate the Y position to get and maintain the correct keyway depth. Let’s say the radial depth of the keyway is .200  with a depth of 1 inch, I will 1st position the tool at X0 Y0  and about .300 to .500 above the surface to broach. Then utilizing a sub program I will incrementally move the tool in down out back up then in again, and repeat. The main program will have the lines leading up to the sub as follows:
G00 X0 Y0 Z.4;
M98 P500 L100;

TIP: The L is the number of times to repeat sub program (no decimal), if L does not work on your machine the 1st set of digits after the P will be the repeat amount i.e. M98 P100500 is program 500 repeat 100 times.

Once the control gets to the M98 line it will change to the sub program which is as follows:
G00 G91 Y.002 ;    (This 1st move in Y is the depth of cut per pass)
G90 G01 Z-1.0 F100. ;  ( This is the cutting stroke down)
G00 G91 Y-.300 ;   (Retract, the Y must be greater than the radial depth of keyway)
G00 G90 Z.4 ;  (Stroke up out of bore)
G91 Y.300 ;  (Repositions the tool back to where the last depth of cut was taken)
M99 ;     (Restart the sub program)

TIP: Change back the position to G90 after the M98 line, also the L value must be equal to the depth of cut. I.e. we wanted .200 total so we had depth of cut of .002 and repeated 100 times .002 X 100 gives us a final depth of .200.


Keyway Broaching on Lathe CNC Broach ToolThe motion of the tool in the lathe is identical to the motion of the tool in the mill. You just have to consider that the lathe is moving on a diametrical value in the X direction not a .001 for .001. The lathe is moving on a .001 for .002 in the X direction. Since it is easier to set the geometry offset in the lathe on the tip of the tool I will just use the actual tip of the tool like normal tools in the lathe are used. This allows you to adjust the final cutting size with the X wear offset as normal. I 1st position the tool with same clearances as before just using the actual sizes NOT manipulating the work offset. Let’s say the Bore is 2.000 DIA. And the radial depth of key way is .200, and 1.000 long again. Same as before position the tool close but not on the cutting point in the main program.
M19 ;
G00 G98 X2.0 Z.400 ;  (Remember the G98 FEED PER MIN)
M98 P500 L100 ;    (The same L and or 2 digits format prior works like the mill too)
Once the M98 line is read by control it then switches to program 500 and repeats 100 times.
G00 U.004 ; (The incremental X move is the depth of cut .004 on DIA is .002 radially)
G01 Z-1.000 F100. ; (Cutting stroke in to bore)
G00 U-.500 ; (Retract out of keyway, must be larger than double the Radial depth)
G00 Z.400 ; (Stoke of tool out of bore)
G00 U.500; (Repositions tool back to last depth of cut)
M99;   (Repeats sub program)

TIP: Remember to change the FEED units back to G99 after M98 line. Also the depth of cut is actually only .002 per side that’s why we have the .004 in the U value. Remember that the U retract from keyway must be larger than double the radial keyway depth i.e. our keyway was .200 radially so to get the broach tool all the way out of the key way we would have to retract more than .400, that’s why I used .500, also keep in mind the number of repeating times of the program will be proportional to the depth of cut as well. I.e. our bore was 2.000 DIA. With a keyway radial depth of .200 the final size of the keyway would be 2.400 DIA. If the key way was on both side which it is not. Now you can see the depth of cut U.004 moves the tool incrementally .004 on a DIA. Every pass for 100 times so .004 X 100 equals .400 which gives us a 2.400 DIA. end point for the broach tool.



This method will work for mills that do not have the option to orientate the spindle to a designated degree by way of G or M code command.

The following code can be used in place of the M19 in any mill template. You will then be able to have more control over what position the tool is in in order to make it aligned with the broach you are trying to cut. The codes are below and the explanation and use will follow.

(Delete the M19 on any mill template and replace with the following)
M03 S10
G04 P500
M03 S0

There is now 4 lines replacing 1 line.

  1. The 1st line M19 will lock the spindle in the tool change position, this is important since we want the spindle to begin its rotation from the same position every time.
  2. The 2nd line M03 S10 will start the spindle rotating at a very slow RPM
  3. The 3rd line G04 P500 is a dwell code. This is like an egg timer to the machine the code is non modal so will automatically cancel its self once the time has expired. (NOTE: the P is the time to wait. NO DECIMAL IS IMPORTANT, the time is in mille seconds.
  4. The 4th and last line will then change the RPM of the spindle to 0 thus locking the spindle in whatever position it would be in after a rotation of 500 mille seconds.
Mill broaching


I recommend making a program with just the 4 lines in it. Then once you have installed your CNC Broach Tool in the spindle run the program with just the 4 lines.

Take not at what position the tool is stopped in. The only number you will have to change is the time which is the P keep adjusting the P value until the broach is aligned in the desired direction close by eye. Then proceed to indicate the tool tip and tweak the P value until the indication is good. Now enter the same P value that worked in the program you are going to run the part with.

For Informational Purposes Only