"Automatic" Tool Length Offset


(Neil Ferreri) #1

I do everything I can to avoid tool changes in a job. Even when I probe for Z height, I run into the occasional issue.
I’ve been messing around with macros in CNCjs and wanted to share something that I think is pretty cool. In a job with a M6 tool change command, my macro will:

  1. Go to a designated tool length offset (TLO) probe location in machine coordinates. Wait for confirmation.

  2. Probe the Z axis & store the information.

  3. Go to a tool change location and wait for tool change & confirmation.

  4. Return to TLO probe location. Wait for confirmation.

  5. Probe the Z axis & calculate the difference from the previous tool. Apply a tool length offset using G43.1
    Wait for confrimation.

  6. Go to tool change location (to remove wires & stuff). Wait for confirmation.

  7. Restore all modal states, return to last location in job, continue job on resume.

Unfortunately, I’m no videographer, so the video I tried to get was garbage. I did capture the post tool change carving - below. I went from a long .25" end mill to a much shorter (~20mm) .125" one. The test carve I did had an intentional overlap of toolpaths, so I could assess the precision. In an earlier, non-carving, test I measured the difference in Z to be less than .001".

I just used an aluminum block laid on my wasteboard as a probe plate. Eventually, I may mill a pocket for a smaller probe plate so it doesn’t move. I really don’t need the “tool change location”, but it helped remind me of the steps.

Anyway, hope someone can use this. I’ve attached the TLO macro for CNCjs.

Video after tool change - https://photos.app.goo.gl/3PenMJsd9C6LKAzE3

I have another video where I tried the idea on another machine that I’m not going to post for reasons…if you want to see it, let me know and I’ll PM you a link.


CNCJS CNC Control Software
Consistent Z for relief but inconsistent for pockets. What went wrong?
Building a simple bank
New Linear Z - Rev 2 - Now updated for easy tram adjustment
(Neil Ferreri) #2

Finally made a video demonstrating the functionality of the tool length offset macro. I’ve attached the more recent one (used in video) to this post.
Sorry about the video quality…I’m no videographer. Was doing some machine tune-ups when I made this.
Let me know if you have questions.


TLO_SO3_XL macro.nc (2.4 KB)

Switching between bits in 1 project
(Idan) #3

Thanks for the script!

CNC js looks like a solid replacement to CM. Anything you miss having or have you used it all along?


(Luke) #4

I’m just re-visitng this. Can you tell me the bits I should be changing for my machine? I don’t have an XXL. I want to send the machine to to front right corner for probing and tool change.

In an ideal world

  • I’d finish Job A
  • Run Macro
  • Go to Machine front right
  • Change tool
  • Probe
  • Return to 0

If I can give you the details can you tell me what to change?

Thanks

Luke


(Neil Ferreri) #5

@MrBeaver When you say “finish Job A”, do you mean you’d run an entire job? This macro was meant for a tool change within a job. If you’re planning on using it that way (as a tool change / tool length offset), the key is this section at the top (added some comments to help explain):
%SAFE_HEIGHT = -20 ;MACHINE COORDINATE This is distance from the Z limit switch for travel moves
%TOOL_CHANGE_X = -300 ;Decided not to use in this version, everything happens in the same spot
%TOOL_CHANGE_Y = -300 ;Decided not to use in this version, everything happens in the same spot
%TOOL_CHANGE_Z = -10 ;MACHINE COORDINATE This is distance from the Z limit switch for tool change
%TOOL_PROBE_X = -710 ;MACHINE COORDINATE Location for probe (and tool change)
%TOOL_PROBE_Y = -300 ;MACHINE COORDINATE Location for probe (and tool change)
%TOOL_PROBE_Z = -35 ;MACHINE COORDINATE This is distance from the Z limit switch to start probing
%PROBE_DISTANCE = 100 ;Max distance to probe for Z
%PROBE_FEEDRATE = 75 ;Probe feedrate
%RETRACTION_DISTANCE = 10 ;Retract after probe (relative distance)

Basically, I would recommend you change the TOOL_PROBE_X & TOOL_PROBE_Y machine coordinates to match where you want the probing and tool changing to happen. You can fine tune the Z heights for speed. I kept the TOOL_PROBE_Z and TOOL_CHANGE_Z different, so I would know something happened. The part I don’t like right now is that CNCjs can’t display custom messages on program pauses.
The sequence as it is:

  1. Pause at tool change in gcode

  2. Go to probing location

  3. Probe with original tool

  4. Retract for tool change

  5. Go back to probe height

  6. Probe with new tool

  7. Retract to probe height (to remove wires and such)

  8. Return to pre-tool change macro position and resume job

If that doesn’t sound like what you’re trying to do, let me know and I might be able to help out.


(Luke) #6

Thanks for coming back so quickly.

I usually export my jobs by tool length, at this stage I’d rather have it as a standalone macro. I can then test and get familiar with it.

Thanks for the extra commentary that helps. When doing the tool change - how do I know when it pauses? Any chance I can use an external resume button? It’s not on the CM board but I have it.

How does this look? It feels very wrong.
G90
; Go to Safe Z
G53 Z-10
; Go to tool probe X,Y
G53 X10 Y800
G53 Z[TOOL_PROBE_Z]
; Wait until the planner queue is empty
%wait
; Pause the program before probing
M1
; Cancel tool length offset
G49
; Probe toward workpiece with a maximum probe distance
G91 ; Relative positioning
G38.2 Z-150 F75
G0 Z2 ;lift 2mm
G38.2 Z-5 F45 ;Probe Z
G90 ; Absolute positioning
%ORIGINAL_TOOL = [posz]
; A dwell time of one second to make sure the planner queue is empty
G4 P1

; Retract from the touch plate
G91 ; Relative positioning
G0 Z-10
G90
G53 Z-10

; Wait until the planner queue is empty
%wait
; Pause the program for a manual tool change
M1
; Wait until the planner queue is empty
%wait
G53 Z-150
; Pause the program before probing
M1
; Cancel tool length offset
G49
; Probe toward workpiece with a maximum probe distance
G91 ; Relative positioning
G38.2 Z-150 F75
G0 Z2 ;lift 2mm
G38.2 Z-25 F45 ;Probe Z
G90 ; Absolute positioning
; A dwell time of one second to make sure the planner queue is empty
G4 P1
; Update the tool length offset
G43.1 Z[posz-ORIGINAL_TOOL]
; Retract from the touch plate
G91 ; Relative positioning
G0 Z-10
G90 ; Absolute positioning
; Raise to tool change Z
G53 Z[TOOL_CHANGE_Z]
; Wait until the planner queue is empty
%wait
; Pause the program for cleanup (e.g. remove touch plate, wires, etc)
M1
; Go to previous work position
G0 X[X0] Y[Y0]
G53 Z20


(Neil Ferreri) #7

Careful with your positives and negatives, depending on your setup.
I work in negative machine space (grbl default), so I home back right (Z top) and my work piece is always in negative XYZ.

Are you sure you don’t want X-10 Y-800?

This is a relative move, and would move the spindle down 10mm, into the probe block. You have that in a couple places.

150mm below limit switch. Too far on my machine…I’d rather the probe take longer.

20mm ABOVE limit switch

These don’t mean anything unless the variables are defined. Maybe you left that part out. If you want to go back to X0Y0, just use G0 X0 Y0. the brackets are for stored values.

Now that I’m looking at these macros again, I may simplify it. I used the G43.1 (Tool Length Offset) because that’s how tool changes are traditionally handled. It might make more sense to use a G10 L20 command.

If you confirm your machine position for probing, I could try to make something more concise.


(Neil Ferreri) #8

@idank I’m sorry I missed your reply.
I’ve tried a bunch of free gcode streaming software and I always come back to CNCjs. The only thing I’d say I wish I could do is autolevel. Bcnc & Chilipeppr both autolevel, but are lacking in usability (bcnc) and features/reliability (chillipeppr). CNCjs is just simple, feature packed, open, and has a slick GUI.


(Luke) #9

That would be great thank you!

I checked and you are right - negative numbers. I’d like to have the machine go to X-10, y-800 and Z-10 for tool change/probe.

I’d like to use the play button to action things? I think M1 command?

Ideally I’d like to use it in this way:

Run macro which takes to probe position
Press play to probe - return to top of Z (-10)
Manual tool change
Press play to probe again
press play and returns to 20mm above zero

Thanks

Luke


(Neil Ferreri) #10

Not sure on his handling of the pauses right now, but you’ll have to click “continue” a four times through the macro (ready to probe, tool changed, ready to probe, all done). I left the pauses as M0 because during my testing I was able to jack things up with an M1. I had to try pretty hard, but, right now, the M0 is the safer choice.

I’ve attached a macro that should do what you were hoping. Let me know how it goes.
ToolChange_standalone.NC (2.4 KB)


(Luke) #11

Amazing

I will look to try it this evening and let you know my results!

Thank you very much for helping.


(Luke) #12

I just took a crack at loading it into UGCS but it didn’t like it one bit.

Any idea how I would run it in UGCS?


(Neil Ferreri) #13

Aaah… This is for use with CNCjs. Won’t work with any other senders. Been a while since I’ve used UGS, but I don’t think you can use variables or store values. If I’m wrong on that, I’ll take a look when I get back to a computer.


(Luke) #14

That isn’t a problem as I want to move to CNCJS.

Silly question, but why won’t it work in UGCS?


(Neil Ferreri) #15

It’s not pure gcode. Different gcode senders handle certain commands in different ways. The storing of values can’t happen on the controller, grbl isn’t setup for that. CNCjs allows for JavaScript style expressions in its macros. Basically the macro I uploaded for you stores the value of your probe’s height relative to your work’s Z0. Let’s say your probe surface is at work Z-4.225 with the original end mill. When you put a different end mill in and probe, chances are the probe surface is a different distance. The macro just waiting for the new tool to contact the probe and makes that position equal to Z-4.225. That all means that Z0 is the exact same for your new tool as it was for the original.


(Luke) #16

Very useful to know! Thank you.

I’ll test it asap


(Luke) #17

just thinking about this

Could you also create an easy to modify code for probing?


(Neil Ferreri) #18

Probably. Depends what you’re looking for.