Back to GSM Code List

M19: orienting the spindle and holding it there

M19 orients the spindle: it turns it to a particular angular position and leaves it there, still and held by the control, instead of turning or free. It is the function the machine uses internally on every tool change, so the drive keys in the taper line up, and the one the program uses when you have to know exactly which way the cutting edge faces: finish boring that comes out without a scratch, mounting angle heads or lining up special tooling. Which angle it orients to and how you program another one depend on the builder.

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
Spindle
Machine
Milling, Turning, Mill-turn
Risk
Medium
Example
M19

Syntax by control

Fanuc

M19

On most Fanucs, M19 takes the spindle to the orientation position set by parameter, with no arguments. Some machines accept an angle programmed with an extra address or with builder specific codes, but it is not universal: look at the M code list of your machine.

Haas

M19 P45.

On machines with a vector drive spindle, Haas lets you orient to a particular angle: P for whole degrees and R for degrees with decimals (M19 R45.5). Without that capability, a bare M19 orients to the fixed position of the machine.

Siemens 840D / 828D

SPOS=45

Siemens does not use M19 as a standard instruction: orientation is programmed with SPOS (or SPOSA if you want the program to carry on while the spindle gets into position), with the angle written directly and with the option of choosing the direction of rotation. Many builders also map M19 to the default position.

Heidenhain TNC (Klartext)

CYCL DEF 13.0 ORIENTACION

On the TNCs orientation is programmed with cycle 13, which carries the angle in its parameter, or with M19 if the builder has defined it on the machine. The boring cycles with oriented retract call it on their own.

Turning

M19

On a lathe, orienting the spindle is used for the tool change on machines with a magazine, for engaging the C axis and for lining the part up before transferring it to the sub spindle. The particular codes vary a great deal between builders, so here more than ever the machine manual rules.

Address letters used with it

LetterWhat it setsUnit
P (Haas)Orientation angle in whole degrees: M19 P90. Only on machines whose spindle can orient to any position.degrees
R (Haas)Orientation angle with decimals: M19 R45.5. Same function as P, with more resolution.degrees
Angle by parameter (Fanuc)When M19 takes no arguments, the position it orients to is stored in a machine parameter. It is not changed from the program.degrees, machine setting
SPOS= (Siemens)The equivalent instruction with the angle written directly, for example SPOS=45. It accepts a direction of approach to that position.degrees
M03 / M04 / M05They do not accompany M19, they cancel it: any new spindle command releases the orientation. That is what you have to write to go back to work.no units

Worked example

Finish boring a 40 mm H7 hole with a single point boring bar. If the bar comes out with the spindle stopped in any old position, the edge scores the wall you have just finished. The answer is to orient the spindle, move the edge a few tenths away from the side it faces and only then come up. The G76 cycle does exactly this internally; seeing it written by hand helps you understand what is going on.

O0019 (MANDRINADO CON SALIDA ORIENTADA)
( 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. )
T9 M06 (BARRA DE MANDRINAR D40)
( Single point boring bar, set to the finish size. )
G90 G54 G00 X60. Y45. S900 M03
( Absolute, work offset, positioning over the hole and spindle on. )
G43 H09 Z50.
( T9 length offset. )
G00 Z2. M08
( Approach and coolant on. )
G01 Z-35. F60
( Finish pass down to the bottom of the hole, at a fine feedrate. )
M05
( Stops the spindle before orienting it. Some machines orient from rotation and others demand the spindle stopped: check yours. )
M19
( Orients the spindle to its reference position and holds it locked there. From this block on you know which way the edge of the bar faces. On a Haas with a vector spindle you could set the angle with M19 P0. )
G91 G01 X-0.3 F500
( Moves the edge three tenths away in incremental, toward the side opposite the one it faces. Which sign you need depends on how the bar is mounted and on what angle your machine orients to: check it dry with an indicator before the first part. )
G90 G00 Z50.
( Now it comes out in rapid, with the edge nowhere near the finished wall. )
G00 X60. Y45.
( Recovers the nominal position in the plane, undoing the three tenths shift. )
M09
( Coolant off. )
G91 G28 Z0. M05
( Z to the reference point. The M05 releases the spindle orientation: while it is oriented, the spindle cannot turn. )
G90 M30
( Back to absolute and end. )
Open the simulator to check the example

Practical keys to using M19 in the workshop

What a spindle is oriented for

The commonest use is not in programs: it is the machine itself that orients the spindle on every tool change, so the drive keys of the spindle line up with the slots in the holder. It shows up in the program when the angular position of the edge matters: finish boring that has to come out without marking the wall, back spotfacing tools that only pass through the hole in one orientation, angle heads that engage on a key and have to end up pointing along a particular axis, and probes or special tooling with a defined side. On a lathe it is also used to engage the C axis and to hand the part over to the sub spindle.

The angle is what varies most between machines

M19 with no arguments takes the spindle to whatever orientation position the machine has stored, and that position is set by the builder: it does not have to be the same on two machines from the same maker. Being able to program an angle is another matter and depends on the spindle: Haas allows it with P and R on vector spindles, Siemens handles it with SPOS and Heidenhain with cycle 13. That is why a block with M19 and a following move does not get copied between machines: you have to check again which way the edge ends up.

What an oriented spindle is and what it is not

An oriented spindle is stopped in a particular position and held there by the servo, not by a mechanical brake. That means two things. First, it is not a C axis: you cannot interpolate it with the linear axes or mill a keyway by turning the part; for that you need a real C axis, which is another machine option. Second, while it is oriented the motor is applying torque to hold the position, so it is not something to leave sitting there indefinitely. Any later M03, M04 or M05 releases the orientation.

Mistakes that cost you a part (or a tool)

  • Assuming M19 orients to the same angle on every machine: the orientation position is a builder setting and it changes even between similar machines.
  • Moving the edge the wrong way after the M19: instead of clearing the wall, the bar digs into it and scores the finished hole all the way down.
  • Forgetting to start the spindle again after the M19: the orientation holds, and the next operation goes in to cut with the spindle locked and breaks the tool.
  • Programming the M19 with the spindle at high rpm: some controls brake and orient on their own, others alarm and some take an age. Writing M05 first always works.
  • Using M19 as if it were a C axis: orienting is taking up a position, not interpolating. Milling a slot by turning the oriented spindle is not possible.
  • Leaving the spindle oriented through long stops: the motor holds the position with torque and heats up without doing any work at all.
  • Copying the oriented retract boring block from one machine to another without checking the direction of the move again: the same code and the opposite result.

Frequently Asked Questions (FAQ)

What angle does M19 orient to?

To whatever orientation position the machine is set up with, which is a builder setting and not a constant of the code. On many machines it matches the position needed for the tool change. If you need a particular angle, check it dry with an indicator or a mark before you trust it.

How do I program a particular angle?

It depends on the control. On Haas with a vector spindle, with M19 P for whole degrees and M19 R for decimals. On Siemens, with SPOS=45. On Heidenhain, with cycle 13. On many Fanucs it cannot be done from the program and you have to work with the fixed position of the machine.

Is M19 the same as having a C axis?

No. M19 puts the spindle at a point and holds it there; the C axis turns the spindle into another axis, able to interpolate with X, Y and Z to mill slots, contours or hole patterns. Orienting is a position; the C axis is controlled motion.

Why does the machine orient the spindle on every tool change?

Because the drive keys of the spindle have to fit the slots in the holder. If the spindle stopped in any old position, the taper would not go in or it would go in forced. That orientation is done by the machine on its own during the M06, with nothing to write.

How is the orientation cancelled?

With any new spindle command: an M03, an M04 or an M05 release the position. No specific cancel code is needed. What you do have to remember is to write it, because while the spindle is oriented it does not turn.

Related codes

Other codes in Spindle

See the full list of G and M codes

Related tools