The software just plunges the tool into the sensor at full speed. As soon as one of the inputs goes low it backs up 1 mm and then descends slowly until it breaks the connection again.
There was only one small problem ... I made it for the wrong corner of my XY table! Having it on the right meant that the vacuum pipe had to clear it so could not be as close to the workpiece as it could otherwise be. No problem, I just got HydraRaptor to make another base for the left hand corner. I designed the part in Visio and then manually made a Python script to mill it. At some point I need to find a free CAD / CAM program for things like this.
Here is the drawing :-
This is what the script looks like :-
And here it is installed :-from Hydra import *
from Arc import *
from Tool import *
from Line import *
hydra = Hydra("10.0.0.42")
top = 6.1
base = -0.3
hydra.work_origin = (-50,0)
hydra.work_height = top
hydra.measure_tool(end_mill)
hydra.tool = end_mill
tr = end_mill.radius
# recess
hydra.drill((0,0), 18.0, top, 5.6)
hydra.drill((0,0), 15.0, top, 5.6)
# spring well
hydra.drill((0,0), 10.0, top, 3.0)
hydra.drill((0,0), 2 * tr, top, 3.0)
hydra.drill((0,0), 7.0, 3.0, 1.0)
hydra.drill((0,0), 2 * tr, 3.0, 1.0)
# screw hole
hydra.drill((13.5,19), 5.0, top, base)
# outline
outline = [Line(-10,32.5), Arc(-9,32.5,-9,33.5,-1), Line(26,33.5), Arc(26,32.5,27,32.5,-1),
Line(27,-9), Arc(26,-9,26,-10,-1), Line(0,-10), Arc(0,0,-10,0,-1)]
hydra.mill(outline, top , base)
del hydra
You can see that I used JB Weld to glue the pins in. I did that to stop them moving when I soldered the wires on, as Perspex melts very easily.
Below is a video of the new base being made. You can see the right handed version of the tool sensor being used at the beginning. I upped the feed rate to 15mm per second with no problems. Even so it took more that 15 minutes to make the piece so I have speeded up the video by a factor of two.
Obviously it is important to switch the spindle motor off when measuring the tool! At the moment I am doing this manually. I forgot once but I got away with it because it measures so quickly. The next job is to put the motor under software control.