FIFTY LINETurn G-code
Online generatorOnline calculatorsReference

G96 and G97 codes on a CNC lathe: CSS vs constant RPM (Fanuc, LinuxCNC)

· ~10 min read

In short: G97 is constant spindle speed, S in RPM (G97 S800 M3 = 800 RPM). G96 is constant surface speed (CSS), S in m/min or ft/min (G96 S150 M3 = 150 m/min), and the control changes the RPM with the diameter. G96 always needs a spindle limit: D in LinuxCNC, G50 S… or G92 S… on Fanuc. Threads are cut in G97 only.

Spindle speed on a CNC lathe is set in one of two modes: G97, constant RPM, with S in revolutions per minute, or G96, constant surface speed (CSS), with S in metres per minute (or feet per minute in inch mode) while the control recalculates the RPM from the current diameter. Below we look at how they differ, when to use which, how to keep the spindle from running away, and how it is written in LinuxCNC and on Fanuc. At the end there is a short note on the coolant codes M7, M8, M9.

Contents

  1. RPM and surface speed: the formula
  2. G97: constant RPM
  3. G96: constant surface speed
  4. Spindle limit: D in LinuxCNC, G50 on Fanuc
  5. G96 and feed: G94 or G95
  6. Example: facing with G96 in LinuxCNC
  7. G96 and G97 on Fanuc: example program
  8. Common mistakes
  9. Coolant: M7, M8, M9
  10. How Turn G-code handles it

RPM and surface speed: the formula

Surface speed Vc is how fast the workpiece surface moves past the cutting edge. Insert makers give it in their catalogues, for example 150-250 m/min (about 500-800 SFM) for carbide in mild steel. Spindle speed n depends on it and on the diameter D at the cutting point:

metric:  n = 1000 × Vc / (π × D)    n in RPM, Vc in m/min, D in mm
inch:    n = 12 × Vc / (π × D)      n in RPM, Vc in ft/min (SFM), D in inches

Here is what that means for Vc = 150 m/min:

Diameter, mm RPM for 150 m/min
100 477 RPM
50 955 RPM
20 2387 RPM
10 4775 RPM
5 9549 RPM
0 (centerline) infinite

At the same RPM, the surface speed on a 100 mm diameter is ten times higher than on a 10 mm diameter. That is why there are two modes.

To get the RPM for your diameter, the feed per minute and ready G96/G97 lines, use the lathe RPM and cutting speed calculator.

G97: constant RPM

G97 S800 M3      (800 RPM, spindle clockwise)

The spindle keeps the commanded RPM whatever the tool is doing. This is the default mode, and it is required in several cases:

  • Threading. G33 and G76 (LinuxCNC) and G32 (Fanuc) sync the feed to the spindle. If the RPM changes between passes, the passes will not line up. Threads are cut in G97 only; see threading in LinuxCNC with G33 and G76.
  • Drilling, countersinking, center drilling. The cutting diameter is the drill diameter while X = 0. In G96 the control would go straight to the spindle limit.
  • Small diameter changes. Turning from Ø25 to Ø20 gains almost nothing from G96, and G97 is easier to check.
  • A lathe without variable spindle speed (belt steps, gearbox): the control simply cannot change RPM on the fly.

G96: constant surface speed

G96 D2000 S150 M3   (150 m/min, no more than 2000 RPM)

The control keeps recalculating the RPM from the tool’s X position: the closer to the centerline, the faster the spindle. Surface speed and cutting conditions stay the same along the whole pass. Where it shows:

  • Facing. Without G96 the surface speed drops to almost zero towards the center, the finish near the center gets torn, and at the outside the insert may run too hot. With G96 the finish is even across the face.
  • Parting off. Same picture: the diameter shrinks as the tool goes in, and constant surface speed keeps the cut stable up to the spindle limit.
  • Tapers and spheres, especially with a big diameter difference.
  • Finishing passes on stepped shafts: the same surface finish on every step.
  • Insert life. The insert stays in its speed range instead of running too slow on one diameter and too fast on another.

A condition for G96: X = 0 must be exactly on the spindle centerline. The control calculates RPM from the tool’s real distance from the axis; if the tool’s X offset is wrong, so is the RPM.

Spindle limit: D in LinuxCNC, G50 on Fanuc

By the formula, RPM goes to infinity at the centerline. In practice the spindle runs up to its maximum, and the chuck and workpiece with it. With a heavy or poorly clamped part, a chuck with a speed rating, or a long part without support, that is dangerous. So G96 is always written with a spindle limit:

LinuxCNC Fanuc
Spindle limit D word on the same line A separate G50 S… (system A) or G92 S… (systems B and C)
How it is written G96 D2000 S150 M3 G50 S2000 then G96 S150 M3

Pick the limit by the weakest link: the chuck rating, workpiece balance, stick-out, the spindle itself.

G96 and feed: G94 or G95

G96 is almost always paired with G95, feed per revolution (F in mm/rev or in/rev). The chip thickness then stays constant: as RPM rises, the feed in mm/min rises with it.

If you stay in G94 (F in mm/min or in/min), the feed per revolution drops as the RPM climbs near the center, and the insert starts rubbing instead of cutting. That is a bad combination for G96.

Example: facing with G96 in LinuxCNC

A short program facing a Ø50 mm blank at constant surface speed. This is an illustration, not Turn G-code output:

G21 G18 G7 G90 G95       (mm, XZ plane, X as diameter, feed per rev)
G54
T1 M6
G96 D2500 S150 M3        (150 m/min, no more than 2500 RPM)
M8                       (coolant on)
G0 X52 Z2
G0 Z0
G1 X-0.4 F0.15           (face to center, 0.15 mm/rev)
G0 Z2
M9                       (coolant off)
G97 S500                 (leave G96 before stopping the spindle)
M5
M30

What matters here:

  • the D2500 limit is on the G96 line itself;
  • F0.15 is per revolution (G95);
  • before the spindle stops, and before any threading, G97 S… switches the program back to constant RPM explicitly.

G96 and G97 on Fanuc: example program

On Fanuc, G96 and G97 themselves work the same way as in LinuxCNC. The differences are around them:

  • The spindle limit is a separate line. In G-code system A (the most common one on Fanuc lathes) it is G50 S…, in systems B and C it is G92 S…. Which system your machine uses is set by a control parameter; check your machine’s manual.
  • G50 / G92 also set the coordinate system. Put only S on that line, no X or Z, or the control will shift the work zero as well.
  • Feed per revolution is G99 in system A (G95 in systems B and C), feed per minute is G98 (G94).
  • Decimal point. On many Fanuc controls X52 without a point is read as 0.052 mm, so coordinates are written as X52..

The same Ø50 facing as above, for Fanuc in system A:

O0001
G21 G40 G99              (mm, no nose radius comp, feed per rev)
T0101                    (tool 1, offset 1)
G50 S2500                (limit 2500 RPM; in system B/C - G92 S2500)
G96 S150 M3              (150 m/min)
G0 X52. Z2. M8
G0 Z0.
G1 X-0.8 F0.15           (face to center, 0.15 mm/rev)
G0 Z2.
G97 S500                 (back to constant RPM)
M9
M5
M30

Threading on Fanuc, just like in LinuxCNC, starts with a switch to G97 with an explicit speed, for example:

G97 S600 M3              (constant 600 RPM)
G76 ...                  (threading cycle)

If a program was written for LinuxCNC and has to run on a Fanuc, check exactly these spots: Fanuc will not understand D on the G96 line, the limit has to move to G50/G92.

Common mistakes

  1. G96 without a spindle limit. The first pass to the center, and the spindle is at its maximum. The most dangerous mistake on this list.
  2. Threading in G96. G97 was forgotten after facing, and the next threading pass runs at a changing RPM. The passes will not line up, and the part is scrap.
  3. Drilling in G96. The drill sits at X = 0 and the control goes to the spindle limit.
  4. G96 with G94. Near the center the feed per revolution drops and the insert rubs instead of cutting.
  5. A wrong X offset. The spindle centerline is not at X = 0, so the RPM is calculated wrong.
  6. Units. With G21, S in G96 is m/min; with G20 it is ft/min. S150 in an inch program is a very different speed.

Coolant: M7, M8, M9

Code What it does
M7 Mist coolant on
M8 Flood coolant on
M9 Coolant off

Many LinuxCNC lathes have a single pump, and it may be wired to M8 or to M7. Check which code does what in your machine configuration (HAL). Coolant is usually switched on after the spindle starts and off before it stops, as in the example above. The full table of G- and M-codes is in the LinuxCNC G-code and M-code reference for lathes.

How Turn G-code handles it

Turn G-code outputs spindle speed in G97 mode: every cycle form has an RPM field, and the program gets a line like this (a real excerpt from a facing program):

G21 G18 G90 G8 G40 G80 G94
G54

G97 S200 M3

Any control understands that, and threading cycles are guaranteed to run at constant RPM. The program does not output G96 at the moment. If you want constant surface speed for facing or parting off, you can replace the G97 S… line with G96 D… S… by hand and check the program in the LinuxCNC preview before running it.

Coolant M-codes are configurable: M8/M9 by default, and in the “Coolant codes” window you can set your own on and off codes for your control. The setting applies to all 12 cycles at once.

Try it yourself: download Turn G-code - 15 days free, no key needed.

← All articles