Back to Supported G-Codes
M0/M1 - Program Pause
DMC File Mode: Not Supported
Streaming Mode: Supported
Description
The M0 and M1 commands pause program execution in streaming mode. When encountered, the G-code processing queue stops executing commands and waits for a resume signal. This is useful for manual interventions, tool changes, or inspection during automated operations. M1 (Optional Stop) behaves identically to M0 (Program Pause) in this implementation.
Syntax
M0
M1
Resuming Execution
After an M0 or M1 command pauses execution, you can resume processing by calling Start() again. The Start() method is idempotent: if the processor is paused, it resumes from where it left off; if already running, it is a no-op.
// Resume execution after M0/M1 pause
streamer.Start();
Note: Start() is only available in streaming mode. If the program is not currently paused, calling Start() has no effect.
Examples
Basic Program Pause
G1 X10 Y10 F500
; Move to position
M0
; Pause for inspection
G1 X20 Y20
; Continue after resume
Tool Change Sequence
G1 X50 Y50 Z5 F1000
; Position for drilling
M3 S1000
; Start spindle
G1 Z-10 F200
; Drill hole
G1 Z5
; Retract
M5
; Stop spindle
M0
; Pause for tool change
M3 S2000
; Resume with new tool
C++ Implementation Example
// Add commands including pause
streamer.AddGCodeCommand("G1 X10 Y10 F500");
streamer.AddGCodeCommand("M0"); // Pause here
streamer.AddGCodeCommand("G1 X20 Y20");
streamer.Start();
// Later, resume execution after M0 pause
streamer.Start();