CNC Lathe G Code Programming
Standard G-Codes for CNC Lathes
G0 - Rapid Movement
G1 - Linear Feed Movement
G2 - Clockwise Interpolation - Circular Movement
G3 - Counter Clockwise Interpolation - Circular Movement
G4 - Dwell
G9 - Exact Stop
G10 - Set Data
G17 - XY Machine Plane Selection
G18 - ZX Machine Plane Selection
G19 - YZ Machine Plane Selection
G20 - Machine is Programmed in Inches
G21 - Machine is Programmed in Millimeters
G28 - Return Home (First Reference Position)
G30 - Return to the Second Reference Position
G40 - Cancel the Turning Tool Nose Radius Compensation
G41 - Turning Tool Nose Radius Compensation - Left
G42 - Turning Tool Nose Radius Compensation - Right
G50 - Maximum Spindle Speed Limit
G52 - Local Coordinate System Setting
G53 - Machine Coordinate System Setting
G54 - Work Offset / Work Coordinate System
G55 - Work Offset / Work Coordinate System
G56 - Work Offset / Work Coordinate System
G57 - Work Offset / Work Coordinate System
G58 - Work Offset / Work Coordinate System
G59 - Work Offset / Work Coordinate System
G80 - Cancel a Canned Cycle
G81 - Drilling Canned Cycle
G82 - Drilling Canned Cycle
G83 - Peck Drilling Canned Cycle
G84 - Tapping Canned Cycle
G85 - Boring Canned Cycle
G86 - Boring Cycle
G90 - Absolute Programming
G91 - Incremental Programming
G92 - Thread Cutting Canned Cycle
G96 - Constant Surface Speed Selection
G97 - Spindle Speed Selection
G98 - Feed Rate Per Minute
G99 - Feed Rate Per Revolution
Standard M-Codes for CNC Lathes
M0 - Machine Stop / Program Stop
M1 - Optional Stop (There is a button on the controller that allows the program to stop at this point)
M2 - End of Program
M3 - Spindle Rotation Counter Clockwise / Spindle Start
M4 - Spindle Rotation Clockwise / Spindle Start
M8 - Coolant On (There are normally more coolant codes)
M9 - Coolant Off
M10 - Chuck Clamp
M11 - Chuck Unclamp
M17 - Turret Rotation Forward
M18 - Turret Rotation Reverse
M19 - Orientate the Spindle
M30 - End of the Program / Reset the Program
M36 - Parts Catcher Extend, On
M37 - Parts Catcher Retract, Off
M98 - Subprogram Call, Jump-to
M99 - Subprogram End
Terms To Understand
M - Codes - Miscellaneous CNC function programming in the standard G-Code programming format. The M-codes vary by the machine tool builder
Modal - A term that means that two G-Codes from the same group cannot be executed on the same line of code, or at the same time.
The Order of a CNC Program
The Program Number
A Tool Change Call
Define a Tool Length Offset Number
Define a Work Coordinate System Number
Tool Path Code
Axis Zero Return
End of the Program
FACING THE PART - G CODE PROGRAM
%
O0010 (PROGRAM NUMBER)
(LATHE PART)
G50S3000 (MAXIMUM SPINDLE SPEED)
T0101 (TOOL CALL, TOOL OFFSET CALL)
G96S1500M3 (CONSTANT SURFACE SPEED, TURN SPINDLE ON AT 1500RPM)
(FACING OPERATION)
G0G54G90X1.85Z0.0M8 ( G54 WORK COORDINATE, RAPID TO X1.85, Z0, COOLANT ON)
G1G99X0.0F.003 (FACE PART TO X0.0)
G0Z.100 (RAPID TO Z.1)
G0X2.0 (RAPID TO X2.0)
G0X6.5M9 (RAPID TO X 6.5, COOLANT OFF)
M30 (END OF PROGRAM)
%
Turning The Outside Diameter - G Code Program
%
O0011 (PROGRAM NUMBER)
(LATHE PART)
G50S3000 (MAXIMUM SPINDLE SPEED)
T0101 (TOOL CALL, TOOL OFFSET CALL)
G96S1500M3 (CONSTANT SURFACE SPEED, TURN SPINDLE ON AT 1500RPM)
(OD TURN OPERATION)
G0G54G90X1.75Z0.05M8 (G54 WORK COORDINATE, RAPID TO X 1.75, Z.05, COOLANT ON)
G1G99Z-4.010F.006 (FINISH TURN PART)
G0X1.85 (RAPID ABOVE PART)
G0Z.1 (RAPID TO Z.1)
G0X6.5M9 (RAPID TO X6.5, COOLANT OFF)
M30 (END OF PROGRAM)
%