Custom GCode to offset tool height on Tool Change
Posted: Sun Apr 05, 2020 7:04 am
Hi all - managed to get my 8x4 handmade CNC working over the past few weeks and decided I wanted to have a probe switch to help offset the z height on tool changes, here's a few pictures of the setup and the GCode I'm using - seems to be working so far but any improvements/tweaks are always welcomed:
Tool-Change Code:
G91 G0 Z8 (shift to safe height)
G21 G40 G49
G17
G90
G53 G0 X550 Y24.5 F600 (move to probe switch position)
M5
M0(MSG, Click 'Continue' when the spindle has stopped)
G38.2 Z-90 F100 (probe current tool)
#5000=#<_z> (set variable #5000 to current z height that triggered switch)
G53 G0 X550 Y24.5 Z0.0 F300 (move to safe height to change the tool)
M0(MSG, Change tool)
G38.2 Z-90 F100 (probe new tool)
#4999=#<_z> (set variable #4999 to new z height that triggered switch
G0 Z0 F300 (move to old Z0)
G92 Z[#5000-#4999] (set new Z0 to offset difference in tool height)
Tool-Change Code:
G91 G0 Z8 (shift to safe height)
G21 G40 G49
G17
G90
G53 G0 X550 Y24.5 F600 (move to probe switch position)
M5
M0(MSG, Click 'Continue' when the spindle has stopped)
G38.2 Z-90 F100 (probe current tool)
#5000=#<_z> (set variable #5000 to current z height that triggered switch)
G53 G0 X550 Y24.5 Z0.0 F300 (move to safe height to change the tool)
M0(MSG, Change tool)
G38.2 Z-90 F100 (probe new tool)
#4999=#<_z> (set variable #4999 to new z height that triggered switch
G0 Z0 F300 (move to old Z0)
G92 Z[#5000-#4999] (set new Z0 to offset difference in tool height)