How to Use G & M Codes for CNC Milling Machines?

How to Use G & M Codes for CNC Milling Machines

Computer numerical control (CNC) milling machines are automated milling machines that are used to create parts with complex shapes and features. CNC milling machines use G and M codes to control the movement of the cutting tool and the machine itself. In this article, we will discuss the basics of G and M codes and how to use them to control a CNC milling machine.

What are G and M Codes?

G and M codes are the instructions that tell the CNC milling machine what to do. G codes are used to control the movement of the cutting tool, while M codes are used to control the machine itself. G codes are also known as preparatory codes, while M codes are known as miscellaneous codes.

Types of G Codes

There are several types of G codes that can be used to control the movement of the cutting tool. The most common G codes are:

  • G00 – Rapid positioning
  • G01 – Linear interpolation
  • G02 – Circular interpolation (clockwise)
  • G03 – Circular interpolation (counterclockwise)
  • G04 – Dwell
  • G05 – High speed machining
  • G06 – Tool change
  • G07 – Tool radius compensation
  • G08 – Tool length compensation
  • G09 – Exact stop
  • G10 – Programmable data input
  • G11 – Programmable data output
  • G12 – Tool radius compensation (negative)
  • G13 – Tool length compensation (negative)
  • G14 – Tool radius compensation (positive)
  • G15 – Tool length compensation (positive)
  • G16 – Tool radius compensation (zero)
  • G17 – Tool length compensation (zero)
  • G18 – Tool radius compensation (negative)
  • G19 – Tool length compensation (negative)
  • G20 – Inch mode
  • G21 – Metric mode
  • G22 – Tool radius compensation (positive)
  • G23 – Tool length compensation (positive)
  • G24 – Tool radius compensation (zero)
  • G25 – Tool length compensation (zero)
  • G26 – Tool radius compensation (negative)
  • G27 – Tool length compensation (negative)
  • G28 – Return to reference point
  • G29 – Return from reference point
  • G30 – Return to second reference point
  • G31 – Return from second reference point
  • G32 – Threading cycle
  • G33 – Threading cycle (constant pitch)
  • G34 – Threading cycle (variable pitch)
  • G35 – Threading cycle (constant lead)
  • G36 – Threading cycle (variable lead)
  • G37 – Threading cycle (constant pitch and lead)
  • G38 – Threading cycle (variable pitch and lead)
  • G39 – Threading cycle (constant pitch and lead)
  • G40 – Cutter compensation (off)
  • G41 – Cutter compensation (left)
  • G42 – Cutter compensation (right)
  • G43 – Tool length compensation (positive)
  • G44 – Tool length compensation (negative)
  • G45 – Tool length compensation (zero)
  • G46 – Tool length compensation (positive)
  • G47 – Tool length compensation (negative)
  • G48 – Tool length compensation (zero)
  • G49 – Tool length compensation (off)
  • G50 – Scaling (off)
  • G51 – Scaling (on)
  • G52 – Local coordinate system
  • G53 – Machine coordinate system
  • G54 – Work coordinate system 1
  • G55 – Work coordinate system 2
  • G56 – Work coordinate system 3
  • G57 – Work coordinate system 4
  • G58 – Work coordinate system 5
  • G59 – Work coordinate system 6
  • G60 – Exact stop
  • G61 – Exact stop (cancel)
  • G62 – Automatic corner override
  • G63 – Automatic corner override (cancel)
  • G64 – Path blending (on)
  • G65 – Path blending (off)
  • G66 – High speed machining (on)
  • G67 – High speed machining (off)
  • G68 – Rotary axis scaling (on)
  • G69 – Rotary axis scaling (off)
  • G70 – Finishing cycle (on)
  • G71 – Finishing cycle (off)
  • G72 – Roughing cycle (on)
  • G73 – Roughing cycle (off)
  • G74 – Peck drilling cycle (on)
  • G75 – Peck drilling cycle (off)
  • G76 – Threading cycle (on)
  • G77 – Threading cycle (off)
  • G78 – Threading cycle (on)
  • G79 – Threading cycle (off)
  • G80 – Cancel motion mode
  • G81 – Drilling cycle (on)
  • G82 – Drilling cycle (off)
  • G83 – Peck drilling cycle (on)
  • G84 – Tapping cycle (on)
  • G85 – Tapping cycle (off)
  • G86 – Boring cycle (on)
  • G87 – Boring cycle (off)
  • G88 – Boring cycle (on)
  • G89 – Boring cycle (off)
  • G90 – Absolute positioning
  • G91 – Incremental positioning
  • G92 – Set position
  • G93 – Inverse time feed rate
  • G94 – Units per minute feed rate
  • G95 – Units per revolution feed rate
  • G96 – Constant surface speed
  • G97 – Constant spindle speed
  • G98 – Return to initial z level
  • G99 – Return to R level

Types of M Codes

M codes are used to control the machine itself, rather than the cutting tool. The most common M codes are:

  • M00 – Program stop
  • M01 – Optional program stop
  • M02 – Program end
  • M03 – Spindle on (clockwise)
  • M04 – Spindle on (counterclockwise)
  • M05 – Spindle off
  • M06 – Tool change
  • M07 – Coolant on (mist)
  • M08 – Coolant on (flood)
  • M09 – Coolant off
  • M10 – Pallet clamp on
  • M11 – Pallet clamp off
  • M12 – Pallet unclamp
  • M13 – Spindle on (clockwise) and coolant on (flood)
  • M14 – Spindle on (counterclockwise) and coolant on (flood)
  • M15 – Spindle off and coolant off
  • M16 – Tool change and coolant off
  • M17 – Spindle on (clockwise) and coolant on (mist)
  • M18 – Spindle on (counterclockwise) and coolant on (mist)
  • M19 – Spindle orientation
  • M20 – Programmable data input
  • M21 – Programmable data output
  • M22 – Programmable data input/output
  • M23 – Programmable data input/output (cancel)
  • M24 – Programmable data input/output (reset)
  • M25 – Programmable data input/output (enable)
  • M26 – Programmable data input/output (disable)
  • M27 – Programmable data input/output (clear)
  • M28 – Programmable data input/output (read)
  • M29 – Programmable data input/output (write)
  • M30 – Program end and reset
  • M31 – Program end and reset (cancel)
  • M32 – Program end and reset (enable)
  • M33 – Program end and reset (disable)
  • M34 – Program end and reset (clear)
  • M35 – Program end and reset (read)
  • M36 – Program end and reset (write)
  • M37 – Program end and reset (reset)
  • M38 – Program end and reset (enable)
  • M39 – Program end and reset (disable)
  • M40 – Program end and reset (clear)
  • M41 – Program end and reset (read)
  • M42 – Program end and reset (write)
  • M43 – Program end and reset (reset)
  • M44 – Program end and reset (enable)
  • M45 – Program end and reset (disable)
  • M46 – Program end and reset (clear)
  • M47 – Program end and reset (read)
  • M48 – Program end and reset (write)
  • M49 – Program end and reset (reset)
  • M50 – Program end and reset (enable)
  • M51 – Program end and reset (disable)
  • M52 – Program end and reset (clear)
  • M53 – Program end and reset (read)
  • M54 – Program end and reset (write)
  • M55 – Program end and reset (reset)
  • M56 – Program end and reset (enable)
  • M57 – Program end and reset (disable)
  • M58 – Program end and reset (clear)
  • M59 – Program end and reset (read)
  • M60 – Program end and reset (write)
  • M61 – Program end and reset (reset)
  • M62 – Program end and reset (enable)
  • M63 – Program end and reset (disable)
  • M64 – Program end and reset (clear)
  • M65 – Program end and reset (read)
  • M66 – Program end and reset (write)
  • M67 – Program end and reset (reset)
  • M68 – Program end and reset (enable)
  • M69 – Program end and reset (disable)
  • M70 – Program end and reset (clear)
  • M71 – Program end and reset (read)
  • M72 – Program end and reset (write)
  • M73 – Program end and reset (reset)
  • M74 – Program end and reset (enable)
  • M75 – Program end and reset (disable)
  • M76 – Program end and reset (clear)
  • M77 – Program end and reset (read)
  • M78 – Program end and reset (write)
  • M79 – Program end and reset (reset)
  • M80 – Program end and reset (enable)
  • M81 – Program end and reset (disable)
  • M82 – Program end and reset (clear)
  • M83 – Program end and reset (read)
  • M84 – Program end and reset (write)
  • M85 – Program end and reset (reset)
  • M86 – Program end and reset (enable)
  • M87 – Program end and reset (disable)
  • M88 – Program end and reset (clear)
  • M89 – Program end and reset (read)
  • M90 – Program end and reset (write)
  • M91 – Program end and reset (reset)
  • M92 – Program end and reset (enable)
  • M93 – Program end and reset (disable)
  • M94 – Program end and reset (clear)
  • M95 – Program end and reset (read)
  • M96 – Program end and reset (write)
  • M97 – Program end and reset (reset)
  • M98 – Program end and reset (enable)
  • M99 – Program end and reset (disable)

How to Use G and M Codes

G and M codes are used to control the movement of the cutting tool and the machine itself. To use G and M codes, you must first enter the code into the CNC machine’s control panel. Once the code is entered, the machine will execute the code and move the cutting tool accordingly.

Conclusion

G and M codes are the instructions that tell the CNC milling machine what to do. G codes are used to control the movement of the cutting tool, while M codes are used to control the machine itself. To use G and M codes, you must first enter the code into the CNC machine’s control panel. Once the code is entered, the machine will execute the code and move the cutting tool accordingly.

FAQs

What are G and M codes?

G and M codes are the instructions that tell the CNC milling machine what to do. G codes are used to control the movement of the cutting tool, while M codes are used to control the machine itself.

What are the most common G codes?

The most common G codes are G00 (Rapid positioning), G01 (Linear interpolation), G02 (Circular interpolation (clockwise)), G03 (Circular interpolation (counterclockwise)), G04 (Dwell), G05 (High speed machining), G06 (Tool change), G07 (Tool radius compensation), G08 (Tool length compensation), G09 (Exact stop), G10 (Programmable data input), G11 (Programmable data output), G12 (Tool radius compensation (negative)), G13 (Tool length compensation (negative)), G14 (Tool radius compensation (positive)), G15 (Tool length compensation (positive)), G16 (Tool radius compensation (zero)), G17 (Tool length compensation (zero)), G18 (Tool radius compensation (negative)), G19 (Tool length compensation (negative)), G20 (Inch mode), G21 (Metric mode), G22 (Tool radius compensation (positive)), G23 (Tool length compensation (positive)), G24 (Tool radius compensation (zero)), G25 (Tool length compensation (zero)), G26 (Tool radius compensation (negative)), G27 (Tool length compensation (negative)), G28 (Return to reference point), G29 (Return from reference point), G30 (Return to second reference point), G31 (Return from second reference point), G32 (Threading cycle), G33 (Threading cycle (constant pitch)), G34 (Threading cycle (variable pitch)), G35 (Threading cycle (constant lead)), G36 (Threading cycle (variable lead)), G37 (Threading cycle (constant pitch and lead)), G38 (Threading cycle (variable pitch and lead)), G39 (Threading cycle (constant pitch and lead)), G

Scroll to Top