M01 G-Code: How the CNC Optional Stop Works

You’re running a CNC program and the machine suddenly stops. The spindle winds down, the coolant shuts off, and everything goes quiet. Was it a crash? An alarm?

Nope — it’s an M01. An optional stop. And it did exactly what it was supposed to do.

M01 is a code that pauses your program mid-run so the operator can step in, check something, and then send the machine back to work. The key word is optional — a switch on the control panel controls whether M01 actually stops the machine or gets ignored completely.

This guide explains how M01 works, when to use it, and how it compares to similar codes like M00 and M30.

Key Takeaways

  • M01 is the optional stop code — it pauses the program only when the optional stop switch is turned on
  • When triggered, it stops all axis movement, the spindle, and coolant flow
  • Nothing is reset — active modes like feed rate and spindle speed stay in memory
  • Press Cycle Start to resume the program from the next line
  • If the optional stop switch is off, the machine ignores every M01 in the program
M01 – At A Glance
FunctionOptional Stop
StopsSpindle, coolant, axis movement
TypeNon-modal
Resets anything?No
Resume withCycle Start button
Controlled byOptional Stop switch/button on the control panel

What does M01 do?

M01 is called the optional stop. It pauses your CNC program mid-cycle — but only if the optional stop switch on the control panel is turned on.

haas cnc control panel with optional stop button highlighted
Haas optional stop button

When the machine reads an M01 and the switch is on, it stops axis movement, turns off the spindle, and shuts off coolant. The program pauses and waits for the operator to press Cycle Start before it continues.

If the optional stop switch is off, the machine skips right past every M01 it reads. The program keeps running like normal.

What does M01 actually stop?

When M01 triggers, these functions are turned off:

  • All axis movement
  • Spindle rotation
  • Coolant flow

One important thing to know: M01 does not restart these functions when you press Cycle Start. It only pauses the program. If the spindle or coolant was turned off by the M01, the programmer needs to turn them back on in the lines that follow the M01. Otherwise, the machine resumes movement with the spindle off.

When should you use M01?

Optional stops give the operator a chance to step in without stopping production entirely. Common reasons to use M01 include:

  • Checking part dimensions mid-program
  • Inspecting the cutting tool for wear or damage
  • Doing a manual tool change
  • Clearing chips from the part or fixture
  • Adjusting coolant lines
  • Adding tapping fluid before a threading operation
cnc machine table with coolant lines and spindle shown
So many coolant lines to move

The key benefit is flexibility. If the optional stop isn’t needed for a given run, the operator simply leaves the switch off and the machine ignores it. If a quality check is required — say, measuring every fifth part — the switch gets turned on for that one cycle.

How to resume after M01

When the program pauses on an M01, the machine holds its position and waits. All previously active settings — feed rate, spindle speed, unit mode, work offset — stay exactly as they were.

To continue, press the Cycle Start button. The program picks up at the very next line after the M01 code.

fanuc cnc control panel with cycle start button highlighted
Fanuc cycle start button

The programmer is responsible for making sure the spindle and coolant are turned back on in the program after an M01, if they’re needed. The machine won’t turn them on automatically on resume.

COMMON MISTAKE – Leaving the Optional Stop Switch On in Production

Forgetting to turn off the optional stop switch after setup is one of the most common ways to accidentally halt a production run.

If the switch is left on, the machine will stop every time it hits an M01 — even if the operator isn’t expecting it. Always confirm the switch is off before running lights-out or unattended.

M01 vs M00: What’s the difference?

M00 is the mandatory program stop. M01 is the optional program stop. They behave the same way when they trigger — both stop movement, spindle, and coolant, and both resume with Cycle Start.

The difference is one simple thing: M00 always stops the machine. M01 only stops the machine if the optional stop switch is on.

Try it for yourself below.

Interactive — Program Stop Visualizer

Press Cycle Start to run the program. It runs automatically and stops when it hits a stop command.

Speed:
— M01 will be skipped
Machine State
Spindle
Coolant
Feed
ProgramIDLE
Press Cycle Start to run the program.
Executing
Completed
Stop command
Skipped (M01 off)

Use M00 when a stop is required every single time — such as a mandatory tool change or a critical inspection point. Use M01 when the stop is situational and you want the flexibility to bypass it during normal production.

M01 vs M30: What’s the difference?

M30 ends the program and resets back to the beginning. M01 just pauses it.

After an M01, pressing Cycle Start continues from the next line in the program. After an M30, pressing Cycle Start starts the entire program over from the top.

M30 is also not affected by the optional stop switch. It ends the program every time, no matter what.

FAQS

Does M01 reset the work offset or tool compensation?

No. M01 only pauses the program. Active work offsets, tool length compensation, cutter radius compensation, and modal G-codes all stay in effect. Nothing is reset until the program ends or those codes are cancelled explicitly.

Does M01 automatically turn the spindle back on when I press Cycle Start?

No. M01 turns off the spindle, coolant, and axis movement — but it does not turn them back on when you resume. The programmer must include M03 (spindle on) and M08 (coolant on) after the M01 in the program if they’re needed to continue.

Can I use more than one M01 in a single program?

Yes. You can place M01 as many times as needed throughout a program. Each one is a separate optional pause point. All of them will trigger if the optional stop switch is on, and all of them will be skipped if it’s off.

What’s the difference between M00 and M01?

Both stop the machine the same way. The difference is that M00 is a mandatory stop — it always halts the program. M01 is conditional — it only stops the program when the optional stop switch on the control panel is turned on.

Leave a Comment