G code is used for the machine tool what type of action to perform, such as
- Rapid movement
- Controlled feed in a straight line or arc
- Set tool information such as offset
- Dwell
- Plain Selection
M code is used for machine function, such as
- Spindle ON/OFF
- Coolant ON/OFF
- Open workstation door
- Tool changing
- Other machine-related terms
G code is used for the Preparatory function whereas the M code is used for the Miscellaneous function.