CNC Lathe Codes

cnc lathe codes

Contents

What are CNC lathe codes?

CNC lathe codes consist primarily of G-codes and M-codes, along with address codes and canned cycles. These codes form a programming language that controls the operations of a CNC lathe, including tool movement, spindle control, coolant management, and various machining functions.

The codes can range from simple movement commands to complex parametric programming, allowing for precise control and automation of the machining process.

Common G-codes and M-codes in CNC Lathe Programming

This table covers the most commonly used G-codes and M-codes in CNC lathe programming.

Note that some codes may vary slightly depending on the specific CNC control system being used. Always refer to your machine’s programming manual for the exact implementation of these codes.

CodeCategoryFunctionNotes
G00MotionRapid positioning
Moves at maximum speed to specified position
G01MotionLinear interpolation
Moves in a straight line at specified feed rate
G02MotionCircular interpolation CW
Creates clockwise circular arc
G03MotionCircular interpolation CCW
Creates counterclockwise circular arc
G20UnitInch system
Sets programming to inch system
G21UnitMetric system
Sets programming to metric system
G28MotionReturn to home positionMoves to machine zero point
G96SpindleConstant surface speed
Maintains constant cutting speed
G97SpindleConstant spindle speedMaintains constant RPM
M03MiscellaneousSpindle on clockwise
Starts spindle rotation clockwise
M04MiscellaneousSpindle on counterclockwise
Starts spindle rotation counterclockwise
M05MiscellaneousSpindle stopStops spindle rotation
M30MiscellaneousProgram endEnds program and resets
G00MotionRapid positioning
Moves at maximum speed to specified position
G01MotionLinear interpolation
Moves in a straight line at specified feed rate
G02MotionCircular interpolation CWCreates clockwise circular arc
G03MotionCircular interpolation CCW
Creates counterclockwise circular arc
G04DwellDwell
Pause program for specified time
G20UnitInch system
Sets programming to inch system
G21UnitMetric system
Sets programming to metric system
G28MotionReturn to home positionMoves to machine zero point
G40CompensationTool nose compensation cancel
Cancels tool nose radius compensation
G41CompensationTool nose compensation left
Applies left tool nose radius compensation
G42CompensationTool nose compensation right
Applies right tool nose radius compensation
G50SettingSet coordinate systemEstablishes a coordinate system
G54CoordinateWork coordinate system 1
Selects work coordinate system 1
G55CoordinateWork coordinate system 2
Selects work coordinate system 2
G56CoordinateWork coordinate system 3
Selects work coordinate system 3
G57CoordinateWork coordinate system 4
Selects work coordinate system 4
G58CoordinateWork coordinate system 5
Selects work coordinate system 5
G59CoordinateWork coordinate system 6
Selects work coordinate system 6
G70CycleFinishing cyclePerforms finishing cycle
G71CycleStock removal in turningPerforms rough turning cycle
G72CycleStock removal in facingPerforms rough facing cycle
G73CyclePattern repeating
Performs pattern repeating cycle
G74CycleFace groovingPerforms face grooving cycle
G75CycleOuter/Inner diameter groovingPerforms OD/ID grooving cycle
G76CycleThreading cycle
Performs multi-pass threading cycle
G90ModeAbsolute programming
Sets absolute coordinate programming
G91ModeIncremental programming
Sets incremental coordinate programming
G94FeedFeed per minute
Sets feed rate in units per minute
G95FeedFeed per revolution
Sets feed rate in units per revolution
G96SpindleConstant surface speed
Maintains constant cutting speed
G97SpindleConstant spindle speedMaintains constant RPM
G98ReturnReturn to initial level
Returns to initial Z-axis level in canned cycles
G99ReturnReturn to R level
Returns to R-axis level in canned cycles
M00MiscellaneousProgram stopStops program execution
M01MiscellaneousOptional stop
Stops program if optional stop switch is on
M03MiscellaneousSpindle on clockwise
Starts spindle rotation clockwise
M04MiscellaneousSpindle on counterclockwise
Starts spindle rotation counterclockwise
M05MiscellaneousSpindle stopStops spindle rotation
M06MiscellaneousTool change
Performs automatic tool change
M08MiscellaneousCoolant onTurns on flood coolant
M09MiscellaneousCoolant offTurns off all coolant
M10MiscellaneousChuck clampClamps the chuck
M11MiscellaneousChuck unclampUnclamps the chuck
M19MiscellaneousOriented spindle stop
Stops spindle at a specific orientation
M30MiscellaneousProgram endEnds program and resets
M41MiscellaneousGear select 1Selects spindle gear range 1
M42MiscellaneousGear select 2Selects spindle gear range 2
M43MiscellaneousGear select 3Selects spindle gear range 3
M44MiscellaneousGear select 4Selects spindle gear range 4
M98MiscellaneousSubprogram callCalls a subprogram
M99MiscellaneousSubprogram endEnds a subprogram and returns

Example of a simple CNC lathe program:

O1000 (SIMPLE TURNING PROGRAM)
G21 G40 G95 G97
G28 U0 W0
T0101 (TURNING TOOL)
G50 S2000
G96 S180 M03
G00 X50.0 Z0.1
G01 X-1.6 F0.15
G00 X50.0 Z2.0
G28 U0 W0
M30

This program does the following:

  1. Sets up the machine (metric, tool comp off, feed per rev, constant RPM)
  2. Returns to home position
  3. Selects tool 1
  4. Sets max spindle speed and turns on constant surface speed
  5. Moves to starting position
  6. Performs a facing cut
  7. Retracts
  8. Returns home
  9. Ends the program

While these codes are standardized to some extent, there can be variations between different machine manufacturers and controllers.

Back to Top: CNC Lathe Codes

gavin yi
CEO & Project Manager
Shenzhen Yijin Hardware Co., Ltd.

Gavin Yi

Gavin Yi is a distinguished leader in precision manufacturing and CNC technology. As a regular contributor to Modern Machine Shop and American Machinist magazines, he shares expertise on advanced machining processes and Industry 4.0 integration. His research on process optimization has been published in the Journal of Manufacturing Science and Engineering and International Journal of Machine Tools and Manufacture.

Gavin serves on the National Tooling & Machining Association (NTMA) board and frequently presents at the International Manufacturing Technology Show (IMTS). He holds certifications from leading CNC training institutions including Goodwin University’s Advanced Manufacturing program. Under his leadership, Shenzhen Yijin Hardware collaborates with DMG Mori and Haas Automation to drive innovation in precision manufacturing.

gavin yi

yijin hardware logo w

Get a quote from the China’s #1
CNC Machining Services.

Ready to get started?
Connect with us today!

Categories
  • Case Studies
  • CNC Machining
  • Custom Fasteners
  • Materials
  • News & Blog
  • Sheet Metal
  • Surface Finish

More To Explore

what is micro cnc machining
CNC Machining
What is Micro CNC Machining?

Micro CNC machining is a specialized manufacturing process that uses computer numerical control (CNC) technology to create incredibly small and precise components, often measuring in

cnc machining manufacturers in china
CNC Machining
Top 10 China CNC Manufacturer Services

As businesses increasingly turn to China for CNC machining services, explore the top 10 manufacturers shaping the industry landscape. From Rapid Direct’s AI-driven instant quoting

Start today. Get parts made fast.

Free Machined Parts Design to Your Projects with Fast Turnaround Times.
Please enable JavaScript in your browser to complete this form.
Click or drag files to this area to upload. You can upload up to 15 files.

Please attach your 2D CAD drawings and 3D CAD models in any format including STEP, IGES, DWG, PDF, STL, etc. If you have multiple files, compress them into a ZIP or RAR. Alternatively, send your RFQ by email to info@yijinsolution.com.

3D Drawing Formats: .step/.stp, .dwg, .m3d, .x_t, .sldprt, .stl, .CATPart, .CATProduct, .iges/.igs
2D Drawing Formats: .dwg, .cdw, .SLDDRW, .scr

Compressed Formats: .zip, .rar, .7z

Image Formats: .pdf, .jpg/.jpeg, .gif, .png, .webp, .tif/.tiff

Video Format: .mp4

Office Formats: .txt, .docx, .xlsx, .ppt, .ods