Simple CNC Programming Code
Simple CNC Programming Code
; Simple CNC program to mill a rectangular pocket
; Units in millimeters
G21 ; Set units to millimeters
G17 ; Select XY plane
G90 ; Absolute positioning
; Start spindle and move to start position
M6 T1 ; Tool change to tool 1
M3 S1200 ; Start spindle at 1200 RPM
G0 Z5.0 ; Raise to clearance height
G0 X0 Y0 ; Move to start position
; Start cutting
G1 Z-1.0 F100 ; Move down to cutting depth
G1 X50.0 F200 ; Move to X50
G1 Y30.0 ; Move to Y30
G1 X0 ; Move back to X0
G1 Y0 ; Move back to Y0
; Finish up
G0 Z5.0 ; Raise to clearance height
M5 ; Stop spindle
G0 X0 Y0 ; Return to home position
M30 ; End of program