https://www.americanmicroinc.com/resources/difference-g-code-m-code/#what

  1. What is G Code?

    A G code in CNC programming controls the movements of a machine, dictating how and where a machine should move to fabricate a part.

    What is M Code?

    An M code in CNC programming controls miscellaneous machine functions, including starting and stopping specific actions or programs.

    These two codes work together to manufacture parts and components, making them essential in the manufacturing and industrial sectors.

  2. Different letters dictate how the machine moves and numbers set the parameters. While the system is called G code, G is not the only letter used. Other letters have different functions in the program, which tend to be the same, regardless of a machine’s dialect.

    For example, the functions of the following letters in G code include:

    • N: The N value gives the line number.
    • G: The G number tells when the tool to move and stop.
    • X, Y, Z: These values indicate the position of the tool in three dimensions — X for horizontal, Y for vertical and Z for depth.
    • F: F relates to how quickly the machine feeds the piece.
    • S: S tells the machine how quickly to move the spindle.
    • T: The T tells the machine which tool to use.
    • M: M values give miscellaneous functions or machine functions, telling the device how to act by giving on and off directions.
    • I and J: These values indicate the incremental center of any arcs the machine makes.
    • R: R gives the radius of arcs made by the machine.
    • A: A values direct the tool around the x-axis.
    • B: The number with B shows the rotational value around the y-axis.
    • C: An auxiliary axis that rotates around the z-axis gets its positional value from the C value.
    • D: This number shows how much the system offsets the tool diameter.
    • L: L gives the system a value to indicate repeating operations and how many times they need to loop.
    • P: The program jumps in time or a delayed time with the P command.

    Other alphanumeric designations depend on the machine’s capabilities.

  3. These three operations include the following:

    1. Move in a straight line as quickly as possible.
    2. Move in a straight line at a specified rate.
    3. Move in a circle at a specified speed.
    • G0: Go as fast as possible to a specified coordinate.
    • G1: Move in a straight line.
    • G2: Create an arc in a clockwise direction.
    • G3: Make a counterclockwise arc.
  4. M codes give the machine instruction on when to turn on or off operations not involved with cutting. For specific processes, for example, the machine may need to flood the system with coolant and shut it off after the temperature drops. These are two separate actions in M code.
  5. M commands have generic values that include the following:

    • M00: Stop whatever program is currently operating — axes, coolant flooding or spindle.
    • M01: This command indicates an optional stop for the program.
    • M02: End of the currently running program.
    • M03: Begin to move the spindle clockwise.
    • M04: Start moving the spindle counterclockwise or in reverse.
    • M05: Stop moving the spindle.
    • M06: Load on a different tool. Typically, this command comes with the T value. For example, you may see “T1 M06.”
    • M08: Start flooding the system with coolant.
    • M09: Stop the coolant flow.

https://carlsonmfg.com/cnc-g-code-m-code-programming/

  1. 
    G00 Rapid Transverse Motion
    G01 Motion by a feed rate
    G02 Motion in an arc clockwise
    G03 Motion in an arc counter clockwise
    G04 Dwell
    
    G17 XY Plane selection
    G18 XZ Plane selection
    G19 YZ Plane selection
    G28 Return to Machine zero for axis selected
    
    G40 Cutter compensation Cancel
    G41 2D Cutter compensation Left
    G42 2D Cutter compensation Right
    G43 Tool length compensation + (add to tool length offset)
    G44 Tool length compensation – (subtract tool length offset)
    G49 Cancels G43 G44
    G50 Sets a speed limit for Constant surface speed (lathe)
    G52 Set Work Coordinate system
    G54 Work coordinate system #1
    G55 Work coordinate system #2
    G56 Work coordinate system #3
    G57 Work coordinate system #4
    G58 Work coordinate system #5
    G59 Work coordinate system #6
    
    G65 Macro Subroutine call
    G70 Bolt Hole Circle
    G71 Holt Hole Arc
    G72 Bolt holes along an Angle
    G73 High Speed Peck Drilling
    G74 Reverse Tapping
    G80 Turns off all canned cycles
    G81 Drilling
    G82 Spot Drilling
    G83 Peck drilling
    G84 Tapping cycle
    
    G90 Calls up an absolute Co-ordinate grid system Positioning
    G91 Calls up an incremental Co-ordinate grid system Positioning
    G92 Set Work Coordinate system shift value -(grid shift)
    G94 Feed per minute mode
    G95 Feed per spindle revolution mode
    G96 turns on Constant Surface Speed (lathe)
    G97 Turns off Constant Surface Speed (lathe)
    G98 Canned cycle initial point return
    G99 Canned cycle R Plande return
    
    M00 Program stop – Tells the CNC machine to stop in the middle of a program.
    M01 Optional Program Stop – Tells the CNC machine to stop ONLY if the optional stop switch is active
    M02 Program end
    M03 Turns the Spindle on in a Clockwise direction
    M04 Turns the Spindle on in a Counter-Clockwise direction
    M05 Turns the Spindle off
    M06 Tool change
    M07 Optional coolant is not available on all machine configurations
    M08 Turns flood coolant on
    M09 Turns flood coolant off
    M10 Normally used to turn 4th Axis brake on (mill)
    M11 Normally used to turn 4th Axis brake off (mill)
    M19 Spindle Orientation
    M30 Program end and reset
    
    M31 Chip conveyor on (forward)
    M33 Chip conveyor off
    M88 Turns through the spindle coolant on
    M89 Turns through the spindle coolant off
    M97 Calls up sub program for local program
    M98 Sub Program Call
    M99 Loop or return to rerun a sub program
    
    
    

https://www.doubao.com/chat/181318342283522

  1. Lathe(车床)和 Mill(铣床)是机械加工中两种不同的机床设备,它们的主要区别如下:

    一、加工方式

    1. Lathe(车床)
      • 主要通过工件旋转作主运动,车刀作进给运动来加工回转体零件。
      • 例如加工圆柱形的轴、盘类零件等,通过车削可以得到精确的外径、内径、端面以及螺纹等特征。

    2. Mill(铣床)
      • 通常是铣刀旋转作主运动,工件作进给运动。
      • 可以加工平面、沟槽、齿轮、螺旋面等多种形状,适用于加工形状较为复杂的零件。


    二、加工对象

    1. Lathe(车床)
      • 擅长加工具有回转表面的零件,如轴类、盘类、套类零件等。
      • 能进行外圆车削、内孔车削、螺纹加工等操作,对于圆柱形状的零件加工精度高。

    2. Mill(铣床)
      • 适用于加工各种平面、曲面和不规则形状的零件。
      • 可以加工箱体、凸轮、模具等零件,对于复杂的几何形状和多面加工具有优势。


    三、刀具类型

    1. Lathe(车床)
      • 主要使用车刀,包括外圆车刀、内孔车刀、螺纹车刀等。
      • 车刀的形状和角度根据不同的加工要求进行选择,以保证加工质量和效率。

    2. Mill(铣床)
      • 有多种刀具可供选择,如立铣刀、面铣刀、球头铣刀等。
      • 不同的刀具适用于不同的加工任务,例如立铣刀用于加工沟槽和轮廓,面铣刀用于加工平面。


    四、操作特点

    1. Lathe(车床)
      • 操作相对较为简单,主要控制工件的旋转速度和车刀的进给速度。
      • 对于初学者来说,较容易上手,但要掌握高精度的加工技巧需要一定的经验。

    2. Mill(铣床)
      • 操作相对复杂,需要同时控制铣刀的旋转速度、进给速度以及工件的移动方向和速度。
      • 铣床的编程也较为复杂,需要掌握一定的数控编程知识才能充分发挥其功能。


  2. 在 CNC(计算机数字控制)中,“arc” 代表圆弧运动轨迹。

    具体来说:

    • 圆弧可以是二维平面上的,也可以是三维空间中的。在二维情况下,通常由圆心坐标、半径、起始角度和终止角度等参数来确定一个圆弧轨迹。例如在数控铣削或车削加工中,刀具可以沿着特定的圆弧轨迹进行切削,以加工出圆形轮廓、弧形凹槽等形状。
    • 在三维加工中,圆弧轨迹可能更加复杂,涉及到多个坐标轴的协同运动,以实现空间中的圆弧形状加工。

    圆弧运动轨迹在 CNC 加工中有重要的应用,可以使加工出的零件具有光滑的曲线表面,提高零件的精度和外观质量。

  3. “canned cycles” 的中文意思是 “固定循环”“ canned” 有罐装的、预调的、千篇一律的意思,在这里可以理解为预先设定好的;“cycles” 是循环、周期的意思。

    在机械加工领域,固定循环是指用一个 G 代码指令代表一系列通常使用的加工操作,例如钻孔循环、镗孔循环、攻丝循环等。它可以简化编程,提高编程效率和准确性。

    例如,对于钻孔操作,固定循环可以自动完成快速定位到孔的位置、进给下钻、暂停排屑、快速退刀等一系列动作,而不需要程序员逐一编写每个动作的指令。

  4. 在 CNC(计算机数字控制)中,“spindle” 代表主轴。

    主轴在 CNC 机床中起着关键作用:

    • 驱动刀具或工件旋转:在铣床、加工中心等设备中,主轴通常安装刀具并高速旋转,对工件进行切削加工。在车床中,主轴则带动工件旋转。
    • 影响加工精度和表面质量:主轴的精度、转速稳定性和刚性直接影响加工零件的尺寸精度、表面粗糙度等。高速、高精度的主轴可以实现更精细的加工。
    • 可进行变速控制:根据不同的加工要求,可以通过控制系统调整主轴的转速,以获得最佳的加工效果。

  5. 在 CNC 中,通常可以使用特定的 M 代码来停止主轴(spindle)转动。

    常见的用于停止主轴转动的 M 代码是 M05。

    当 CNC 程序执行到 M05 指令时,主轴会逐渐减速并停止转动。

    例如,在一个数控加工程序中,当完成一个加工操作后,可以在适当的位置插入 M05 指令来停止主轴,以便进行下一步操作,如更换刀具、测量工件等。