MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.14k stars 19.2k forks source link

[BUG] Z Offset / Z Home Height disparity #27294

Open classicrocker883 opened 1 month ago

classicrocker883 commented 1 month ago

Did you test the latest bugfix-2.1.x code?

Yes, and the problem still exists.

Bug Description

Home position + Z Offset does not make sense.

When Z Offset is set to > or < 0.00, the resulting Home height should not be affected, at the very least, the logic is backwards.

Say you have a bed leveling probe, and you set the Z Offset to -0.60, and have Z_CLEARANCE_DEPLOY_PROBE = 10. Z Home position will be 10.60.

Likewise, if it were set to +0.60, Z Home position will be 9.40.

Here is a crude demonstration representation of how this looks:

zoffset

The blue line indicates when the Nozzle/Hotend is (Z= 0.00)

In this example, (Middle of image) let's say Z Offset = 0.00, and the position of the nozzle is Z=0.00, this results in the nozzle (blue line) slightly floating above the bed surface (indicated in grey).
To correct the difference so the nozzle (blue line) now can touch the bed surface , you change Z Offset = -0.10.
But as you can see, this increases the Home height by that difference. (Right side of image)

Then when you change Z Offset = +0.10, this obviously lets the nozzle float even higher above the bed surface (blue line), yet the Home position is now decreased (Left side of image).

Bug Timeline

No response

Expected behavior

Home position should be 10.00

Actual behavior

with Z Offset @ -0.60, Home position is 10.60 with Z Offset @ +0.60, Home position is 9.40

Steps to Reproduce

  1. Using UBL, but probably any bed leveling type should do.
  2. Go to your printer and Home the machine.
  3. If you have set your Z Offset, you may notice the Z Home height saying +/- the Z Offset

Version of Marlin Firmware

bugfix-2.1.x

Printer model

No response

Electronics

No response

LCD/Controller

No response

Other add-ons

No response

Bed Leveling

UBL Bilinear mesh

Your Slicer

None

Host Software

None

Don't forget to include

Additional information & file uploads

Configs

DerAndere1 commented 1 month ago

There are multiple z offsets. Which one are you talking about? How did you set it?

ThomasToka commented 1 month ago

Z-offset: distance from Probe to the nozzle. Z-offset can't be positive cause in this case the nozzle would touch the bed before the probe.

Thats my understanding of the Z-offset.

DerAndere1 commented 1 month ago

Lets assume 1) you do not print with a workspace offset active 2) //#define HOTEND_OFFSET_Z { 0.0 } 3) the bed surface is meant to be at machine position z=0. 4) your bed leveling mesh matches the physical bed geometry of the heated bed 5) You enable bed leveling compensation after homing

Then, NOZZLE_TO_PROBE_OFFSET is set correctly when the nozzle touches the bed and the current Z position is reported to be 0.0 after the following Gcode is run:

M190; heat the bed
G28; home
M420 S1; enable bed leveling compensation
G1 Z0; move to z=0.0
M400; finish all moves

If you want that the machine moves to a certain position at the end of G28, enable and set Z_AFTER_HOMING accordingly.
If that does not work as expected, please provide steps to reproduce the issue, including a description how you measure the "Z Home position" (e.g. 10.10)

classicrocker883 commented 1 month ago

the Z Offset I refer to is in ProUI, Z Probe Wizard - BABY_Z_VAR which is defined as probe.offset.z

@ThomasToka

Z-offset can't be positive cause in this case the nozzle would touch the bed before the probe.

I dont know what case this would be true, but using something like an Ender-3, a positive Z-offset means the opposite. + Offset would raise the nozzle away from the bed. - Offset brings it closer (lower) to the bed.

classicrocker883 commented 1 month ago

@DerAndere1 Z_POST_CLEARANCE is defined by Z_AFTER_HOMING (ifdef), otherwise it is Z_CLEARANCE_FOR_HOMING it doesn't matter what it is defined as, the disparity remains the same.

To reproduce, simply Home the machine and observe the current Z position. However you set Z_CLEARANCE_FOR_HOMING is where the printer then is (@ lets say 10.00), but when you introduce Z-Offset, this changes where the printer ends up homing.

DerAndere1 commented 1 month ago

This is probably caused by the following line:

https://github.com/MarlinFirmware/Marlin/blob/cc122bec8293f5c49c7a07f5a90a9c0448a48262/Marlin/src/module/motion.cpp#L728

which was introduced in commit https://github.com/MarlinFirmware/Marlin/commit/f53217b2c5bf7d61d21ee6784ec251bc7a670eb3, probably to reach the specified clearance below the probe between probing runs. Maybe @thinkyhead remebers why this was done.

Can we safely change https://github.com/MarlinFirmware/Marlin/blob/cc122bec8293f5c49c7a07f5a90a9c0448a48262/Marlin/src/module/motion.cpp#L742-L745

to this ?

  void do_move_after_z_homing() {
    DEBUG_SECTION(mzah, "do_move_after_z_homing", DEBUGGING(LEVELING));
    #ifdef Z_POST_CLEARANCE
      do_z_clearance(Z_POST_CLEARANCE, false, true);
thinkyhead commented 1 month ago

Z-offset: distance from Probe to the nozzle. Z-offset can't be positive cause in this case the nozzle would touch the bed before the probe.

@ThomasToka — It can indeed be positive, for machines that have the nozzle press into the bed, pushing on a spring mechanism that then triggers a switch, as on the Micromake D1 deltabot, for example.

thinkyhead commented 1 month ago

The Z_CLEARANCE_DEPLOY_PROBE is clearance above Z0 sometimes, but when used in a scenario where the probe will be deployed it refers to clearance above the height at which the probe will get triggered (or above 0, whichever is greater), which inversely corresponds to the probe offset set by M851 Z<offset>.

Example: The command M851 Z-2 indicates that the probe trigger-point is 2mm below the nozzle, so the nozzle will need to be > 2mm above the bed when the probe is deployed (Z_CLEARANCE_DEPLOY_PROBE - min(0, probe.offset.z).

Now, consider the scenario where you physically adjust your probe and issue a new M851 Z command. You will want the Z axis to do a different raise for probing in reponse to your change…. Maybe the nozzle now needs to be > 3mm above the bed.

JKZuchel commented 1 month ago

Hi I would like to comment that a got a GEEETECH i3 pro b printer and the first thing I did was flashing Marlin Bugfix 2.1.x and the auto home Z function from the LCD display would do its thing and zero out the Z axis all good there, but when it was done, it would move the extruder back to home and place it 5mm above the printing bed, the issue is that the display would say 5mm but it in reality was 10mm, now that I came across this post, flashed the printer with Marlin Bugfix 2.0.x and now it works just fine.

PSA: Sorry if am not being clear english is my second language and am I new to the 3d printer world.