a blog of ideas and improvements for tormach cnc mills
articles | for sale | about | contact


THE X BOSS PROBING ROUTINE

APR 18 2024

 

Here's a shortcut I've wanted for a long time.

It's tedious probing the center of X on projects, especially when they don't clear a vise (so you can't use the built-in Rectangular Probing Routine).

You basically have to manually probe one side, rise up, jog over, probe the other side, divide by two and ugh.

Not to mention that your work will be varying widths. Some days you may be on a 1" piece. Other days, a 10" piece. How would you automate that?

What if someone wrote a script that asked you the approximate width of your project, then did it all with one button press?


Two files to make this work. This one first ensures you're in Pathpilot, then asks for the width of your work. It then injects that line into the actual probing script. Finally, it moves your mouse to the MDI line and runs the script.

If you put this in \tmc\configs\tormach_mill\nc_subs (actually, put it in /gcode/subroutines (easier to remember)) as M110 (no extension) and reboot the machine, you can call the entire thing from the MDI line by simply typing M110.

#!/bin/bash

if [[ "$(xdotool getactivewindow getwindowname)" == *'tormach'* ]]; then

entered_value=$(zenity --entry --title "X Travel" --text "Enter approx width of work.")

new_line="G1 F50 X[#<_X>+$entered_value ] (MOVE TO OTHER SIDE)"

sed -i "14s/.*/$new_line/" /home/operator/gcode/subroutines/xboss.nc

xdotool sleep .1
xdotool mousemove 70 440
xdotool click 1
xdotool mousemove 70 400
xdotool click 1
xdotool sleep .1
xdotool type "O<XBOSS> CALL"
xdotool key Return

fi

This is the actual probing routine that goes in /gcode/subroutines (/home/operator/gcode/subroutines) as xboss.nc

o<xboss> sub

G28.1                         (GET CURRENT MACHINE COORDS TO #5161 #5162 #5163)
#666 =      [18 - #5161]      (#666 IS "1100M MAX X" MINUS G53 CURRENT POSITION, THUS HOW MUCH X IS LEFT)
#667 =      [#<_X>+#666]      (#667 IS WCS CURRENT POSITION + HOW MUCH IS LEFT, THUS GOOD FOR CURRENT WCS)

G38.2       F20 X#667         (FAST PROBE FROM STARTING POINT, AS FAR AS NECESSARY)
G1          F20 X[#<_X>-.05]  (BACK OFF BRO)
G38.2       F1  X[#<_X>+.1 ]  (SLOW PROBE)
G10         L20 P0 X0         (SET PROBED LOCATION TO X0)

G1          F20 X[#<_X>-.05]  (BACK OFF BRO)
G1          F50 Z[#<_Z>+1  ]  (RISE)
G1          F50 X[#<_X>+3  ]  (MOVE TO OTHER SIDE. THIS IS THE LINE THAT IS EDITED VIA THE INPUT BOX)
G1          F50 Z[#<_Z>-1  ]  (DESCEND)

G38.2       F20 X[#<_X>-2  ]  (FAST PROBE BACK INTO WORK)
G1          F20 X[#<_X>+.05]  (BACK OFF BRO)
G38.2       F1  X[#<_X>-.1 ]  (SLOW PROBE)

#2 = #<_X>                    (SET THE VARIABLE)

G1          F20 X[#<_X>+.05]  (BACK OFF BRO)
G1          F50 Z[#<_Z>+1  ]  (RETRACT TO SAFETY HEIGHT)
G1          F50 X[#2/2     ]  (MOVE TO CENTER OF WORK)

G10         L20 P0 X0         (SET CENTER OF WORK TO X0)

o<xboss> endsub