(2018/05/22) INCH
(=======================================)
(WJV sample GRBL UGS g-code )
N010 (probe to find center of circular hole)
N020 (This program should run as given here.)
N030 (insert numbers in place of .)
N040 (Delete lines N020, N030, and N040 when you do that.)
N000 (=== this is for inch system ===)
N000 (=== To use: ===)
N000 (place the Edgefinder on the corner of the workpiece ===)
N000 (=== position the probe over the approximate center of the hole ===)
N000 (=== Set Z above near surface of finder ===)
N000 (=== Manually set DRO X=0 Y=0 Z=0 ===)
N000 (=== connect wire to probe and verify circuit works ===)
N000 (=== CYCLE START ===)
N000 (Zero X, Y, & Z, DRO when instructed)
()
(=== PROGRAM RUNS FROM HERE === )
N000 G20 (INCH)
N000 G40 G49 G54 G80 G90 G91.1 (set to default work offset)
N000 G52 X0 Y0 Z0 (Cancel any temporary offsets)
()
M0 (Stopped: Press START to continue)
()
N000 G0 Z1.0000 (go to safe height)
N000 G0 X0.0000 Y0.0000 (Go to X & Y zero)
()
(=== SETUP OPERATION FOR YOUR SYSTEM ===)
(=== CAUTION THIS IS setup for INCH system ===)
N000 #4 = 5.0 (=== G1 Slow Feed speed IPM ===)
N000 #5 = 1.0 (=== G4 Dwell short time seconds ===)
N000 #6 = 2.5 (=== G4 Dwell long time seconds ===)
()
N060 #1001 = 0.0000 ()
N070 #1002 = 0.0000 ()
N080 #1003 = 0.1250 (Thickness of Edgefinder to workpiece)
N080 #1004 = [#1003 * 0.80] (Depth into hole: 80% of Edgefinder thickness to work piece)
N100 #1005 = 0.0370 ( )
N100 #1006 = 0.0200 ( close to surface of edge finder)
()
(=== Temporary storage for edge finder to find center of hole)
#1011 = 0.000 (X_min1) (first pass)
#1012 = 0.000 (Y_min1) (first pass)
#1021 = 0.000 ([X_max1 + X_min1]/2)(calc center X) (Good X)
#1022 = 0.000 ([Y_max1 + Y_min1]/2)(calc center Y) (pretty Good Y)
#1023 = 0.000 (Z top of finder)
#1031 = 0.000 ([X_min2) (second pass)
#1032 = 0.000 ([Y_min2) (second pass)
#1041 = 0.000 ([X_min2 + X_min2]/2)(calc center X) (Very Good X)
#1042 = 0.000 ([Y_min2 + Y_min2]/2)(calc center Y) (Very Good Y)
#1043 = 0.000 ([Z - ]) (Top of workpiece)
()
M0 (Stopped: Press START to continue)
()
(=== find top of edgefinder here ===)
N000 G0 Y#1005 (move probe +Y side of hole)
N000 G0 Z#1006 F#5
N130 G31 Z[0.0000 - [#1002*2]] F#4 (probe for top of edge finder)
N000 #1023 = #2002 (save Z = top of edge finder)
()
(=== second try at Z-top ===)
N000 G0 Z[#1023 + #1006/5] F#4
N130 G31 Z[#1023 - #1006/5] F[#4/5] (probe for top of edge finder)
N000 #1033 = #2002 (save Z = top of edge finder)
()
N000 #1004 = [#1023 - #1004] (set to safe distance inside hole)
N000 G0 Z[#1023 + #1006] (Move to 0.200 above Edge finder)
()
#1043 = [#1033 - #1003] (calculate top of work piece)
()
M0 (Stopped: Press START to continue)
()
(=== find center of hole ===)
(=== First X ===)
N110 G0 X#1001 Y#1002 (move above nominal hole center)
N120 G1 Z#1004 F#4 (move into hole - to be cautious, substitute G1 for G0 here)
N130 G31 X[#1001 - #1005] F#4 (probe for -X side of hole)
N140 #1011 = #2000 (save results) (//#2000 is x DRO position)
N150 G0 X#1001 Y#1002 (back to center of hole)
N160 G31 X[#1001 + #1005] (probe for +X side of hole)
N170 #1021 = [[#1011 + #2000] / 2.0] (find pretty good X-value of hole center)
(=== Second Y ===)
N180 G0 X#1021 Y#1002 (back to center of hole)
N190 G31 Y[#1002 - #1005] (probe -Y side of hole)
N200 #1012 = #2001 (save results)
N210 G0 X#1021 Y#1002 (back to center of hole)
N220 G31 Y[#1002 + #1005] (probe +Y side of hole)
N230 #1022 = [[#1012 + #2001] / 2.0] (find pretty good Y-value of hole center)
()
(=== Third X again ===)
N250 G0 X#1021 Y#1022 (back to better center of hole)
N260 G31 X[#1021 + #1005] (probe +X side of hole)
N270 #1031 = #2000 (save results)
N280 G0 X#1021 Y#1022 (back to center of hole)
N290 G31 X[#1021 - #1005] (probe -X side of hole)
N300 #1041 = [[#1031 + #2000] / 2.0] (calculate very good X-value of hole center)
()
(=== Fourth Y again ===)
N180 G0 X#1041 Y#1022 (back to better center of hole)
N190 G31 Y[#1022 - #1005] (probe -Y side of hole)
N200 #1032= #2001 (save results)
N210 G0 X#1041 Y#1022 (back to center of hole)
N220 G31 Y[#1022 + #1005] (probe +Y side of hole)
N230 #1042 = [[#1032 + #2001] / 2.0] (find very good Y-value of hole center)
()
N340 G0 X#1041 Y#1042 (back to VERY GOOD center of hole)
()
G4 P#5 (short delay)
N000 G0 Z[#1023 + #1003 + 0.2000] (clear the hole to remove edgefinder)
G4 P#6 (long delay)
()
( === G58 coordinates )
N000 #5301 = [#5221 + #1041 ] (Work OFFSET 5 X)
N000 #5302 = [#5222 + #1042 ] (Work OFFSET 5 Y)
N000 #5303 = [#5223 + #1043 ] (Work OFFSET 5 Z)
()
( === G59 P10 coordinates )
N000 #5401 = [#5221 + #1041 ](Work OFFSET 10 X)
N000 #5402 = [#5222 + #1042 ](Work OFFSET 10 Y)
N000 #5403 = [#5223 + #1043 ](Work OFFSET 10 Z)
()
M0 (Stopped: Press START to continue)
()
N000 G59 P10
()
(N000 G52 X#1041 Y#1022 Z#1023)
()
M0 (Stopped: Press START to continue)
()
G0 X0 Y0 Z0 (=== This is work-piece X0, Y0, Z0 === work-offset 10 ===)
()
( === you will want to work in G58 or G59 P10 coordinates unless you zero the DROs ===)
()
N000 G54 (set to default work offset)
()
N350 M2 (that's all, folks)