08 Jul

Height probe for CNC-machine [Part I]

Our computer aided work horse, customized Shapeoko2 milling machine, is working well. Yet, we have been able to make pcbs with pretty good results but also wood carving. After clearing the machine from all that glassfiber and wood dust we are ready to add new feature to the machine.

Small bumps for machine, one giant fail end result

While your milling machine is top notched and tuned for accuracy, your work piece might not. Not even close. A piece of plain copper pcb is not flat. There is easily +- .1 to +- .2 mm height differencies on the board(warpage etc.). It does not sound much and is not a real problem with flat head tools, but if you aim to say 12 mils (.3 mm) with a V-carve tool working its way at 0.23 mm deep,  you see the point.

Copper board bumps are small, even tiny, compared to downs and hills on surface of wood where scale is millimeters. Again, it really depends your output if that matters. However, carving with your precious milling tool 1 mm deep on one side of the wood and suddenly you hear (and smell) a failure and see your tools stalling at 5 mm deep on other side and that 3 mm safety height (machine's travelling height) you set up was no way near enough.

IMG_20160706_110901

What the hell! My eyes told me this is a flat piece of wood!

 

Computer aided height probing

So how do you deal with those quirks on a copper board. Well, you can take your blacksmith hammer and forge it to flat but we bet it's not a good idea. Most CNC-softwares, like Chilipeppr which we like to use, have height probing capability. It forms a matrix of probing points of your choise and modifies your g-code so that height differencies are taking care of.

Probing hardware setup for pcb copper board is simple by using the Zmin input of tinyg board (CNC-controller board installed in our Shapeoko2). Grounding the pcb board by soldering the wire on copper board and connecting the other end of the wire on tinyg ground while Zmin input connects to milling tool. Now there will be a loop when milling tool touches the board. This is how we have done it and after couple of broken tools works like charm.

This setup not going to work with non-conductive materials like wood. We need new kind of probing sensor.

Proximity sensor

When it comes to mechanical sensor, first in mind is a simple limit switch. It would be easy to handle and cheap but needs serious fixing accessories aside. More off-the-shelf solution is ready-made touch probe with proximity (inductive) sensor which fits out-of-box on our machine. Lets tear one apart and see what's inside.

IMG_20160706_110634

43mm CNC Digitizing Touch Probe Sensor

 

Touch probe comes with 4 tips, 2 with V-shape and 2 with ball tip. Proximity sensor (TS12-02N-2) is baked (screwed and replaceable) on upper half of sensor. Bottom half is attached to probe tip with a metal plate and finally there is a spring between halves.

proximity_sensor

Inductive proximity sensor

 

TS12-02N-2 is an active sensor with three color coded wires. It takes 10-30 VDC and yields same voltage with max 200mA output current via black wire. Take a look datasheet for more detailed internal schematic. This is NPN output with normally closed function. This means that while your load is connected to collector side of transistor (in this case, between black wire and brown wire) it provides input voltage over the load. Normally closed (N.C.) means that transistor is "closed" and conducting, hence connection to ground is formed.

NPN_schema

TS12-02N-2 connection

 

Lets see how tinyg board limit swtich inputs are formed. Synthetos claims following:

The inputs are 3.3v logic inputs and must not have 5v applied to them or you will burn out the inputs. The inputs are de-glitch filtered with a resistor-capacitor circuit (RC circuit), and pulled up to 3.3v on the board via 2.7K ohm resistors (strong pullup).

Our mechanical limit switches  for X- and Y- axis are set as N.C. Since all limit switches are required to function same way, we need N.C for Zmin limit. How N.C. works on tinyg is following. As stated, inputs are pulled high via pullup resistor. Since limits are normally closed (tied to ground), hence limit inputs are low while limits are not triggered. This means we have to provide 3.3 V logic high to Zmin input when triggered.

limit_input_schema

Limit logic input

Dividing voltage

Based on sensor's schematic, we can use the proximity sensor to drive Zmin input on tinyg board. Remember, voltage level over load is same as input voltage of the sensor and in this case will be 24 V taken from tinyg power supply. That is way too much for Zmin input to handle. This is where voltage divider circuit kicks in. Lets draw a schematic to see what we up to.

sensor_input_schema

Proximity sensor limit input schematic

 

So R2 is our load here, right? Lets make it big say 10K. Adding another resistor between black and blue (ground) like nice and round 2K. We then get (2/12)*24 V = 4 V on limit_input. That is a bit off from 3.3V but perfectly fine (< 5 V) for testing (we can adjust values later).

Breadboard testing

Breadboard testing

 

Test run shows that this setup works as indended. Voltage values are 0.71 V while not triggered, which is below low input max logic value (Can you see why 0.7 V? Hint: Diode) and still considered as logic low. When trigger voltage jumps to 4.2 V which is within 5% tolerance what we calculated.

Here is voltage divider connection board. Tweaked resistor values are one 10K for R1 and 1K plus 3 x 100R plus 220R in series for R2, providing about 3.1 V trigger voltage.

Connection board with voltage divider

Connection board with voltage divider

 

What about auto-leveling

The proximity sensor works great as Z-limit sensor, a question is does it work on auto-leveling procedure? Answer is no and a test run verifies this. Reason is that auto-leveling has opposite function compared to N.C limit switches. As we told earlier, PCB auto-leveling is wired such that loop is normally open (ground  to tool - loop is open while there is a gap between tool and grounded PCB). To get this work on auto-leveling, we need to invert the logic but that's for part II.