Tool Length Sensor/Zero Z Sensor for CNC.

Having used a simple setup with 2 wires, one connected to a alligator clip and the other soldered to a small piece of PCB, that kept breaking, I decided to make a better sensor to set the Z height of my CNC. This is a very simple build. It's built around 2 components, a 12x12mm microswitch and a footswitch actuator.

I modeled the 3D parts according to the dimensions of these components.

I modeled it also to work with the M3 screws I had that kinda matched the length or the assembly and I modeled the space for captive nuts.

After that I 3D printed it with FormFutura ApolloX on my Wanhao Duplicator 4S, soldered the wires of the cable to the switch, superglued the switch to the base and tightened the plunger to the top part of the assembly.

After that I connected it to my Stepcraft CNC. I used the probe Z Macro (M31) and it worked fine. But then the Z zero will be offset by the height that the switch gets triggered. So to fix that I lowered the zero until the tool touched the base of the CNC machine and read the value (negative) of the Z. Then all that I had to do was to set that value in the macro M31. Now when I probe the Z it will automatically compensate for the height of the sensor.  M31 macro, with value to edit in red:

//M31 probing macro double Zmin = -100; double Feedrate = 100; double retractheight = 10; double newZ = 36.8625; //The new Z DRO value after probing. //if(!exec.GetLED(56)||!exec.GetLED(57)||!exec.GetLED(58)) // If machine was not homed then it is unsafe to move in machine coordinates, stop here... //{ //  MessageBox.Show("The machine was not yet homed, home the machine before run to parking position!"); //  exec.Stop(); //  return; //} while(exec.IsMoving()){} exec.Wait(200); exec.Code("G31 Z" + Zmin + "F" + Feedrate); // Move to the probe sensor position in XY while(exec.IsMoving()){} exec.Wait(200); exec.ChangeaxisDROvalue(2, newZ.ToString()); //Change the DRO value exec.Wait(200);  //Safety wait for the UC100 syncronisation if(!exec.Ismacrostopped()) // If tool change was not interrupted with a stop only then validate new tool number {  double Zup = exec.GetZmachpos() + retractheight;  exec.Code("G00 G53 Z" + Zup); // Move 10mm above probe plate  while(exec.IsMoving()){}  exec.Wait(1000); }

Parts needed: 3x M3x25 screws 3x M3 nuts 1x Footswitch actuator 1x 12x12mm microswitch

This is pretty simple to make if you know how to 3D model, but if you want to make mine, you can get the model below:

Buy my product


©Turnhout, 2019 by JD Music Labs. Proudly created with