LinuxCNC M5

M5 is a G-code M instruction in LinuxCNC that stops the selected spindle. An optional $ parameter selects which spindle is stopped; without it the command applies to spindle 0. M5 can be issued whether the spindle is turning or already stopped.

Source checked5/5 values · 2026-10-26

Specification

1 source
Languagegcode
CodeM5
GroupSpindle Control
SyntaxM5 [$n]
DialectLinuxCNC

Parameters

NameDescription
$nSpindle to stop. Omit to operate on spindle 0; use $-1 to operate on all active spindles.

Study notes

  • The optional $ parameter selects the spindle: $0, $1, $2 address individual spindles, and $-1 operates on all active spindles.
  • If $ is omitted, M5 operates on spindle 0, which is the normal behaviour for a single-spindle machine.
  • Example from the document: M5 $2 stops spindle 2 and leaves the other spindles rotating.
  • M19 spindle orient is in the same modal group (group 7) as M3, M4 and M5, and M19 is cleared by any of M3, M4 or M5.
  • Program end (M2/M30) stops the spindle as if M5 were executed, along with resetting offsets, plane, distance mode and coolant.
↑↓ navigate↵ openesc close