G-code is the common name for the most widely used CNC programming language. It was developed in the 1950s at MIT. The language is very “primitive” in today’s standards. All the commands are represented by codes (G01, G02, etc..) and not by meaningful words. Variables are represented by numbers(#500, #151, etc..) and not by words and conditional logic is very limited. Amazingly this 70-year-old language is still the industry standard. Several tool manufacturers developed higher-end Wizard-like languages such as Mazak – Mazatrol or Okuma – AOT, but none of them gained very high popularity.
The target of the code is to control the movements of a computerized controlled machine. The code basically “tells” the machine in what path to move from one coordinate to the next (Called “Toolpath”), and at what speed (Called “Feedrate”).
Feedrate - At what speed to move to the next coordinate.
3
S
Spindle Speed - At speed the spindle should be rotating.
4
I,J,K
Arc center for G02/G03
5
O
Program Number
6
N
Line (Block) Number
7
M
Miscellaneous function - See separate List
8
T
Select a tool from Magazine / Turret
9
P
Parameter Number
M Codes
“G” stands for Geometry and hence the G-Code commands are responsible for the movements of the machine that create the geometry of the part. “M” stands for Machine (or Miscellaneous) and the M-Codes are responsible for Machine commands that cause particular operations of the equipment. Unlike G-codes, which can appear multiple times on the same line, M-Code is limited to one code per line.
List of M-codes
* Press ⊕ to read the full explanation
wdt_ID
CODE
ACTION
EXPLNATION
1
M00
Machine Stop
The Machine will stop the operation in the middle of the program
2
M01
Optional stop
The machine will stop in the middle of the program only if the optional stop button is "On".
3
M02
program End
End of Program
4
M03
Spindle on CW direction
The spindle will start to rotate in CW direction at the speed given in the S parameter
5
M04
Spindle on CCW direction
The spindle will start to rotate in CCW direction at the speed given in the S parameter
6
M05
Spindle stop
The spindle will stop rotating
7
M06
Automatic
tool change (ATC)
The machine will change the tool and pick from the Turret/Magazine a new tool according to the "T" parameter
8
M07
Mist (Shower) Coolant On
A spray of coolant fluid droplets
9
M08
Flood Coolant On
An overflowing of coolant fluid.
10
M09
Coolant off
Shut down the coolant (Both M07 & M08)
11
M30
End of Program
The spindle will start to rotate in CW direction at the speed given in the S parameter
12
M41 - M44
Gear
selection
Select the gear suitable for the spindle speed (ON lathe Machines)
13
M48
Feedrate
override On
Operator feedrate overide is respected
14
M49
Feedrate override Off
Operator feedreate override is ignored.
15
M98
Subprogram
call
Passes control to the subprogram number provided in parameter P
16
M99
Subprogram end
Placed at end of the subprogram and returns the control to the main program one line after the line it was called from.