M05 CNC Code: Spindle Off Command Explained

The M05 code stops the spindle. That’s it. One code, one job.

When the CNC controller reads M05, it cuts power to the spindle motor and the spindle coasts to a stop. Any active spindle rotation — whether started with M03 or M04 — is cancelled.

Key Takeaways

  • M05 stops the CNC spindle
  • It cancels both M03 (clockwise) and M04 (counterclockwise) rotation
  • M5 and M05 are the same — the leading zero is optional
  • Several other codes also stop the spindle, but M05 is the dedicated command
  • Always stop the spindle before changing tools on machines that don’t handle this automatically
M05 – At A Glance
FunctionStop spindle rotation
TypeNon-modal
CancelsM03, M04

What Does M05 Do?

M05 cancels any active spindle rotation. It works whether the spindle was turned on with M03 (clockwise) or M04 (counterclockwise).

Spindle direction

You’ll see M05 used most often in two places: between operations that require the spindle to be stopped, and at the end of a program alongside M30.

Here’s a simple example showing M05 in context:

T01 M06               (Tool change — tool 1)
G54 G90 G00 X0. Y0.   (Move to start position)
S1200 M03             (Spindle on, 1200 RPM, clockwise)
G01 Z-0.5 F10.        (Feed down to depth)
G00 Z1.0              (Retract)
M05                   (Spindle off)
M00                   (Program stop — operator inspects part)
S1200 M03             (Restart spindle for next operation)

In that example, M05 stops the spindle before the program pause so the operator isn’t working near a spinning tool.

Try It: Spindle Control Simulator

The best way to understand M05 is to see it in action. Use the simulator below to toggle the spindle on and off using the same M-codes you’d program into a real CNC machine.

Click M03 or M04 to start the spindle, then hit M05 to stop it. Drag the speed slider to change the RPM and watch how the spindle behaves at different speeds.

Try It CNC Spindle Control Simulator
Status OFF
Dir.
1200 RPM
Program Output
— click a button above —

Notice that M03 and M04 both require M05 to stop — the spindle won’t stop on its own just because your tool is done cutting. That’s why M05 shows up in almost every CNC program.

M5 vs M05 — Is There a Difference?

No. They’re the same command. The CNC controller reads both identically.

The leading zero is just formatting. You’ll see M05 in textbooks and reference materials because it looks consistent alongside other two-digit M-codes. On the shop floor, plenty of programmers write M5 because it’s one less character.

If you’re programming on your own, use whichever style you prefer. If you’re working in an established shop, match the style already used in existing programs.

Do You Need M05 Before a Tool Change?

It depends on the machine and the postprocessor.

Most modern CNC machining centers automatically stop the spindle when they see a tool change command (M06). If that’s your machine, you don’t need to manually program M05 before M06 — the control handles it.

On older machines or certain lathes, the spindle doesn’t stop automatically. If you’re not sure about your machine, check the manufacturer’s documentation or look at how existing programs are written.

COMMON MISTAKE – Assuming the spindle will stop automatically before a tool change

On some machines it does — on others it doesn’t. If your machine doesn’t auto-stop and you skip M05 before M06, you risk a tool change with a spinning spindle.

Always verify what your specific machine does.

What other codes stop the spindle?

M05 is the dedicated spindle-off command, but several other codes also stop the spindle as part of a larger action.

M00 — Program Stop Stops the spindle, coolant, and all axis motion. The program pauses until the operator presses Cycle Start again. Use it when you need to inspect the part mid-program.

M01 — Optional Stop Does the same thing as M00, but only if the Optional Stop switch on the machine is turned on. If the switch is off, the machine skips M01 entirely. Useful for production runs where you want to skip checks after a part is dialed in.

M02 — Program End (Legacy) A legacy code from the days of paper tape. It ends the program. On most modern machines, M02 is treated the same as M30. You won’t see it much in new programs.

M30 — Program End with Rewind The standard program-end code. Stops the spindle, stops coolant, ends the program, and resets the cursor back to the top of the program. Use M30 to end every program.

The key difference between M05 and these codes: M05 only stops the spindle. The other codes stop everything. If you just need the spindle off — and you want the program to keep running — M05 is the right choice.

FAQS

Does M05 stop the coolant too?

No. M05 only stops the spindle. To stop coolant, you need M09. Most programs use both M05 and M09 together at the end of an operation.

Can I use M05 in the middle of a program?

Yes. M05 can appear anywhere in a program. You’d use it any time you need the spindle to stop without pausing or ending the program — like before an inspection step or between spindle-direction changes.

Does M05 brake the spindle or let it coast?

It depends on the machine. Some controllers apply an orientation or brake after M05; others let the spindle coast to a stop naturally. High-speed machining centers often have active braking. Check your machine’s documentation if timing matters.

What’s the difference between M05 and M00?

M05 stops only the spindle. M00 stops the spindle, the coolant, all axis motion, and pauses the program until the operator restarts it. Use M05 when you want the spindle off but the program to continue. Use M00 when you need to pause everything.

Leave a Comment