M05 G-Code Command

  • 2 mins read

M05 G-Code Command

M05 is a CNC G-code command that turns off a rotating spindle. It cancels any spindle rotation that has been set with either the M03 code (clockwise spindle rotation) or M04 code (counterclockwise spindle rotation) and is commonly used prior to a tool change or other changes in the machining process.

How M05 G-Code Command Is Used

Here’s an example of M05 being used in a G-code program with comments in brackets and including a spindle on command for 2000 rpm:

G00 X0 Y0 Z50    (Rapid positioning to the starting point)
M03 S2000       (Spindle on at 2000 rpm, clockwise rotation)
G01 X10 Y10 F100 (Linear interpolation at feed rate 100 to X=10 and Y=10)
G01 X20 Y0 F100  (Linear interpolation at feed rate 100 to X=20 and Y=0)
M05             (Spindle off)
G91 G28 X0. Y0. Z0. (Home position move)
M30

In this example, the program starts by positioning the tool at the starting point, then turns on the spindle at 2000 rpm with the M03 command. The tool then moves in a straight line to X=10 and Y=10, and then to X=20 and Y=0, both at a feed rate of 100 units per minute. Finally, the M05 command turns off the spindle. The comments in the program are included in brackets for clarity and to explain the purpose of each command.