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.28k stars 19.23k forks source link

[BUG] All Z Offset Values Result in Same Behavior - No Effect #27505

Closed xaviervilla closed 6 days ago

xaviervilla commented 1 week ago

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

Yes, and the problem still exists.

Bug Description

Z Offset with ABL (BIQU_MICROPROBE_V2) has no effect on the physical height of the nozzle at specified Z Values. i.e. Offset of -2 and -10 both result in nozzle crashing into bed at Z = 1.

This is a separate issue but I will mention it here because it is possibly related: I tried to use PROBE_OFFSET_WIZARD but it gave strange undefined behavior even after wiping EEPROM and reinitializing so I disabled it. I would use it to find a z offset around -1.4 and when I hit done the Z Offset would then show ~36.x offset.. All subsequent "G29" procedures after this action resulted in "Probe Failed".

Bug Timeline

Oldest commit I saw this behavior was 70ef7978b418691904b1fe70f6c1009295eb5f7f

Expected behavior

I expect that with a z probe offset of -2, my nozzle is too high off the build plate when I do G0 Z0 but Nozzle crashes at Z = 1. I would expect that with a Z probe offset of -5, my nozzle is WAY too high off the build plate when I do G0 Z0 but nozzle crashes at Z = 1 again. I have ENABLE_LEVELING_AFTER_G28 defined, and it appears to work as intended because bed leveling always shows "on" in the menus.

Actual behavior

Different Z probe offset values make no difference to height of nozzle at Z=0.

Steps to Reproduce

;  ##### Starting from a fresh state:

M502
//action:notification Hardcoded Default Settings Loaded
echo:Hardcoded Default Settings Loaded
ok

M500
echo:Settings Stored (682 bytes; crc 28459)
//action:notification Settings Stored
ok

; ##### Retrieving from EEPROM to make sure settings look good from config.h
M501
echo:V90 stored settings retrieved (682 bytes; crc 2845941
//action:notification Stored settings retrieved
echo:; Linear Units:
echo:  G21 ; (mm)
echo:; Temperature Units:
echo:  M149 C ; Units in Celsius
echo:; Filament settings (Disabled):
echo:  M200 S0 D1.75
echo:; Steps per unit:
echo:  M92 X80.00 Y80.00 Z400.00 E430.17
echo:; Max feedrates (units/s):
echo:  M203 X800.00 Y800.00 Z5.00 E25.00
echo:; Max Acceleration (units/s2):
echo:  M201 X800.00 Y800.00 Z100.00 E5000.00
echo:; Acceleration (units/s2) (P<print-accel> R<retract-accel> T<travel-accel>)              :
echo:  M204 P800.00 R500.00 T800.00
echo:; Advanced (B<min_segment_time_us> S<min_feedrate> T<min_travel_feedrate> J              <junc_dev>):
echo:  M205 B20000.00 S0.00 T0.00 J0.08
echo:; Home offset:
echo:  M206 X0.00 Y0.00 Z0.00
echo:; Auto Bed Leveling:
echo:  M420 S0 Z10.00 ; Leveling OFF
echo:; Material heatup parameters:
echo:  M145 S0 H185.00 B45.00 F255
echo:  M145 S1 H240.00 B110.00 F255
echo:; Hotend PID:
echo:  M301 P21.73 I1.54 D76.55
echo:; Bed PID:
echo:  M304 P50.71 I9.88 D173.43
echo:; Controller Fan:
echo:  M710 S64 I0 A1 D60 ; (25% 0%)
echo:; Z-Probe Offset:
echo:  M851 X-40.00 Y4.00 Z-2.00 ; (mm). ; ##### Biqu Probe activates below the nozzle
echo:; Stepper driver current:
echo:  M906 X580 Y580 Z580
echo:  M906 T0 E650
echo:; Driver stepping mode:
echo:  M569 S1 X Y Z
echo:  M569 S1 T0 E
echo:; Linear Advance:
echo:  M900 K0.40
echo:; Filament load/unload:
echo:  M603 L80.00 U100.00 ; (mm)
ok

; ##### Homing
G28
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
X:157.00 Y:113.00 Z:7.00 E:0.00 Count X:12560 Y:9040 Z:2800
ok

; ##### Running ABL to get mesh
G29
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
Bilinear Leveling Grid:
      0      1      2      3      4
 0 +0.283 +0.160 +0.150 +0.140 +0.277
 1 +0.172 +0.030 +0.017 +0.013 +0.092
 2 +0.150 +0.013 +0.023 -0.025 +0.005
 3 +0.180 +0.057 +0.050 +0.020 +0.082
 4 +0.275 +0.158 +0.138 +0.142 +0.135

X:235.00 Y:221.00 Z:12.00 E:0.00 Count X:18800 Y:17680 Z:4800
ok

;  ##### Storing that mesh
M500
echo:Settings Stored (682 bytes; crc 43468)
//action:notification Settings Stored
ok

;  ##### Testing different heights at center of bed to get more accurate Z Offset
G0 X125 Y125
ok
G0 Z4
ok
G0 Z2
ok
G0 Z1.6
ok
G0 Z1.4
ok
G0 Z1.5
ok
; ######## At Z1.5 paper feels good under the nozzle

;######## Set -1.5 as z offset and save 
M851 Z-1.55
ok
M500
Mecho:Settings Stored (682 bytes; crc 56691)
//action:notification Settings Stored
ok

;######## verify change took effect in EEPROM
503
echo:; Linear Units:
echo:  G21 ; (mm)
echo:; Temperature Units:
echo:  M149 C ; Units in Celsius
echo:; Filament settings (Disabled):
echo:  M200 S0 D1.75
echo:; Steps per unit:
echo:  M92 X80.00 Y80.00 Z400.00 E430.17
echo:; Max feedrates (units/s):
echo:  M203 X800.00 Y800.00 Z5.00 E25.00
echo:; Max Acceleration (units/s2):
echo:  M201 X800.00 Y800.00 Z100.00 E5000.00
echo:; Acceleration (units/s2) (P<print-accel> R<retract-accel> T<travel-accel>):
echo:  M204 P800.00 R500.00 T800.00
echo:; Advanced (B<min_segment_time_us> S<min_feedrate> T<min_travel_feedrate> J<junc_dev>):
echo:  M205 B20000.00 S0.00 T0.00 J0.08
echo:; Home offset:
echo:  M206 X0.00 Y0.00 Z0.00
echo:; Auto Bed Leveling:
echo:  M420 S1 Z10.00 ; Leveling ON
echo:  G29 W I0 J0 Z0.28250
echo:  G29 W I1 J0 Z0.16000
echo:  G29 W I2 J0 Z0.15000
echo:  G29 W I3 J0 Z0.14000
echo:  G29 W I4 J0 Z0.27750
echo:  G29 W I0 J1 Z0.17250
echo:  G29 W I1 J1 Z0.03000
echo:  G29 W I2 J1 Z0.01750
echo:  G29 W I3 J1 Z0.01250
echo:  G29 W I4 J1 Z0.09250
echo:  G29 W I0 J2 Z0.15000
echo:  G29 W I1 J2 Z0.01250
echo:  G29 W I2 J2 Z0.02250
echo:  G29 W I3 J2 Z-0.02500
echo:  G29 W I4 J2 Z0.00500
echo:  G29 W I0 J3 Z0.18000
echo:  G29 W I1 J3 Z0.05750
echo:  G29 W I2 J3 Z0.05000
echo:  G29 W I3 J3 Z0.02000
echo:  G29 W I4 J3 Z0.08250
echo:  G29 W I0 J4 Z0.27500
echo:  G29 W I1 J4 Z0.15750
echo:  G29 W I2 J4 Z0.13750
echo:  G29 W I3 J4 Z0.14250
echo:  G29 W I4 J4 Z0.13500
echo:; Material heatup parameters:
echo:  M145 S0 H185.00 B45.00 F255
echo:  M145 S1 H240.00 B110.00 F255
echo:; Hotend PID:
echo:  M301 P21.73 I1.54 D76.55
echo:; Bed PID:
echo:  M304 P50.71 I9.88 D173.43
echo:; Controller Fan:
echo:  M710 S64 I0 A1 D60 ; (25% 0%)
echo:; Z-Probe Offset:
echo:  M851 X-40.00 Y4.00 Z-1.55 ; (mm). ; ############ Here we see the correct offset
echo:; Stepper driver current:
echo:  M906 X580 Y580 Z580
echo:  M906 T0 E650
echo:; Driver stepping mode:
echo:  M569 S1 X Y Z
echo:  M569 S1 T0 E
echo:; Linear Advance:
echo:  M900 K0.40
echo:; Filament load/unload:
echo:  M603 L80.00 U100.00 ; (mm)
ok

;######## auto Home again (I have ENABLE_LEVELING_AFTER_G28 on so leveling is still on and visible in LCD menu as “on”)
G28
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
echo:busy: processing
X:157.00 Y:113.00 Z:6.56 E:0.00 Count X:12560 Y:9040 Z:2620
ok

; ###### Test nozzle height as it approaches  0 height.
G0 X125 Y125 Z4
ok
G0 Z2
ok
G0 Z1
ok
; ########## Nozzle is already pressing into the build plate. cannot go lower

; ####### Sanity Check that this is broken
G0 Z15
M851 Z-5. ; #### Bogus z offset value
G0 Z2
ok
G0 Z1
; ######## Again Nozzle pressing into build plate at same exact point as with other z offset, cannot go lower

Version of Marlin Firmware

M115 FIRMWARE_NAME:Marlin bugfix-2.1.x (Oct 30 2024 00:14:03) SOURCE_CODE_URL:github.com/MarlinFirmware/Marlin PROTOCOL_VERSION:1.0 MACHINE_TYPE:Ender-3 Pro KINEMATICS:Cartesian EXTRUDER_COUNT:1 UUID:cede2a2f-41a2-4748-9b12-c55c62f367ff Cap:SERIAL_XON_XOFF:0 Cap:BINARY_FILE_TRANSFER:0 Cap:EEPROM:1 Cap:VOLUMETRIC:1 Cap:AUTOREPORT_POS:1 Cap:AUTOREPORT_TEMP:1 Cap:PROGRESS:0 Cap:PRINT_JOB:1 Cap:AUTOLEVEL:1 Cap:RUNOUT:0 Cap:Z_PROBE:1 Cap:LEVELING_DATA:1 Cap:BUILD_PERCENT:1 Cap:SOFTWARE_POWER:0 Cap:TOGGLE_LIGHTS:0 Cap:CASE_LIGHT_BRIGHTNESS:0 Cap:EMERGENCY_PARSER:1 Cap:HOST_ACTION_COMMANDS:1 Cap:PROMPT_SUPPORT:1 Cap:SDCARD:1 Cap:MULTI_VOLUME:0 Cap:REPEAT:0 Cap:SD_WRITE:1 Cap:AUTOREPORT_SD_STATUS:1 Cap:LONG_FILENAME:1 Cap:LFN_WRITE:0 Cap:CUSTOM_FIRMWARE_UPLOAD:0 Cap:EXTENDED_M20:1 Cap:THERMAL_PROTECTION:1 Cap:MOTION_MODES:0 Cap:ARCS:1 Cap:BABYSTEPPING:1 Cap:EP_BABYSTEP:0 Cap:CHAMBER_TEMPERATURE:0 Cap:COOLER_TEMPERATURE:0 Cap:MEATPACK:0 Cap:CONFIG_EXPORT:0 ok

Printer model

Modified Ender 3 Pro

Electronics

BTT SKR Mini E3 V3

LCD/Controller

Stock LCD

Other add-ons

BIQU MicroProbe V2, Sprite Direct Drive Extruder, Phaetus Dragon UHF

Bed Leveling

ABL Bilinear mesh

Your Slicer

Prusa Slicer

Host Software

Other (explain below)

Don't forget to include

Additional information & file uploads

My config diff of the SKR mini e3 v3 configs here:

https://github.com/MarlinFirmware/Configurations/commit/e8b69f0882acd6ea8999104151e5c79aec4d0b15

My config diff compared to the default config in the Marlin repo if that is helpful at all:

https://github.com/MarlinFirmware/Marlin/compare/bugfix-2.1.x...xaviervilla:Marlin:z-offset-fix_bugfix-2.1.x

Config files:

Configs.zip

I embedded a bunch of GCode above that can be utilized for testing (in steps to reproduce section).

Nuck-TH commented 1 week ago

I reproduce it on Kingroon KP3s with current bugfix. Changing offset directly, using wizard or babystepping it doesn't change first layer thickness at all, it is always the same. Configuration.zip

xaviervilla commented 1 week ago

Interesting. ~Babystep live during the first layer did work for me, but saving to EEPROM after the print did not solve the issue when I went to reprint.~ (Edit for clarification: realized I was just using regular babystepping z, not z offset.)

I spent a significant amount of time trying to figure out if it was me doin something wrong but I’m pretty confident now that there is a bug here. This is my first time ever using ABL though so maybe I’m missing something.

In the meantime, I may try manually moving to the Z height I need in my g code and then setting the current position to zero before my print. I believe that should be a temporary workaround for people who need to print.

ThomasToka commented 1 week ago

Have you tried to enable those two already?

#define BABYSTEP_ALWAYS_AVAILABLE
#define BABYSTEP_ZPROBE_OFFSET
Nuck-TH commented 1 week ago

BABYSTEP_ZPROBE_OFFSET was already enabled, BABYSTEP_ALWAYS_AVAILABLE did nothing to change situation.

xaviervilla commented 1 week ago

Apologies, I was adjusting babystep during my first layer, not BABYSTEP_ZPROBE_OFFSET. I have BABYSTEP_ZPROBE_OFFSET disabled. So I cannot verify if I had the same or different behavior as what @Nuck-TH described with babystepping Although they definitely seem related. I could enable it and try that too but I would need to make some custom GCODE because I've pretty much destroyed my bed trying to sort this out.. I have a little time to dig into the code and check recent commits now.

xaviervilla commented 1 week ago

Looks like this was added to G29. Looking into why.

        // Unapply the offset because it is going to be immediately applied
        // and cause compensation movement in Z
        const float fade_scaling_factor = TERN(ENABLE_LEVELING_FADE_HEIGHT, planner.fade_scaling_factor_for_z(current_position.z), 1);
        current_position.z -= fade_scaling_factor * bilinear_z_offset(current_position);
xaviervilla commented 1 week ago

Okay after looking through the G29 code, I decided to try G29 Z5 and that made the nozzle 5MM off the bed when Z showed zero on the build plate. And my Mesh shows:

      0      1      2      3      4
 0 +5.307 +5.170 +5.150 +5.148 +5.280
 1 +5.175 +5.035 +5.010 +5.028 +5.090
 2 +5.145 +5.015 +5.012 +4.990 +5.035
 3 +5.193 +5.052 +5.043 +5.045 +5.080
 4 +5.195 +5.160 +5.145 +5.133 +5.140

I believe this is to be expected from the documentation I read.

I don't see anywhere in the G29 code that looks like it is applying the offset from the EEPROM/config value, but only from the gcode command itself. Is this expected?

I'm thinking I should look into the M851 code now.

robherc commented 1 week ago

I expect that with a z probe offset of -2, my nozzle is too high off the build plate when I do G0 Z0 but Nozzle crashes at Z = 1. I would expect that with a Z probe offset of -5, my nozzle is WAY too high off the build plate when I do G0 Z0 but nozzle crashes at Z = 1 again.

I haven't read through your configs yet, but I ### did### notice a slight problem with your logic here. The more negative you set your PROBE_Z_OFFSET, the further BELOW the prob's trigger-point you're telling Marlin to move to get the nozzle to Z=0.

Will you please attempt setting your Z_PROBE_OFFSET to +2mm; then re-home; then G1 X110 Y110 Z0.1 F1500 If the Z_PROBE_OFFSET is being applied, that should most DEFINITELY end motion with ths nozzle a few mm above your bed surface.

xaviervilla commented 1 week ago

Will you please attempt setting your Z_PROBE_OFFSET to +2mm; then re-home; then G1 X110 Y110 Z0.1 F1500 If the Z_PROBE_OFFSET is being applied, that should most DEFINITELY end motion with ths nozzle a few mm above your bed surface.

I did try positive values as well, but I’ll give it a shot again and respond with what happens. Thanks for the feedback. I got mixed up when I posted that, (it was about 2am and I was tired). But I agree with you, the expectation should have been that with -5 offset the nozzle crashes at an earlier point (z=4 in that example). But it continues to crash at Z=1 each time, regardless of the Z offset.

xaviervilla commented 6 days ago

@robherc I initially followed your instructions and then got the same behavior I mentioned.

; Probe the bed
G29 
...
      0      1      2      3      4
 0 +0.253 +0.138 +0.123 +0.112 +0.255
 1 +0.148 +0.018 -0.005 -0.007 +0.065
 2 +0.120 -0.005 +0.003 -0.048 -0.018
 3 +0.140 +0.035 +0.028 +0.000 +0.060
 4 +0.235 +0.135 +0.118 +0.128 +0.125

X:235.00 Y:221.00 Z:11.55 E:0.00 Count X:18800 Y:17680 Z:4620
ok

; Set Positive Z probe offset
M851 Z2
ok

M500
echo:Settings Stored (682 bytes; crc 49771)
//action:notification Settings Stored
ok

; Move to bed center
G1 X110 Y110 Z5 F1500
echo:busy: processing
ok

; Incrementally lower nozzle
G1 Z3
ok
G1 Z2
ok
G1 Z1
; Nozzle is already pressed into the bed

And then I re-read what you said. You said to home again after setting the Z offset. I tried again, homing right after setting the Z offset and to my disbelief it worked. Persists reboots as well. The final z probe offset value I needed was -1.4. First print is going down great now.

Retrospective:

I feel very dumb for not figuring that out on my own. Looking through my command history and even the gcode in the original post, I was not homing each time between my tests. Oddly, the prints that tried trying were homing so I don't know why those changes didn't seem like they were applying, but it was probably something I was doing wrong. My other source of confusion is that I thought I was babystepping Z probe offset and storing to EEPROM during my prints. But I was actually just adjusting regular babystep Z which is different and does not get stored to EEPROM at all.

Summary:

Users must home after setting the z probe offset for it to be applied and take effect. While I am tempted to close this issue, I'll leave it open for a dev to close at their discretion with this closing remark:

On the Marlin Documentation on M851, there is no mention that homing is required after setting the Z offset. In fact, in the videos I watched online, there was also no mention of this. Is this new? If this is the desired behavior I believe that it should definitely be documented better on the M851 page. Otherwise, I think it makes the most sense for M851 to automatically apply the Z offset immediately.

Thank you to all who helped.

robherc commented 6 days ago

Users must home after setting the z probe offset for it to be applied and take effect.

Actually, this is because you disabled the babystepping for z_probe_offset. When that is enabled, while it may still be recommendable to re-home after the adjustment, it is generally not necessary, as the printer is babystepping to "live-apply" the new Z-Offset as you adjust the setpoint.