浏览代码

No retroactive changes with M851 Z

If using babystep to adjust the Z probe offset, the axis will move and the mesh will be updated at the same time, causing a doubling of the Z offset over the rest of the print.

To correct for this, the current Z position would need to be modified in the opposite direction, canceling out the additional Z offset added to the mesh. This would be confusing to users, and moreover it would not be accurate without also taking the current Z fade level and current Z height into account.

It might make sense to change the mesh in the case where no babystepping is taking place, but this could be considered an undesirable side-effect of changing the `zprobe_zoffset`.

One way to remedy this would be to return to storing the mesh with `zprobe_zoffset` included, then subtracting `zprobe_zoffset` from the returned Z value. Thus, a babystep moving the Z axis up 1mm would subtract 1 from `zprobe_zoffset` while adding 1 to all mesh Z values.

Without including the `zprobe_zoffset` in the `z_values` there is no safe way to alter the mesh in conjunction with babystepping, although it's fine without it.
Scott Lahteine 7 年前
父节点
当前提交
3bba7d60f3

+ 3
- 8
Marlin/src/gcode/motion/M290.cpp 查看文件

37
     for (uint8_t a = X_AXIS; a <= Z_AXIS; a++)
37
     for (uint8_t a = X_AXIS; a <= Z_AXIS; a++)
38
       if (parser.seenval(axis_codes[a]) || (a == Z_AXIS && parser.seenval('S'))) {
38
       if (parser.seenval(axis_codes[a]) || (a == Z_AXIS && parser.seenval('S'))) {
39
         const float offs = constrain(parser.value_axis_units((AxisEnum)a), -2, 2);
39
         const float offs = constrain(parser.value_axis_units((AxisEnum)a), -2, 2);
40
+        thermalManager.babystep_axis((AxisEnum)a, offs * planner.axis_steps_per_mm[a]);
40
         #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
41
         #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
41
-          if (a == Z_AXIS) {
42
-            zprobe_zoffset += offs;
43
-            refresh_zprobe_zoffset(true); // 'true' to not babystep
44
-          }
42
+          zprobe_zoffset += offs;
45
         #endif
43
         #endif
46
-        thermalManager.babystep_axis((AxisEnum)a, offs * planner.axis_steps_per_mm[a]);
47
       }
44
       }
48
   #else
45
   #else
49
     if (parser.seenval('Z') || parser.seenval('S')) {
46
     if (parser.seenval('Z') || parser.seenval('S')) {
50
       const float offs = constrain(parser.value_axis_units(Z_AXIS), -2, 2);
47
       const float offs = constrain(parser.value_axis_units(Z_AXIS), -2, 2);
48
+      thermalManager.babystep_axis(Z_AXIS, offs * planner.axis_steps_per_mm[Z_AXIS]);
51
       #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
49
       #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
52
         zprobe_zoffset += offs;
50
         zprobe_zoffset += offs;
53
-        refresh_zprobe_zoffset(); // This will babystep the axis
54
-      #else
55
-        thermalManager.babystep_axis(Z_AXIS, offs * planner.axis_steps_per_mm[Z_AXIS]);
56
       #endif
51
       #endif
57
     }
52
     }
58
   #endif
53
   #endif

+ 0
- 1
Marlin/src/gcode/probe/M851.cpp 查看文件

35
     const float value = parser.value_linear_units();
35
     const float value = parser.value_linear_units();
36
     if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
36
     if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
37
       zprobe_zoffset = value;
37
       zprobe_zoffset = value;
38
-      refresh_zprobe_zoffset();
39
       SERIAL_ECHO(zprobe_zoffset);
38
       SERIAL_ECHO(zprobe_zoffset);
40
     }
39
     }
41
     else
40
     else

+ 3
- 10
Marlin/src/lcd/ultralcd.cpp 查看文件

1100
         ENCODER_DIRECTION_NORMAL();
1100
         ENCODER_DIRECTION_NORMAL();
1101
         if (encoderPosition) {
1101
         if (encoderPosition) {
1102
           const int16_t babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
1102
           const int16_t babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
1103
-          encoderPosition = 0;
1104
-
1105
           const float new_zoffset = zprobe_zoffset + planner.steps_to_mm[Z_AXIS] * babystep_increment;
1103
           const float new_zoffset = zprobe_zoffset + planner.steps_to_mm[Z_AXIS] * babystep_increment;
1106
           if (WITHIN(new_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
1104
           if (WITHIN(new_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
1107
 
1105
 
1109
               thermalManager.babystep_axis(Z_AXIS, babystep_increment);
1107
               thermalManager.babystep_axis(Z_AXIS, babystep_increment);
1110
 
1108
 
1111
             zprobe_zoffset = new_zoffset;
1109
             zprobe_zoffset = new_zoffset;
1112
-            refresh_zprobe_zoffset(true);
1113
             lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
1110
             lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
1114
           }
1111
           }
1112
+          encoderPosition = 0;
1115
         }
1113
         }
1116
         if (lcdDrawUpdate) {
1114
         if (lcdDrawUpdate) {
1117
           lcd_implementation_drawedit(PSTR(MSG_ZPROBE_ZOFFSET), ftostr43sign(zprobe_zoffset));
1115
           lcd_implementation_drawedit(PSTR(MSG_ZPROBE_ZOFFSET), ftostr43sign(zprobe_zoffset));
1678
     static void lcd_load_settings()    { lcd_completion_feedback(settings.load()); }
1676
     static void lcd_load_settings()    { lcd_completion_feedback(settings.load()); }
1679
   #endif
1677
   #endif
1680
 
1678
 
1681
-  #if HAS_BED_PROBE && DISABLED(BABYSTEP_ZPROBE_OFFSET)
1682
-    static void lcd_refresh_zprobe_zoffset() { refresh_zprobe_zoffset(); }
1683
-  #endif
1684
-
1685
-
1686
   #if ENABLED(LEVEL_BED_CORNERS)
1679
   #if ENABLED(LEVEL_BED_CORNERS)
1687
 
1680
 
1688
     /**
1681
     /**
2000
       #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
1993
       #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
2001
         MENU_ITEM(submenu, MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
1994
         MENU_ITEM(submenu, MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
2002
       #elif HAS_BED_PROBE
1995
       #elif HAS_BED_PROBE
2003
-        MENU_ITEM_EDIT_CALLBACK(float32, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX, lcd_refresh_zprobe_zoffset);
1996
+        MENU_ITEM_EDIT(float32, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
2004
       #endif
1997
       #endif
2005
 
1998
 
2006
       MENU_ITEM(submenu, MSG_LEVEL_BED, _lcd_level_bed_continue);
1999
       MENU_ITEM(submenu, MSG_LEVEL_BED, _lcd_level_bed_continue);
3647
     #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
3640
     #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
3648
       MENU_ITEM(submenu, MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
3641
       MENU_ITEM(submenu, MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
3649
     #elif HAS_BED_PROBE
3642
     #elif HAS_BED_PROBE
3650
-      MENU_ITEM_EDIT_CALLBACK(float32, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX, lcd_refresh_zprobe_zoffset);
3643
+      MENU_ITEM_EDIT(float32, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
3651
     #endif
3644
     #endif
3652
 
3645
 
3653
     // M203 / M205 - Feedrate items
3646
     // M203 / M205 - Feedrate items

+ 1
- 6
Marlin/src/module/configuration_store.cpp 查看文件

247
     set_z_fade_height(new_z_fade_height);
247
     set_z_fade_height(new_z_fade_height);
248
   #endif
248
   #endif
249
 
249
 
250
-  #if HAS_BED_PROBE
251
-    refresh_zprobe_zoffset();
252
-  #endif
253
-
254
   #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
250
   #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
255
     refresh_bed_level();
251
     refresh_bed_level();
256
     //set_bed_leveling_enabled(leveling_is_on);
252
     //set_bed_leveling_enabled(leveling_is_on);
355
         sizeof(mbl.z_values) == GRID_MAX_POINTS * sizeof(mbl.z_values[0][0]),
351
         sizeof(mbl.z_values) == GRID_MAX_POINTS * sizeof(mbl.z_values[0][0]),
356
         "MBL Z array is the wrong size."
352
         "MBL Z array is the wrong size."
357
       );
353
       );
358
-      const bool leveling_is_on = mbl.has_mesh;
359
       const uint8_t mesh_num_x = GRID_MAX_POINTS_X, mesh_num_y = GRID_MAX_POINTS_Y;
354
       const uint8_t mesh_num_x = GRID_MAX_POINTS_X, mesh_num_y = GRID_MAX_POINTS_Y;
360
-      EEPROM_WRITE(leveling_is_on);
355
+      EEPROM_WRITE(mbl.has_mesh);
361
       EEPROM_WRITE(mbl.z_offset);
356
       EEPROM_WRITE(mbl.z_offset);
362
       EEPROM_WRITE(mesh_num_x);
357
       EEPROM_WRITE(mesh_num_x);
363
       EEPROM_WRITE(mesh_num_y);
358
       EEPROM_WRITE(mesh_num_y);

+ 0
- 36
Marlin/src/module/probe.cpp 查看文件

640
   return measured_z;
640
   return measured_z;
641
 }
641
 }
642
 
642
 
643
-void refresh_zprobe_zoffset(const bool no_babystep/*=false*/) {
644
-  static float last_zoffset = NAN;
645
-
646
-  if (!isnan(last_zoffset)) {
647
-
648
-    #if ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(BABYSTEP_ZPROBE_OFFSET) || ENABLED(DELTA)
649
-      const float diff = zprobe_zoffset - last_zoffset;
650
-    #endif
651
-
652
-    #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
653
-      // Correct bilinear grid for new probe offset
654
-      if (diff) {
655
-        for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
656
-          for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
657
-            z_values[x][y] -= diff;
658
-      }
659
-      #if ENABLED(ABL_BILINEAR_SUBDIVISION)
660
-        bed_level_virt_interpolate();
661
-      #endif
662
-    #endif
663
-
664
-    #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
665
-      if (!no_babystep && planner.leveling_active)
666
-        thermalManager.babystep_axis(Z_AXIS, -LROUND(diff * planner.axis_steps_per_mm[Z_AXIS]));
667
-    #else
668
-      UNUSED(no_babystep);
669
-    #endif
670
-
671
-    #if ENABLED(DELTA) // correct the delta_height
672
-      delta_height -= diff;
673
-    #endif
674
-  }
675
-
676
-  last_zoffset = zprobe_zoffset;
677
-}
678
-
679
 #if HAS_Z_SERVO_ENDSTOP
643
 #if HAS_Z_SERVO_ENDSTOP
680
 
644
 
681
   void servo_probe_init() {
645
   void servo_probe_init() {

+ 0
- 1
Marlin/src/module/probe.h 查看文件

34
 
34
 
35
 #if HAS_BED_PROBE
35
 #if HAS_BED_PROBE
36
   extern float zprobe_zoffset;
36
   extern float zprobe_zoffset;
37
-  void refresh_zprobe_zoffset(const bool no_babystep=false);
38
   #define DEPLOY_PROBE() set_probe_deployed(true)
37
   #define DEPLOY_PROBE() set_probe_deployed(true)
39
   #define STOW_PROBE() set_probe_deployed(false)
38
   #define STOW_PROBE() set_probe_deployed(false)
40
 #else
39
 #else

正在加载...
取消
保存