G-code academy

M03, M04, M05 - Spindle rotation control

Auxiliary codes M03 and M04 are designed to control spindle rotation. The only difference between these two M codes is the direction of rotation.

M03 - Start rotating the spindle clockwise.
The M03 command remains active until it is canceled with M04 or M05.

M04 - Start rotation of the spindle counterclockwise.
The M04 command remains valid until it is canceled with M03 or M05.

M05 - Stop spindle rotation. At the end of the machining program and before changing the tool, you need to stop the spindle rotation using command M05.


Example:
G00X0Y0
M3 S6000; Start rotating the spindle clockwise at a speed of 6000 rpm.
G00Z5
G01X10Y10
G01Z-0.5F700
G01X40Y10
G01X40Y40
G01X10Y40
G01X10Y10
G00Z5
M5; Stop spindle rotation
G00X0Y0