M04 turns the CNC spindle on in a counterclockwise (CCW) direction. It’s most commonly used with left-hand tooling and is less common than M03, but knowing when and how to use it correctly matters.
Key Takeaways
- M04 starts the spindle in a counterclockwise direction
- It’s used with left-hand tooling on mills, and in reverse tapping and certain lathe operations
- Always pair M04 with an S word (spindle speed) on the same line, or set speed on the line before
- Stop the spindle with M05 before reversing direction — don’t switch from M03 to M04 without stopping first
- M4 and M04 are identical — the leading zero is optional
| M04 – At A Glance | |
|---|---|
| Function | Start spindle counterclockwise (CCW) |
| Type | Non-modal (one-shot) |
| Cancelled by | M05 (spindle stop) |
| Used with | S (spindle speed), M03, M05 |
What Does M04 Do?
The M04 code turns the CNC spindle on in a counterclockwise direction.
M04 tells the CNC machine to start the spindle and rotate it counterclockwise when viewed from the spindle nose. On a vertical machining center, that means the spindle turns in the opposite direction from standard right-hand cutting tools.
This is different from M03, which starts the spindle clockwise. Most milling operations use M03 because standard end mills and drills are right-hand cutting tools. M04 is the less common of the two.
Compare the two movements below.
When Is M04 Used?
M04 is used in three main situations:
Left-hand tooling on a mill
Some specialty tools — like left-hand taps or certain thread mills — require CCW rotation to cut properly. If you run them with M03, you’ll break the tool or produce a bad thread.
Reverse tapping (rigid tapping retract)
On machines without a tapping spindle, some programs use M04 to reverse the spindle and retract the tap after threading. On modern machines with rigid tapping, this is handled automatically — but older programs may still use M04 for this.
Certain lathe operations
On CNC lathes, M04 can be used for left-hand threading or when the part geometry requires reverse spindle direction.
M04 Code Example
M05 (Spindle stop)
You can also set the speed on a separate line before the M04:
S1500
M04
Both work the same way. The machine uses the last S value stored in memory.
COMMON MISTAKE – Running M04 with a right-hand tool
Why it matters: Right-hand end mills and drills are designed to cut in the M03 (clockwise) direction. Using M04 will cause the tool to rub instead of cut, which ruins the tool and can damage the part or machine.
COMMON MISTAKE – Switching directly from M03 to M04 without stopping the spindle first
Why it matters: Most CNC controls require the spindle to stop (M05) before reversing direction. Skipping M05 can trigger an alarm, and on some machines it puts stress on the spindle motor and drive.
M4 vs M04 — Is the Zero Required?
No, the zero is not required. M4 and M04 do the exact same thing. The CNC controller reads them identically.
You’ll often see M04 in textbooks and reference materials because it’s the “official” format. In practice, plenty of programmers drop the zero and use M4. Either is fine — just be consistent with whatever format your shop uses.
M03 vs M04 — Which One Do You Need?The short answer: use M03 unless you have a specific reason for M04.
M03 turns the spindle clockwise and works with standard right-hand tooling — which covers the vast majority of CNC milling and drilling operations. M04 is for left-hand tooling and the special situations covered above.
| Code | Direction | Tooling |
|---|---|---|
| M03 | Clockwise (CW) | Right-hand tools (standard) |
| M04 | Counterclockwise (CCW) | Left-hand tools |
If you need to change direction during a program, always stop the spindle with M05 first.
Which Code Turns the Spindle Off?
M05 stops the spindle. It works the same regardless of whether the spindle was running with M03 or M04.
Related Codes to Know
When working with M04, you’ll also use these codes regularly:
S code — Sets the spindle speed in RPM. Most controllers accept a range of 1–9,999 or 1–99,999 depending on the machine. Always set S on the same line as M04, or on the line directly before it.
M03 — Spindle on clockwise. The more common counterpart to M04.
M05 — Spindle stop. Always use this before reversing from M04 to M03 or vice versa.
G96 — Constant surface speed mode, used on lathes. The machine automatically adjusts RPM as the cutting diameter changes to maintain a consistent surface speed.
G97 — RPM mode. The spindle runs at a fixed RPM regardless of cutting diameter. This is the standard mode on mills.
FAQs
What is M04 used for in CNC programming?
M04 starts the CNC spindle in a counterclockwise (CCW) direction. It’s primarily used with left-hand tooling on mills, for reverse tapping on older machines, and for certain lathe operations requiring CCW spindle rotation.
What is the difference between M03 and M04?
M03 starts the spindle clockwise and is used with standard right-hand tooling. M04 starts the spindle counterclockwise and is used with left-hand tooling. The vast majority of CNC milling and drilling operations use M03.
Do I need to include a spindle speed with M04?
You should always include an S word (spindle speed) either on the same line as M04 or on the line before it. If no speed is programmed, the machine uses the last speed stored in memory — which may not be what you want.
Can I switch from M03 to M04 without stopping the spindle?
No. You should always program M05 (spindle stop) before switching direction. Most controls will alarm out if you try to reverse without stopping first, and doing so can damage the spindle drive on some machines.