Worth learning a bit of gcode.
Subroutines and parameters are quite powerful
Example code to get you started. I have not checked this on a machine / linuxcnc simulator. Probably has errors.
Code:
( Zig-Zag Spoilboard Facing Program with Parameters and Subroutine )
( Fully commented for beginners - for use with LinuxCNC )
( Units are millimeters - use G21 for mm or G20 for inches )
G21 ( Set units to millimeters - use G20 for inches )
G17 ( Use XY plane for machining )
G90 ( Use absolute positioning mode )
G64 ( Best path blending mode for smoother motion )
( --- USER-DEFINED PARAMETERS --- )
#100 = 12.0 ( Tool diameter - useful for planning )
#101 = 10.0 ( Step-over between each row in Y direction )
#102 = 1.0 ( Total depth to cut into the spoilboard )
#103 = 0.5 ( Depth per pass - amount to cut per layer )
#104 = 600.0 ( Width of the area to face in X direction )
#105 = 300.0 ( Height of the area to face in Y direction )
#106 = 1000 ( Spindle speed in RPM )
#107 = 500 ( Feedrate in units per minute for cutting moves )
#108 = 5.0 ( Safe Z height above material to avoid collisions )
( --- INTERNAL / TEMPORARY VARIABLES --- )
#110 = 0.0 ( Current Z depth, starts at zero on surface )
#111 = 0 ( Row counter for Y passes )
#115 = 0 ( Direction toggle for zig-zag: zero means forward pass, one means reverse pass )
( --- DERIVED VALUES FROM PARAMETERS --- )
#112 = [#104 / #101] ( Calculate how many rows fit across X based on step-over )
#113 = [#102 / #103] ( Calculate how many depth passes needed to reach total depth )
( --- PROGRAM START --- )
G0 Z#108 ( Move Z to safe height before starting )
M3 S#106 ( Turn spindle on clockwise at RPM from parameter )
G4 P2 ( Wait for 2 seconds to let spindle reach speed )
G0 Z#108 ( Confirm safe Z before any XY moves )
G0 X0 Y0 ( Move to starting XY origin at safe Z )
( --- Z-DEPTH PASS LOOP --- )
#114 = 0 ( Initialize Z pass counter )
o100 while [#114 LT #113] ( Repeat passes until total depth reached )
G0 Z#108 ( Retract to safe Z before repositioning )
G0 X0 Y0 ( Return to XY origin at safe Z )
#110 = [#110 - #103] ( Lower cutting depth by depth per pass )
o110 if [#110 LT -#102] ( If cutting deeper than total depth )
#110 = -#102 ( Clamp cutting depth to max depth )
o110 endif
G1 Z#110 F#107 ( Feed down to current cutting depth )
#111 = 0 ( Reset Y row counter for this depth pass )
#115 = 0 ( Reset zig-zag direction toggle to forward )
( --- Y ROW LOOP --- )
o200 while [#111 LT #112] ( Loop through all rows across Y direction )
o<zigzag_row> call ( Call subroutine to cut one row, direction depends on toggle )
#111 = [#111 + 1] ( Increment Y row counter )
#115 = [1 - #115] ( Toggle direction: 0 becomes 1, 1 becomes 0 )
o200 endwhile ( End Y row loop )
G1 Z#108 F#107 ( Retract to safe Z before next depth pass )
#114 = [#114 + 1] ( Increment Z pass counter )
o100 endwhile ( End Z pass loop )
( --- PROGRAM END --- )
M5 ( Stop spindle )
G0 Z#108 ( Move to safe Z )
G0 X0 Y0 ( Return to origin )
M2 ( End of program )
( --- SUBROUTINE: ZIGZAG ROW --- )
o<zigzag_row> sub
( Cuts one row in X direction, then steps over in Y )
( Uses toggle #115 to choose direction )
o<zigzag_row_dir0> if [#115 EQ 0] ( Forward pass )
G90 ( Use absolute positioning )
G1 X[#104] F#107 ( Move forward in X to max distance )
G91 ( Switch to relative positioning )
G1 Y[#101] F#107 ( Step over in Y by step-over distance )
G90 ( Return to absolute positioning )
o<zigzag_row_dir0> endif
o<zigzag_row_dir1> if [#115 EQ 1] ( Reverse pass )
G90 ( Absolute positioning )
G1 X0 F#107 ( Move X back to zero )
G91 ( Relative positioning )
G1 Y[#101] F#107 ( Step over in Y )
G90 ( Absolute positioning )
o<zigzag_row_dir1> endif
o<zigzag_row> endsub