Bird
0
0
CNC Programmingscripting~3 mins

Program end (M30) in CNC Programming

Choose your learning style9 modes available
Introduction
The M30 command stops the CNC program and resets it to the start. It tells the machine the job is done and ready for the next run.
When you finish writing a CNC program and want to mark its end.
To stop the machine safely after completing all machining steps.
When you want the program to rewind and be ready to run again without restarting the machine.
To signal the operator that the program has completed its cycle.
When automating multiple parts production and the machine needs to reset after each part.
Syntax
CNC Programming
M30
M30 is usually placed at the very end of a CNC program.
It stops the spindle, turns off coolant, and rewinds the program to the start.
Examples
Moves tool to home, stops spindle, then ends program with M30.
CNC Programming
N100 G00 X0 Y0 Z0
N110 M05
N120 M30
Simple program end command alone to stop and reset.
CNC Programming
M30
Sample Program
This program moves the tool safely, starts the spindle, cuts a line, stops the spindle, and ends with M30 to reset.
CNC Programming
O1000 (Simple CNC program)
G21 (Set units to mm)
G90 (Absolute positioning)
G00 X0 Y0 Z5 (Rapid move to safe start)
M03 S1000 (Start spindle clockwise at 1000 RPM)
G01 Z-5 F100 (Cut downwards at feed 100)
G01 X50 Y0 F200 (Cut in X direction)
G00 Z5 (Retract tool)
M05 (Stop spindle)
M30 (End program and rewind)
OutputSuccess
Important Notes
M30 resets the program counter to the beginning, so the CNC can run the program again without reloading.
Some machines may require M30 to fully stop and reset; others may use M02 for a similar purpose but without rewind.
Always place M30 at the end to avoid unexpected machine behavior.
Summary
M30 stops the CNC program and resets it to the start.
Use M30 at the end of your CNC code to safely finish the job.
It prepares the machine for the next run without manual restart.