• ascnc@asianstarcnc.com

Mastering CNC Turning: A Comprehensive Guide to G-Code and M-Code Programming

In the world of CNC (Computer Numerical Control) machining, the success of your projects heavily relies on your ability to understand and implement the programming language central to controlling machine tools. For those working with CNC turning machines, becoming proficient in G-code and M-code programming is essential. In this comprehensive guide, we will dive into the world of CNC turning codes, providing you with everything you need to know for more efficient and precise production.

An Introduction to CNC Turning

CNC turning is one of the most common techniques used in the manufacturing industry to produce cylindrical components. Compared to traditional manual lathes, CNC turning machines offer greater accuracy, repeatability, and more complex designs. The key to this precision and efficiency lies in the programming codes that control the machine's movement, speed, and cutting actions.

G-Code and M-Code: The Building Blocks of CNC Turning Programming

The language used for programming CNC machines is mainly composed of two sets of codes: G-code and M-code. G-codes, or "preparatory codes," dictate the actual movement and positioning of the cutting tool, while M-codes, or "miscellaneous codes," control additional machine functions like coolant and spindle activation. Both code sets are critical to successful CNC turning and require a deep understanding of their capabilities.

G-Code Basics

G-code consists of numerical values and letter addresses that instruct the machine on calculating position and speed. Some common G-code commands are:

G00: Rapid positioning

G01: Linear interpolation

G02: Clockwise circular interpolation

G03: Counterclockwise circular interpolation

G28: Return to machine zero point

Each command has its own specific use in controlling the cutting tool, allowing you to create complex shapes and finished parts with incredible precision. A solid understanding of G-code commands will allow you to take your CNC turning projects to the next level.

M-Code Basics

M-code commands serve as additional machine controls that supplement the actions specified by G-code. A few common M-code commands include:

M03: Start spindle clockwise

M04: Start spindle counterclockwise

M05: Stop spindle

M08: Coolant on

M09: Coolant off

M-code greatly enhances the capabilities of CNC turning machines by expanding the suite of available actions, leading to smoother operation and better-quality parts.

Practical Tips for G-Code and M-Code Use

Now that you have a basic understanding of G-code and M-code commands, here are some practical tips for using them effectively in your CNC turning projects:

1. Plan your toolpath: Before writing your program, take the time to plan out the movements and actions of your cutting tool. This will make it easier to create an efficient and error-free program.

2. Start with the basics: Begin by programming simple parts and gradually add complexity as you gain experience and confidence in your coding abilities.

3. Test and verify: Whenever you create a new program or make changes to an existing one, always test and verify your code through simulation software or a dry run on the machine. This helps identify any potential issues or errors before production begins.

4. Document your code: Consistently document your code with comments and revisions, making it easier to maintain, update, and troubleshoot in the future.

5. Be mindful of operator safety: Ensure that your program takes operator safety into account, incorporating safety features like protective housing, emergency stops, and appropriate coolant use.

Explore Further: Advanced G-Code and M-Code Techniques

As you become more proficient in CNC turning programming, you can delve deeper into advanced G-code and M-code techniques, such as:

Canned cycles: Utilizing pre-programmed cycles can simplify your code and reduce repetitive steps while still achieving complex and precise toolpaths.

Macros: Creating and using custom macros can automate and streamline complex tasks, saving time and increasing efficiency.

Subroutines: Subroutines, also known as subprograms, allow you to arrange your code into smaller sections for easier organization and reuse.

This comprehensive guide to G-code and M-code programming in CNC turning aims to provide you with the essential knowledge required to excel in this field. A strong foundation in these programming languages will empower you to craft complex designs with precision and efficiency. The better you understand the potential of CNC turning codes, the more successful your projects will be. Happy programming!

cnc turning all codes

What is CNC Turning

CNC turning is a process that involves using computer numerical control (CNC) machines to shape and finish various materials, such as metals and plastics, into desired shapes and sizes.
This process is typically used in the manufacturing industry to produce precision parts and components for a wide range of applications, including automotive, automation, aerospace, medical, machinery, and industrial.

CNC Turning service

Asianstar Professional CNC Turning Service

Asianstar CNC turning Service offers precision machining for a wide range of materials, including metals, plastics, and composites. With high level facilities and skillful operators, we can produce high-quality parts with tight tolerances and intricate designs.

Our CNC turning capabilities allow us to produce parts with diameters ranging from 0.5 mm to 480mm and lengths up to 450mm. We offer both single and multi-axis turning, as well as live tooling options for added complexity and accuracy.

We use proven processes and quality control measures to ensure that every part we produce meets our clients' specifications and expectations.

Whether you need a single prototype or high-volume production runs, our CNC turning service can provide the precision and reliability you need to get your project completed on time and on budget.

CNC Turning service

Components Sizes of Asianstar CNC Turning Service

Unit (mm) Min Max
Out Diameter 0.5 480
Inner Diameter (Hole) 0.3 465
Length 1.0 450
Groove Diameter 0.4 above
Thread M1.2 above

Components Tolerance of Asianstar CNC Turning Service

Unit (mm) Tolerance according to sizes
Height Tolerance Diameter Size 0.5 to 3 3 to 6 6 to 30 30 to 120 120 to300 300 to480
Tolerance ±0.003 ±0.010 ±0.020 ±0.030 ±0.035 ±0.040
Length Tolerance Length Size 0.5 to 3 3 to 6 6 to 10 10 to 20 20 to 30 30 above
Tolerance ±0.010 ±0.020 ±0.250 ±0.250 ±0.030 ±0.035

Components shape and position tolerance of Asianstar CNC Turning Service

Tolerance Class followed Tolerance (mm)
Straightness and Flatness Verticality Symmetry
10 10 to 30 30 to 100 100 to 300 300 to 1000 1000 to 3000 to 100 100 to 300 300 to 1000 1000 to 3000 to 100 100 to 300 300 to 1000 1000 to 3000
H ±0.015 ±0.02 ±0.03 ±0.05 ±0.10 ±0.15 ±0.02 ±0.025 ±0.03 ±0.035 ±0.02 ±0.03 ±0.04 ±0.05

Capability of Asianstar CNC Turning Service

Type of Turning Machine Diameter Size (mm) Length Size (mm) Productivity (PCS/Month)
Auto Turning Machine Simple Turning Machine Multi Turning Machine Pin Turning Machine Min 0.5 Max 480 Min 1.0 Max 450 200’000/Item


Multiple Machining Processes

Multiple Machining Processes

Asianstar has various machining processes to support different types of components from client, we can choose the best suitable manufacturing solution to carry result in perfect performance and cheap cost

Flexible Custom Service

Flexible Custom Service

With skillful machining technologies, Asianstar is flexible to support clients on different materials and different structures of the components, we also flexible on the components quantities and even assembly

Create Designing for Clients

Create Designing for Clients

Not only producing according to clients drawings, Asianstar also propose the better designing to clients, supporting clients to buildup improved designing or even new generation components

Standard Procedures

Standard Procedures

Asianstar production, as experienced by many years, is strictly following internal Standard Operating Procedures, to make sure the production schedule is smooth and plans are well carried out well without accidents

Standard Procedures

Standard Procedures

Asianstar strictly controlling product quality by system. We start QC controlling from production plan once setting up, to production process by monitoring QC checking and until the final Inspection before packing

Fast Lead-Time Delivery

Fast Lead-Time Delivery

Asianstar strictly control the production processes, teams keep the plan moving ahead according to the procedures, we have internal time management schedule which mostly bring earlier lead-time of delivery

Asianstar: Professional CNC Machining Supplier

From year of 2005, Asianstar Company establish the CNC Machining Factory in Guangdong Province, China.
We mostly provide CNC Turning, Milling, Drilling, Grinding, and Multi Machining processes service on various materials.
With the Belief of becoming a key supplier in the supply-chain of Precision Components, we strictly control our product quality, keep high precision on our components production, buildup the whole-process QC System and submit the satisfaction for every order.
By long term development, we have buildup partnership with world-wide clients, supporting our partners in Designing, Optimizing, Producing and Testing on each type of components.


CNC Turning Service

CNC Turning Service

Our CNC Turning Service provides different sizes of roll shape work-pieces, the diameter range is from 0.5mm to 480mm, reaching tolerance +/-0.003mm.

CNC Milling Service

CNC Milling Service

Our milling machines and CNC centers are able to produce complicated structure part, five-axis devices produce multi-sides at one-time jag which bring high precision result

Sheet Metal Fabrication

Sheet Metal Fabrication

Our Sheet Metal Fabrication provides slicing, punching, bending, welding, painting and assembling for set products, unique tooling for each project to raise production efficiency

Aluminum Extrusion

Aluminum Extrusion

Our Aluminum Extrusion brings clients various shapes of aluminum parts, high efficiency for mass quantity, our precision extrusion mold control tolerance within 0.01mm

Forging Service

Forging Service

For some steel serious products, we apply Forging Service to make out their outer shape and them use CNC devices to start drilling, forming, rolling, cutting, etc.

Finishing Service

Finishing Service

Our Surface Finishing Service uses chemical or electro post-treatments after machining tasks are finished, normally includes Oxide, Anodizing, Passivation, E-Plating, Painting,etc.


  • Q1.Do you support ODM/OEM?

    Yes, we support ODM/OEM, we provide custom-made service for clients or even support clients on designing or improving

  • Q2.Do You Have Stock
  • Q3.What Is Your Production Capacity?
  • Q4.Where Is Your Factory?
  • Q5.Can You Provide Samples?
  • Q6.How About Your After-sales Service?
Get The Best Quotes Now