Tool changes And Z Height

Hey makermatt,

my M6 ‘tool-change’ routine does not differ much from the second part of Mike’s bit setter macro but his is a two-part tool setter routine (one runs at ‘program start’, one at ‘tool change’ in the SETTINGS page). Besides the fact that I have other dialogs and helpful comments in the code, it does what a tool setter does: It probes and stores the first tool Z at program start, remembers the previous G92 offset which is your workpiece Z zero (=workpiece height) that you probed (or manually set) before program run, and on the next tool change with probing Z, computes the new Z height according to the difference of the first tool to the second tool. It saves the G92 offset each time with G92.2 and restores is with G92.3.

Here I took Mike’s Bit setter macro v2.0 and added Aiph5u-style comments so you can better understand and tweak it:

Part one, for the ‘program-start’ field in the settings page:

(Runs at 'program-start')
(This is Mike's Bit Setter Macro v2.0 2021-01-13, with comments added by Aiph5u on 2024-03-31 v1.0)
M70 ; Save modal states
M5 ; Stop the spindle
G21 ; Set metric units mode
G40 ; Turn cutter compensation off
G49 ; Cancel Tool Length Compensation
G17 ; Select XY plane
G90 ; Set absolute distance mode
G53 G0 Z-10 ; Lift Z rapidly to Z=-10 mm in absolute machine coordinates - manual tool change position
G53 G0 X780 Y50 ; Go rapidly to X=780 mm, Y=50 mm in absolute machine coordinates - manual tool change position
M0 (MSG, Attach Probe Magnet, Attach Dust Boot, Click "Continue")
G0 Z10 ; Go rapidly to a position 10 mm above currently active workpiece Z zero
G92.2 ; Turn off G92 offsets but keep parameters 5211 - 5219 available.
F100 ; Set feedrate to 100 mm/min for probing. (which means slow)
G38.2 Z-133 ; Move the milling motor downwards until the bit touches the touch plate
#5000=#<_Z> ; Set the user parameter 5000 to the current Z position value
G53 G0 Z-10 ; Lift Z to rapidly to Z=-10 mm in absolute machine coordinates - manual tool change position
M0 (MSG, Remove Probe Magnet, Click “Continue”)
G92.3 ; G92.3 - Restore the G92 offset to the values previously saved in parameters 5211 to 5219
G0 X0 Y0 ; Rapidly move to your workpiece X and Y origin
M72 ; Restore modal states
G90 ; Set absolute distance mode
G17 ; Select XY plane

Part two, for the ‘tool-change’ field in the SETTINGS page:

(Runs at 'tool-change')
(This is Mike's Bit Setter Macro v2.0 2021-01-13, with comments added by Aiph5u v1.0 on 2024-03-31)
M70 ; Save modal states
S0 ; Set spindle speed to 0
G21 ; Set metric units mode
G40 ; Turn cutter compensation off
G49 ; Cancel Tool Length Compensation
G17 ; Select XY plane
G90 ; Set absolute distance mode
G53 G0 Z-10 ; Go rapidly to Z=-10 mm in absolute machine coordinates - manual tool change position
G53 G0 X780 Y50 ; Go rapidly to X=780 mm, Y=50 mm in absolute machine coordinates - manual tool change position
M0 (MSG, Remove Dust Boot, Change Tool, Attach Probe, Click "Continue")
G92.2 ; Turn off G92 offsets but keep parameters 5211 - 5219 available.
F100 ; Set feedrate to 100 mm/min for probing. (which means slow)
G38.2 Z-133 ; Move the milling motor downwards until the bit touches the touch plate
#4999=#<_Z> ; Set the user parameter 4999 to the current Z position value
G92.3 ; G92.3 - Restore the G92 offset to the values previously saved in parameters 5211 to 5219
G0 Z25.4 ; Go rapidly to a 25.4 mm above currently active workpiece Z zero
G92 Z[#5000-#4999+25.4] ; Compute the new Z offset by subtracting new tool length offset from old tool length offset and make this the new tool length offset
G53 G0 Z-10 ; Lift Z rapidly to Z=-10 mm in absolute machine coordinates - manual tool change position
#5000=#4999 ; Set user parameter 5000 to the value in user parameter 4999
M0 (MSG,REMOVE MAGNET!!!, Replace Dust Boot, Click “Continue”)
G0 X0 Y0 ; Rapidly move to your workpiece X and Y origin
M72 ; Restore modal states

The above is Mike’s Bit Setter Macro v2.0, I changed nothing except that I put some g-codes in the preamble to one code per line for more space for the comments.

:warning: This bit setter macro assumes that you know which tool Nr. is the bit to be first used in the program, that you mounted it into the collet and secured it with the two wrenches and that you probed or manually set your workpiece Z zero height before starting the toolpath program.*

I can’t test this tool setter routine because I have no machine attached to my Onefinity controller at the moment (waiting for a move). So if you can test it I am sure the forum members will be interested in your report, also I can help you to tweak it. The tool change position (X=780, Y=50) is obiously near the right end of a Wooworker (816 × 816 mm). You can also have your manual tool change position on the left end, by setting it to X=0, Y=0 (which is the machine home).

Possible Modifications

  1. In order to have the tool number honored, I would replace (MSG, …Change Tool…) by (DEBUG, …insert tool Nr. #<_selected_tool>…)
    Note: "DEBUG resolves the parameters, MSG does not
  2. Friendlier dialogs :slight_smile:

Part one, for the ‘program-start’ field in the settings page:

(Runs at 'program-start')
(This is Mike's Bit Setter Macro v2.0 2021-01-13, with comments and different dialogs added by Aiph5u on 2024-03-31 v1.1)
M70 ; Save modal states
M5 ; Stop the spindle
G21 ; Set metric units mode
G40 ; Turn cutter compensation off
G49 ; Cancel Tool Length Compensation
G17 ; Select XY plane
G90 ; Set absolute distance mode
G53 G0 Z-10 ; Lift Z rapidly to Z=-10 mm in absolute machine coordinates - manual tool change position
G53 G0 X780 Y50 ; Go rapidly to X=780 mm, Y=50 mm in absolute machine coordinates - manual tool change position
M0 (MSG, Please connect the touch plate to the controller, place the touch plate underneath the bit and attach the magnet end to the collet of your milling motor. Click "Continue" if you're ready.)
G0 Z10 ; Go rapidly to a position 10 mm above currently active workpiece Z zero
G92.2 ; Turn off G92 offsets but keep parameters 5211 - 5219 available.
F100 ; Set feedrate to 100 mm/min for probing. (which means slow)
G38.2 Z-133 ; Move the milling motor downwards until the bit touches the touch plate
#5000=#<_Z> ; Set the user parameter 5000 to the current Z position value
G53 G0 Z-10 ; Lift Z to rapidly to Z=-10 mm in absolute machine coordinates - manual tool change position

M0 (MSG, Please remove the magnet end from the collet, remove the touch plate, attach the dust boot and start the router. Click “Continue” if you’re ready.)

G92.3 ; G92.3 - Restore the G92 offset to the values previously saved in parameters 5211 to 5219
G0 X0 Y0 ; Rapidly move to your workpiece X and Y origin
M72 ; Restore modal states
G90 ; Set absolute distance mode
G17 ; Select XY plane

Part two, for the ‘tool-change’ field in the SETTINGS page:

(Runs at 'tool-change')
(This is Mike's Bit Setter Macro v2.0 2021-01-13, with comments and different dialogs added by Aiph5u on 2024-03-31 1.1)
M70 ; Save modal states
S0 ; Set spindle speed to 0
G21 ; Set metric units mode
G40 ; Turn cutter compensation off
G49 ; Cancel Tool Length Compensation
G17 ; Select XY plane
G90 ; Set absolute distance mode
G53 G0 Z-10 ; Go rapidly to Z=-10 mm in absolute machine coordinates - manual tool change position
G53 G0 X780 Y50 ; Go rapidly to X=780 mm, Y=50 mm in absolute machine coordinates - manual tool change position
M0 (DEBUG, Please remove the dust boot, remove the tool and insert tool Nr. #<_selected_tool> and tighten the collet with both wrenches. Then please connect the touch plate to the controller, place the touch plate underneath the bit and attach the magnet end to the collet of your milling motor. Click "Continue" if you're ready.)
G92.2 ; Turn off G92 offsets but keep parameters 5211 - 5219 available.
F100 ; Set feedrate to 100 mm/min for probing. (which means slow)
G38.2 Z-133 ; Move the milling motor downwards until the bit touches the touch plate
#4999=#<_Z> ; Set the user parameter 4999 to the current Z position value
G92.3 ; G92.3 - Restore the G92 offset to the values previously saved in parameters 5211 to 5219
G0 Z25.4 ; Go rapidly to a 25.4 mm above currently active workpiece Z zero
G92 Z[#5000-#4999+25.4] ; Compute the new Z offset by subtracting new tool length offset from old tool length offset and make this the new tool length offset
G53 G0 Z-10 ; Lift Z rapidly to Z=-10 mm in absolute machine coordinates - manual tool change position
#5000=#4999 ; Set user parameter 5000 to the value in user parameter 4999
M0 (MSG, Please remove the magnet end from the collet, remove the touch plate, attach the dust boot, and start the router. Click "Continue" if you're ready.)
G0 X0 Y0 ; Rapidly move to your workpiece X and Y origin
M72 ; Restore modal states

DISCLAIMER: I did not test this tool setter routine. Reports and feedback will surely be appreciated by the community.

See also

Mike’s Updated Bit Setter Macro 2021-07-05

Mike posted an Updated version on 2021-07-05 which is shown here:

Part one, for the ‘program-start’ field in the settings page:

(Runs at program start)
(This is Mike's Updated Bit Setter Macro v2021-07-05)
G90 ; Absolute distance mode
G17 ; Select XY plane
#5000=-999
o10 sub
    G53 G0 Z-10
    G53 G0 X780 Y50
    o15 if [[#5000] EQ -999]
        M0 (msg, Remove Dust Boot, Attach Magnet, Click "Continue"…)
    o15 else
        G53 G0 X600
            M0 (debug, Remove Dust Boot, Insert Tool #<_selected_tool>, Attach Magnet, Click "Continue"…)
            G53 G0 X780
    o15 endif
    G92.2
    G53 G0 Z-70
    G38.2 Z-133 F100
    G0 Z[#<_Z>+1] F100
    G38.2 Z-133 F25
o10 endsub

Part two, for the ‘tool-change’ field in the SETTINGS page:

(Runs on M6, tool-change)
(This is Mike's Updated Bit Setter Macro v2021-07-05)
M70
S0 M5
G21 G40 G49 G17 G90
o20 if [[#5000] EQ -999]
    o10 call
    #5000 = #<_Z>
    G53 G0 Z-10
    G92.3
o20 endif
o10 call
#4999= #<_Z>
G92.3
G0 Z25.4
G92 Z[#5000-#4999+25.4]
G53 G0 Z-10
#5000 = #4999
M0 (MSG,Remove Probe, Install Dust Boot, Click "Continue"…)
G0 X0 Y0
M72
3 Likes