Tool Length Sensor#

What is a tool length sensor?#

A tool length sensor (TLS for short) measures the length of the cutting tool. It is used to adjust the height offset after a tool change.

Imagine you have a job that uses two tools, T1 and T2. Let’s say T1 is longer and T2 is shorter. For example they could be used for the roughing pass and the finishing pass.

If you don’t set the Z height when you switch from T1 to T2, the second tool will cut higher than it is supposed to because it is shorter. You will have to change the Z zero to have the tip of T2 match the tip of T1.

One way is to reset the Z zero using a Z probe or eyeball it with a piece of paper. This could be inaccurate, and sometimes even impossible if the reference surface has been milled away during the first pass.

That’s where the tool length sensor comes in. It provides a constant reference point that doesn’t depend on the current material state.

It works by measuring the length of the first tool, then the length of the second tool, and then adjusting the Z offset based on the difference between the two lengths.

I will not get into details of how this process works in practice. It very much depends on the sender software and the specific workflow. This article will focus on the making of the sensor itself.

How is a TLS different from a Z probe?#

They are quite similar. Both essentially measure the height at a given position. They often use similar G-code with the G38.2 command.

There are however some fundamental differences:

  • A TLS is usually permanently fixed to the machine, while the Z probe is positioned by hand for every measurement. As such, the TLS is often located at the edge of the working area, away from any cutting operations

  • The height of the Z probe is important for accurate measurements, but the height of the TLS is irrelevant. That’s because what ultimately matters is the relative difference between the tools

  • The accuracy of a TLS is usually more important than that of the Z probe. That’s because the Z probe is used once per job, but the TLS can be used multiple times. Any inaccuracies will show as gaps between the toolpaths

  • A Z probe often requires a separate wire to be connected to the tool with an alligator clip or a magnet. A TLS ideally should not require a connection to the tool. This is especially important with automatic tool changers, where you can’t pause and connect the clip during the program

Sensor types#

Most commonly, a TLS contains an electrical switch. It could be a normally-open switch that makes contact when pushed by the tool, or a normally-closed switch that breaks contact when pushed. The normally-closed switches require very small movement to break the contact and are more accurate.

Another type of TLS relies on electrical contact between the tool and a metal surface. In the simplest form it could have no moving parts. The metal surface can be arbitrarily large and accommodate larger tool widths.

There are purely optical TLS devices that detect the tool using a light beam. They don’t need any moving parts. However they may require the spindle to rotate the tool, because tools have different profiles when viewed from different angles.

A hybrid optical sensor could have a mechanical plunger, which interrupts a light beam.

Off the shelf sensors#

One can purchase an off-the-shelf sensor. Here are a few examples:

They can be very robust, but often have some undesirable characteristics

  • A commercial TLS can be quite tall. Hobby-level CNC machines don’t have generous travel on the Z axis, so a tall sensor can limit the tool length you can have. A long tool may not fit above the sensor even when the spindle is at the top-most position. A potential mitigation is to create a pocket into the work surface to bury the sensor at a lower height

  • Some sensors utilize a normally-closed switch. This doesn’t play well with the Z probe, which is intrinsically normally-open (the Z probe works by making contact, not by breaking contact). Since plain Grbl has only one probe input, which needs to be shared by the TLS and the Z probe, they have to use the same type of switch

  • Some sensors require external power. They may have circuitry to reverse the logic of a normally-closed switch to normally-open. Or they have to power an optical receiver. Or they may need power for wireless communication. This requires an additional power source and extra wiring

DIY tool sensor#

I could not find one that fits my needs perfectly, so I set out to build one on my own.

Version 1#

For version 1 of my tool sensor I had a few requirements

  1. Low profile
  2. Normally-open logic
  3. Good repeatable accuracy

I designed what is basically a plastic housing for a large push button. The largest I could find was 16mm, which was good enough for most bits.

The two plastic halves attach with M3 screws and threaded inserts. The sensor is secured to the machine bed with M4 screws and T nuts.

This sensor worked fine for me for a couple of years. It had a few limitations

  • It couldn’t fit larger tools, like a 1" surfacing bit
  • There was no overtravel protection
  • The button surface may not be perfectly level, which would skew the results for large diameter tools
  • The surface of the button was made of soft metal, which wears down over time and needs replacement

By then I had also upgraded the stock DC spindle with a larger VFD motor. The new spindle was permanently grounded to avoid the need for an alligator clip when Z-probing. This meant that I no longer need a mechanical switch for the tool sensor. A simple metal plate would be enough.

Version 2#

The second iteration had a few more requirements:

  1. Low profile
  2. Large area (1" or more)
  3. Leveling support
  4. Overtravel protection

The new design had a static part with the overtravel switch and a moving part that holds a metal plate. The moving part is suspended on 4 springs using 4mm linear bearings.

The leveling was inspired by the Prusa MK3 nyloc bed leveling mod. There are 4 screws in the corners that can be adjusted to change the height up and down. The screws are special D4xM3 20mm “roller shoulder screw bearing bolts”. They have a smooth 4mm shaft in the middle and M3 thread at the end. The shaft rides inside the linear bearings and the threaded portion goes inside the nyloc nuts.

For the metal plate I used a FoxAlien aluminum touch probe. It has a generous 30x30mm surface that is perfect for my needs.

The overtravel switch is wired in parallel with the Z limit switch. If the bit doesn’t stop and continues to push the plate, the switch will trigger the hard limit alarm.

I also made a plastic cover that protects the probe from dust when not in use.

To calibrate the sensor, I wrote two JavaScript macros for OpenBuilds:
FindCenter.js - it would approach the plate from the left and the front to find the actual location and then compute the center. This is going to be the tool sensor location

Leveling.js - it measures the height at 9 points on the plate and prints out the results. You can then use the screws to adjust the tilt

This version worked great for a while. However after a few projects I noticed small pits starting to appear at the center of the probe. That’s because every tool goes to the exact same spot every time and pecks at the soft aluminum.

I approached the problem in two ways:

  1. I added a random offset to the sensor location. The spindle wouldn’t go to the exact same spot every time, but use a random spot within 1mm of the center
  2. I replaced the aluminum with a harder metal

Version 3#

Version 3 of the sensor replaces the aluminum probe with hardened steel plate. I used a 30mm precision gauge block with overall dimensions 30x35x9 mm.

I also put the dust cover on an axis so it can swing away. It rotates on a 8x25mm steel pin. There are 3 tiny 3x2mm magnets that snap the cover in the closed and opened positions.

The main challenge was how to attach a wire to the steel plate. The original idea was to drill and tap for an M3 screw, similar to the aluminum plate. That didn’t work. Try as I might on my small drill press, I could only make a tiny scratch in the steel surface. Surely someone with more experience working with hard metals, and with better tools, can get it to work.

The second approach was to push two flat spade connectors from the side with screws. This was successful and ended up as the final solution.

The swing dust cover was a neat idea, but didn’t work as well as expected. It only provided protection from the top, allowing dust to get in from the sides. I went back to the previous design with a fully detachable cover. Both variants are included in the download.

So far this version 3 appears to be a winner. After a few projects the steel plate shows no signs of wear at all. The electrical contact with the pressed spade connectors is holding well. Accuracy is quite good, especially with 2-stage probing - first a faster seek pass and then slower precise measurement.

Downloads#

Here you can download the models for all 3 versions:

tool_sensor_v1.zip

tool_sensor_v2.zip

tool_sensor_v3.zip

All plastic parts are printed from PETG with 0.2mm layer height.

Discussion#

Comment Form is loading comments...

  © 2026 Ivo Beltchev cnc@ibeltchev.com