CNC programming practice problems: 30 lathe and mill exercises you cut and grade in the browser
Even one a day is fine. Your pass marks stay in this browser.


Practice problems for CNC lathe and machining center programs that you can type, cut and auto-grade in your browser — 30 exercises (15 lathe, 15 mill). On top of the 10 from the intro articles and the 5 on the machining center page, we added the single canned cycles G90, G94, G92, G83 and G73, the M98 subprogram, a two-tool setup and combined problems that finish a whole drawing, and arranged them from basic up to about grade 2 of the Japanese skills test in order of difficulty. All problems are our own, and every answer was checked to pass in the simulator. To learn what the codes mean first, read Introduction to CNC Lathe Programs and Machining Center Programming for Beginners.
Lathe 0/15 Mill 0/15
How to use: write, press ▶, compare with the drawing
Open a problemClick a problem heading to open it; its simulator starts only then, to keep the page light.
Write the missing linesAdd the moves at the “(---- … ----)” line in the black editor. Give numbers a decimal point.
Press ▶ to cut and grade▶ compares the cut shape with the drawing (blue dashed line) and shows “Pass!” when it matches. Any warning or error gives “Not yet”.
See the hint or answerIf stuck: the hint, the matching section of the intro, and finally the example answer. Passed problems get a mark that stays in this browser.
The simulators are simplified learning tools. The lathe reads the basics of FANUC-compatible G-code system A (G00–G03, G04, G28, G32, G50, G90, G92, G94, G96–G99); the mill reads G17 arcs, cutter compensation G41/G42, tool length offset G43, canned cycles G73–G89, the M98 subprogram and custom macro WHILE loops[1][2][4][3]. The lathe tool tip is a point (nose radius 0), and bores and the multiple repetitive cycles G71, G70 and G76 are not handled (rough with G90 instead). Teaching with a simulator before the real machine has also been reported in technical colleges and vocational high schools[14][15].
Lathe: basic (L1–L6) facing, steps, taper, radius, thread, chamfers

Start by redoing the five intro exercises (L1–L5), then go on to L6, which finishes a contour in one pass. If “add the decimal point”, “F after G01” and “retract before the next move” have become habits here, the canned-cycle problems get easy.
L1
BasicFace the end
The stock is φ40, with a 1 mm allowance on the face. The tool (OD turning tool T0101) is already at X44. Z0. From here, feed to the center to finish the face at Z0.
Hint
One G01 line that moves only X. Feed about F0.15.
If stuck: The same exercise in the intro (No. 1)
┅ Rapid G00━ Cutting feed━ Threading┅ Drawing line
Show a sample answer
O0001 G28 U0 W0 T0101 G50 S3000 G96 S150 M03 G99 G00 X44. Z0. M08 G01 X0. F0.15 G00 Z2. G00 X100. Z100. M09 G28 U0 W0 M05 M30
L2
BasicTurn a step in 2 passes
Turn φ40 stock down to φ30 for a length of 25 mm from the face. This tool can cut up to 2.5 mm deep on radius. The first pass (X35.) is already written, so finish to X30. with the second pass.
Hint
Same form as the first pass, with only X changed to 30. Don't forget to retract to X42. at the end.
If stuck: The same exercise in the intro (No. 2)
┅ Rapid G00━ Cutting feed━ Threading┅ Drawing line
Show a sample answer
O0001 G28 U0 W0 T0101 G50 S3000 G96 S150 M03 G99 G00 X42. Z2. M08 X35. G01 Z-25. F0.2 X42. G00 Z2. X30. G01 Z-25. X42. G00 Z2. G00 X100. Z100. M09 G28 U0 W0 M05 M30
L3
BasicChamfer C1 and taper
The stock is φ30. Chamfer the corner of the face at C1 (1 mm × 45°), turn φ26 to Z-15, and from there cut a taper that reaches φ30 at Z-25.
Hint
For both the chamfer and the taper, writing X and Z on the same line moves the tool diagonally (G01 X26. Z-1.).
If stuck: The same exercise in the intro (No. 3)
┅ Rapid G00━ Cutting feed━ Threading┅ Drawing line
Show a sample answer
O0001 G28 U0 W0 T0101 G50 S3000 G96 S150 M03 G99 G00 X24. Z2. M08 G01 Z0. F0.15 X26. Z-1. Z-15. X30. Z-25. X32. G00 Z2. G00 X100. Z100. M09 G28 U0 W0 M05 M30
L4
BasicConvex R and concave R
The stock is φ24. Round the tip corner with R3 (φ14 → φ20), turn φ20 to Z-18, and round the root with R2 to blend into φ24.
Hint
Rounding the tip (convex R) is G03; rounding the root (concave R) is G02. For both, write the end point X, Z and R.
If stuck: The same exercise in the intro (No. 4)
┅ Rapid G00━ Cutting feed━ Threading┅ Drawing line
Show a sample answer
O0001 G28 U0 W0 T0101 G50 S3000 G96 S150 M03 G99 G00 X14. Z2. M08 G01 Z0. F0.12 G03 X20. Z-3. R3. G01 Z-18. G02 X24. Z-20. R2. G01 X26. G00 Z2. G00 X100. Z100. M09 G28 U0 W0 M05 M30
L5
BasicRelief groove and M20×1.5 thread
The stock is φ20 (already turned to the thread's major diameter). With grooving tool T0202 (3 mm wide, referenced to its left corner on the chuck side), cut a φ17 relief groove from Z-20 to Z-23, then cut an M20×1.5 external thread with threading tool T0303 using G92. The final X is 18.16 (= 20 − 2 × 0.6134 × 1.5).
Hint
Cut the groove with G01 X17. and pause briefly with G04. For the thread, listing lines with only X below G92 repeats the same cycle a little deeper each time.
If stuck: The same exercise in the intro (No. 5)
┅ Rapid G00━ Cutting feed━ Threading┅ Drawing line
Show a sample answer
O0005 G28 U0 W0 T0202 (GROOVE W3) G97 S600 M03 G00 X22. Z-23. M08 G01 X17. F0.05 G04 X0.5 G00 X22. G28 U0 W0 T0303 (THREAD 60DEG) G97 S800 M03 G00 X22. Z5. G92 X19.4 Z-21.5 F1.5 X18.9 X18.5 X18.3 X18.16 G00 X100. Z100. M09 G28 U0 W0 M05 M30
L6
BasicFinish C2 and C1 chamfers and an R2 fillet in one contour
The stock is Ø36. Two roughing passes (leaving 0.4 mm on diameter and 0.2 mm in length) are written. In one finishing contour: chamfer the front C2 (Ø24 → Ø28), turn Ø28 to Z-14, blend into Ø32 with an R2 fillet, turn Ø32 to Z-30, and put a C1 chamfer on the shoulder up to Ø36.
Hint
Chamfers are G01 with X and Z on the same line. The concave fillet at the root is G02 (in this article’s view). For the C1 on the shoulder, go up to X34. and then diagonally to X36. Z-31.
If stuck: Intro: G00–G03 moves
┅ Rapid G00━ Cutting feed━ Threading┅ Drawing line
Show a sample answer
O0106 G28 U0 W0 T0101 G50 S3000 G96 S150 M03 G99 G00 X37. Z2. M08 X32.4 G01 Z-29.8 F0.25 X37. G00 Z2. X28.4 G01 Z-13.8 X33. G00 Z2. X24. G01 Z0. F0.12 X28. Z-2. Z-14. G02 X32. Z-16. R2. G01 Z-30. X34. X36. Z-31. X38. G00 Z2. G00 X100. Z100. M09 G28 U0 W0 M05 M30
Lathe: canned cycles (L7–L12) G90, G94, grooves, G92, parting

In system A, G90 (OD), G94 (face) and G92 (threading) are single canned cycles that pack four moves — feed in, cut, retract, return — into one line. From line 2 on, write only the value that changes (X or Z) and the same cycle repeats[1][2][9]. In a G90 taper, R is the radius difference between the start of cut and the end point, taken at the Z of the cycle start point (L8).
L7
IntermediateRough a diameter in four G90 passes
The stock is Ø50. Turn 30 mm from the face down to Ø40. This tool takes at most 2.5 mm per side. The tool is at X52. Z2. (the cycle start point). Use the single turning cycle G90 in four passes: X47., X44., X41. and X40.
Hint
Line 1: G90 X47. Z-30. F0.25. From line 2 write only X — the same cycle repeats to the same Z. Each pass returns to the start point (X52. Z2.).
If stuck: Canned cycles
┅ Rapid G00━ Cutting feed━ Threading┅ Drawing line
Show a sample answer
O0107 G28 U0 W0 T0101 G50 S3000 G96 S150 M03 G99 G00 X52. Z2. M08 G90 X47. Z-30. F0.25 X44. X41. X40. G00 X100. Z100. M09 G28 U0 W0 M05 M30
L8
IntermediateCut a taper with G90 R (R depends on the start Z)
The stock is Ø40. Cut a taper that is Ø30 at the face (Z0) and Ø40 at Z-20. The tool is at X42. Z2. Use G90 X40. Z-20. with R (radius difference between the start of cut and the end; negative means smaller at the front), increasing it R-1.5, R-3., R-4.5 (from line 2 write X and R, e.g. X40. R-3.), and finish with the R that gives the drawn taper. What is that last R?
Hint
G90 starts cutting at the start Z2. The taper grows 10 mm in diameter over 20 mm, so at Z2. it is Ø29. R = (29 − 40) ÷ 2 = −5.5. Computing R-5. from Ø30 at Z0 gives the wrong taper.
If stuck: Lathe multiple repetitive cycles
┅ Rapid G00━ Cutting feed━ Threading┅ Drawing line
Show a sample answer
O0108 G28 U0 W0 T0101 G50 S3000 G96 S150 M03 G99 G00 X42. Z2. M08 G90 X40. Z-20. R-1.5 F0.2 X40. R-3. X40. R-4.5 X40. R-5.5 G00 X100. Z100. M09 G28 U0 W0 M05 M30
L9
IntermediateFace a shoulder with G94
The stock is Ø60. Leave Ø30 in the center and face the outer part 6 mm deep to make a shoulder. The tool is at X62. Z2. Use the facing cycle G94 in three passes: Z-2., Z-4. and Z-6.
Hint
G94 goes: rapid to Z → cut along X → cut back along Z → rapid to the start. X is where the cut ends (X30.); from line 2 write only Z.
If stuck: Canned cycles
┅ Rapid G00━ Cutting feed━ Threading┅ Drawing line
Show a sample answer
O0109 G28 U0 W0 T0101 G50 S3000 G96 S150 M03 G99 G00 X62. Z2. M08 G94 X30. Z-2. F0.2 Z-4. Z-6. G00 X100. Z100. M09 G28 U0 W0 M05 M30
L10
IntermediateCut a 6 mm groove with a 3 mm tool
The stock is Ø30. Cut a 6 mm wide groove to Ø24 between Z-15 and Z-21. Grooving tool T0202 is 3 mm wide, referenced at its left (chuck-side) corner. The tool is already at X32. Z-18. Plunge twice.
Hint
Because the reference is the left corner, a plunge at Z-18. cuts Z-18 to Z-15. The second is at Z-21. Dwell at the bottom with G04, then rapid out to X32. before moving Z.
If stuck: Intro: grooves and threads
┅ Rapid G00━ Cutting feed━ Threading┅ Drawing line
Show a sample answer
O0110 G28 U0 W0 T0202 (GROOVE W3) G97 S600 M03 G99 G00 X32. Z2. M08 Z-18. G01 X24. F0.05 G04 X0.5 G00 X32. Z-21. G01 X24. G04 X0.5 G00 X32. G00 X100. Z100. M09 G28 U0 W0 M05 M30
L11
IntermediateThread M20×2.5 with G92 (infeed distribution)
The stock is Ø20; the relief groove (Z-25 to Z-28, Ø16.5) is written. With threading tool T0303, cut an M20×2.5 external thread with G92 from Z5. to Z-26.5 inside the groove. The final X is 16.93 (= 20 − 2 × 0.6134 × 2.5). Split the infeed into 7 passes, deep at first and shallower each time.
Hint
The total infeed is 3.07 mm on diameter. For example 0.9, 0.7, 0.5, 0.4, 0.3, 0.2, 0.07 gives X19.1 → 18.4 → 17.9 → 17.5 → 17.2 → 17. → 16.93. Reduce the infeed as you go deeper so the cutting area stays about the same each pass.
If stuck: G76 infeed calculator
┅ Rapid G00━ Cutting feed━ Threading┅ Drawing line
Show a sample answer
O0111 G28 U0 W0 T0202 (GROOVE W3) G97 S500 M03 G99 G00 X22. Z2. M08 Z-28. G01 X16.5 F0.05 G04 X0.5 G00 X22. G28 U0 W0 T0303 (THREAD 60DEG) G97 S600 M03 G00 X22. Z5. G92 X19.1 Z-26.5 F2.5 X18.4 X17.9 X17.5 X17.2 X17. X16.93 G00 X100. Z100. M09 G28 U0 W0 M05 M30
L12
IntermediatePart off: fix the rpm with G97 and go to the center
The stock is Ø30. Part off 30 mm from the face (Z-33 to Z-30) with grooving tool T0202 (3 mm wide) down to the center (X0.). The program still says G96 S100 with no G50: going toward the center, the spindle would run up to the machine maximum. Fix the speed with G97 S800, slow the feed just before the center (X4.), and part off to X0.
Hint
Change line 4 to G97 S800 M03, then G01 X4. F0.05 → X0. F0.03. If you part off under G96, always set a G50 S limit first (both are used in practice).
If stuck: Intro: G50, G96, G97
┅ Rapid G00━ Cutting feed━ Threading┅ Drawing line
Show a sample answer
O0112 G28 U0 W0 T0202 (GROOVE W3) G97 S800 M03 G99 G00 X32. Z2. M08 Z-33. G01 X4. F0.05 X0. F0.03 G00 X32. G00 X100. Z100. M09 G28 U0 W0 M05 M30
Lathe: advanced and grade 2 level (L13–L15)

The practical part of the grade 2 skills test for CNC lathe work has you plan the process from a drawing, write the program and actually cut the part[11][10]. We did not copy any test task; instead we drew our own parts with similar elements (steps, taper, radius, groove, thread, tool change). Past problems can be viewed on the public site of the Japan Vocational Ability Development Association (viewing only, copying prohibited)[13].
L13
AdvancedTwo tools: turn with T01, then groove with T02
The stock is Ø32 with 1 mm on the face. With T0101, face to Z0 and turn Ø30 to Z-35. Then change to T0202 (grooving, 3 mm wide, referenced at the left corner) at a safe position and cut a Ø26 groove at Z-23 to Z-20 under G97 S700.
Hint
Before changing tools, move away with G00 X100. Z100. → G28 U0 W0. After T0202, set the speed again with G97 and write M03. A plunge at Z-23. cuts Z-23 to Z-20.
If stuck: Intro: tools and offsets
┅ Rapid G00━ Cutting feed━ Threading┅ Drawing line
Show a sample answer
O0113 G28 U0 W0 T0101 G50 S3000 G96 S150 M03 G99 G00 X35. Z0. M08 G01 X0. F0.15 G00 Z2. X30. G01 Z-35. F0.2 X34. G00 X100. Z100. G28 U0 W0 T0202 (GROOVE W3) G97 S700 M03 G00 X34. Z2. Z-23. G01 X26. F0.05 G04 X0.3 G00 X34. G00 X100. Z100. M09 G28 U0 W0 M05 M30
L14
Grade 2 levelCombined 1: a shaft with steps, taper, radius, groove and thread
The stock is Ø40 with 1 mm of stock on the face (the first lines of the template already face it to Z0). From the face, the drawing is: C1, Ø20 (M20×1.5 thread to Z-18), relief groove (Z-18 to Z-21, Ø17), shoulder up to Ø24 then a convex R2 to Ø28, Ø28 to Z-30, a taper reaching Ø36 at Z-40, and Ø36 to Z-48. Write G90 roughing (0.4 mm left on diameter) → finishing → groove → thread.
Hint
Stop each roughing pass before it digs into the taper or radius: X32.4 goes only to Z-35, where the taper is Ø32. The convex R in the finish is G03; the last thread X is 18.16 (= 20 − 2 × 0.6134 × 1.5).
If stuck: Intro: G00–G03 moves
┅ Rapid G00━ Cutting feed━ Threading┅ Drawing line
Show a sample answer
O0114 G28 U0 W0 T0101 G50 S3000 G96 S150 M03 G99 G00 X43. Z0. M08 G01 X0. F0.15 G00 Z2. X42. G90 X36.4 Z-47.8 F0.25 X32.4 Z-35. X28.4 Z-29.8 X24.4 Z-20.8 X20.4 G00 X18. G01 Z0. F0.12 X20. Z-1. Z-21. X24. G03 X28. Z-23. R2. G01 Z-30. X36. Z-40. Z-48. X42. G00 X100. Z100. G28 U0 W0 T0202 (GROOVE W3) G97 S600 M03 G00 X24. Z2. Z-21. G01 X17. F0.05 G04 X0.5 G00 X24. X100. Z100. G28 U0 W0 T0303 (THREAD 60DEG) G97 S800 M03 G00 X22. Z5. G92 X19.4 Z-19.5 F1.5 X18.9 X18.5 X18.3 X18.16 G00 X100. Z100. M09 G28 U0 W0 M05 M30
L15
Grade 2 levelCombined 2: M24×2 thread, 4 mm groove, concave R and taper
The stock is Ø40 with 1 mm of stock on the face (the first lines of the template already face it to Z0). From the face: C1.5, Ø24 (M24×2 thread to Z-13), a 4 mm relief groove (Z-13 to Z-17, Ø21), Ø24 to Z-20, a concave R3 into Ø30, Ø30 to Z-30, a taper reaching Ø38 at Z-46, and Ø38 to Z-55. Work out how to cut a 4 mm groove with the 3 mm tool, and the last thread X (21.55).
Hint
Cut the groove at Z-17. and Z-16. (overlapping 1 mm). The concave R is G02. Stop the roughing pass before the R at Z-21.8 (for X26.4) so it does not dig in. Give the thread a run-up of at least twice the lead (Z6.).
If stuck: Intro: grooves and threads
┅ Rapid G00━ Cutting feed━ Threading┅ Drawing line
Show a sample answer
O0115 G28 U0 W0 T0101 G50 S3000 G96 S150 M03 G99 G00 X43. Z0. M08 G01 X0. F0.15 G00 Z2. X42. G90 X38.4 Z-54.8 F0.25 X34.4 Z-38. X30.4 Z-29.8 X26.4 Z-21.8 X24.4 Z-19.8 G00 X21. G01 Z0. F0.12 X24. Z-1.5 Z-20. G02 X30. Z-23. R3. G01 Z-30. X38. Z-46. Z-55. X42. G00 X100. Z100. G28 U0 W0 T0202 (GROOVE W3) G97 S600 M03 G00 X26. Z2. Z-17. G01 X21. F0.05 G04 X0.5 G00 X26. Z-16. G01 X21. G04 X0.5 G00 X26. X100. Z100. G28 U0 W0 T0303 (THREAD 60DEG) G97 S600 M03 G00 X26. Z6. G92 X23.2 Z-15. F2. X22.6 X22.1 X21.8 X21.6 X21.55 G00 X100. Z100. M09 G28 U0 W0 M05 M30
Mill: basic (M1–M5) facing, slots, circle, boss, holes

On a machining center the basic order is: safety block (G21 G90 G17 G40 G49 G80) → tool change → spindle on → tool length offset with G43 → cut. The five basic problems are the same as in the intro article, and you get the pass mark here too.
M1
BasicFacing: cut 0.5 mm off the top face
The stock is 80×60×20 aluminum, and the origin is the front-left corner of the top face. Use T1 (φ20 end mill) to cut 0.5 mm off the top face and make it flat. The first pass (going right along Y0) and the move to Y15 are already written. Shift Y by 15 mm each time and go back and forth until Y60.
Hint
Write X-15. and X95. alternately, with a line that increases Y by 15 between them. Stepping over by 15 mm, less than the 20 mm tool width, leaves no uncut streaks.
If stuck: Exercises in the intro
O2001 G21 G90 G17 G40 G49 G80 G54 T1 M06 S2400 M03 G00 X-15. Y0. G43 H1 Z30. M08 Z2. G01 Z-0.5 F300 X95. F800 Y15. X-15. Y30. X95. Y45. X-15. Y60. X95. G00 Z30. M09 M30
M2
BasicTwo slots: move with G00, cut with G01
With T2 (φ10), cut two slots (10 wide, 3 deep) from X10 to X70 along the lines Y15 and Y45. After cutting one, raise to Z2. and rapid to the start of the second.
Hint
G01 Z-3. F150 → X70. F500 → G00 Z2. → X10. Y45. → plunge again with G01 and cut. Never move inside the material with G00.
If stuck: Exercises in the intro
O2002 G21 G90 G17 G40 G49 G80 G54 T2 M06 S3200 M03 G00 X10. Y15. G43 H2 Z30. M08 Z2. G01 Z-3. F150 X70. F500 G00 Z2. X10. Y45. G01 Z-3. F150 X70. F500 G00 Z30. M09 M30
M3
BasicRound pocket: full circle with G03 (I, J)
At center X40 Y30, cut a round recess (pocket) 30 in diameter and 4 deep with T2 (φ10). The program is written up to the point where the tool has plunged to Z-4. at the center.
Hint
Moving to X50. brings the outside of the tool to radius 15. From there, G03 X50. Y30. I-10. J0. makes one full turn. A full circle cannot be written with R, so write it with I and J (the distance from the start point to the center).
If stuck: Exercises in the intro
O2003 G21 G90 G17 G40 G49 G80 G54 T2 M06 S3200 M03 G00 X40. Y30. G43 H2 Z30. M08 Z2. G01 Z-4. F100 X50. F400 G03 X50. Y30. I-10. J0. G01 X40. G00 Z30. M09 M30
M4
BasicRound boss: cutter radius compensation G41 and G02
Leave a cylinder (boss) 40 in diameter centered at X40 Y30 and cut 5 deep around it. The tool is T2 (φ10), and compensation number D2 is assumed to hold the tool radius, 5. The program is written up to the point where compensation is applied and the tool has reached the front of the circle (X40. Y10.).
Hint
G41 offsets the tool to the left of its direction of travel. Going clockwise (G02) around the outside of the circle gives climb milling. The end point is the same as the start point, X40. Y10., and the center is J20. away.
If stuck: Exercises in the intro
O2004 G21 G90 G17 G40 G49 G80 G54 T2 M06 S3200 M03 G00 X65. Y-10. G43 H2 Z30. M08 Z2. G01 Z-5. F150 G41 D2 Y10. F500 X40. G02 X40. Y10. I0. J20. G01 X20. G40 X10. Y-10. G00 Z30. M09 M30
M5
BasicFive holes: repeat with G91 and K
Drill five holes of φ6.8 and 10 deep along the line Y30, every 15 mm from X10 to X70. The drill (T3) is waiting at X-5. Y30. Z30. Write it in one block using G91 (incremental) and K (the repeat count; L on Mitsubishi Electric and Haas).
Hint
In G91, both R and Z are incremental. The R point is −28 from the current height Z30 (= Z2), and the hole bottom is −12 from the R point (= Z-10). Each repeat advances 15 in X, so five repeats from X-5 drill holes at X10, 25, 40, 55 and 70.
If stuck: Exercises in the intro
O2005 G21 G90 G17 G40 G49 G80 G54 T3 M06 S1800 M03 G00 X-5. Y30. G43 H3 Z30. M08 G91 G99 G81 X15. Y0. Z-12. R-28. K5 F180 G80 G90 G00 Z30. M09 M30
Mill: intermediate (M6–M12) G41, pockets, taps, macros, G83

M6–M10 are the same five exercises as on the machining center page. M11 and M12 compare G83 (deep peck, back to the R point every time) and G73 (high-speed peck, backs off a little) on the same hole. In both, Q is the depth of each peck, and the retract amount is set by a parameter[3][4][9]. The tap feed is pitch × rpm (F500 for M8×1.25 at S400)[7].
M6
IntermediateCut the outline (G01, cutter comp)
Leave a rectangle X10–70, Y10–50 and cut around it 5 mm deep. Use T1 (Ø10) with G41 cutter compensation.
If stuck: Exercises on the machining center page
O0001 G21 G90 G17 G40 G49 G80 G54 T1 M06 S3000 M03 G00 X0. Y-5. G43 H1 Z30. M08 Z2. G01 Z-5. F300 G41 D1 X10. Y0. F600 Y50. X70. Y10. X5. G40 X0. Y-5. G00 Z30. M09 M30
M7
IntermediateRounded outline (G02, G03)
Leave X10–70, Y10–50 with R8 corners and cut the outline 4 mm deep.
If stuck: Exercises on the machining center page
O0002 G21 G90 G17 G40 G49 G80 G54 T1 M06 S3000 M03 G00 X0. Y-5. G43 H1 Z30. M08 Z2. G01 Z-4. F300 G41 D1 X10. Y0. F600 Y42. G02 X18. Y50. R8. G01 X62. G02 X70. Y42. R8. G01 Y18. G02 X62. Y10. R8. G01 X18. G02 X10. Y18. R8. G01 Y20. G40 X0. Y25. G00 Z30. M09 M30
M8
IntermediatePocket (helical entry)
Cut a pocket centred at X40 Y30, 40 wide and 24 long, 6 mm deep with T5 (Ø6). Do not plunge straight — enter with a helix (G03 with Z).
If stuck: Exercises on the machining center page
O0003 G21 G90 G17 G40 G49 G80 G54 T5 M06 S5000 M03 G00 X42. Y30. G43 H5 Z30. M08 Z1. #1=0 WHILE [#1 GT -6] DO1 #1=#1-1.5 G03 X42. Y30. Z#1 I-2. J0. F300 END1 G03 X42. Y30. I-2. J0. G01 X23. Y21. F500 X57. Y25. X23. Y29. X57. Y33. X23. Y37. X57. Y39. X23. Y21. X57. Y39. X23. Y21. G00 Z30. M09 M30
M9
IntermediateDrilling and tapping (G81, G83, G84)
At X15 Y15, X65 Y15, X65 Y45 and X15 Y45: spot drill (T2, 2 deep) → Ø6.8 pilot (T3, 18 deep, G83) → M8 tap (T4, 14 deep, G84).
If stuck: Exercises on the machining center page
O0004 G21 G90 G17 G40 G49 G80 G54 T2 M06 S2000 M03 G00 X15. Y15. G43 H2 Z30. M08 G99 G81 X15. Y15. Z-2. R2. F150 X65. Y45. G98 X15. G80 T3 M06 S1800 M03 G00 X15. Y15. G43 H3 Z30. G99 G83 X15. Y15. Z-18. R2. Q3. F180 X65. Y45. G98 X15. G80 T4 M06 S400 M03 G00 X15. Y15. G43 H4 Z30. G99 G84 X15. Y15. Z-14. R5. F500 X65. Y45. G98 X15. G80 M09 M30
M10
IntermediateHole pattern with a macro (WHILE)
Drill seven Ø6.8 holes (10 deep) on Y30 from X10 to X70 every 10 mm, looping X with variable #1 and WHILE.
If stuck: Exercises on the machining center page
O0005 G21 G90 G17 G40 G49 G80 G54 T3 M06 S1800 M03 G00 X10. Y30. G43 H3 Z30. M08 #1=10 WHILE [#1 LE 70] DO1 G99 G81 X#1 Y30. Z-10. R2. F180 #1=#1+10 END1 G80 G00 Z30. M09 M30
M11
IntermediateDeep holes with G83 (choosing Q)
The stock is 80×60×40. Drill three holes 30 mm deep (6× diameter) with the Ø5 drill (T1) at X20, X40 and X60 on Y30. Use G83, which returns to the R point every peck so chips do not pack, with a peck Q of 3 mm.
Hint
G99 G83 X20. Y30. Z-30. R2. Q3. F150 → X40. → G98 X60. Write Q in mm with a decimal point (Q3. = 3 mm). The deeper the hole, the smaller the Q, following the tool maker’s data.
If stuck: Canned cycles
O0211 G21 G90 G17 G40 G49 G80 G54 T1 M06 S1900 M03 G00 X20. Y30. G43 H1 Z30. M08 G99 G83 X20. Y30. Z-30. R2. Q3. F150 X40. G98 X60. G80 G00 Z30. M09 M30
M12
IntermediateCompare G73 and G83 on the same hole
With the Ø6.8 drill (T3), drill X25 Y30 with G73 (high-speed peck) and X55 Y30 with G83 (deep peck), both 18 deep with Q3. After ▶, compare the toolpaths and cycle times.
Hint
G73 backs off a little each peck to break chips (fast); G83 pulls out to the R point each time to clear them (less packing, slower). Cancel each with G80 before the next cycle.
If stuck: Canned cycles
O0212 G21 G90 G17 G40 G49 G80 G54 T3 M06 S1800 M03 G00 X25. Y30. G43 H3 Z30. M08 G99 G73 X25. Y30. Z-18. R2. Q3. F180 G80 G99 G83 X55. Y30. Z-18. R2. Q3. F180 G80 G00 Z30. M09 M30
Mill: advanced and grade 2 level (M13–M15)

M98 calls the same moves grouped in a subprogram; the repeat count is given with L (also on Mitsubishi Electric and Haas)[3][4]. The two combined problems are our own drawings based on the scope of the grade 2 practical test for machining center work (outline, pocket, drilling, tapping)[12]. Cutter compensation is started on a straight move, away from the work, as a rule[8][3].
M13
AdvancedThree identical slots with an M98 subprogram
With T1 (Ø10), cut three slots (10 wide, 3 deep) from Y15 to Y45 on X15, X40 and X65. Write one slot in subprogram O1100 in G91 (incremental) and call it three times from the main program with M98 P1100 L3. The tool waits at X15. Y15. Z2.
Hint
The subprogram is 4 lines: Z down 5 (Z2 → Z-3) → Y +30 → Z up 5 → X25. Y-30. to the next slot start. Always switch back to G90 afterwards (G90 G00 Z30. in the main program).
If stuck: Custom macro basics (M98 and G65)
O0213 G21 G90 G17 G40 G49 G80 G54 T1 M06 S3000 M03 G00 X15. Y15. G43 H1 Z30. M08 Z2. M98 P1100 L3 G90 G00 Z30. M09 M30 O1100 G91 G01 Z-5. F150 Y30. F500 G00 Z5. X25. Y-30. M99
M14
Grade 2 levelCombined 1: rounded outline, pocket and four holes
Stock 80×60×20. With T1 (Ø10), leave X10–70, Y10–50 with R8 corners and cut the outline 4 deep, then cut a pocket X30–50, Y20–40 (R5 corners) 3 deep in the middle. Finally drill four holes 12 deep with T3 (Ø6.8) at X18 Y18, X62 Y18, X62 Y42 and X18 Y42.
Hint
The outline is the same as exercise 7 (rounded outline) at Z-4. For the pocket, move the Ø10 tool center back and forth over X35–45, Y25–35 every 5 mm; the corners come out R5 from the tool radius. Drill with G99 (back to R) and G98 on the last hole.
If stuck: Intro: cutter compensation G41, G42, G40 and D
O0214 G21 G90 G17 G40 G49 G80 G54 T1 M06 S3000 M03 G00 X0. Y-5. G43 H1 Z30. M08 Z2. G01 Z-4. F300 G41 D1 X10. Y0. F600 Y42. G02 X18. Y50. R8. G01 X62. G02 X70. Y42. R8. G01 Y18. G02 X62. Y10. R8. G01 X18. G02 X10. Y18. R8. G01 Y20. G40 X0. Y25. G00 Z2. X35. Y25. G01 Z-3. F150 X45. F500 Y30. X35. Y35. X45. G00 Z30. T3 M06 S1800 M03 G00 X18. Y18. G43 H3 Z30. G99 G81 X18. Y18. Z-12. R2. F180 X62. Y42. G98 X18. G80 M09 M30
M15
Grade 2 levelCombined 2: round boss and M8 taps in the corners
Stock 80×60×20. With T1 (Ø10), leave a Ø40 boss centered at X40 Y30 and cut around it 5 deep, then tap M8×1.25 at the four corners X8 Y8, X72 Y8, X72 Y52 and X8 Y52: spot (T2, 2 deep) → Ø6.8 pilot (T3, 18 deep, G83) → tap (T4, 14 deep, G84, S400).
Hint
Enter the boss at its front point (X40. Y10.) along the tangent line Y10 with G41, then go once around with G02 X40. Y10. I0. J20. (the tool stays to the left of travel = outside). The tap feed is pitch × rpm = 1.25 × 400 = F500.
If stuck: Intro: drilling cycles G81, G83, G84
O0215 G21 G90 G17 G40 G49 G80 G54 T1 M06 S3000 M03 G00 X60. Y-5. G43 H1 Z30. M08 Z2. G01 Z-5. F300 G41 D1 Y10. F600 X40. G02 X40. Y10. I0. J20. G01 X25. G40 X15. Y-5. G00 Z30. T2 M06 S2000 M03 G00 X8. Y8. G43 H2 Z30. G99 G81 X8. Y8. Z-2. R2. F150 X72. Y52. G98 X8. G80 T3 M06 S1800 M03 G00 X8. Y8. G43 H3 Z30. G99 G83 X8. Y8. Z-18. R2. Q3. F180 X72. Y52. G98 X8. G80 T4 M06 S400 M03 G00 X8. Y8. G43 H4 Z30. G99 G84 X8. Y8. Z-14. R5. F500 X72. Y52. G98 X8. G80 M09 M30
Common pitfalls: learn them from the simulator warnings


Still in G00 into the stockForgetting to switch to G01 before cutting hits the stock at rapid and gives a “crash” error. Before a tool change go to G28 U0 W0 or well clear of the work.
How to start G41Start cutter compensation on a straight move, not an arc, away from the work, and cancel with G40 away from it. Starting on an arc gets a warning in the simulator[8].
Other common slips: computing the G90 taper R at Z0 (L8), mixing up the grooving tool’s reference corner (L10, L13), too short a thread run-up (L11), roughing passes that dig into a taper or radius (L14, L15), and carrying on in G91 (M13). When a problem does not pass, use the Z position (X and Y on the mill) shown in the grade box to find the line at fault.
Exam dates for Japan's machining-trade skills tests and study pages by trade are listed in Japan's skills tests (machinery): FY2026 second-half dates and study guide.
FAQ
- How can I practice CNC programming on my own?
- Read the intro articles for what the codes mean, then work through this set from the basic problems, writing each without looking at the answer and checking with ▶. Once you pass, change the numbers to make your own drawing and write it again. Programs can be shared as a link, so a senior colleague can check them.
- What should I check before running on a real machine?
- Besides what you practiced here, check that machine’s tool offsets, work coordinates and parameters (how numbers without a decimal point are read, the G-code system, the G73 retract, and so on). At first run one block at a time (single block) with reduced rapid, watching the tool position. Follow your shop’s rules and the machine manual.
- How is this different from studying for the written skills test?
- The written test asks about the meaning of G codes and choosing cutting conditions; the practical test has you plan the process and program from a drawing and cut the part[11][12]. This set suits the practical skill of “write it and check the motion”. How to solve the planning paper is covered in our article on the grade 2 planning paper.
- Is the programming the same on controls other than FANUC?
- The basic G00–G03, canned cycles and M98 are almost the same on FANUC-compatible machines such as Mitsubishi Electric and the Siemens ISO dialects[2][3][1][4]. However, numbers such as G90 and G92 change with the lathe G-code system (A, B, C), and some controls, such as Okuma OSP, use a different style altogether. Check differences between makers in the G and M code dictionary.
Just want to play with simulators? See 11 machining simulators that run in your browser; for free-form lathe programs, the CNC lathe page; and for the mill, the machining center page.
Sources
- Siemens: SINUMERIK ISO Dialects Turning Programming Manual (ISO dialect, 2007)
- Mitsubishi Electric: 700/70 Series Programming Manual (Lathe System), IB-1500057
- Mitsubishi Electric, "700/70 Series Programming Manual (Machining Center System)," IB-1500072
- Siemens, "SINUMERIK ISO Dialects Milling Programming Manual" (ISO dialects, 2007)
- Haas Automation: Lathe Programming Workbook (PDF)
- Haas Automation: G50 Spindle Speed Limit (lathe)
- Haas Automation, "G84 Tapping Canned Cycle" (mill)
- Haas Automation, "Mill Operator’s Manual 17 – G-Codes" 17.3 Cutter Compensation
- Shibaura Machine, "Canned cycle commands" (machine tool glossary)
- Ministry of Health, Labour and Welfare: NC Lathe Operation (commentary on trade skill test tasks, Monozukuri Meister program) (in Japanese)
- JAVADA: Trade Skill Tests: Job Content (Machining, NC lathe operation) (in Japanese)
- Japan Vocational Ability Development Association (JAVADA), "Contents of Work in the National Trade Skill Tests" (Machining: machining center work)
- JAVADA: Trade Skill Test Question Public Site (in Japanese)
- Imai, Shintani: “Development and Practice of an NC Machine Tool Designed for Safety in Hands-On Education,” Journal of the Japanese Society for Engineering Education 63(3) (2015) (in Japanese)
- “A Case Study of using Swansoft CNC Simulator Software in Vocational Education,” Atlantis Press (a case at a vocational high school)
More articles
NCSetting Work Zero and Tool Length on a Machining Center: Edge Finders, Touch Probes, Tool Setters, G54 and G43
NCThread Mill Programming: Helical Interpolation, G02/G03 and Z Direction, Feed Correction, Entry, Controls
NC