G Code Snippets
Random code for future reference
Useful Links
http://linuxcnc.org/docs/html/gcode/o-code.html
Using a Subroutine to Drill Holes
This example uses a subroutine (o100) and named parameters
% M3 ;Turn spindle clockwise (n/a) ; Move to hole and drill it - presumes last state was safe height ; #1 = X ; #2 = Y o100 sub #<drill_depth> = -20 #<drill_feed_rate> = 50 #<move_feed_rate> = 200 #<safe_height> = 10 G01 X#1 Y#2 F#<drill_feed_rate> ;Set Feed Rate Slow G01 Z#<drill_depth> ;Drill hole, Coordinated motion ("Straight feed") F#<move_feed_rate> ;Set Feed Rate Fast G01 Z#<safe_height> ;Go up to safe height o100 endsub ; drill holes o100 call [-12.34] [7.125] o100 call [-12.34] [-7.125] o100 call [0] [14.25] o100 call [0] [-14.25] o100 call [12.34] [7.125] o100 call [12.34] [-7.125] ; return to zero G00 X0 Y0 M5 %
Using a Subroutine to Cut Circle
% ; From centre X/Y cut a hole of Radius R - presumes last state was safe height ; #1 = X ; #2 = Y ; #3 = R o100 sub #<drill_depth> = -4 #<drill_feed_rate> = 50 #<move_feed_rate> = 200 #<safe_height> = 5 G01 X#1 Y#2 Z#<safe_height> G02 X#1 Y#2 I#3 J0 ; F#<drill_feed_rate> ;Set Feed Rate Slow ; G01 Z#<drill_depth> ;Drill hole, Coordinated motion ("Straight feed") ; F#<move_feed_rate> ;Set Feed Rate Fast ; G01 Z#<safe_height> ;Go up to safe height o100 endsub o100 call [0.0] [0.0] [15.0] %