- Practice · 8 marks
CNC lathe part program with G and M codes
Explain the meaning of the following codes used in CNC programming: G00, G01, G02/G03, G28, G90/G91, M03, M05, M08, M30. Prepare a part program for a CNC lathe to machine a bar of 40 mm diameter and 100 mm length to the following shape: face the end; turn a 30 mm diameter for a length of 50 mm from the face with a 1.5 mm x 45 degree chamfer at the end of the 30 mm diameter. Use two roughing passes (diameter 40 to 36 mm, then 36 to 32 mm) and one finishing pass to 30 mm. Use diameter programming, 800 rpm and feed 0.2 mm/rev for roughing, and 1200 rpm and 0.08 mm/rev for finishing. The tool is T0101.
Meaning of the codes
| Code | Meaning |
|---|---|
| G00 | Rapid positioning (no cutting) |
| G01 | Linear interpolation at programmed feed |
| G02 / G03 | Circular interpolation, clockwise / counter-clockwise |
| G28 | Return to the reference (home) position |
| G90 / G91 | Absolute / incremental dimensioning (on milling controls; lathes often use X, Z for absolute and U, W for incremental) |
| M03 | Spindle on, clockwise |
| M05 | Spindle stop |
| M08 | Coolant on |
| M30 | End of program and rewind |
G-codes are preparatory functions (motion and mode); M-codes are miscellaneous machine functions.
Assumptions
- FANUC-type format, metric units (G21), feed per revolution (G99), diameter programming (X is a diameter).
- Work zero (Z0) at the finished face; X0 on the axis. Stock Ø40.
- Roughing passes at Ø36 and Ø32 (2 mm depth per side each) leave 1 mm per side; the finish pass cuts to Ø30 and cleans the shoulder at Z-50.
- The chamfer is taken at the free (faced) end of the 30 mm diameter: Ø27 at Z0 rising to Ø30 at Z-1.5. The tool starts on the chamfer line 1 mm in front of the face (X25, Z1) so that it enters the cut smoothly.
Program
O0100 (TURN DIA 30 X 50 WITH CHAMFER)
N10 G21 G99 G40 G97 (metric, mm/rev, cancel comp)
N20 T0101 (select tool 1, offset 1)
N30 S800 M03 (spindle 800 rpm CW)
N40 G00 X42.0 Z2.0 M08 (approach, coolant on)
(FACING)
N50 G00 Z0.0
N60 G01 X-1.0 F0.1 (face to centre)
N70 G00 X42.0 Z2.0
(ROUGHING PASS 1 - DIA 36)
N80 G00 X36.0
N90 G01 Z-50.0 F0.2
N100 G00 X42.0 Z2.0
(ROUGHING PASS 2 - DIA 32)
N110 G00 X32.0
N120 G01 Z-50.0 F0.2
N130 G00 X42.0 Z2.0
(FINISH PASS WITH CHAMFER)
N140 G00 X25.0 Z1.0 S1200 (start on chamfer line)
N150 G01 X30.0 Z-1.5 F0.08 (1.5 x 45 deg chamfer)
N160 G01 Z-50.0 (finish dia 30)
N170 G01 X42.0 (clean shoulder face)
N180 G00 Z2.0
N190 G28 U0 W0 M05 (home, spindle stop)
N200 M09 (coolant off)
N210 M30 (end of program)
Notes on the program
- Each roughing pass retracts to X42, Z2 at rapid speed through the area already cut, so the tool does not drag over the work.
- The chamfer is a straight G01 move: the diameter changes by mm (Ø27 to Ø30) over a length of 1.5 mm, giving 45 degree.
- Machining time of one roughing pass: min.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Lathe operations, taper turning and turning calculations · Manufacturing and Production Processes, chapter 7
- NC and CNC machines: elements and justification · Manufacturing and Production Processes, chapter 9
- Milling, shaper and drilling machine operations · Manufacturing and Production Processes, chapter 7
- RA: employee-projects with no part used · Database Management System, chapter 3
- Bullet embedded in bar, h = 260 mm · Applied Mechanics (Dynamics), chapter 6 · asked 2×
- Rate analysis: 40 mm PCC 1:2:4 floor · Estimating and Costing, chapter 4
- Rate analysis: 40 mm asphalt wearing coat · Estimating and Costing, chapter 4
All Manufacturing and Production Processes chapter 9 questions →