G96, G97 (Spindle Control Mode)
Two spindle control modes are possible, depending on the mode the spindle speed is calculated differently:
G96 (Only for Lathe)
Select constant surface speed, S is now specified as meters per minute in mm mode (G21) or Feet per minute in inch mode (G20). This means that the spindle speed is adapted automatically when the Radius changes. Suppose you program G96 S150 in millimeter mode, the spindle speed is calculated by: RPM = S / (2 * PI * X), and X is the radius. So your X zero must be where the diameter is zero.
Example: Your actual X position is 100 (100 millimeters = 0.1 meter), and you program G96 S150 D1000, this would result in a spindle RPM of 150 / (2 * PI * 0.1) = 238.7 rev/min. D1000 limits the maximum speed to 1000 RPM.
G97 is normal RPM mode, and S... specifies the RPM.