G38.2 zero z axis
The G38.2 gcode moves the bit until a touch-point is reached. grbl implements G38.2 for three axes; this only implements the z axis.
This implementation is slightly irregular, as G38.2 is supposed to finish at the touch point without altering the home position, in grbl the user would use G92 for that. We don’t have G92 (beyond the scope of this ) so this zeroes the z axis at the touch point. If the touch point is not reached, the ‘STOP’ command is issued to halt further execution without altering the zero. An example of operation in inches mode would be to execute this command file:
G20
G90
G38.2 Z-.15 F1
G20
G90
M02
The probe is assumed to be connected to AUX4, which is set at the top of CNC_Functions.h . Ground is attached to the router (bit) and AUX4 to the touch plate. AUX4 is configured as INPUT_PULLUP and is pulled LOW when the probe touches the plate.
I use a piece of aluminum sheet for a ground touch plate
and an alligator clip to attach to the bit to AUX4
The parameters for G38.2 are the axis (Z in this instance, X and Y are currently ignored…) and the distance to travel before cancelling in case of a failure to touch down ( -.15 units in the above example) and the speed to travel (I like a slow speed). If you like millimeters, change the G20 to G21 and use a suitable value for Z.
To zero Z, I unplug the router , slide the plate under the sled, hook up the cable to AUX4 and the plate and clip onto the bit. Then I use the Z-axis panel to drive the z-axis to a bit above the plate, less than .15 inches in the above example, and execute the above gcode sequence. I’ve got it pasted into one of my macros, but it works if you run it as a cut file instead. The z-motor moves until the bit just barely touches down and Z gets set to zero at that moment. If the bit fails to touch down, you get an error message that the “probe did not connect” and the z axis value stays unchanged.