Back to GSM Code List

M03, M04 and M05: spindle forward, reverse and spindle stop

M03 starts the spindle clockwise, M04 counterclockwise and M05 stops it. The direction is always judged from the spindle looking toward the part, that is, from behind the tool: with M03, a right-hand cutter or drill, which is the normal thing, cuts. The speed comes from the S, which can go in the same block (S3000 M03) or before it. On a lathe it is not automatic: the right direction depends on whether the turret is front or rear and on whether the tool is right-hand or left-hand.

For reference only: syntax changes with the control, the post-processor and the machine parameters. Check the official manual and run a simulation before cutting. Legal notice.

Family
Machine
Machine
Milling, Turning, Mill-turn
Risk
Medium
Example
M03 S1800 / M05

Syntax by control

Fanuc / Haas (milling)

G90 G54 G00 X40. Y30. S2400 M03

The usual thing is to write it in the positioning block, so the spindle comes up to speed while the table moves. Most controls wait for the spindle at speed signal before running the first feed move, but that depends on the machine.

Fanuc / Haas (turning)

G97 S1500 M03

On a lathe the M nearly always goes with a G96 or G97 in front, because the S means one thing or another depending on which is active. On rear turret machines, the direction the operator sees from outside looks reversed compared with a mill: what is in charge is the cutting edge of the insert, not the visual impression.

Siemens 840D / 828D

S1200 M3

Siemens writes M3, M4 and M5 with no leading zero. On multi spindle machines they are addressed with SETMS or by writing the spindle number before the M (for example M2=3 for the second spindle), and SPOS orients it to an angle.

Heidenhain TNC (Klartext)

TOOL CALL 5 Z S3000 M3

The rotation can be written in the tool call itself, along with the S, or on a separate line as M3. M5 stops it. The tool, its length and its radius all come in with that same instruction.

Live tooling and second spindles

M133 P2000 (ejemplo de torno Haas)

Live tools on a lathe and second spindles are not governed by M03/M04/M05 on every machine: some builders use their own codes (M133, M134 and M135 on Haas lathes, for example) and others combine rotation and coolant in a single M. Check the builder's M code list.

Address letters used with it

LetterWhat it setsUnit
SSpindle speed. It is modal: leave it out and the one from the previous operation is used, which is one of the commonest reasons for a broken drill.rpm (m/min if G96 is active on a lathe)
P (builder specific)On some two spindle machines or machines with live tooling, a P or a suffix picks which spindle the order goes to or gives it its speed. It is not standard: it depends on the builder.integer or rpm, depending on the builder
M03 / M04 / M05They carry no arguments of their own. M03 and M04 exclude each other and M05 cancels either one; a program stop or a reset cancels them too.no units

Worked example

Two operations in a row on a milling machine: drilling a hole and tapping it M8. It shows the three functions in their place and, along the way, clears up the commonest misunderstanding: in rigid tapping with G84 you do not program M04 to back the tap out, because the cycle reverses the rotation itself.

O0003 (TALADRAR Y ROSCAR M8)
( Program header. )
G21 G17 G40 G49 G80
( Millimeters, XY plane and a clean state. )
G91 G28 Z0.
( Z to the reference point in incremental before the change. )
T3 M06
( 6.8 mm drill, the tap drill for an M8 thread of 1.25 pitch. )
G90 G54 G00 X40. Y30. S2400 M03
( The spindle starts clockwise while the table positions: that way it is up to speed before the tool has to cut. The drill is right-hand, hence M03. )
G43 H03 Z25.
( T3 length offset. )
M08
( Coolant on. )
G99 G81 Z-20. R3. F250
( Drills the tap drill hole. )
G80 G00 Z50. M09
( Cancels the cycle, retracts and shuts the coolant off. )
M05
( Stops the spindle before the change. Plenty of machines do it themselves, but not all, and reaching the changer with the spindle turning wrecks the arm. )
G91 G28 Z0.
( Z to the reference point. )
T7 M06 (MACHO M8X1.25)
( The tap comes in. )
G90 G54 G00 X40. Y30. S600 M03
( M03 again: the tap is right-hand, so it goes in turning clockwise. If it were a left-hand tap it would have to start in M04. )
G43 H07 Z25.
( T7 length offset. )
M08
( Coolant on. )
M29 S600
( Enables rigid tapping on Fanuc, synchronizing spindle and Z axis. On Haas the G84 is already rigid and this block is not needed. )
G84 Z-18. R5. F750
( Tapping. The feedrate is the pitch times the rpm: 1.25 by 600 is 750 mm/min. At the bottom the cycle reverses the rotation by itself to back the tap out. )
G80 G00 Z50. M09
( Cancels the cycle and retracts. )
G91 G28 Z0. M05
( Z to the reference point and spindle stopped before finishing. )
G90 M30
( Back to absolute and end of program. )
Open the simulator to check the example

Practical keys to using M03/M04/M05 in the workshop

How to know which direction you need

The reference is always the same: look from the spindle toward the part, as if you were standing behind the tool, and M03 turns the way the hands of a clock do. Another way to see it is the right hand rule with the thumb pointing toward the spindle. Since nearly every cutter, drill and tap is right-hand, in milling M03 is the normal case and M04 only shows up with left-hand tooling, left-hand taps or the odd special deburring operation. If in doubt, start the spindle in fresh air and look at the helix of the tool.

On a lathe the direction is not copied from the mill

On a lathe what turns is the part, so the direction depends on the geometry of the whole setup: front or rear turret, right-hand or left-hand insert, tool above or below the centerline. With a rear turret and a right-hand insert the usual work is M03 but the part looks like it turns backwards seen from outside, and on front turret machines the combination changes. The practical check is to look at which way the edge faces and which way it has to bite. With the tool mounted the wrong way, the edge works on its back and breaks on the first pass.

What M05 does and what it does not

M05 cuts the rotation command and the spindle slows on whatever ramp the machine has. It does not release the spindle and does not lock it, it does not shut the coolant off, it does not cancel the programmed S and it is not an emergency brake. On some controls the next block starts running before the spindle has fully stopped, so an M05 followed immediately by a move is no guarantee the tool is standing still. For the tool change, many machines stop the spindle by themselves, but writing it costs one block and works everywhere.

Mistakes that cost you a part (or a tool)

  • Tapping with a left-hand tap turning in M03: the tap does not cut, it grabs and snaps off down the hole.
  • Milling with M04 and a right-hand cutter: the tool rubs with the back of the edge instead of cutting, heats up, leaves a terrible finish and eventually breaks.
  • Programming the S and forgetting the M03: the axes run the feed move with the spindle stopped and the tool enters the part without turning.
  • Inheriting the S from the previous operation: a 20 mm drill starting at the 6000 rpm of the finishing cutter is a guaranteed breakage.
  • Reaching the tool change with the spindle turning on machines that do not stop it on their own: the changer arm takes the worst of it.
  • On a lathe, picking the direction without looking at the turret and the hand of the insert: the tool works on its back, leaves the surface scored and breaks the tip.
  • Going past the speed limit of the chuck, the collet holder or the tool itself: that ceiling is set by the workholding maker, not by the spindle maker.
  • Asking for low rpm with a lot of torque on machines with gear ranges without selecting the right range (M41 and M42 on many lathes): the spindle runs out of torque and the tool digs in.

Frequently Asked Questions (FAQ)

M03 turns clockwise seen from where?

From the spindle looking toward the part, that is, from behind the tool. If you stand in front of the mill and look up, you see it the other way around, and half the confusion comes from there. With that reference, M03 makes any right-hand tool cut, which is practically everything in a shop.

When do you need M04?

With left-hand tooling: left-hand taps, left-hand cutters or drills and some deburring tools that work by pulling. On a lathe, M04 shows up routinely depending on the turret and insert combination. In rigid tapping with G84 you do not write it: the cycle reverses the rotation on its own.

Can I put the S and the M03 in the same block?

Yes, and it is the usual thing: S2400 M03. You can also write the S in an earlier block, because it is modal. What is worth doing is putting the M03 in the positioning block so the spindle picks up speed while the axes move and you do not lose seconds on every tool.

Is M05 compulsory before the change or the M30?

The control does not demand it and many machines stop the spindle themselves at the change and at the end of the program. But that depends on the builder and on the setup, so writing it is the safe habit: it costs one block and works the same on every machine in the shop.

Why does M03 look like it turns backwards on a lathe?

Because the reference is still the spindle axis looking toward the part, and on a lathe the operator is looking from the opposite side. On top of that, with a rear turret the tool attacks from above and behind. What you have to check is not the visual impression but whether the edge of the insert bites the material the right way.

Related codes

Other codes in Machine

See the full list of G and M codes

Related tools