Make a Tool Length Sensor for Stepcraft 2 CNC




Introduction: Make a Tool Length Sensor for Stepcraft 2 CNC

This is a tutorial on making a quick and dirty tool length sensor for the Stepcraft 2 CNC platform. This is just a quick demonstration with materials at hand that can be built in a few minutes. It works, but I would suggest, since you have a fancy mill, making one that has a little more heft and polish to it.

The idea here is to create a switch. One contact is going to be the Alligator clip, which will be attached the Endmill, the other contact will be the copper plate. When the tool touches the touch plate, it will create electrical continuity between the two wires, just like pressing a button. The machine control software will sense that and stop the Z, setting its value to its current position (the top of the touch plate), plus an offset equal to the thickness of your sensor (which is set in software).

What you'll need:

- Two pieces of stranded wire, a few feet long

- a scrap of blank PCB (or other consistently flat conductive metal that can be soldered to)

- an aligator clip

- various tools such as a soldering iron, a flathead screw driver, an allen wrench set, and wire strippers

Step 1: Build the Hardware

Strip the ends of the wires, tin them, and solder the end of one to the scrap of pcb. The other wire should have two stripped ends, one for the controller board, the other for the alligator clip.

If you've built your machine already, you'll need to flip it on its side to access the bottom panel. Remove it and attach the sensor wires to the two empty holes in the screw terminal block. The positions are noted on the circuit board and in the assembly manual. They should also be the only two empty ones. Polarity doesn't matter here. I ran the wires out the space in the jack panel, tying them around one of the standoffs for strain relief.

Step 2: Setup the Software

Plug in the mill and open up UCCNC. We're going to test the switch first.

- In the Diagnostics Tab, on the left hand side there is the I/O monitor. Watch item I10 and touch the plate and the alligator clip. The little green light should go off. This means that the controller board is sensing continuity, and our switch works. YAY! If it doesn't go off, check your connections again.

- In the Configuration Tab and the I/O Setup sub-tab change the Probe Pin to 10, Port 1, and check Active Low. Save and Apply the settings.

- Go back to the Diagnostics Tab, and do the touch test again, now you should see I10 go off, and Probe, in the I/O Function Monitor turn on. This means it still works. YAY!

- Next we're going to change Macro 31 and program in the thickness of our touch plate. A Macro is just a control script to do a pre-programed action or movement. Macro 31 is triggered when we press the Touch Off button in the control interface. It's a text file called M31.txt located in UCCNC/Profiles/Macro_Stepcraft2_*yourModelNumber*/. Find that, and replace it with the file attached here. I would probably save the old one somewhere else, just in case. Measure the thickness of your sensor, mine was 1.55mm. Open M31.txt in a text editor and input that value (in Millimeters) for the *newZ* variable where it says "**THE THICKNESS OF YOUR SENSOR GOES HERE!!**". Save the file and restart UCCNC.


Step 3: Test the Sensor

To test the sensor, place it on top of your workpiece. It is only a small piece of pcb and very lightweight, so it's liable to not want to lay flat. I had to hold mine down...not ideal, but cheap and fast. Attach the alligator clip to the endmill (as shown in the image), and press the Touch Off button in UCCNC. Be ready to press the Emergency Stop if it doesn't register the touch, and don't use your expensive 1/100th inch endmill when testing this. If everything goes ok, it will touch, then back off 10mm and stop. Then you can zero the Z and it should go just to the top of your material. Input the g0 z0 command into the MDI input line in UCCNC to do it quickly.

VID_20150831_094635.mp4 from Kina Smith on Vimeo.

- Next Steps: Now that you have this fancy milling machine, why would have a Tool Length Sensor made from a scrap of PCB? Go make something cool. I made mine out of a block of aluminum. It would be cooler if it was made of Brass with Walnut accents....but I'm cheap.

If you have questions, please use the comments section below.

Thanks for reading.

1 Person Made This Project!


  • Anything Goes Contest

    Anything Goes Contest



11 months ago

Amazing tutorial, thank you so much for sharing. I did have to adjust it slightly for the m700 but everything worked.


3 years ago

You beat me to a post. Great idea ;-) To keep the work side conforming to the material you are using, I use grocery store aluminum foil and a simple glue stick to generate the tool target point. Instead of solder I have another alligator clip on the sensor side. For those with the aluminum T-Slot table, keep in find that it is electrically grounded to the sensor board and one of your alligator clips is the same ground. Color code them so you always clip the non-ground one to the tool bit (or else it won't work). Thanks for the post.

My method also assumes 0 Z starts from the top surface of your material which is the way I program my tool paths. Which the funny thing is, you don't need anything special if you have the T-Slot table and you just want your tool to go down and touch it to find zero from the table surface (with the tool not spinning of course). But most of us use some type of spoiler board as a protective layer when we purposefully plunge through the material on the final pass to cut it free. If you have a tool changer (which I don't have) then something like what the other made does make sense.


6 years ago


Thank you for this nice subject.

Does this code work with mach3 ?


Reply 6 years ago

This is written for UCCNC. I am unfamiliar with Mach3, but you can check compatibility and report back.

Here is a macro programming reference: