I'm trying to hand-code a program to do some turning on my RF-30 mill and I'm trying to wrap my head around subroutines. The program below is for a Mach3 controller and takes a Cut Depth and Cut Length parameter, then loops however many times from the start point.
I've never written a program by hand before, so I was wondering if any of you see any major flaws with this approach. Cheers, and thanks for any insight.
Code:
( Axle )
G20 G90 G91.1 G64 G40 G49
G0 Z0.25
T0 M6
G17
M3 S1900
G0 Z0
G1 F5 X.250
#1=.010 (SUBROUTINE DEPTH)
#2=1.27 (SUBROUTINE LENGTH)
M98 P100 L12
(FINISH PASS)
G1 F5 X.123
G1 F17 Z-1.270 X.125 (TAPER SPRING PASS)
G1 X.350
M5
M30
O100
(TURNING SUBROUTINE)
G91 (BEGIN INCREMENTAL)
G1 F5 X[0-#1] (CUT DEPTH)
G1 F17 Z[0-#2] (CUT LENGTH)
G1 X#1 (PULL OUT TO START X")
G0 Z#2 (RAPID TO START Z)
G1 F7 X[0-#1] (BACK TO START X)
G90 (END INCREMENTAL)
M99
%