Here is the WHILE loop that I added to the program to make this work in an automated fashion. I added this to the rook since I was already done with the queen but I have used this technique a few times for non-chess parts.
#1 = 10 (Roughing Passes)
#2 = 2 (finishing passes)
#3 = [#1 + #2] (total passes)
#4 = 0.013 (Rough DOC)
#5 = 0.004 (Fine DOC)
#6 = [[#1 * #4]+[#2*#5]] (total material removed)
#7 = 0 (Z holding place value)
(DEBUG, #1 = num rough)
(DEBUG, #2 = num fine)
(DEBUG, #3 = total passes)
(DEBUG, #6 = material to remove)
M1
(----- Start of G-code -----)
()
G7 (Dia. Mode)
G18 (XZ Plane)
G90 (Absolute Distance Mode)
G40 (Turn Cutter Compensation Off)
G91.1 (Arc Incremental IJK)
G20 (units in inches)
G54 (Work Offset)
G30 (Park Tool)
T2828
G96 S 351 D 2000
G95 F 0.0120 (Units per Revolution Mode)
M8 (Flood Coolant ON)
M3 (Spindle ON, Forward)
G0 z0.5 (go to known position)
G10 L20 P1 Z[0.5 -#6] (move enough for total material removal)
o101 while [#3 GT 0]
G0 X1.3000 ( go to safe X, then start Z before issuing G71)
G0 Z0.2600
(G71 P1192 D0.0100 F0.0120 J0.0060 L6 I0.0030 K0.0030 R0.0100 E1)
(Finish Pass)
G96 S 351 D 2000
G95 F 0.0020 (Units per Revolution Mode)
G0 X1.3000 ( go to safe X)
G0 Z0.2600 ( go to start Z)
G42 (Cutter compensation - on)
G0 X0.0000 Z0.2600
G1 X0.0000 Z0.0000
G1 X0.1185 Z-0.1310
G2 X1.0923 Z0.0000 I0.1051 K0.5795
G1 X1.2000 Z0.0000
G40 (cutter compensation - off)
G1 X1.3000 ( go to safe X)
G0 Z0.400 ( go to safe Z)
o103 IF [#1 LT 2] (check to see if that was the last roughing pass or any finish pass)
M1
G10 L20 P1 Z[0.4+ #5]
#2=[#2-1]
(DEBUG, #1 = num rough)
(DEBUG, #2 = num fine)
o103 ENDIF
o102 IF [#1 GT 1] (check to see if still roughing after this)
(DEBUG,#1)
M1
G10 L20 P1 Z[0.4+ #4]
#1=[#1-1]
(DEBUG, #1 = num rough)
(DEBUG, #2 = num fine)
o102 ENDIF
#3 = [#1 + #2] (total passes)
(DEBUG, #3 = total passes)
o101 endwhile
(“o-code subroutine for profile”)
(Note: all profile subroutine code is in parenthesis)
(o1192 SUB)
( G1 X0.0000 Z0.2600)
( G1 X0.0000 Z0.0000)
( G1 X0.1185 Z-0.1310)
( G2 X1.0923 Z0.0000 I0.1051 K0.5795)
( G1 X1.2000 Z0.0000)
(o1192 ENDSUB)
M9 (All Coolant Off)
M5 (Spindle OFF)
G30 (Park Tool)
()
(----- End of Profiling -----)
M30 (end program)