logo
logo
Sign in

16 USEFUL G-CODE AND M-CODE COMMANDS YOU MIGHT NOT HAVE KNOWN ABOUT

avatar
MarkonAdam
16 USEFUL G-CODE AND M-CODE COMMANDS YOU MIGHT NOT HAVE KNOWN ABOUT


G-code and M-code are the two basic command systems used in programming and controlling CNC machine tools. G-code defines tool movement and positioning, while M-code controls additional functions and machine settings.

In this article, we will look at 16 useful G-code and M-code commands that you may not be aware of, but can greatly improve your efficiency on CNC metal milling and turning machines, fiber optic and CO2 laser machines, CNC wood CNC milling machines, and much more CNC equipment.


  1. G0: Rapid traverse: The G0 command is used to perform rapid traverse of the tool to specified coordinates without milling or cutting the material. This is useful for moving the tool between different points on the machine without delay.
  2. G2/G3: Circular Milling: G2 and G3 are used to perform circular milling in one plane. G2 performs clockwise milling and G3 performs counterclockwise milling. The commands require the center of the circle and radius to be specified.
  3. G17/G18/G19: Coordinate Plane Selection: G17, G18, and G19 are used to select a coordinate plane in 3D space. G17 specifies the XY (table plane), G18 specifies the XZ (vertical milling plane), and G19 specifies the YZ (horizontal milling plane).
  4. G28: Return to origin: The G28 command moves the tool back to the origin that is defined in the machine setup. This is useful for quickly returning the tool to the starting position.
  5. G40/G41/G42: Cancel radius compensation: G40, G41 and G42 are used to cancel the tool radius compensation. G40 cancels compensation, G41 performs compensation on the left side of the tool, and G42 performs compensation on the right side of the tool.
  6. G80: Cancel Modal Commands: G80 cancels all modal commands, preventing commands from being executed again without an explicit instruction.
  7. G90/G91: Coordinate System Selection: G90 sets the absolute coordinate system, where values are specified relative to the origin. G91 is used to select a relative coordinate system where values are specified relative to the current tool position.
  8. G94/G95: Feed rate selection: G94 sets the tool feed rate in units of time length (e.g., mm/min or inch/min). G95 sets the feed rate in units of time per spindle revolution (e.g., mm/rev or inch/rev).
  9. G96: Constant surface finish speed. The spindle speed is varied to maintain the same surface finish speed of the material.
  10. M0/M1: Program Stop: M0 and M1 are used to temporarily stop the program. M0 requires operator confirmation before resuming the program, and M1 does not require confirmation.
  11. M3/M4/M5: Spindle On/Off: M3 is used to turn the spindle on and rotate clockwise, M4 is used to turn the spindle on and rotate counterclockwise, and M5 is used to stop the spindle.
  12. M6: Tool Change: The M6 command is used to automatically change tools during operation. This allows the program to use different tools without the need for operator intervention.
  13. M8/M9: Cooling on/off: M8 is used to turn the cooling system on and M9 to turn it off. This is useful when milling or cutting materials that require cooling.
  14. M30: Program End: M30 indicates the end of the program and returns the tool to its original position. This is useful for automatically ending the program and preparing the machine for the next job.
  15. M48/M49: Enable/disable speed and feed correction control: M48 and M49 are used to turn spindle speed and feed rate correction control on and off.
  16. M98/M99: Subroutine Call: M98 is used to call a subroutine that is contained in a separate file. M99 reverts program execution back after calling the subroutine.


CONCLUSIONS:

The G-code and M-code commands provide powerful tools for programming and controlling CNC machines. Knowing these 16 useful commands can greatly improve the efficiency and flexibility of your material handling process. Feel free to experiment and explore other G-code and M-code commands to better utilize the potential of your equipment.

collect
0
avatar
MarkonAdam
guide
Zupyak is the world’s largest content marketing community, with over 400 000 members and 3 million articles. Explore and get your content discovered.
Read more