M30 – End The Program And Rewind

This command ends the program and rewinds back to the first line of the G-code file.

 


Syntax & Parameters

 

  • M30

  • L value – When added to M30, the program repeats for the specified number of cycles

    • L10 runs the G-code 10 times before rewinding and stopping

    • L0 causes the program to rewind and repeat in an infinite loop

 

 

 

INFORMATION: When a G-code file loops, the spindle does not stop on M30 until the final cycle. This eliminates spindle spin-up and spin-down time between cycles.


Example Program

 

N10 G00 X0 Y0
N20 G00 X10
N30 M30
N40 G00 Y10

 

  • N10: Moves both the X and Y axes to position 0.00

  • N20: Moves the X axis to position 10

  • N30: Ends the program and rewinds to line N10

  • Pressing Cycle Start will restart the program from line N10

 


Infinite Loop Example

 

N10 G00 X0 Y0
N20 G00 X10 
N30 M30 L0    

 

This program executes lines N10 to N30, then rewinds to N10 and starts again automatically.
 

It will continue until manually stopped.

 


Repeat 20 Times Example

 

N10 G00 X0 Y0 
N20 G00 X10 
N30 M30 L20

 

This program executes lines N10 to N30, then rewinds and repeats until 20 cycles are completed.


After the final cycle, the program rewinds to N10 and stops.