M05 CNC Code Explained: An Easy Intro for Beginners [Spindle Off]

What does a M05 code do?

The M05 code turns the spindle off.

M05 cancels any spindle rotation that has been set with either the M03 code (clockwise spindle rotation) or M04 code (counterclockwise spindle rotation).

Which codes are used to turn the spindle on?

Spindle direction

There are two codes for turning the CNC spindle on.

M03 turns it on in a clockwise direction. M03 is used with right hand tooling.

M04 turns it on in a counterclockwise direction. M04 used with left hand tooling.

If you need to change directions, then it is best to stop the spindle before changing directions.

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

M5 vs M05

Some people get confused about whether the 0 is required to include with an M05 code.

To clear this up, there is no need to include the zero in the code. 

The CNC machine will read the code the same. It really is just a matter of preference.

Often you will see the full M05 code used in textbooks or other reference materials. In practice though, many prefer the shortened M5 code in their programs.

If you are working on your own, then go with whichever format you prefer. 

If you work in a bigger shop, make sure to stick to the format that the business has been using.

What other codes will stop the spindle?

There are multiple codes that turn the spindle off. 

Most of them perform multiple functions such as stopping various machine functions all at once. Some of those codes are:

M00 and M01 are both stops.

They both will turn off the spindle, turn off the coolant, stop any machine movement and pause your program until the cycle start button is pushed again. 

The difference between the two is that M00 will always cause the machine to act in this way and M01 will only cause the CNC to perform these action if the optional stop switch or button is set to on.

M02 and M30 are both program end codes. 

They will cause the machine to shut everything down just like the M00 and M01 codes but instead of pausing the program, they stop it.

M02 is a legacy code from when many CNC programs were made on tape for the machine to read. The M02 code would cause the machine to end the program. 

The M30 command would end the program and then rewind the tape back to the beginning of the program.

In many newer CNC machines, the M02 code is treated the same as the M30 code. In cases where the default is not to treat the codes the same, the machine often has a setting that can allow it to treat them both as M30 codes.

M02 codes are not needed on newer CNC machines. M30 is the standard code to end a CNC program.

Want to learn more about CNC G Code?

Leave a Comment