Manual tool change + tool lengh touch off
- MaHa
- Offline
- Platinum Member
-
- Posts: 427
- Thank you received: 182
After eg. T99 is used to touchoff X Y Z , and afterwards probed, it is reverenced with #<_ToolZRef> = #5063
All following probed tools getting offset from first tool with G43.1 Z[#<_ToolZ> - #<_ToolZRef>]
linuxcnc.org/docs/2.8/html/gcode/g-code.html#gcode:g43.1
That is why tooltable is not used for length and G43 is not needed in gcode. DIAM entrys should be done, if cuttercompensation used.
from tool-change:
( My sequence of Running; )
( 1. Use a T99, a .250" Rod, to touch off X, Y, and Z of WCS as modeled in CAM )
( 2. Manually input M600 ) or just enter #<_ToolDidFirst> = 0 in MDI
( 3. Manually call an M6 T99, tool will touch off on toolsetter and store tool height )
( 4. Load program and run, M6 in program will prompt tool change, after changing, tool will touch off and Z will adjust )
( 5. Run any and all code using the same desired Z height for the WCS as designed )
( 6. For new WCS repeat from Step #1 )
Please Log in or Create an account to join the conversation.
- russ
- Offline
- New Member
-
- Posts: 6
- Thank you received: 0
I had just spent the last few hours trying to get gcode to update the tool table but ill just disable it and make sure I number my tools properly. now I can at least put this part to bed, now i need to start looking into a debounce feature since the toolsetter is re-triggering sometimes after detection.
Please Log in or Create an account to join the conversation.
- andypugh
-
- Offline
- Moderator
-
- Posts: 23377
- Thank you received: 4966
I don't need to probe tool lengths as my machine has repeatable tool holders. (What spindle are you using? Given the effort that you are going to in the rest of the router build I would be surprised if you were not using a tool-changing spindle)
Please Log in or Create an account to join the conversation.
- russ
- Offline
- New Member
-
- Posts: 6
- Thank you received: 0
Please Log in or Create an account to join the conversation.
- Todd Zuercher
-
- Offline
- Platinum Member
-
- Posts: 5010
- Thank you received: 1464
Please Log in or Create an account to join the conversation.
- andypugh
-
- Offline
- Moderator
-
- Posts: 23377
- Thank you received: 4966
It very much depends on the work you are doing, and I am generally making it up as I go along

Please Log in or Create an account to join the conversation.
- tightmopedman9
- Offline
- Senior Member
-
- Posts: 69
- Thank you received: 7
Please Log in or Create an account to join the conversation.
- furynick
- Offline
- Junior Member
-
- Posts: 32
- Thank you received: 8
Update configuration file (ini)
[MACROS]
MACRO = init_probe
[TOUCHPLATE]
# Touchplate dimensions
OFFSETX = 3.306
OFFSETY = 3.767
OFFSETZ = 6.172
[TOOLSENSOR]
# Absolute coordinates of the toolsetter pad
X = 680.5
Y = 6.0
# Absolute Z start search coordinates, adjust to match the longest tool
Z =-25.0
# Absolute Z height to safely travel to toolsetter
TRAVELZ = 0.0
# Maximum search distance and direction (sign), adjust to match the difference between the longest and shortest tools
MAXPROBE = -25
[CHANGE_POSITION]
# Absolute coordinates of the tool change point
X = 650.0
Y = 100.0
Z = -10.0
[RS274NGC]
# Relative path to macros folder
SUBROUTINE_PATH = macros
REMAP=M6 modalgroup=6 prolog=change_prolog ngc=change epilog=change_epilog
change.ngc (stored in macros folder)
O<change> sub
;(debug, in change tool_in_spindle=#<tool_in_spindle> current_pocket=#<current_pocket>;)
;(debug, selected_tool=#<selected_tool> selected_pocket=#<selected_pocket>;)
;(debug, current tool z_offset=#5403)
;otherwise after the M6 this information is gone!
#<xpos> = #<_x> (PRINT,save absolute X=#<_x>;)
#<ypos> = #<_y> (PRINT,save absolute Y=#<_y>;)
#<tlo> = #5403 (PRINT,current offset for tool #<_selected_tool>=#<tlo>;)
#<cht> = #<_ini[CHANGE_POSITION]TRAVELZ>
#<chx> = #<_ini[CHANGE_POSITION]X>
#<chy> = #<_ini[CHANGE_POSITION]Y>
#<chz> = #<_ini[CHANGE_POSITION]Z>
#<tsm> = #<_ini[TOOLSENSOR]MAXPROBE>
#<tsx> = #<_ini[TOOLSENSOR]X>
#<tsy> = #<_ini[TOOLSENSOR]Y>
#<tsz> = #<_ini[TOOLSENSOR]Z>
; we must execute this only in the milltask interpreter
; or preview will break, so test for '#<_task>' which is 1 for
; the milltask interpreter and 0 in the UI's
O100 if [#<_task> EQ 0]
O100 return [999]
O100 endif
O200 if [#<_hal[gmoccapy.toolmeasurement]> EQ 0]
O200 return [3] ; indicate no tool measurement
O200 endif
O300 if [#<_hal[gmoccapy.searchvel]> LE 0]
O300 return [-1] ; indicate searchvel <= 0
O300 endif
O400 if [#<_hal[gmoccapy.probevel]> LE 0]
O400 return [-2] ; indicate probevel <= 0
O400 endif
G53 G0 Z[#<cht>] (PRINT,move to travel height)
G53 G0 X[#<chx>] Y[#<chy>] (PRINT,move to change position)
G53 G0 Z[#<chz>]
G49 (PRINT,cancel tool offset)
G92.2 (PRINT,turn off G92 offsets)
M6 (PRINT,real change tool)
O700 if [#<_selected_tool> EQ 99]
G10 L1 P99 Z0 (PRINT,reset probe offset)
O700 else
G53 G0 X[#<tsx>] Y[#<tsy>] (PRINT,move to toolsensor)
G53 G0 Z[#<tsz>]
F #<_hal[gmoccapy.searchvel]> (PRINT,set search speed)
G91 (PRINT,relative move )
G38.2 Z#<tsm> (PRINT,touch sensor)
G0 Z2 (PRINT,release sensor)
F #<_hal[gmoccapy.probevel]> (PRINT,set probe speed)
G38.2 Z-4 (PRINT,touch sensor)
G90 (PRINT,absolute move)
O800 if [#5070 EQ 0]
O800 return [-3] ; indicate probe contact failure to epilog
O800 endif
G10 L10 P[#<_selected_tool>] Z[#4963] (PRINT,set absolute offset for tool #<_selected_tool>;)
G43
O700 endif
G92.3 (PRINT,restore G92 offsets)
G53 G0 Z[#<cht>] (PRINT,move to travel height)
G0 X[#<xpos>] Y[#<ypos>] (PRINT,return to where we were in WCS X=#<xpos> Y=#<ypos>;)
; signal success be returning a value > 0:
O<change> endsub [1]
M2
init_probe.ngc (stored in macros folder)
O<init_probe> SUB
(PRINT,Probe init)
G94 (PRINT,use feedrate in units/min )
G92.1 (PRINT,remove G92 offsets)
G90 (PRINT,absolute distance mode)
G49 (PRINT,cancel tool length compensation)
G40 (PRINT,turn cutter compensation off)
G10 L2 P0 X0 Y0 Z0 (PRINT,reset coordinate system)
O100 IF [ #<_current_tool> NE 99 ] (PRINT,tool loaded: #<_current_tool>;)
T99 M6 (PRINT,mount probe)
O100 ENDIF
O101 IF [ #<_metric> EQ 1 ] (PRINT,set probe feeds according to units )
#<fast> = 150.0 (PRINT,selected metric units )
#<slow> = 30.0
#<retract> = 3.0
#<tool_diam> = #5410 (PRINT,tool diameter=#<tool_diam>mm)
O101 ELSE
#<fast> = 6.0 (PRINT,selected imperial units )
#<slow> = 1.2
#<retract> = 0.1
#<tool_diam> = #5410 (PRINT,tool diameter=#<tool_diam>in)
O101 ENDIF
(PRINT,touch plate Z probe)
G38.2 Z[#<_ini[AXIS_Z]MIN_LIMIT>] F[#<fast>] (PRINT,Z probe toward workpiece with error )
G91 (PRINT,relative move )
G0 Z[#<retract>] (PRINT,retract)
G0 Z-[#<retract>/2] (PRINT,move forward half retract distance)
G38.2 Z-[#<retract>] F[#<slow>] (PRINT,Z probe slowly, got Z probe at #5063)
G10 L20 P0 Z[#<_ini[TOUCHPLATE]OFFSETZ>] (PRINT,set Z offset in current WCS)
G0 Z#<retract> (PRINT,retract)
(PRINT,touch plate X probe)
G0 X-[#<retract> + #<tool_diam>] (PRINT,move in front of touch plate)
G0 Z-[#<retract> * 2] (PRINT,go down by twice retract length)
G38.2 X[#<retract> + #<tool_diam>] F[#<fast>] (PRINT,X probe toward workpiece with error )
G0 X-[#<retract>] (PRINT,retract)
G0 X[#<retract>/2] (PRINT,move forward half retract distance)
G38.2 X[#<retract> + #<tool_diam>] F[#<slow>] (PRINT,X probe slowly, got X probe at #5061)
G10 L20 P0 X-[#<_ini[TOUCHPLATE]OFFSETX> + #<tool_diam> / 2] (PRINT,set X offset in current WCS)
G0 X-[#<retract>] Z[#<retract>*2] (PRINT,retract)
(PRINT,Touch plate Y probe)
G0 X[#<retract> + #<tool_diam>] Y-[#<retract> + #<tool_diam>] (PRINT,move below of touch plate)
G0 Z-[#<retract>*2] (PRINT,go down by twice retract length)
G38.2 Y[#<retract> + #<tool_diam>] F[#<fast>] (PRINT,X probe toward workpiece with error)
G0 Y-[#<retract>] (PRINT,retract)
G0 Y[#<retract>/2] (PRINT,move forward half retract distance)
G38.2 Y[#<retract> + #<tool_diam>] F[#<slow>] (PRINT,Y probe slowly, got Y probe at #5062)
G10 L20 P0 Y-[#<_ini[TOUCHPLATE]OFFSETY> + #<tool_diam> / 2] (PRINT,set Y offset in current WCS)
G0 Y-[#<retract>] Z[#<retract> * 2] (PRINT,retract)
G90 (PRINT,absolute move)
G0 X0 Y0 (PRINT,move to travel height)
G53 G0 Z[#<_ini[CHANGE_POSITION]TRAVELZ>] (PRINT,move to safe travel height)
G53 G0 X[#<_ini[TOOLSENSOR]X>] Y[#<_ini[TOOLSENSOR]Y>] (PRINT,move to toolsensor)
G53 G0 Z[#<_ini[TOOLSENSOR]Z>]
F #<_hal[gmoccapy.searchvel]> (PRINT,set search speed)
G91 (PRINT,relative move )
G38.2 Z#<_ini[TOOLSENSOR]MAXPROBE> (PRINT,touch sensor)
G0 Z2 (PRINT,release sensor)
F #<_hal[gmoccapy.probevel]> (PRINT,set probe speed)
G38.2 Z-4 (PRINT,touch sensor)
#4963 = #5063 (PRINT,store probe trigger Z value)
G90 (PRINT,absolute move)
G53 G0 Z[#<_ini[CHANGE_POSITION]TRAVELZ>] (PRINT,move to travel height)
G53 G0 X[#<_ini[CHANGE_POSITION]X>] Y[#<_ini[CHANGE_POSITION]Y>] (PRINT,move to change position)
G53 G0 Z[#<_ini[CHANGE_POSITION]Z>]
O<init_probe> ENDSUB
M2
Please Log in or Create an account to join the conversation.
- furynick
- Offline
- Junior Member
-
- Posts: 32
- Thank you received: 8
Move manually approximately over the bottom/left corner of workpiece
Hit init_probe in gmoccapy
The probe (Tool 99) is loaded if it's not already
3 axis of touchplate are probed (Z, X and Y)
The probe is then probed on toolsetter and offset in current WCS is stored
Spindle is moved back to change position
M6 remap probe every tool on toolsetter using G10 L10 with previously stored offset value
Any comment is welcome to improve/secure the process
Please Log in or Create an account to join the conversation.
- Vector
-
- Offline
- Premium Member
-
- Posts: 112
- Thank you received: 26
The stock code as of this comment isn't usable since it doesn't return the machine to the same location as before the tool-change was called.
There's a pull request that hopes to address that: PR 2706 .
There's also a post of that code at my stand-alone repository .
And there's a video of how it can be setup and used over on youtube .
It's also attached here, substitute it in your QtDragon configuration wherever you find qt_auto_probe_tool.ngc.
All the best.
Please Log in or Create an account to join the conversation.