CNC Milling Training Lesson 10: CNC Milling Program Example – Complete Part

15 November 2026

Mentor CNC Editorial Team

Face milling on a CNC machining center: the first operation of the complete part program

Face milling with an indexable face mill in a CNC milling program example

In the previous lessons we covered the machine, axes, coordinates, G and M codes, cutting tools, workholding, work zero and tool offsets, canned cycles and safe program proving one by one. In this lesson we put them together on a single part: we read the drawing, plan the operations, choose tools and cutting data and then write a complete CNC milling program example with face milling, an outer contour, a pocket, spot drilling, drilling and tapping.

The program is written for a vertical machining center with a FANUC control (M series). Each section explains why a code was chosen and what to watch for.

1. Lesson objectives

  • Work out the operation sequence from a milling drawing.
  • Plan the raw stock, workholding and work zero together.
  • Prepare a tool list with starting cutting data.
  • Program an outer contour and a pocket finish with G41.
  • Use a ramp entry and separate roughing and finishing.
  • Machine holes and threads with G81, G83 and G84.
  • Prove a finished program on the machine in a safe order.

2. Part drawing and machining plan

TOP VIEWX0 Y0XY1570100155080907040304×R54×R64× M10×1.5FRONT VIEWZ0raw top Z+220541215CNC MILLING LESSON 10 – PRACTICE PARTMaterial:Aluminium EN AW-6061Raw stock:100 × 80 × 22 mmFinished thickness:20 mm (2 mm faced off top)Work zero:X0 Y0 front-left cornerZ0 finished top faceBoss:90 × 70, corner R5, height 5Pocket:40 × 30, corner R6, depth 4centre X50 Y40Holes:4× M10×1.5tap tip Z-12, full thread ≥ 7drill Ø8.5 – full-dia depth 15Hole centres:X15/X85 – Y15/Y65Clamping:vise, 10 mm gripGeneral tolerance:ISO 2768-mMentor CNC training example
Lesson 10 practice part: top view, front view and part data. All dimensions in mm.

The part is machined from a 100 × 80 × 22 mm aluminium block. A 90 × 70 mm boss with R5 corners and 5 mm height is left on top; the 5 mm band around it is milled down to Z-5. A 40 × 30 mm pocket with R6 corners and 4 mm depth sits in the middle of the boss, and there are four M10×1.5 blind threaded holes at the corners.

The general rule for the sequence is: reference face first, then the outer form, then the inner form, and holes last. Face milling leaves burrs at hole edges, and machining over a tapped hole afterwards can damage the thread entry. Operations done with the same tool (outer contour and pocket) are grouped to reduce tool changes.

3. Material, workholding and work zero

Material: EN AW-6061 aluminium. It cuts easily but tends to stick to the cutting edge, so use sharp, polished tools made for aluminium and plenty of coolant.

Workholding: the part sits on parallels in a vise with a 10 mm grip, so 12 mm of the 22 mm stock is above the jaws. In finished coordinates the top of the jaws is about Z-10. The deepest outside cut is Z-5, leaving 5 mm clearance to the jaws. The stock sides are assumed to be flat and square; saw-cut stock must have its sides machined first.

Work zero (G54): X0 Y0 is the front-left corner of the stock, found with an edge finder. Z0 is the finished top face. The raw top is 2 mm higher, so when a tool touches the raw face it must read Z+2. Setting Z0 on the raw face is a common mistake: the part stays 2 mm thick and every depth is measured from the wrong reference.

4. Tool list and cutting data

ToolDescriptionOffsetSpeedFeedOperation
T1Ø50 indexable face millH1S3800F1500Face milling (2 mm)
T2Ø10 3-flute carbide end mill for aluminium, centre cuttingH2, D2 = 5.000S7000F200 ramp, F600 pocket, F800 contourOuter contour, pocket roughing and finishing
T3Ø12 90° NC spot drillH3S2500F250Spot and Ø10.4 chamfer
T4Ø8.5 HSS-E drill (118°)H4S2200F330Peck drilling with G83
T5M10×1.5 machine tap (spiral flute for blind holes)H5S500F750Rigid tapping with G84

These are example starting values for aluminium; take the final values from the tool maker’s catalogue and adjust them to the machine power and setup rigidity. A quick check: for T2, Vc = π × 10 × 7000 / 1000 ≈ 220 m/min and fz = 800 / (3 × 7000) ≈ 0.038 mm/tooth. For T4, Vc ≈ 59 m/min and 330 / 2200 = 0.15 mm/rev. The tapping feed is fixed: F = S × pitch = 500 × 1.5 = 750 mm/min. D2 holds the tool radius (5.000); size corrections after finishing are made in D2, not in the program.

5. Operation sequence

  1. T1: face the top to Z0.
  2. T2: outer contour of the boss at Z-5 in one pass.
  3. T2: ramp into the pocket and rough it with 0.5 mm finishing stock.
  4. T2: finish the pocket walls with G41.
  5. T3: spot and chamfer the four holes.
  6. T4: peck drill with G83.
  7. T5: rigid tap with M29 and G84.

6. Complete program

O1010 (LESSON 10 PRACTICE PART)
(MATERIAL AL 6061 - STOCK 100X80X22)
(X0 Y0 FRONT LEFT CORNER - Z0 FINISHED TOP)
N10 G21 G17 G40 G49 G80 G90 G94
(T1 - D50 FACE MILL)
N20 T1 M06
N30 G54 G90 G00 X-30. Y20. S3800 M03
N40 G43 H1 Z50. M08
N50 Z5.
N60 G01 Z0 F500
N70 X130. F1500
N80 G00 Z5.
N90 X-30. Y60.
N100 G01 Z0 F500
N110 X130. F1500
N120 G00 Z50. M09
N130 M05
N140 G91 G28 Z0
N150 G90
(T2 - D10 END MILL - OUTER CONTOUR)
N160 T2 M06
N170 G54 G90 G00 X-10. Y-10. S7000 M03
N180 G43 H2 Z50. M08
N190 Z5.
N200 G01 Z-5. F300
N210 G41 G01 X5. Y-10. D2 F800
N220 Y70.
N230 G02 X10. Y75. R5.
N240 G01 X90.
N250 G02 X95. Y70. R5.
N260 G01 Y10.
N270 G02 X90. Y5. R5.
N280 G01 X10.
N290 G02 X5. Y10. R5.
N300 G01 Y20.
N310 G40 G01 X-10.
N320 G00 Z5.
(T2 - POCKET ROUGHING - RAMP ENTRY)
N330 X35.5 Y40.
N340 Z1.
N350 G01 X64.5 Z-1.5 F200
N360 X35.5 Z-4.
N370 X64.5 F600
N380 Y30.5
N390 X35.5
N400 Y49.5
N410 X64.5
N420 Y40.
(T2 - POCKET FINISHING)
N430 X50.
N440 G41 G01 Y25. D2
N450 X64.
N460 G03 X70. Y31. R6.
N470 G01 Y49.
N480 G03 X64. Y55. R6.
N490 G01 X36.
N500 G03 X30. Y49. R6.
N510 G01 Y31.
N520 G03 X36. Y25. R6.
N530 G01 X50.
N540 G40 G01 Y40.
N550 G00 Z50. M09
N560 M05
N570 G91 G28 Z0
N580 G90
(T3 - D12 SPOT DRILL 90 DEG)
N590 T3 M06
N600 G54 G90 G00 X15. Y15. S2500 M03
N610 G43 H3 Z50. M08
N620 G99 G81 X15. Y15. Z-5.2 R2. F250
N630 X85.
N640 Y65.
N650 X15.
N660 G80 G00 Z50. M09
N670 M05
N680 G91 G28 Z0
N690 G90
(T4 - D8.5 DRILL)
N700 T4 M06
N710 G54 G90 G00 X15. Y15. S2200 M03
N720 G43 H4 Z50. M08
N730 G99 G83 X15. Y15. Z-17.6 R2. Q3. F330
N740 X85.
N750 Y65.
N760 X15.
N770 G80 G00 Z50. M09
N780 M05
N790 G91 G28 Z0
N800 G90
(T5 - M10X1.5 TAP - RIGID)
N810 T5 M06
N820 G54 G90 G00 X15. Y15.
N830 G43 H5 Z50. M08
N840 M29 S500
N850 G99 G84 X15. Y15. Z-12. R5. F750
N860 X85.
N870 Y65.
N880 X15.
N890 G80 G00 Z50. M09
N900 G91 G28 Z0
N910 G91 G28 Y0
N920 G90
N930 M30
%

To see the face, contour, pocket and hole operations of this part with their tool paths, set up each feature in the CNC Milling CAM Simulator and compare the G code it generates with the program above.

7. Face milling (T1)

The Ø50 face mill drops to Z0 outside the part at X-30 Y20 and makes one pass to X130; the second pass is at Y60. The first pass covers Y-5 to Y45 and the second Y35 to Y85, a 10 mm overlap that clears the full 80 mm width. Start and end points are outside the part, so the tool enters from the side instead of plunging. In aluminium the 2 mm can be taken in one pass; in harder material split it (for example Z0.5 roughing, Z0 finishing). Before each tool change G91 G28 Z0 sends Z to the reference point, followed by G90.

8. Outer contour and G41 cutter compensation

T2 goes down to Z-5 outside the part at X-10 Y-10. G41 G01 X5. Y-10. D2 switches on cutter compensation: the tool is offset to the left of the path by D2 (5 mm). Compensation is always started outside the part with a linear move longer than the tool radius; otherwise the control alarms or the tool gouges the contour.

The coordinates are the drawing dimensions: X5, Y75, X95 and Y5 are the boss edges and R5 the corner radii. The tool travels clockwise around the boss, which gives climb milling with M03. With the tool centre 5 mm outside the edge, the Ø10 tool removes the whole 5 mm band in one pass, and the stock corners are cleared during the R5 arcs. The contour overlaps up to Y20 and G40 cancels compensation outside the part.

9. Pocket: ramp entry, roughing and finishing

Pocket milling: cutting data and tool path programming

Ramp entry: an end mill plunging straight down cannot cut well at its centre or clear chips. So the tool ramps from Z1 between X35.5 and X64.5: to Z-1.5 on the first move and to Z-4 on the way back. Dropping 2.5 mm over 29 mm gives a ramp angle of about 5°. Check the allowed ramp angle in the tool catalogue; the tool must be centre cutting.

Roughing: 0.5 mm is left on the walls. The pocket runs from X30 to X70, so the finishing tool centre is at X35/X65 and roughing uses X35.5/X64.5; the same logic gives Y30.5 and Y49.5. A pass along Y40 is followed by a rectangular loop. Stepovers are wide in this simple example; for larger pockets a CAM system or the control’s pocket cycle gives a better path.

Finishing: the tool moves to the pocket centre (X50 Y40) and switches on compensation with G41 G01 Y25. D2. The wall is machined counter-clockwise with G03 R6 corners. The corner radius (R6) is larger than the tool radius (5 mm), so compensation works; with a tool radius larger than the corner radius the control could not compensate the arc and would alarm. Compensation is cancelled with G40 at the pocket centre.

10. Spot drilling and G83 drilling

A 90° spot drill with G81 makes sure the drill starts exactly on centre. With a 90° point the spot diameter is twice the depth, so Z-5.2 gives a 10.4 mm chamfer that also prevents burrs at the thread entry. G99 returns the tool to the R plane (Z2) after each hole, which is enough because there are no obstacles between the holes.

Ø8.5 is the common tap drill for M10×1.5. In G83 the drill retracts to the R plane after every Q3 (3 mm) peck to clear chips. Depth: the drawing asks for 15 mm at full diameter; the 118° point adds about 0.3 × 8.5 ≈ 2.6 mm, so the drill tip goes to Z-17.6. The part is 20 mm thick, so the drill does not break through.

11. Rigid tapping with G84 and M29

In rigid tapping the spindle rotation and the Z feed are synchronized. On FANUC this mode is selected with M29 S500 before G84; the M code number is set by parameter No. 5210 and can differ between machines. No separate M03 is needed, the cycle controls spindle direction. With a floating tap holder, M29 is not used and the spindle is started with M03.

Feed is F = S × pitch = 500 × 1.5 = 750 mm/min. The R plane is Z5 so the tap reaches speed before entering the material. The tap tip goes to Z-12. The tap chamfer (about 2–3 pitches for form C) does not cut a full thread, so the usable full thread is about 7.5–9 mm, hence “full thread ≥ 7” on the drawing. Because the drill reaches full diameter at Z-15, 3 mm of chip space remains below the tap.

12. Proving the program on the machine

  1. Run the program in the control’s graphic display or a simulator and compare the tool path with the drawing.
  2. Check G54, tool lengths H1–H5 and D2 = 5.000. Confirm with a tool that the raw top reads Z+2.
  3. Do the first run with Single Block on, rapid override at 25% or F0 and a low feed override.
  4. After each G43 line, read the distance to go and confirm visually that the tool stops at Z50.
  5. Raise the override slowly during the first cut while watching chips, sound and coolant.
  6. Measure the boss, the pocket and the depths on the first part and correct with D2 and the H offsets.

13. Common mistakes

  • Setting Z0 on the raw face: the part stays 2 mm thick and all depths shift.
  • Not matching the H number to the tool (for example H2 with T4): wrong tool length and a collision risk.
  • Starting compensation on the part or with a very short move.
  • Entering the tool diameter in D2 instead of the radius: the contour is 5 mm oversize.
  • Plunging an end mill straight into the pocket.
  • Ignoring the drill point length when setting the drill depth.
  • Using a tapping feed other than speed × pitch, or forgetting M29.
  • Using the cutting data as given without checking the tool catalogue.

14. Lesson summary

The order for a complete part program is always the same: read the drawing, plan workholding and work zero, prepare the tool list, sequence the operations from the reference face to the holes, write the program and prove it on the machine under control. This lesson combined face milling, a G41 outer contour, a ramped pocket, G81 spot drilling, G83 peck drilling and G84 rigid tapping with M29 in one program. Rewriting the same structure with different dimensions is the best way to make CNC milling programming stick.

Frequently asked questions

Why is Z0 set on the finished top face and not on the raw face?

All depths on the drawing are measured from the finished face. With Z0 on the finished face, Z-4 and Z-5 in the program match the drawing directly. The raw face is then defined as Z+2 and face milling goes down to Z0.

Why is G41 used on the outer contour?

With the spindle turning clockwise (M03) and the tool offset to the left of the path (G41), the tool travels clockwise around an outer contour and counter-clockwise inside a pocket. Both give climb milling, which means a better finish and longer tool life.

How is the feedrate calculated for tapping?

In feed per minute (G94), F = spindle speed × pitch. For an M10×1.5 tap at 500 rpm, F = 500 × 1.5 = 750 mm/min. Any other F value damages the thread or breaks the tap.

What happens if M29 is left out?

On a machine that needs M29 for rigid tapping, G84 then runs as a standard tapping cycle and the spindle and Z axis are not synchronized. With a rigid holder this can break the tap. Some machines select rigid tapping by parameter without M29; check your machine manual.

Why is the drill programmed to Z-17.6 and not Z-15?

The 15 mm on the drawing is the full-diameter depth. The point of a 118° drill is about 0.3 × diameter longer: 0.3 × 8.5 ≈ 2.6 mm. So the drill tip is programmed to Z-17.6.

Mentor CNC logo

MENTOR CNC
CNC knowledge from the shop floor

Mentor CNC turns hands-on shop-floor experience in CNC turning, CNC milling, CNC controls, cutting tools and engineering calculations into clear, practical technical content.

Our goal is to help operators, students, engineers and shop owners reach accurate information faster and make safer, more efficient decisions in production.