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.

<p>Simple and Works great! Thanks for sharing :))</p>
<p>Hi </p><p>Thank you for this nice subject.</p><p>Does this code work with mach3 ?</p>
This is written for UCCNC. I am unfamiliar with Mach3, but you can check compatibility and report back. <br><br>Here is a macro programming reference: http://www.machsupport.com/wp-content/uploads/2013/02/Mach3_V3.x_Macro_Prog_Ref.pdf
<p>Such a great and simple idea! Thanks for sharing! </p>

About This Instructable




More by kinasmith:How to Mill a circuit board with a Stepcraft Mill and EagleCAD Make a Tool Length sensor for Stepcraft 2 CNC Compost Sensor 
Add instructable to: