Auto bed probing and compensation with G29 Development

The marlin firmware has G29 to G32 built in, and I want to try and use it. This will require adding a probe (preferable stowable), and some extra G-code.

G29-G32: Bed probing
G29 Detailed Z-Probe
probes the bed at 3 points.
G30 Single Z Probe
probes bed at current XY location.
G31 Report Current Probe status
reports whether Z probe is triggered.
G32 Probe Z and calibrate with FPU
probes the bed at 3 points and updates transformation matrix for bed leveling compensation.

G32 would be the code to use, and apparently the probe is just hooked up in parallel to the Z end stop.
Not sure where the probing positions are stored, but it can probably be set to whatever.

Now how do we get it mounted to the TAZ? it would have to be stowable after probing is done.

EDIT: should be G29, not G32

FIles are going up on thingiverse.
Anti-backlash Z-nut and motor to M6 couplers (needed to make the Z-probing compensation accurate):

Bed probing parts:

G-code for bed probing (use as the custom G-code in Slic3r at the beginning of each program). You may need to adjust the X positions for the deploy and retract positions since every machines X limit switch may be in a different position.
bed_level_W_probe.gcode (534 Bytes)

M203 X192 Y208 Z4 ; set max rapid rates mm per sec
G91; set to incremental motion
G1 Z10.0 F11520; raise Z
G90; set to absolute motion
G28 X0 Y0; home X and Y axes
G1 X276 F11520; go to probe deployment position
G1 X288 F350; deploy probe
G1 X250 F11520; go to safe place
G28 Z0; Home Z axes
G29; probe bed
G1 Z12.0 F240; raise probe off bed
G1 X14 F11520; go to probe retract position
G1 X0.5 F350; retract probe
G1 X1 F350; move away from limit switch 
M206 X0.0 Y0.0 Z0.0; offset home position for fine tuning

and the Configuration.h file for the TAZ with the probing. You will have to adjust the “probe offset from extruder” position settings when you calibrate your own probe, but this should get you close.
Configuration.h (16.8 KB)
and the other firmware files you need to get probing working are found here:

Also Geneb found the following things that need to be changed in the firmware too:

  1. You’ll need to change the Z axis micro-steps to 4 in Configuration_adv.h.
    Look for the #define of MICROSTEP_MODES and change it like so:
    #define MICROSTEP_MODES {16,16,4,16,16}

  2. In Configuration.h, you’ll need to make sure that you’ve got the extruder steps set correctly. If you’ve got a “Factory” built TAZ, the steps per MM for the extruder will be shown on the calibration sheet that came with the printer. For mine, it was 860, so I modified DEFAULT_AXIS_STEPS_PER_UNIT to use that value, as shown:
    #define DEFAULT_AXIS_STEPS_PER_UNIT {100.5,100.5,800,860,800}

I’m pretty sure these are the only two “gotchas” in the process.

And he even put together this nice videos of the install process.

Similar to this?

yup, similar.

but I was thinking that the probe would pivot, or be cammed down when the x carriage goes to the max X travel, and retracts when it goes to X0. that way whenever the machine homes, the probe is out of the way. but programs would have to be slightly limited in x, so they do not accidentally deploy the probe.

then the code to get it to work would be simple. something like:

G0 Z10 (to make sure there is room for the probe to deploy)
G0 X289 (go to max X to deploy probe)
G32 (run probe routine)
G0 x0 (retract probe)

some good info here, but very few pictures:

and this is closer to what I am thinking, but still not quite. (but it has a video)


I passed that autoprobe video to Jeff last week. What a great feature.

For a method to deploy the probe without using any travel, what about a Nichrome wire that pulls the probe up when the extruder heat is on and lets a light spring drop it into a stop when the extruder heat is off?


IF the bed is level
IF you use a 3 point plate securement system
IF the build plate is flat within acceptable tolerance
your z probe could just touch 3 metal plates of a known thickness that are between the plate clamps and the build surface but stick out enough to touch off on. That would allow the system to check for level and z axis offset at the same time.

During manual leveling you would just need to run to three pre programmed points and turn the bed screw until a light comes on (inline with the probe power). Once all three securement points pass a go-no-go test you know your bed is level and the z-offset can be derived easily.

I haven’t measured the flatness of the plate used on the TAZ but the plate used on the CubeX is flat within 0.001" (25 microns) which means once you get three points set to the same z height, everything else is good to go after applying an offset to set the z-axis offset. Unfortunately, CubeX has a terrible setup for table leveling which makes a 5 minute job take 1 hour. I just got a TAZ so I’ll see what I can do to make the leveling and z-offset easier for it too.

I do not want to level the bed physically. just probe it and compensate in the program for it (at the beginning of every program). that is what G32 does. it compensates for the un-levelness automatically. Just like rotating a work piece coordinate.

I have plenty of extra X and Y travel in the TAZ, so I would like to use that to deploy and retract the probe…simpler is better, and adding the extra electronics for a deployment system is not simple, so I want to avoid it. Printing some parts for a deployment mechanism is easy enough.

some more info.

got my basic design done.

probe drops during the last 22mm of x travel to the right, and retracts when homed. I was hoping to not use more than 12mm, so i still might tweak it some. took some work to get that cam system right though.

right now it is activated by the x rod holders, but I could have it activate by something attached to the frame, at a specific Z height only, or something attached to the bed, at a specific Z and Y position only. this would help prevent inadvertent deployment if you had a large print.

BTW, looks like the firmware does need to be updated for this to work.

bed leveling firmware is here:
and in the config file is where the probe coordinates and probe offsets are stored.

I don’t see how you can use the G-29 function of the G-code with any backlash in the Z axis (such as the Lulzbot machines have). To see what I’m talking about, use Pronterface to home the Z axis then move the Z axis up 0.5mm. Then, move it down in 0.1 mm steps. When you change directions you will have to click the 0.1 mm down button 3-4 times before the Z-axis will start moving back down.

Using the G-29 auto-leveling function would cause errors because any backlash would show up as errors as the Z axis moves up and down as it tries to compensate for an unlevel bed while moving.

good point, and that may be a problem with the Stock TAZ.

But I have already fixed (or at least seriously reduced) the Z hysteresis and backlash on my machine. New stiffer “Z-nut springs” with backlash eliminating dual M6 nuts in each of them. I am still perfecting that mod though, but I am confident the Z hysteresis can be reduced considerably…linear ball bearings will help too.

BTW, I got the firmware working, and G32 does not do anything…looks like G29 is the code to use, as you mentioned.

Sounds great. Keep us posted. I think auto z-offset and auto leveling should be included in every printer setup. Automating those two areas would greatly reduce print fails for beginner users. It would also greatly decrease the time devoted to maintenance vs. just printing.

new bearing holder.
printed just like it sits. no support.

Got it working…printing now.

It is certainly not as quiet with the Z steppers moving constantly, but so far so good.
got video, but will have to post that latter.

The Z hysteresis is gone…at least visually, when moving in 0.1mm increments.

video of the probe deployment in action.
If you look close you can see the custom threaded rod mounts moving as it prints. replacing the flexible vinyl tube with these printed nylon mounts was one of the Z backlash fixes.

Very nice work!

Very cool!

On my printer all of the z hysteresis is due to backlash in the z nut. Am I missing something?

BTW, nice video. What do you use to rotate the probe down?