G code and M code Mechanical Engineering Insights
What is G-code
G-code is a programming language used to control CNC (Computer Numerical Control)
machines. It provides a set of instructions that tells the machine how to move its tools, control
its speed, and perform various operations such as cutting, drilling, milling, or 3D printing.
G Codes and Descriptions
G-Code Description
G0 Rapid positioning
G1 Linear interpolation
G2 Clockwise circular/helical interpolation
G3 Counterclockwise circular/Helical interpolation
G4 Dwell
G10 Coordinate system origin setting
G12 Clockwise circular pocket
G13 Counterclockwise circular pocket
G15/G16 Polar Coordinate moves in G0 and G1
G17 XY Plane select
G18 XZ plane select
G19 YZ plane select
G20/G21 Inch/Millimetre unit
G28 Return home
1
G code and M code Mechanical Engineering Insights
G-Code Description
G28.1 Reference axes
G30 Return home
G31 Straight probe
G40 Cancel cutter radius compensation
G41/G42 Start cutter radius compensation left/right
G43 Apply tool length offset (plus)
G49 Cancel tool length offset
G50 Reset all scale factors to 1.0
G51 Set axis data input scale factors
G52 Temporary coordinate system offsets
G53 Move in absolute machine coordinate system
G54 Use fixture offset 1
G55 Use fixture offset 2
G56 Use fixture offset 3
G57 Use fixture offset 4
G58 Use fixture offset 5
G59 Use fixture offset 6 / use general fixture number
2
G code and M code Mechanical Engineering Insights
G-Code Description
G61/G64 Exact stop/Constant Velocity mode
G68/G69 Rotate program coordinate system
G70/G71 Inch/Millimetre unit
G73 Canned cycle – peck drilling
G80 Cancel motion mode
G81 Canned cycle – drilling
G82 Canned cycle – drilling with dwell
G83 Canned cycle – peck drilling
G85/G86/G88/G89 Canned cycle – boring
G90 Absolute distance mode
G90.1 Absolute IJK mode
G91 Incremental distance mode
G91.1 Incremental IJK mode
G92 Offset coordinates and set parameters
G92.x Cancel G92 etc.
G93 Inverse time feed mode
G94 Units Per Min.
3
G code and M code Mechanical Engineering Insights
G-Code Description
G98 Rapid Height By Z Height
G99 Rapid Height By R Height
What is M Code
In CNC (Computer Numerical Control) machining, M codes—often called miscellaneous
codes—are commands that control various machine functions that aren’t directly related to
the tool’s movement (which is typically handled by G codes). They are used to manage
auxiliary functions of the machine, such as starting or stopping the spindle, turning the
coolant on or off, pausing the program, and initiating tool changes.
M Codes and Descriptions
M Code Description
M00 Mandatory Program Stop
M01 Optional or Planned Program Stop
M02 Program End
M03 Spindle On Forward/Clockwise
M04 Spindle On Reverse/Counterclockwise
M05 Spindle Stop
M07 Mist Coolant On
M08 Flood Coolant On
M09 Coolant Off
M10 Pallet Clamp On
4
G code and M code Mechanical Engineering Insights
M11 Pallet Clamp OFF
M13 Spindle Clockwise and Coolant On
M19 Spindle Orientation
M30 Program End and Rewind
M48 Enable Feed/Speed Overrides
M49 Disable Feed/Speed Overrides
M52 Unload last tool from spindle
M60 Automatic pallet change
M98 Subprogram Call
M99 Return From Subprogram / Rewind
Applications of CNC (Computer Numerical Control)
CNC technology is widely used across various industries due to its precision, automation, and
efficiency. Here are some key applications:
1. Manufacturing Industry
CNC machining is used to produce complex parts with high accuracy.
Common in automobile, aerospace, and medical equipment manufacturing.
Produces engine parts, turbine blades, and surgical instruments.
2. Aerospace Industry
Used for aircraft components like engine parts, landing gear, and structural
elements.
Ensures tight tolerances and lightweight materials for aviation needs.
3. Automotive Industry
CNC machines manufacture gears, engine components, brake system parts, and
body panels.
5
G code and M code Mechanical Engineering Insights
Supports mass production with consistent quality.
4. Medical Sector
CNC is used to create prosthetics, implants (hip, knee), and surgical tools.
Ensures precise and patient-specific designs.
5. Electronics Industry
Used in PCB (Printed Circuit Board) manufacturing.
Helps in producing small, complex parts with high accuracy.
6. Woodworking & Furniture Making
CNC routers cut, engrave, and shape wood for furniture, doors, and decorative
panels.
Allows for intricate designs with minimal waste.
7. Metal Fabrication
CNC plasma and laser cutters shape and engrave metals for construction, machine
parts, and artwork.
Reduces manual labor and increases efficiency.
8. Military & Defense
Used for manufacturing weapons, vehicles, drones, and communication devices.
Ensures reliability and precision in critical defense applications.
9. Textile Industry
CNC machines control automated embroidery and fabric cutting.
Helps in mass production with high accuracy.
10. Jewelry & Engraving
CNC machines assist in crafting intricate jewelry designs and engraving metals.
Enables mass production while maintaining detail.
CNC technology has revolutionized multiple industries by enhancing precision, speed, and
automation, leading to improved productivity and cost efficiency.