Page 1 of 1

Custom GCode to offset tool height on Tool Change

Posted: Sun Apr 05, 2020 7:04 am
by Chris
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)

Re: Custom GCode to offset tool height on Tool Change

Posted: Tue Apr 07, 2020 3:12 pm
by Doug
Nice work. My only suggestion would be to insert an M70 at the beginning of the program to save the machine state and M72 at the end of the program to restore the original state after the probing sequence is completed.

Re: Custom GCode to offset tool height on Tool Change

Posted: Wed Apr 08, 2020 12:14 am
by Chris
Thanks Doug - will add that in