Table of Contents
G-code and M-code are programming languages used to control CNC (Computer Numerical Control) machines. They provide instructions for machine movements and operations. Understanding these codes is essential for creating precise and efficient machining processes.
Basics of G-code
G-code commands specify the movement of the machine’s axes. They include instructions for positioning, speed, and tool changes. Common G-codes include G00 for rapid positioning and G01 for linear interpolation.
Basics of M-code
M-code commands control machine functions that are not related to movement. These include starting or stopping the spindle, coolant control, and tool changes. For example, M03 starts the spindle, and M05 stops it.
Practical Examples
Consider a simple milling operation where a tool moves to a specific position, starts the spindle, performs cutting, and then stops the spindle. The sequence of G-code and M-code might look like this:
Example:
G00 X0 Y0
M03
G01 X50 Y50 F100
M05
This sequence moves the tool rapidly to the origin, starts the spindle, performs a linear move to position X50 Y50 at a feed rate of 100, and then stops the spindle.
Common G-code and M-code Commands
- G00: Rapid positioning
- G01: Linear interpolation
- M03: Spindle on (clockwise)
- M05: Spindle stop
- M06: Tool change