Quick Guide to the M05 CNC Code [Spindle Off]

a graphic of a cnc machine with text that says learn g code today m05 spindle off

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).

Want to learn more about CNC G Code?

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.

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