protoloft / klipper_z_calibration

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

Always treat clearance as an absolute value #68

Closed ScramblerUSA closed 1 year ago

ScramblerUSA commented 2 years ago

Rationale: current algorithm treats clearance as an absolute value when comparing current z position, but as a relative value when it comes to moving the head up: if pos_z < clearance move(pos_z + clearance)

This kind of makes sense when the head is all the way down on the bed: if 0 < 20 then move_to(20) Then the higher the head is, the less sense it makes: if 10 < 20 then move_to(30) In an extreme case (z at 19.9 and clearance is 20) it results in moving the head all the way up to 39.9! At the same time if the head is already at 20, it's just kept at this height.

Basically, in my opinion the logic should be "if we are below the safe level, let's move up to that level to clear the things" rather than "if we are below the safe level, let's move up the additional safe level height".

TitusLabs commented 1 year ago

I like it! I guess I didn't do it quite right. However, I'm worried that after a merge somewhere the head crashes.. Could that be the case? If someone set the clearance very small due to this behavior? :thinking:

TitusLabs commented 1 year ago

ok, let's try it...