G-code and M-code are the essential languages that drive modern automated manufacturing, from 3D printing to CNC machining. While G-code controls movement and positioning, M-code manages auxiliary functions like tool changes and coolant application, together allowing for precise control over machine operations. Let's go over the basics of G-code and M-code, showing you how to prepare these crucial instruction files for your own manufacturing projects.

GE Universal Remote Codes, RCA universal remote codes
What are M-Codes
M-codes are an essential component of the programming language used by AutoCAD and Computer-Aided Manufacturing (CAM) systems to instruct CNC machines. These codes work in conjunction with G-codes to control the machine's operations and position the workpiece accurately. While G-codes handle movement instructions, such as linear or arc motions, M-codes - short for miscellaneous or machine codes - manage the broader operational aspects of the equipment.
M-codes dictate when the machine should start or stop various functions. They complement G-codes by providing instructions for actions that occur once the tool is in position. These can include tool changes, coolant application, spindle control, and other auxiliary functions. For instance, M-codes are responsible for commands like turning a tool on or off, which are critical for the proper execution of machining tasks.
In essence, M-codes fill the gaps left by G-codes, ensuring that the CNC machine performs all necessary operations beyond mere positioning and movement.
What are G-Codes
G-code is a programming language used to control automated machine tools in manufacturing. It instructs machines on various operations, from movement to temperature control. Used in 3D printing and CNC machining, G-code translates digital designs into physical objects. To use G-code effectively, you need to understand its basics and learn how to prepare G-code files for your specific equipment. This guide will introduce you to G-code files and their preparation for use in 3D printers or CNC machines.
G-Codes and M-Codes for MASSO
I've compiled a list of frequently used codes that many machine operators rely on. It's important to note that machine configurations can differ significantly between manufacturers. In particular, M-Codes beyond M79 are likely to vary depending on the specific builder. For this reason, it's crucial to consult your machine tool manufacturer to ensure you have the correct information for your particular equipment. The list provided here should be considered a general reference and may not exactly match your machine's programming.
Common G-Codes
g00 - rapid positioning
g01 - linear interpolation motion
g02 - circular interpolation (clockwise)
g03 - circular interpolation (counter clockwise)
g04 - dwell
g10 - set work offset values
g17 - xy plane selection
g18 - zx plane selection
g19 - yz plane selection
g20 - set machine units to inches
g21 - set machine units to millimetres
g28 - return to machine home
g30 - move to parking position
g32 - threading cycle
g38.2 - straight probe cycle
g38.6 - digitizing probing cycle
g53 - move in absolute machine coordinates
g54 to g59 - select work offset coordinate system
g73 - high speed peck drilling
g80 - cancel modal motion
g81 - drilling cycle
g82 - drilling canned cycle with dwell
g83 - peck drilling for deeper holes
g90 - set distance mode to absolute
g91 - set distance mode to incremental
g92 - temporary work offset
g92.1 - cancel temporary work offset
g94 - units per minute mode
g95 - feed per revolution
g96 - turn on constant surface speed (css)
g97 - turn off constant surface speed (css)
g98 - canned cycle - retract back to the initial z
g99 - canned cycle - retract back to r plane
msg - print message to screen
f - feed rate
n - number
s - speed / intensity
( ) - comments
invalid gcode
Common M-Codes
m00 - program stop
m01 - optional program stop
m02 - program end
m03 - spindle on (clockwise)
m03 - plasma torch on
m04 - spindle on (counterclockwise)
m05 - spindle off
m06 - tool change
m07 - turn mist coolant on
m08 - turn flood coolant on
m09 - to turn all coolant off
m10 - chuck or rotary table clamp closed
m11 - chuck or rotary table clamp open
m30 - end the program and rewind
m98 & m99 - sub program call
G-Codes and M-Codes - Sherline CNC machines with the Linux System
You can also find a complete list of G-codes on your Sherline Linux computer at Applications>CNC>G-code Quick Reference.
Common G-Codes
g00 rapid positioning
g01 positioning at a given feed rate
g02 circular/helical interpolation (clockwise)
g03 circular/helical interpolation (counterclockwise)
g07 Lathe diameter mode
g08 Lathe radius mode
g04 dwell
g17 xy plane selection
g18 xz plane selection
g19 yz plane selection
g20 inch system selection
g21 millimeter system selection
g40 cancel cutter diameter compensation
g41 start cutter diameter comp. left
g42 start cutter diameter comp. right
g43 tool length offset (plus)
g49 cancel tool length offset
g54 use preset work coordinate system 1
g55 use preset work coordinate system 2
g56 use preset work coordinate system 3
g57 use preset work coordinate system 4
g58 use preset work coordinate system 5
g59 use preset work coordinate system 6
g80 cancel motion mode (includes canned)
g81 drilling canned cycle
g82 drilling with dwell canned cycle
g85 boring, no dwell, feed out canned cycle
g90 absolute distance mode
g91 incremental distance mode
g92 offset coordinate systems
g94 feed per minute mode
g98 initial level return in canned cycles
g99 "R" level return in canned cycles
G- and M-Codes for CNC
Common G-Codes
g00 rapid positioning
g01 positioning at a given feed rate
g02 circular/helical interpolation (clockwise)
g03 circular/helical interpolation (counterclockwise)
g07 Lathe diameter mode
g08 Lathe radius mode
g04 dwell
g10 coordinate system origin setting
g17 xy plane selection
g18 xz plane selection
g19 yz plane selection
g20 inch system selection
g21 millimeter system selection
g40 cancel cutter diameter compensation
g41 start cutter diameter comp. left
g42 start cutter diameter comp. right
g43 tool length offset (plus)
g49 cancel tool length offset
g53 motion in machine coordinate system
g54 use preset work coordinate system 1
g55 use preset work coordinate system 2
g56 use preset work coordinate system 3
g57 use preset work coordinate system 4
g58 use preset work coordinate system 5
g59 use preset work coordinate system 6
g59.1 use preset work coordinate system 7
g59.2 use preset work coordinate system 8
g59.3 use preset work coordinate system 9
g80 cancel motion mode (includes canned)
g81 drilling canned cycle
g82 drilling with dwell canned cycle
g83 chip-breaking drilling canned cycle
g84 right hand tapping canned cycle
g85 boring, no dwell, feed out canned cycle
g86 boring, spindle stop, rapid out canned
g87 back boring canned cycle
g88 boring, spindle stop, manual out canned
g89 boring, dwell, feed out canned cycle
g90 absolute distance mode
g91 incremental distance mode
g92 offset coordinate systems
g92.2 cancel offset coordinate systems
g93 inverse time feed mode
g94 feed per minute mode
g98 initial level return in canned cycles
g99 "R" level return in canned cycles
Complete list of G- and M-Codes
Common G-Codes
G00 Rapid move G0 X# Y# Z# up to eight axes or G0 Z# X#
G01 Feed Rate move G1 X# Y# Z# up to eight axes or G1 Z# X#
G02 Clockwise move
G03 Counter Clockwise move
G04 Dwell time G04 L#
G08 Spline Smoothing On
G09 Exact stop check, Spline Smoothing Off
G10 A linear feed rate controlled move with a decelerated stop
G11 Controlled Decel stop
G17 XY PLANE
G18 XZ PLANE
G19 YZ PLANE
G28 Return to clearance plane
G33 Threading (Lathe)*
*NOTE: G33 and G33.1 will not work on Sherline CNC mills or lathes because the spindle and the axis are not synchronized.
G35 Bypass error checking on next line
G40 Tool compensation off
G41 Tool compensation to the left
G42 Tool compensation to the right
G43 Tool length compensation - negative direction
G44 Tool length compensation - positive direction
G49 Tool length compensation canceled
G53 Cancel work coordinate offsets
G54-G59 Work coordinate offsets 1 through 6
G61 Spline contouring with buffering mode off
G64 Spline contouring with buffering mode on
G65 Mill out rectangular pocket
G66 Mill out circular pocket
G67 Flycut
G68 Mill out rectangular pocket with radius corners
G70 Inch mode
G71 Millimeter mode
G74 Peck drilling (Lathe) G83 Z# X# R#
G81 Drill cycle G81 X# Y# Z# R#
G82 Dwell cycle G82 X# Y# Z# R#
G83 Peck cycle G83 X# Y# Z# R#
G84 Tapping cycle G84 X# Y# Z# R# C#
G85 Boring cycle 1 G85 X# Y# Z# R#
G86 Boring cycle 2 G86 X# Y# Z# R#
G88 Boring cycle 3 G88 X# Y# Z# R#
G89 Boring cycle 4 G89 X# Y# Z# R#
G90 Absolute mode
G91 Incremental mode
G92 Home coordinate reset G92 X# Y# Z#
G94 IPM mode (Lathe) default
G95 IPR mode (Lathe)
G96 Constant Surface Feed On (Lathe)
G97 Constant Surface Feed Off (Lathe)
Common M-Codes
Default M-codes are used on most machine types. User-customizable M codes will change based on application and user definition.
M00 Program Stop
M01 Program Optional Stop
M02 End the Program
M03 Spindle On Clockwise, Laser, Flame, Power ON
M04 Spindle On Counter Clockwise
M05 Spindle Stop, Laser, Flame, Power OFF
M06 Tool Change
M08 Coolant On
M09 Coolant Off
M10 Reserved for tool height offset
M13 Spindle On, Coolant On
M30 End the Program when macros are used
M91 Readout Display Incremental
M92 Readout Display Absolute
M97 Go to or jump to line number
M98 Jump to macro or subroutine
M99 Return from macro or subroutine
M100 Machine Zero Reset
M199 Mid program start









Comments
No Comments