Hello! I'll try to keep my explanation as short as possible. I'm learning, playing and have a small GRBL machine. I was able to steal / modify / make a macro that successfully facilitates a bit change at a fixed location. Essentially, the macro touches, I change the bit, touch again and Z Zero is shifted accordingly. It works fine. Again, I found some examples and refined it for my setup.

Now, I want to explore combining GCODE files that use different tools; so I can basically run one file and the bit change occurs right in the process.

Anyway! I was working on a project today and tried all of this out. It generally works, except for the fact that for some reason the Z offset change is not working correctly now, within the file. When it starts machining after the bit change, it wants to dive way, way too deep. The file below was very long and I shortened the boring machining sections and you'll see *** notes in there. The important stuff is the beginning, tool change and final machining.

Can anyone see any issues that I might be able to correct? Would be highly appreciated!! Thanks!

-Brian



T1
G17
G21
G90
G0Z20.320
G0X0.000Y0.000
S16000M3
G0X18.411Y86.089Z5.080
G1Z-1.191F635.0
G1X16.864Y85.009F1524.0

*** (BEFORE AND AFTER THIS NOTE IS JUST MACHINING - M5 IS WHERE MY TOOL CHANGE BEGINS

G1X32.742Y21.228
G1X31.839Y21.115
G1X30.964Y20.833
G1X30.174Y20.381
G1X29.469Y19.817
G1X28.848Y19.139
G1X28.396Y18.349
G1X28.086Y17.502
G1X27.916Y16.599
G1Y15.696
G1X28.086Y14.793
G1X28.396Y13.946
G0Z5.080

M5
%wait
%SAFE_HEIGHT = -5
%TOOL_PROBE_X = -34
%TOOL_PROBE_Y = -310
%TOOL_PROBE_Z = -10
%PROBE_DISTANCE = 110
%PROBE_FEEDRATE = 300
%RETRACTION_DISTANCE = 10
%X0=posx, Y0=posy, Z0=posz
%WCS = modal.wcs
%PLANE = modal.plane
%UNITS = modal.units
%DISTANCE = modal.distance
%FEEDRATE = modal.feedrate
%SPINDLE = modal.spindle
%COOLANT = modal.coolant
M5
G90
G21
G53 Z[SAFE_HEIGHT]
G53 X[TOOL_PROBE_X] Y[TOOL_PROBE_Y]
G53 Z[TOOL_PROBE_Z]
%wait
M0
G91
G38.2 Z-[PROBE_DISTANCE] F[PROBE_FEEDRATE]
G0 Z2
G38.2 Z-5 F45
G90
%ORIGINAL_TOOL = posz ;store current work position
G4 P0.5
G91
G0 Z[RETRACTION_DISTANCE]
G90
G53 Z[SAFE_HEIGHT]
%wait
M0
%wait
G53 Z[TOOL_PROBE_Z]
G91
G38.2 Z-[PROBE_DISTANCE] F[PROBE_FEEDRATE]
G0 Z2
G38.2 Z-25 F45
G90
G4 P0.25
G10 L20 Z[ORIGINAL_TOOL]
G4 P0.25
G91
G0 Z[RETRACTION_DISTANCE]
G90
G53 Z[SAFE_HEIGHT]
%wait
M0
G0 X[X0] Y[Y0]
G0 Z[Z0]
[WCS] [PLANE] [UNITS] [DISTANCE] [FEEDRATE] [SPINDLE] [COOLANT]

***(NEXT MACHINING BEGINS HERE, AFTER TOOL CHANGE)

T1
G17
G21
G90
G0Z20.320
G0X0.000Y0.000
S16000M3
G0X33.300Y15.163Z5.080
G1Z0.000F254.0
G1X33.516Y15.265Z-0.006
G1X33.723Y15.438Z-0.013
G1X33.888Y15.661Z-0.020
G1X33.989Y15.909Z-0.027

(MACHINING CONTINUES)