Programs for probing work coordinates in LinuxCNC

I got a great deal on a Blum 3-axis probe on eBay. A very common task is to pick up the coordinates of a workpiece in the vise. The probe tip has an effective radius, and also there is a slight delay before the probe contact is registered. So, what I did was approach the edge moderately fast, detect contact, and then back off just a tiny bit and probe again slower. Then, I correct the detected position to compensate for the radius of the probe tip and do a G10 L20 to set the G54 workpiece offsets to be X=0 Y=0 with the spindle ceterline exactly over the corner.

Detect Exterior lower left of part

This program detects the outside lower left of the part in the XY plane. First, position the part so the probe tip is to the left (-X side) and down (-Y side) of the part's corner, with the Z height at the level you want the probe to touch the part. The program will back away 0.05 units in X and move 0.2 units in +Y to be across from the -X face of the part, and then move in toward the X side of the part up to 0.5 units, or until the probe touches. It then backs out .02 units and tries again at a slower speed. The #1001= line computes the actual coordinate of the edge, the +.0763 is to adjust for the probe tip radius. The same logic is repeated for the Y axis, and then the probe is lifted .3 units in Z and the probe is brought to center right over the XY coords that were computed. Then, G10 L20 P1 is used to set the G54 coordinate system to that value.
      (probe LOWER LEFT)
      g91 g1 F10 Y0.2 X-0.05
      g91 G38.2 X0.5
      G91 G1 F10 X-0.02
      g91 G38.2 F1 X0.1
      G91 G1 F10 X-.1
      G91 Y-.4
      G91 X0.4
      g91 G38.2 Y+0.5
      G91 G1 F11 Y-0.02
      g91 G38.2 F1 Y0.1
      (debug,X,Y   #1001 #1002)
      G91 G01 F10 Z.3
      G90 G01 F10 X#1001 Y#1002
      G10 L20 P1 X0 y0
Download program probell.ngc OR