CNC tool setter with PoKeys and Mach4

Setting tool offsets and measuring tool lengths can be quite frustrating and prone to errors when using a CNC machine. CNC tool setter with reliable probing routine can significantly reduce number of scrapped parts and enable reliable production.

What is CNC tool setter

Most hobby and semi-professional machines do not have an ATC spindle. That means that the tools can not be changed quickly and tool change require loosening the nut with the collet and change tool. The before mentioned part is still quite simple and quick, but the main problem is that now with the new tool you don’t know the length of the tool neither can the length be stored in the tool table since manually changing tools is not repeatable.

To solve that problem, the first and most commonly used option is to touch off tool manually. You can do that with the help of gage block or dowel pin on the known reference surface. That is quite repeatable and easy but also time consuming as well as prone to errors.

Picture displays how to manually set tool offset with help of dowel pin and retracting the spindle away from the pin until the pin slips under the tool.

The better option is to automate that process with the CNC tool setter and reliable probing routine. That can automatically measure the tool lenth and apply the right offset so you can resume machining quickly after changing the tool.

Benefits of automatic tool setter

A sometimes additional operation on a CNC are avoided only because tool change is necessary and manually changing tools is time consuming. The errors can also occur with the tools that are not measured or measured incorrectly.

Tool lenth measuring automation greatly simplifies machining, saving time with a lot less manual labour and quicker production of finished parts. So cnc tool setter is the way to go with that process.

Difference between CNC tool setter and probe

In previous blog post we described mach4 probing with probe tool. Probing in that sense is used when you want to locate the part that you are about to machine. That means that you tell the machine where is the zero point in the machine xyz coordinates where the stock is located.

Tool setting with cnc tool setter is the process of measuring the length of the tool. The zeto point should also coincide with the zero point of the stock. If tool length is not set properly the tool can dig too deep into the material and break the tool in the worst case. If you are lucky the tool will not cut the material at all since it’s length is set too long.

How to connect CNC tool setter with PoKeys

To connect the cnc tool setter device to the PoKeys, in our case the PoKeys57CNC, you first need to find a free pin that is not already used for anything else. The easiest option is to use the pin for probe, which is located on the limit switches connector. If you are already using the probe, than you have to find the other available pin, but you can not use the limit pins for probing. The probing pin must be labelled with grey box as “PIN xx” on the page 11 of PoKeys57CNC manual.

PoKeys57CNC connected to AdapterPNPN board to which probe and tool setter are connected.
Probe is connected to input number 1 and tool setter is connected to input number 2

The easiest way to connect the probe is with AdapterPNPN. If you are using PNP or NPN probe or even if it is just a switch, connecting it to AdapterPNPN and PoKeys57CNC is only a matter of connecting a few wires and setting jumpers to the appropriate side.

PNP sensor’s signal wire should be connected to PNP input on screw terminal. It does not matter if sensor wire is NO (normally open) or NC (normally closed) contact. The benefit of NC wiring is that the error in circuitry and wiring is detected since the signal is not present. If for instance you cut the sensor cable, the error can be triggered. The jumper has to be set accordingly to the PNP side if using PNP sensor.

In case you use NPN sensor, you should connect sensor wire to the NPN input on the terminal, and set the jumper on the NPN side. Again, NO or NC wiring does not matter here, it is managed in the software settings where you can invert the signal if needed.

In case you are using ordinary switch contacts, you can wire switch between VCC and PNP terminal and set jumper to PNP. Or you can wire the switch between NPN and GND with jumper set to the NPN. You still have to connect power supply in order for the adapter to work even though switches do not need supply in order to function.

In our case, the cnc tool setter has two normally closed contacts, one for tool measuring and one for over-travel. We connected in VCC and PNP terminal and set jumper to PNP side on input number 2. LED is on all the time since the sensor is NC, but when we trigger the sensor LED turns off.

The wiring can be checked in the PoKeys app with data logger. PoKeys app has to be opened and right device selected, then data logger tab clicked. New window will open and on the right row with the input pin the state of the pin will change when the probe is activated. The state of the pin could also be verified in Mach4 in the “Diagnostics” tab under “PoKeys plugin – PoLabs”. There are all the pins visible with the colour change when the state of the pin changes.

How to configure Mach4 for automatic cnc tool setter

It is of the utmost importance that the latest version of the Mach4 is installed along with the latest version of the PoKeys plugin. Multiple probing works only with newer versions of the software and reliability is also greater.

The setup for probing is simple, the only thing that has to be configured is input signal in Mach4 configuration under “Configure” -> “Controll…”. In the “Input signals” the Probe Mapping has to be enabled and the right pin chosen. As mentioned before, PoKeys “Pin xx” has to be selected for probing. The seleected “Device” is PoKeys_[serial number] and the input name is selected pin. To invert the pin “Active low” can be selected.

Mach4 settings for input signals for probe 0 or probe 1. There is also the probe status rectangle visible.

If you already have one probe for the xyz probing, then you can connect the cnc tool setter to the probe1 or any other probe.

That is all the configuration in Mach4. You can check the tool setter pin state in GUI, where in case of probe triggering the blue rectangle changes colour. It is always the best practice to test the reliability before serious use.

How to test and touch off tools with CNC tool setter and manual programing

The easiest way to test the probe is to first trigger the probe manually multiple times and observe the behavior of the blue square in the Mach4 GUI. If it reliably change color than wiring is most probably OK. The next step is to start testing automatic measurements.

It is recommended to start with manually writing the folowing g-code line in the MDI and then execute that line. The g-code for probing is G31 if using the probe number 0. For probe number 1 the g-code is G31.1, for probe number 2 it is G32.2 and so on.

The parameters for the g-code are Z distance that the probe or tool will travel to while waiting for the signal. The last parameter is feed rate, which can be initially set to a low value, around 20mm/min to be save. It can be later increased of course.

The g-code for probing with probe 0 to the Z value of -10mm and feed of 20mm/min is “G31 Z-10 F20”. When the line is copied into the MDI window, you can “Cycle Start MDI” to run the line. Try to safely trigger the tool setter or probe to see if the machine stops.

When manually using probing g-code, it is also possible to switch from absolute to relative coordinates with G90 (for incremental or relative positioning), then the Z value in the “G31 Z-10 F20” will be interpreted from the current position and the tool will travel 10mm in negative direction from where it is. It is very important to switch back to G91 after probing to use the absolute positioning again.

In our case the tool setter is positioned on the table of the machine. The main goal was to establish the routine that would touch off tools during machining after manual tool change. The idea is that after you changed the tool the offset would be measured and the work zero would stay where it is. That way the process is reliable and a lot of time is saved.

Automatic routine to touch off tools

In case the tool setter has fixed position on the table, the position must somehow be known to the controller. The most reliable way is to set up the homing routine in case it is not already set up. Then the position of the tool setter has to be manually measured, the easiest was is to jog the machine around and check the machine coordinates. The most important ones are X and Y coordinate since the Z will be probed.

Afterwards, for probing the tool length the following g-code can be run:

M5 (turn off spindle)
G43 H1 (tool lenth offset set to tool 1)
G53 G1 Z0 F3000 (move Z-axis to zero away from the table)
G53 G1 X-38.5 Y-13.1 F3000 (move to tool setter location in X and Y)
M49 (disable feed rate oveeride)
G53 G31.1 Z-65 F300 (probe command)
G10 L1 P1 Z#5073 (apply new tool offset from Mach4 variable #5073 – probe machine coordinate)
M48 (enable feed rate override)

The idea with the upper g-code is to use the machine home coordinate of probe to set as a tool offset so it is mandatory to run homing routine before upper g-code. When the tool length is measured the work offsets (G54, G55, etc.) can be set up afterwards and not before.

With the appropriate coordinate input, the spindle should get right above the tool setter. For your machine, right coordinates have to be applied. After the machine is in the right spot, g-code for probing can be input to measure the tool length offset.

Is automatic tool setter really neccessary?

The tool setter greatly simplifies the cnc machining process and makes it more reliable. Conventional methods of setting up tools still work and are roboust, but they are also time consuming and prone to human errors. And since the tool setter have become cheaper and more radily available there is no reason that machinists would would not use them.

Even though the setup might look complicated at first glance, it is quite quick and simple but more importantly, it pays off to invest time into learning new things as well as do some maintenance and improvements to your machine. We recently also made a big imrpovement to our machine when we eliminated cnc chatter when doing heavier machining. We upgraded the Z axis for much better rigidity and performance.

How to measure tool length without CNC tool setter

The convential method of setting up tools is using a dowel pin or other precision gauge. The best practice is to lower the tool more than the height of the gauge. Then you slowly retract it until the gauge is able to slip under the tool. That way you prevent crashing into the gauge and chipping the tool. The height of the gauge is then inserted into the Mach4 and offset is automatically calculated.

You can also position the tool setter on the workpiece to measure tools. That is usually the case on hobby machines and the tool setter is the simple metal plate with the continuity cable connected between the tool and the setter plate.

There are surely other ways to measure tool lenths that i did not mention. I hope we gave you some insight into tool lenth measuring.


Polabs, develop and manufacture electronic products for many different areas and needs. We also make machines to make work easier, more productive, and high quality. Below, here you can find some latest blog posts and products:

Find out more about probing:

  • 1. G10 g-code
  • 2. CNC datums G53, G54
  • 3. Mach4 programming guide

Related Posts

Machinable case design for PoKeys57CNC motion controller
Although PoKeys57CNC devices are sold as 'naked' boards, the board...
Read more
PoScope4 release 2.7
The latest release of PoScope4 introduces performance improvements Here is a list of...
Read more
Mach3 limit switch tutorial with PoKeys
About Mach3 limit switch tutorial This Mach3 limit switch tutorial will...
Read more
Slovenščina »