protoloft / klipper_z_calibration

Klipper plugin for self-calibrating z-offset
GNU General Public License v3.0
1.05k stars 151 forks source link

Auto Z calibration is not idempotent #70

Closed NameOfTheDragon closed 2 years ago

NameOfTheDragon commented 2 years ago

Conjecture: All things being equal, running auto-Z calibration multiple times should produce the same result each time. That is, the operation should be idempotent.

The conjecture should hold true within the range of errors associated with the probe being used.

I have had a growing suspicion that performing multiple Z calibrations gives rise to a drift in the Z offset, so that it ends up incorrect, and the more you calibrate the more incorrect it becomes. That is, the operation is not idempotent. Leaving aside why you might want to do multiple Z calibrations, let's just say "it happens sometimes".

I measured a series of 14 calibrations, recording the various measurements after each operation. I performed these tests on my Voron 2.4 after a 40 minute heat-soak. My probe is "Klicky-NG". I homed the Z axis before measurements 1, 4, 7 and 14 only.

Measurements

Endstop Nozzle Switch Probe Offset Reset Z
0.377 0.374 7 7.849 0.361167 Y
0.377 0.36 7.438 7.83 0.352833  
0.377 0.349 7.424 7.814 0.340333  
0.377 0.379 7.469 7.854 0.365333 Y
0.377 0.362 7.459 7.84 0.342833  
0.377 0.352 7.451 7.828 0.328667  
0.377 0.378 7.476 7.845 0.347 Y
0.377 0.369 7.463 7.833 0.338667  
0.377 0.362 7.45 7.824 0.336167  
0.377 0.354 7.441 7.82 0.332833  
0.377 0.339 7.437 7.814 0.317  
0.377 0.329 7.432 7.809 0.307  
0.377 0.315 7.427 7.8 0.288667  
0.377 0.376 7.487 7.857 0.346167 Y

Graph of Results - Switch and Probe Positions

image

Conclusions

My findings are that the offset does indeed drift downwards, resulting in the nozzle being too far from the bed. This is most easily seen in the graph. You can see that the measurements slowly drift downward until the Z axis is homed, where they jump back up. This is most noticable in measurements 7-14, where I took a series of 8 samples, homing the Z axis on the first and last sample. The downward trend continues for 7 samples before the large correction at the 8th sample.

Repeated applications of the auto-Z calibration are therefore not idempotent. It is imperative to home the Z axis before each operation in order to obtain correct results. Ideally, this should not be necessary and Z calibration should be idempotent, so this is probably a bug.

NameOfTheDragon commented 2 years ago

The natural question that occurs to people is: "maybe this is caused by expansion and/or warping". I think I have ruled that out, but it would be worth repeating a similar test when the printer is cooling down or cold just to be certain. I have a print in progresss right now but when it finishes I'll repeat the tests on the cooling cycle. If this is due to thermal movement, then the trend should reverse.

NameOfTheDragon commented 2 years ago

D'oh! I repeated the test on the cooling cycle and the trend does in fact reverse, which according to my earlier statement indicates that this is actually a thermal effect and not an idempotency issue. I'm sure that in the recent past I have seen changes of up to 2mm, which I find surprisingly high given that my bed mesh variance is only around 0.16. Oh well, when the data disagrees with the theory, the theory is wrong and that's that. I'll close this issue for now at least.