(2019/05/12) METRIC
(=======================================)
(WJV sample GRBL UGS g-code )
N010 (probe to find center of circular hole)
N020 (This program should run as given here.)
N030 (Items #1001 through #1006 need to be set to meet your CNC operation)
N000 (The values shown below should work for most systems)
N000 (=== This is for METRIC 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 about 5mm (0.2") above surface of finder ===)
N000 (=== Manually set DROs X=0 Y=0 Z=0 ===)
N000 (=== connect wire to probe and verify circuit works ===)
N000 (=== CYCLE START ===)
N000 (=== When done: Fixture Offset 5 will be enabled with ===)
N000 (=== X=0, Y=0, & Z=0 directly on the corner ===)
N000 (=== To work in default Fixture Set DROs X, Y, Z to zero ===)
()
(=== PROGRAM RUNS FROM HERE === )
N000 G21 (METRIC)
N000 G40 G49 G54 G80 G90 G91.1 (set to default work offset & everything)
N000 G92.1 (Cancel any temporary offsets)
()
M0 (Stopped: Press START to continue)
()
N000 G0 Z25.00 (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 METRIC system ===)
N000 #4 = 125.0 (=== G1 Slow Feed speed mm/M ===)
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 = 3.175 (Thickness of Edgefinder to workpiece mm)
N080 #1004 = [#1003 * 0.80] (Depth into hole: 80% of Edgefinder thickness to work piece)
N100 #1005 = 15.00 (METRIC )
N100 #1006 = 5.00 (METRIC, 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 Good X)
#1022 = 0.000 ([Y_max1 + Y_min1]/2) (calc center 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 Very Good X)
#1042 = 0.000 ([Y_min2 + Y_min2]/2) (calc center Very Good Y)
#1043 = 0.000 ([Z - ]) (Top of workpiece)
()
M0 (Stopped: Press START to continue)
()
(=== find top of edgefinder here ===)
(=== start with probe just over the hole & set DRO X=0, Y=0, & Z=0 ===)
()
N000 G0 Y#1005 (move probe +Y side of hole)
N000 G0 Z#1006 F#4 ()
N130 G38.2 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 (lift off top of surface small distance)
N130 G38.2 Z[#1023 - #1006/5] F[#4/5] (probe for top of edge finder)
N000 #1033 = #2002 (save Z = top of edge finder)
()
N000 G0 Z[#1033 + #1006] (lift to 0.200 above Edge finder)
N110 G0 X#1001 Y#1002 (move above nominal hole center)
()
(=== calculate a safe distance into hole ===
N000 #1043 = [#1033 - #1003] (calculate top of work piece)
N000 #1004 = [#1023 - [#1003 * 0.80]] (set to safe distance inside hole)
()
M0 (Stopped: Press START to continue)
()
(=== find center of hole ===)
()
N000 G0 Z[#1033 + #1006] (lift to 0.200" 5mm above Edge finder)
N110 G0 X#1001 Y#1002 (move above nominal hole center)
(=== [1] X- ===)
N120 G1 Z#1004 F#4 (move into hole - to be cautious, substitute G1 for G0 here)
N130 G38.2 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)
(=== [2] X+ ===)
N160 G38.2 X[#1001 + #1005] (probe for +X side of hole)
N170 #1021 = [[#1011 + #2000] / 2.0] (find pretty good X-value of hole center)
()
(=== [3] Y- ===)
N180 G0 X#1021 Y#1002 (back to center of hole)
N190 G38.2 Y[#1002 - #1005] (probe -Y side of hole)
N200 #1012 = #2001 (save results)
(=== [4] Y+ ===)
N210 G0 X#1021 Y#1002 (back to center of hole)
N220 G38.2 Y[#1002 + #1005] (probe +Y side of hole)
N230 #1022 = [[#1012 + #2001] / 2.0] (find pretty good Y-value of hole center)
()
(=== [5] X- again ===)
N250 G0 X#1021 Y#1022 (back to better center of hole)
N260 G38.2 X[#1021 + #1005] (probe +X side of hole)
N270 #1031 = #2000 (save results)
(=== [6] X+ again ===)
N280 G0 X#1021 Y#1022 (back to center of hole)
N290 G38.2 X[#1021 - #1005] (probe -X side of hole)
N300 #1041 = [[#1031 + #2000] / 2.0] (calculate very good X-value of hole center)
()
(=== [7] Y- again ===)
N180 G0 X#1041 Y#1022 (back to better center of hole)
N190 G38.2 Y[#1022 - #1005] (probe -Y side of hole)
N200 #1032 = #2001 (save results)
(=== [8] Y+ again ===)
N210 G0 X#1041 Y#1022 (back to center of hole)
N220 G38.2 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 (Move to VERY GOOD center of hole)
()
G4 P#5 (short delay)
N000 G0 Z[#1023 + #1003 + #1006] (clear the hole to remove edgefinder)
G4 P#6 (long delay)
()
(=== Set Work OFFSET 5 & 10 to put X0 Y0, & Z0 over the corner of the workpiece ===)
()
( === G58 P5 Work Offset 5 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)
()
M0 (Stopped: Press START to continue)
()
N000 G58 (=== USE WORK OFFSET 5 as REFERENCE X0, Y0, & Z0 ===)
()
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 (PROGRAM END: that's all, folks)
(M30) (END & REWIND)
(============================================)
(M-code Meaning For MACH3)
(M0 Program stop )
(M1 Optional program stop )
(M2 Program end )
(M3/4 Rotate spindle clockwise/counterclckwise )
(M5 Stop spindle rotation )
(M6 Tool change) (by two macros)
(M7 Mist coolant on M8 Flood coolant on)
(M9 All coolant off )
(M30 Program end and Rewind )
(M47 Repeat program from first line )
(M48 Enable speed and feed override )
(M49 Disable speed and feed override )
(M98 Call subroutine M99 Return from subroutine/repeat )