Lesson 8: Pockets, Depth Steps and Subprograms
Updated
A rectangular pocket is milled by entering the material on a ramp or helix rather than plunging straight down, with a stepover of up to about 50–60 % of the tool diameter and several depth steps. The repeated depth step is written as a G91 subprogram called with M98 (on Fanuc 0i e.g. M98 P32001 or M98 P2001 L3, depending on the control) and ended with M99.
In this lesson you will learn:
- how to calculate the tool centre path for a rectangular pocket;
- how to enter the material on a ramp or a helix instead of plunging straight down;
- how to choose stepover and depth steps;
- how to move a repeated depth step into a subprogram, call it with M98 and return with M99.
A pocket is a closed recess that the cutter machines from the inside: the tool has to enter the material, clear the floor and finish the walls, and a deeper pocket is cut in several depth steps. As throughout the course, we use a Fanuc-style milling control (e.g. 0i-MF), metric units (G21) and the training plate in EN AW-6082, 100 × 60 × 20 mm: G54 X0 Y0 is the lower-left corner seen from above and Z0 is the top surface. Other controls may behave differently, so the machine manual is always the authority.
Pocket dimensions and tool centre path
We will cut a 40 × 20 mm pocket centred at X50 Y30, 6 mm deep, with R5 corners. The pocket walls are at X30, X70, Y20 and Y40. The tool is T1, a Ø10 mm 3-flute carbide end mill (radius 5 mm). This example is programmed as a tool centre path without G41/G42 radius compensation, so all coordinates are positions of the cutter centre: every wall is offset inwards by the tool radius.
| Feature | Pocket outline | Cutter centre |
|---|---|---|
| X limits | X30 and X70 | X35 and X65 |
| Y limits | Y20 and Y40 | Y25 and Y35 |
| Corners | R5 | sharp (the centre does not arc in the corner) |
| Depth | 6 mm | Z-6, three steps of 2 mm |
The corner radius cannot be smaller than the tool radius – a Ø10 mm cutter cannot produce an R4 corner. When they are equal (R5 and 5 mm), the cutter is wrapped by a 90° arc in the corner, the load jumps briefly and chatter may appear. On the drawing it is therefore better to choose a slightly larger radius (e.g. R6) or to finish corners with a smaller cutter; R5 is kept here to make the arithmetic simple.
Entering the material: ramp or helix
Not every end mill is centre-cutting. If the end teeth do not reach the centre, a straight plunge such as G01 Z-2.0 will jam or break the tool. Even a centre-cutting cutter plunged straight down evacuates chips poorly and takes a high axial load. Pockets therefore use one of two entry methods:
- ramp entry – a G01 move in X (or Y) and Z at the same time; the permissible ramp angle is given by the tool maker;
- helical entry – G02 or G03 with a Z move (helical interpolation). The helix must fit inside the pocket, and for a non-centre-cutting tool its diameter must be large enough not to leave an uncut core in the middle.
In our example the ramp runs along the centre line Y30 from X35 to X65: a 2 mm descent over 30 mm, about 3.8°. The return pass at full depth removes the wedge left by the ramp.
Stepover and depth steps
| Parameter | Starting value | In our example |
|---|---|---|
| Stepover ae in a pocket | ≤ about 50–60 % of tool diameter | 5 mm (50 %) |
| Depth step ap | depends on the cutter, its stick-out and machine rigidity | 2 mm |
| Ramp angle | per tool maker data | ≈ 3.8° |
| T1 speed and feed | S6000 F1200, plunge F300 | same |
In a pocket the cutter often cuts full width (like a slot), so as a starting value the stepover should not exceed about 50–60 % of the diameter. The first pass along the centre line cuts a 10 mm wide slot (Y25–Y35), and the passes along Y25 and Y35 remove 5 mm on each side – that is 50 %. These are example values; the tool maker's data takes priority (see depth and width of cut).
Subprogram with a G91 depth step
All three depth steps are identical except for Z. If the subprogram is written in incremental coordinates (G91), each call starts where the previous one ended and goes another 2 mm down. The main program brings the cutter to X35 Y30 Z0 and calls subprogram O2001 three times.
O0801 (POCKET 40X20X6)
N10 G21 G17 G40 G49 G80 G90
N20 T1 M06 (END MILL D10 3FL)
N30 G54 G00 X35.0 Y30.0 S6000 M03
N40 G43 H1 Z25.0 M08
N50 Z1.0
N60 G01 Z0 F300
N70 M98 P2001 L3 (OR M98 P32001)
N80 G90 G00 Z25.0 M09
N90 G91 G28 Z0
N100 G90
N110 M05
N120 M30
O2001 (ONE 2 MM STEP)
N10 G91 G01 X30.0 Z-2.0 F300 (RAMP)
N20 X-30.0 F1200
N30 Y-5.0
N40 X30.0
N50 Y10.0
N60 X-30.0
N70 Y-5.0
N80 G90
N90 M99
The subprogram starts at X35 Y30, ramps down to X65, returns to X35 at full depth, then follows the centre rectangle X35–X65, Y25–Y35 counter-clockwise (for an inside contour with M03 this is climb milling) and ends where it started, only 2 mm lower. After three calls Z = 3 × (−2) = −6 mm. The G90 block before M99 is essential: if the main program were left in G91, every following move would be measured from the current position. This example cuts the pocket to size in one go; in practice 0.2–0.5 mm is left on the walls and a finishing pass is made with G41 D1.
M98 format on Fanuc controls
| Block | Meaning |
|---|---|
M98 P2001 | O2001 runs once |
M98 P32001 | Fanuc 0i format: the last four digits are the program number (2001), the leading digits the repeat count (3) |
M98 P2001 L3 | Repeat count in address L (e.g. Haas, some other controls and formats) |
M99 | Return to the main program, to the block after M98 |
On the Fanuc 0i series the repeat count is usually written in front of the program number: P32001 means O2001 three times. When a repeat count is given, the program number always occupies the last four digits, so O12 called three times is P30012. Other controls use address L for repeats, and controls with 8-digit program numbers use yet another format. A control that does not understand the format may look for a non-existent program O32001 (alarm, see Fanuc alarm codes) or ignore L and cut a pocket only 2 mm deep. Always check the machine's programming manual before using it. More on M-codes in the M-codes article; complex pockets are usually generated with CAM software.
Exercise
Change the program so that the 6 mm depth is reached in four steps of 1.5 mm. Which two things must change, and what will the ramp angle be? The answer is in the FAQ.
Next lesson: Lesson 9: Lathe programming basics.
Frequently asked questions
Why not simply plunge the end mill straight down?
A non-centre-cutting end mill jams or breaks when plunged, and even a centre-cutting one evacuates chips poorly and takes a high axial load. A ramp or helix spreads the load and lets the chips escape.
What is the difference between M98 P2001 L3 and M98 P32001?
Both run O2001 three times; only the way the repeat count is given differs – in address L or in front of the program number in P. The machine programming manual tells you which format your control accepts.
Why is the pocket programmed on the tool centre and not with G41?
For roughing, a centre path is simple and easy to check. When the walls need an exact size, stock is left and the finishing pass is made with G41 D so the size can be adjusted in the offset table.
Exercise answer
In subprogram O2001 change Z-2.0 to Z-1.5, and in the main program change the repeat count from 3 to 4: M98 P2001 L4 or M98 P42001. Depth 4 × 1.5 = 6 mm; ramp angle atan(1.5 / 30) ≈ 2.9°.
Looking for someone to do this job? Find a manufacturer on the marketplace or post a request.
Services offered I need a service