{"id":"mcode-m05","model_id":"M5","name":"LinuxCNC M5","summary":"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.","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."],"safety_notes":[],"sources":[{"url":"https://linuxcnc.org/docs/html/gcode/m-code.html#mcode:m3-m4-m5","title":"M-Codes","accessed":"2026-10-26"}],"verification":{"status":"source_checked","checked_at":"2026-10-26","values":5,"method":"llm_source_check"},"updated_at":"2026-10-26","type":"instruction","spec":{"language":"gcode","code":"M5","group":"Spindle Control","syntax":"M5 [$n]","parameters":[{"name":"$n","description":"Spindle to stop. Omit to operate on spindle 0; use $-1 to operate on all active spindles."}],"dialect":"LinuxCNC","related":[],"standards":[]},"url":"https://machineschema.com/instruction/mcode-m05","license":"https://creativecommons.org/licenses/by/4.0/"}