M30 – End The Program And Rewind

M30 ends the program and rewinds to the first line of the G-code file. Add L to repeat the program a set number of times, or forever.

Syntax
M30 L__
After M30
Rewinds to line 1
L0
Infinite loop

1. Parameters

WordMeaning
L (optional)Number of cycles. L10 runs the program 10 times, then rewinds and stops. L0 repeats forever until stopped manually.
INFORMATION
When a program loops, the spindle doesn't stop at M30 until the final cycle, so there's no spin-down and spin-up time between cycles.

2. Examples

End and rewind

N10 G00 X0 Y0
N20 G00 X10
N30 M30
N40 G00 Y10
CodeResult
G00 X0 Y0Moves X and Y to 0.
G00 X10Moves X to 10.
M30Ends the program and rewinds to N10. Press Cycle Start to run it again.
G00 Y10Not run.

Infinite loop

N10 G00 X0 Y0
N20 G00 X10
N30 M30 L0

Runs N10 to N30, rewinds to N10 and starts again automatically, until stopped manually.

Repeat 20 times

N10 G00 X0 Y0
N20 G00 X10
N30 M30 L20

Runs N10 to N30 and repeats until 20 cycles are complete. After the last cycle it rewinds to N10 and stops.