M01 G-Code Command
M01 is an optional stop code used in CNC machining. When the machine reads an M01 code and the optional stop switch is on, it will stop the current program in the middle of running. However, 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.
This command behaves exactly the same as M00 when activated.
A common use example would be before a tool change. If you wanted to stop the machine at the end of the current process the optional stop button on the machine can be activated and the machine will stop at the M01 command line before the next tool change.
How M01 G-Code Command Is Used
Here’s an example of how M01 can be used in a G-code program with comments and a spindle on command for 2000 RPM:
T1 M06 (Call up Tool 1) G00 X0 Y0 Z20 (Move to starting position) M03 S2000 (Turn on spindle at 2000 RPM) G43 H1 Z.5 (Set tool length and move to feed position) G01 X10 Y10 Z-5 (Move to cutting position) G02 X15 Y5 R5 (Cut a circle with radius of 5) G00 Z20 (move tool up) M05 (Turn off spindle) G91 G28 X0 Y0 Z0 (Return to starting position) M01 (Optional stop code)
In this example, the program starts by moving to the starting position (X0, Y0, Z20) and turning on the spindle at 2000 RPM with the M03 command. It then moves to the cutting position (X10, Y10, Z-5) and cuts a circle with a radius of 5 using the G02 command. The program then returns to the starting position and turns off the spindle with the M05 command. After the cutting is complete, the M01 code is used as an optional stop code, which means that if the optional stop switch is on, the machine will stop at this point.