What is the difference between a G code and an M code?
G codes (preparatory) define the geometry and tool movement, such as linear interpolations or roughing cycles. M codes (miscellaneous or auxiliary) control the machine hardware, such as starting the spindle (M03), the coolant (M08) or the end of program (M30).
Are G-codes universal for all lathes and milling machines?
Not entirely. Although basic moves such as G00, G01, G02 and G03 are universal, complex canned cycles like G71 for roughing or G83 for peck drilling have different syntax and parameters depending on whether you use Fanuc, Haas, Siemens or Heidenhain.
What is the G01 code and when is it used?
G01 is the linear interpolation code. It tells the tool to move in a straight line to a given coordinate at a controlled cutting feed programmed with the letter F.
What is the difference between codes G90 and G91?
G90 sets absolute positioning, where every coordinate is measured from the part zero (origin). G91 activates incremental positioning, where each new move is calculated from the tool's current position.
What are G41 and G42 codes used for in machining?
These codes activate tool or insert radius compensation. G41 offsets the path to the left of the programmed contour relative to the feed direction, G42 to the right. They are used to machine profiles, chamfers and radii to exact size without gouging.
How are fixed cycles and compensations cancelled?
To avoid crashes you must cancel modal functions once they are no longer needed. G80 cancels any active canned cycle, such as drilling cycles. G40 cancels tool radius compensation, and G49 cancels length compensation, widely used on milling machines.
What are the essential auxiliary M codes?
The most standardised hardware codes are M03 (spindle clockwise), M04 (spindle counter-clockwise), M05 (spindle stop), M08 (coolant on), M09 (coolant off) and M30 (end of program, axes stop and rewind).
Do Fanuc canned cycles work the same on other controls?
No. Although interpolation moves (G00 to G03) are a widely adopted ISO standard, the syntax of complex cycles differs. For example, the lathe roughing cycle is G71 on Fanuc, but Siemens requires a different parameter structure such as CYCLE95.
What does the letter F, S and T mean in the CNC code?
Alongside the G and M codes, the letter F (feed) sets the cutting feed, the letter S (speed) sets the spindle rpm or cutting speed, and the letter T (tool) calls the tool number and its offset in the turret or magazine.