M01 CNC Code Explained: An Easy Intro for Beginners [Optional Stop]

What does the M01 code do?

The M01 code is called an optional stop. 

It stops the current program in the middle of running but only if the optional stop switch or button is on.

If the optional stop switch is not on, then the machine will ignore any M01 codes it reads and continue running the program like normal.

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

When the machine reads an M01 code and the optional stop switch/button is on, it will turn off the following functions:

  • Movement of all axes
  • Spindle rotation
  • Coolant flow
  • The machine pauses reading the program

When the M01 code is used, nothing is reset. In other words, any active modes or parameters will stay as they are. 

The program is merely paused when it reads the M01 code.

The machine will resume reading the program when the cycle start button is pressed after the program stop has occurred.

Note that the machine doesn’t turn on functions when cycle start is pushed. 

If the M01 code turns something off such as the spindle or coolant, it will need to be turned back on in the program.

Learn CNC Programming – It’s Easier Than You Think!

Learning G Code doesn’t have to be difficult…

If you know what to focus on.

Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.

Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!

Make Learning G Code Easy

When should you use an optional stop with M01?

Optional stops are used for many reasons such as:

  • Manual tool changes
  • Checking the dimensions of the part
  • Checking the condition of the cutting tool
  • Clearing chips
  • Adjusting coolant lines
  • Adding tapping oil to a tap
cnc machine table with coolant lines and spindle shown
So many coolant lines to move

Program stops can be used for almost anything. 

Ideally the CNC programmer will list why the M01 code was used in the program and/or on the setup sheet.

How to resume program operation after using an M01 code

The M01 command stops the machine in the middle of reading the program.

However, it does not restart or reset the program. 

The CNC machine will keep all the conditions that were set before the stop occurred such as feed rate, spindle speed, unit mode, positioning mode, etc.

When the programmer wants to resume the program, he or she will have to make sure that they turn the spindle and coolant on again if needed in the program.

The CNC operator will resume the program by pressing the cycle start button.

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

What are the benefits of using the M01 code?

Using the M01 code to put an optional stop in your CNC program allows you to check on the status of your machine or part. It also allows the operator to safely perform any needed manual actions.

Making the stop optional allows the machine to keep running if the stop isn’t needed for every run.

For instance, if you need to check the size of every 5th part then you could simply turn the optional stop switch on for one out of every five runs.

The other four runs can have the optional stop switch set to off and the machine will ignore the optional stop

What to watch out for when using an M01 code

Check the program comments and setup sheet to understand why the program stop has been used.

Most CNC machines are intended to run as much as possible because many businesses will look at it as “making chips means making money”. Because of this, it is usually safe to say that if the machine has been stopped on purpose, it is usually for an important reason.

If you aren’t sure why the M01 code is being used, find someone who does.

M00 [program stop] vs M01 [optional stop]

The M00 code and M01 code are very similar CNC codes.

They both stop the machine in the same way:

  • Machine functions off
  • Program is paused

Both codes required the cycle start button to be pushed after the stop occurs to make the CNC machine resume reading the program.

The difference between them is that the CNC will ignore the M01 code unless the optional stop button or switch is on. 

If the switch is off, the machine will ignore any M01 codes it reads and continue running the program like normal.

M01 [optional stop] vs M30 [program end]

The M01 and M30 codes both stop the machine, but the M01 stop is just a pause in the program. 

The M30 code ends the program.

Pressing cycle start after an M30 code will start the entire program over again.

Pressing cycle start after an M01 code will continue reading the program from the next line after the M01 code was used.

The M30 code is also not affected by whether the optional stop switch is on or off. The M30 code will end the program no matter what.

Want to learn more about CNC G Code?

Leave a Comment