# LinuxCNC M4

Instructions · `M4` · verification: source checked

M4 starts the selected spindle counterclockwise at the speed set by the S word. If the optional $n spindle selector is omitted, the command acts on spindle 0; $n selects a specific spindle and $-1 operates on all active spindles. If the spindle speed is zero, the spindle does not start turning until the speed or override is raised.

## Specification

| Property | Value |
|---|---|
| Language | gcode |
| Code | M4 |
| Group | Spindle Control |
| Syntax | M4 [$n] |
| Dialect | LinuxCNC |

### Parameters

| Name | Description |
|---|---|
| $n | Selected spindle; if omitted the command defaults to spindle 0, and $-1 operates on all active spindles. |

## Connected

- Related: [LinuxCNC S (Set Spindle Speed)](https://machineschema.com/instruction/word-s.md)

## Safety

- With the S speed set to zero or the speed override at zero, M4 does not start spindle rotation; rotation begins when the speed or override is increased.

## Study notes

- The document groups M3, M4, and M5 together with M19 as modal group 7 commands; M19 is cleared by any of M3, M4, or M5.
- M4 may be used when the spindle is already turning, and M5 may be used when it is already stopped.
- If the optional $n is omitted, operation is the same as a single-spindle machine using spindle 0.

## Sources

1. [M-Codes](https://linuxcnc.org/docs/html/gcode/m-code.html#mcode:m3-m4-m5) (accessed 2026-10-26)

---

Source page: https://machineschema.com/instruction/mcode-m04  
JSON: https://machineschema.com/instruction/mcode-m04.json  
License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Cite Machine Schema and the original sources.
