Crash-Free Probing

Users should post macros that they want to share in this forum. It is recommended that you attach the actual macro code to your posting. Also, please include a detailed description of what the macro does and why it is useful. It is also helpful to include line by line comments in the macro g-code file. This will help users modify it to fit their exact needs.

Please only submit one macro per posting and clearly name the subject in a way that describes the macro being posted.

If your macro builds on the work of others, please don't forget to give that person credit for his/her work.
Forum rules
No profanity, No gambling. No porn. No illegal activity of any kind. Violators will be removed without notice.
Post Reply
zeker
Posts: 2
Joined: Thu Apr 17, 2025 1:36 pm

Crash-Free Probing

Post by zeker » Thu Apr 17, 2025 5:28 pm

Hi all!

Crashing your probe into a workpiece can be an expensive mistake. Of course, the probing move itself (G38.2) can't harm your probe because it stops immediately on contact—assuming your probe is connected and configured, of course—but while moving the probe into position (G0 or G1) you have to be really careful about where the probe is relative to the piece to avoid crashing. And if you didn't get enough sleep, that might be iffy.

There's another way. During those positioning moves, you can detect if the probe made contact and stop. You just have to use a probe move (G38.3) which stops when contact is made and allows the program to continue when it isn't.

To demonstrate, here's a macro I wrote to probe the top-back-left of a workpiece in a mill. I use G38.2 for the probing moves, G38.3 for the positioning moves, and G0 for backing off after probing. Probe with confidence with Crash-Free Probing™!

Reminder, your probe has to be connected. This won't save you if it's not.

Code: Select all

(probe to zero at top-back-left of workpiece)
(start this code with your probe within 5mm above, behind, and to the left of the workpiece)

(user variables)
#100 = 5.08 ; probe diameter [mm]
#101 = 5    ; probing depth [mm]
#102 = 0.1  ; after-probing backoff clearance [mm]
#103 = 10   ; probing feed speed [mm/min]
#104 = 100  ; probe positioning feed speed [mm/min]
(note: if you will be probing with several different diameter tools, you can comment out the line defining #100 here and instead define it in the MDI.)


(probing code)
M70 ; save machine settings
G21 ; metric (bcuz imperial sux ofc)
G28.3 X0 Y0 Z0 ; call this zero for now
(debug, REMINDER: ENSURE YOUR PROBE IS CONNECTED AND ENABLED)

(subroutine for probe positioning moves)
o100 sub ; arguments: X move, Y move, Z move
    G38.3 X[#1] Y[#2] Z[#3] F[#104]
    o201 if [#5070 EQ 1]
    	(debug, PROBE TOUCHED DURING POSITIONING MOVE; ROUTINE CANCELLED)
       	M2
    o201 endif
o100 endsub

G90
(debug, MOVING TO Z PROBE LOCATION)
o100 call [#101] [-#101] [0] ; move to Z probe location
(debug, PROBING TOP)
G38.2 Z[-#101] F[#103] ; probe Z
(debug, TOP FOUND)
G28.3 Z0       ; zero Z
G0 Z[#102]

(debug, MOVING TO Y PROBE LOCATION)
o100 call [#101] [0] [#102] ; move to probe the back side
o100 call [#101] [0] [-#101]  ; plunge probe
(debug, PROBING BACK)
G38.2 Y[-#101] F[#103] ; probe Y
(debug, BACK FOUND)
G28.3 Y0       ; zero Y
G0 Y[#102]

(debug, MOVING TO X PROBE LOCATION)
o100 call [0] [#102] [-#101] ; 
o100 call [0] [-#101] [-#101]  ; move to probe the left side
(debug, PROBING LEFT)
G38.2 X5 F[#103]  ; probe X
(debug, LEFT FOUND)
G28.3 X0       ; zero X
G0 X[-#102]

o100 call [-#102] [#102] [#102]
G28.3 X[-#102-#100/2] Y[#102+#100/2]
(debug, SUCCESS! ZEROED POSITION ON TOP-BACK-LEFT)
M72 ; restore machine settings
In my own use, I have this line commented out:

Code: Select all

#100 = 5.08
That's because I like to probe with my cutting bit, which can have various different diameters. Instead of having the probe diameter hardcoded into the macro, I define it in the MDI and then run the macro. For example, for a 3mm end mill I run this in the MDI:

Code: Select all

#100 = 3
Have fun!

zeker
Posts: 2
Joined: Thu Apr 17, 2025 1:36 pm

Re: Crash-Free Probing

Post by zeker » Thu Apr 17, 2025 7:18 pm

Note: for this to work, you need to be using the latest firmware.

Find it [here](https://buildbotics.com/bbctrl-2.0/). Download bbctrl-2.0.4-rc14.tar.bz2 to your computer, and upload it to your Buildbotics controller by going to Settings > Admin > Firmware > Upload.

Huge props to the folks at Buildbotics by the way. I phoned Doug about trying to get this to work, and THE VERY NEXT DAY he pointed me to the new firmware to make it happen. Unparalleled customer support.

User avatar
Doug
Posts: 373
Joined: Fri Feb 02, 2018 4:56 pm

Re: Crash-Free Probing

Post by Doug » Fri Apr 18, 2025 8:20 am

Nice work Zeke,

As an enhancement, you might consider probing on both sides of the probe plate. This allows you to measure the diameter of the probe. For instance:
  • probe from the left and note the position
  • probe from the right and not the position
  • subtract the two positions to get the difference
The difference compared to the width of the probe plate will be the diameter of the probe.

Post Reply