This document provides a comprehensive overview of essential function codes used in CNC (Computer Numerical Control) programming. These codes, including F, S, T, and M, control critical aspects of the machining process such as feed rates, spindle speeds, tool selection, and auxiliary functions.
F Function: Feed Rate Control
The F code is used to command the feed rate of the cutting tool. It can be programmed in two distinct modes.
1. Feed per Revolution (G95)
- 
Format: G95 F~
- 
Description: The value following Fspecifies the distance the tool travels per single revolution of the spindle.
- 
Unit: millimeters per revolution (mm/rev). 
- 
Example: G95 F0.2sets a feed rate of 0.2 mm/rev.
2. Feed per Minute (G94)
- 
Format: G94 F~
- 
Description: The value following Fspecifies the distance the tool travels per minute.
- 
Unit: millimeters per minute (mm/min). 
- 
Example: G94 F100sets a feed rate of 100 mm/min.
S Function: Spindle Speed Control
The S code commands the rotational speed of the spindle.
- 
Basic Spindle Speed (RPM) - 
Format: S~
- 
Description: The value specifies the spindle speed. 
- 
Unit: revolutions per minute (r/min or RPM). 
 
- 
On machines equipped with Constant Surface Speed control, the S function has additional applications:
1. Maximum Spindle Speed Clamp (G50)
- 
Format: G50 S~
- 
Description: Limits the maximum allowable spindle speed, often used in conjunction with constant surface speed. 
- 
Example: G50 S3000sets the maximum spindle speed to 3000 RPM.
2. Constant Surface Speed (CSS) Control (G96)
- 
Format: G96 S~
- 
Description: Maintains a constant cutting speed (surface feet/min or meters/min) at the cutting tool tip, automatically adjusting the spindle RPM as the tool diameter changes. 
- 
Unit: meters per minute (m/min). 
- 
Example: G96 S150commands a constant surface speed of 150 m/min.
3. Cancel Constant Surface Speed (G97)
- 
Format: G97 S~
- 
Description: Deactivates CSS and returns to direct RPM control. The Svalue sets the spindle speed after cancellation.
- 
Example: G97 S3000cancels CSS and sets the spindle to 3000 RPM.
T Function: Tool Selection
The T code is used to select a specific tool and often its corresponding offset.
- 
Format: T~
- 
Description: The digits following Ttypically identify the tool station number and the tool offset number. Common formats are 2-digit (tool only) or 4-digit (tool and offset).
- 
Example 1: T0303selects tool #3 and applies tool wear/geometry offset #3.
- 
Example 2: T0300selects tool #3 and cancels any tool offset.

M Function: Miscellaneous Functions
M codes control auxiliary functions of the machine tool, such as coolant, spindle rotation, and program flow. The following table lists common M codes. Note: The availability and meaning of M codes can vary by machine manufacturer.
| M Code | Primary Function / Meaning | 
|---|---|
| M00 | Program Stop - Unconditional halt | 
| M01 | Optional Stop - Halts only if operator button is enabled | 
| M02 | Program End - Older code, may not reset to start | 
| M03 | Spindle Start (Clockwise/CW) | 
| M04 | Spindle Start (Counter-Clockwise/CCW) | 
| M05 | Spindle Stop | 
| M06 | Tool Change - Automatic Tool Changer (ATC) command | 
| M08 | Coolant On | 
| M09 | Coolant Off | 
| M13 | Spindle CW + Coolant On (Combined cycle) | 
| M19 | Spindle Orientation - Positions spindle at a fixed angle | 
| M30 | Program End and Reset - Returns to program top | 
| M41 | Low Gear Range / Speed Range 1 | 
| M42 | High Gear Range / Speed Range 2 | 
| M48 | Override Cancel Off - Enables feed and speed override | 
| M49 | Override Cancel On - Disables feed and speed override | 
| M68 | Chuck Clamp | 
| M69 | Chuck Unclamp | 
| M98 | Subprogram Call | 
| M99 | Subprogram End / Return | 
| M103 | Spindle Rotation CCW (for Sub-spindle) | 
| M104 | Spindle Rotation CW (for Sub-spindle) | 
| M105 | Spindle Stop (for Sub-spindle) | 
| M106 | Synchronized Spindle Mode | 
| M107 | Cancel Synchronized Spindle Mode | 
| M110 | Main & Sub-spindle Clamp | 
| M111 | Main & Sub-spindle Unclamp | 
| M130 | Bar Feeder Enable | 
| M131 | Bar Feeder Disable | 
*Note: Many M codes (e.g., M07, M50-M59) control specific machine-specific functions like auxiliary coolant, through-spindle coolant, or tailstock control and should be verified with the machine tool's documentation.*
Summary
Understanding and correctly applying F, S, T, and M codes is fundamental to effective CNC programming. The F code controls the tool's movement speed, the S code governs the spindle, the T code manages tooling, and the M code operates the machine's auxiliary functions. Always consult the specific machine tool builder's programming manual for the most accurate and complete list of codes, as implementations can differ.
This guide covers the most common implementations, but specific machine configurations may vary.
 
				 
															