Add "G29 S4" to fine tune Z level for Mesh Bed Leveling.

Also add mbl.z_offset to the EEPROM, bumping the version to V23.
This commit is contained in:
Edward Patel 2016-03-24 22:16:09 +01:00 committed by Scott Lahteine
parent 122bdd187f
commit c606ed447a
6 changed files with 81 additions and 46 deletions

View file

@ -2717,7 +2717,7 @@ inline void gcode_G28() {
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(MESH_BED_LEVELING)
enum MeshLevelingState { MeshReport, MeshStart, MeshNext, MeshSet }; enum MeshLevelingState { MeshReport, MeshStart, MeshNext, MeshSet, MeshSetZOffset };
/** /**
* G29: Mesh-based Z probe, probes a grid and produces a * G29: Mesh-based Z probe, probes a grid and produces a
@ -2729,21 +2729,22 @@ inline void gcode_G28() {
* S1 Start probing mesh points * S1 Start probing mesh points
* S2 Probe the next mesh point * S2 Probe the next mesh point
* S3 Xn Yn Zn.nn Manually modify a single point * S3 Xn Yn Zn.nn Manually modify a single point
* S4 Zn.nn Set z offset. Positive away from bed, negative closer to bed.
* *
* The S0 report the points as below * The S0 report the points as below
* *
* +----> X-axis * +----> X-axis 1-n
* | * |
* | * |
* v Y-axis * v Y-axis 1-n
* *
*/ */
inline void gcode_G29() { inline void gcode_G29() {
static int probe_point = -1; static int probe_point = -1;
MeshLevelingState state = code_seen('S') ? (MeshLevelingState)code_value_short() : MeshReport; MeshLevelingState state = code_seen('S') ? (MeshLevelingState)code_value_short() : MeshReport;
if (state < 0 || state > 3) { if (state < 0 || state > 4) {
SERIAL_PROTOCOLLNPGM("S out of range (0-3)."); SERIAL_PROTOCOLLNPGM("S out of range (0-4).");
return; return;
} }
@ -2759,6 +2760,8 @@ inline void gcode_G28() {
SERIAL_PROTOCOL(MESH_NUM_Y_POINTS); SERIAL_PROTOCOL(MESH_NUM_Y_POINTS);
SERIAL_PROTOCOLPGM("\nZ search height: "); SERIAL_PROTOCOLPGM("\nZ search height: ");
SERIAL_PROTOCOL(MESH_HOME_SEARCH_Z); SERIAL_PROTOCOL(MESH_HOME_SEARCH_Z);
SERIAL_PROTOCOLPGM("\nZ offset: ");
SERIAL_PROTOCOL_F(mbl.z_offset, 5);
SERIAL_PROTOCOLLNPGM("\nMeasured points:"); SERIAL_PROTOCOLLNPGM("\nMeasured points:");
for (int y = 0; y < MESH_NUM_Y_POINTS; y++) { for (int y = 0; y < MESH_NUM_Y_POINTS; y++) {
for (int x = 0; x < MESH_NUM_X_POINTS; x++) { for (int x = 0; x < MESH_NUM_X_POINTS; x++) {
@ -2849,6 +2852,17 @@ inline void gcode_G28() {
return; return;
} }
mbl.z_values[iy][ix] = z; mbl.z_values[iy][ix] = z;
break;
case MeshSetZOffset:
if (code_seen('Z')) {
z = code_value();
}
else {
SERIAL_PROTOCOLPGM("Z not entered.\n");
return;
}
mbl.z_offset = z;
} // switch(state) } // switch(state)
} }

View file

@ -36,10 +36,10 @@
* *
*/ */
#define EEPROM_VERSION "V22" #define EEPROM_VERSION "V23"
/** /**
* V21 EEPROM Layout: * V23 EEPROM Layout:
* *
* 100 Version (char x4) * 100 Version (char x4)
* *
@ -59,62 +59,65 @@
* *
* Mesh bed leveling: * Mesh bed leveling:
* 200 M420 S active (bool) * 200 M420 S active (bool)
* 201 mesh_num_x (uint8 as set in firmware) * 201 z_offset (float) (added in V23)
* 202 mesh_num_y (uint8 as set in firmware) * 205 mesh_num_x (uint8 as set in firmware)
* 203 M421 XYZ z_values[][] (float x9, by default) * 206 mesh_num_y (uint8 as set in firmware)
* 239 M851 zprobe_zoffset (float) * 207 M421 XYZ z_values[][] (float x9, by default)
*
* AUTO BED LEVELING
* 243 M851 zprobe_zoffset (float)
* *
* DELTA: * DELTA:
* 243 M666 XYZ endstop_adj (float x3) * 247 M666 XYZ endstop_adj (float x3)
* 255 M665 R delta_radius (float) * 259 M665 R delta_radius (float)
* 259 M665 L delta_diagonal_rod (float) * 263 M665 L delta_diagonal_rod (float)
* 263 M665 S delta_segments_per_second (float) * 267 M665 S delta_segments_per_second (float)
* 267 M665 A delta_diagonal_rod_trim_tower_1 (float) * 271 M665 A delta_diagonal_rod_trim_tower_1 (float)
* 271 M665 B delta_diagonal_rod_trim_tower_2 (float) * 275 M665 B delta_diagonal_rod_trim_tower_2 (float)
* 275 M665 C delta_diagonal_rod_trim_tower_3 (float) * 279 M665 C delta_diagonal_rod_trim_tower_3 (float)
* *
* Z_DUAL_ENDSTOPS: * Z_DUAL_ENDSTOPS:
* 279 M666 Z z_endstop_adj (float) * 283 M666 Z z_endstop_adj (float)
* *
* ULTIPANEL: * ULTIPANEL:
* 283 M145 S0 H plaPreheatHotendTemp (int) * 287 M145 S0 H plaPreheatHotendTemp (int)
* 285 M145 S0 B plaPreheatHPBTemp (int) * 289 M145 S0 B plaPreheatHPBTemp (int)
* 287 M145 S0 F plaPreheatFanSpeed (int) * 291 M145 S0 F plaPreheatFanSpeed (int)
* 289 M145 S1 H absPreheatHotendTemp (int) * 293 M145 S1 H absPreheatHotendTemp (int)
* 291 M145 S1 B absPreheatHPBTemp (int) * 295 M145 S1 B absPreheatHPBTemp (int)
* 293 M145 S1 F absPreheatFanSpeed (int) * 297 M145 S1 F absPreheatFanSpeed (int)
* *
* PIDTEMP: * PIDTEMP:
* 295 M301 E0 PIDC Kp[0], Ki[0], Kd[0], Kc[0] (float x4) * 299 M301 E0 PIDC Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
* 311 M301 E1 PIDC Kp[1], Ki[1], Kd[1], Kc[1] (float x4) * 315 M301 E1 PIDC Kp[1], Ki[1], Kd[1], Kc[1] (float x4)
* 327 M301 E2 PIDC Kp[2], Ki[2], Kd[2], Kc[2] (float x4) * 331 M301 E2 PIDC Kp[2], Ki[2], Kd[2], Kc[2] (float x4)
* 343 M301 E3 PIDC Kp[3], Ki[3], Kd[3], Kc[3] (float x4) * 347 M301 E3 PIDC Kp[3], Ki[3], Kd[3], Kc[3] (float x4)
* 359 M301 L lpq_len (int) * 363 M301 L lpq_len (int)
* *
* PIDTEMPBED: * PIDTEMPBED:
* 361 M304 PID bedKp, bedKi, bedKd (float x3) * 365 M304 PID bedKp, bedKi, bedKd (float x3)
* *
* DOGLCD: * DOGLCD:
* 373 M250 C lcd_contrast (int) * 377 M250 C lcd_contrast (int)
* *
* SCARA: * SCARA:
* 375 M365 XYZ axis_scaling (float x3) * 379 M365 XYZ axis_scaling (float x3)
* *
* FWRETRACT: * FWRETRACT:
* 387 M209 S autoretract_enabled (bool) * 391 M209 S autoretract_enabled (bool)
* 388 M207 S retract_length (float) * 392 M207 S retract_length (float)
* 392 M207 W retract_length_swap (float) * 396 M207 W retract_length_swap (float)
* 396 M207 F retract_feedrate (float) * 400 M207 F retract_feedrate (float)
* 400 M207 Z retract_zlift (float) * 404 M207 Z retract_zlift (float)
* 404 M208 S retract_recover_length (float) * 408 M208 S retract_recover_length (float)
* 408 M208 W retract_recover_length_swap (float) * 412 M208 W retract_recover_length_swap (float)
* 412 M208 F retract_recover_feedrate (float) * 416 M208 F retract_recover_feedrate (float)
* *
* Volumetric Extrusion: * Volumetric Extrusion:
* 416 M200 D volumetric_enabled (bool) * 420 M200 D volumetric_enabled (bool)
* 417 M200 T D filament_size (float x4) (T0..3) * 421 M200 T D filament_size (float x4) (T0..3)
* *
* 433 This Slot is Available! * 437 This Slot is Available!
* *
*/ */
#include "Marlin.h" #include "Marlin.h"
@ -192,15 +195,17 @@ void Config_StoreSettings() {
mesh_num_x = MESH_NUM_X_POINTS; mesh_num_x = MESH_NUM_X_POINTS;
mesh_num_y = MESH_NUM_Y_POINTS; mesh_num_y = MESH_NUM_Y_POINTS;
EEPROM_WRITE_VAR(i, mbl.active); EEPROM_WRITE_VAR(i, mbl.active);
EEPROM_WRITE_VAR(i, mbl.z_offset);
EEPROM_WRITE_VAR(i, mesh_num_x); EEPROM_WRITE_VAR(i, mesh_num_x);
EEPROM_WRITE_VAR(i, mesh_num_y); EEPROM_WRITE_VAR(i, mesh_num_y);
EEPROM_WRITE_VAR(i, mbl.z_values); EEPROM_WRITE_VAR(i, mbl.z_values);
#else #else
uint8_t dummy_uint8 = 0; uint8_t dummy_uint8 = 0;
dummy = 0.0f;
EEPROM_WRITE_VAR(i, dummy_uint8); EEPROM_WRITE_VAR(i, dummy_uint8);
EEPROM_WRITE_VAR(i, dummy);
EEPROM_WRITE_VAR(i, mesh_num_x); EEPROM_WRITE_VAR(i, mesh_num_x);
EEPROM_WRITE_VAR(i, mesh_num_y); EEPROM_WRITE_VAR(i, mesh_num_y);
dummy = 0.0f;
for (uint8_t q = 0; q < mesh_num_x * mesh_num_y; q++) EEPROM_WRITE_VAR(i, dummy); for (uint8_t q = 0; q < mesh_num_x * mesh_num_y; q++) EEPROM_WRITE_VAR(i, dummy);
#endif // MESH_BED_LEVELING #endif // MESH_BED_LEVELING
@ -366,10 +371,12 @@ void Config_RetrieveSettings() {
uint8_t dummy_uint8 = 0, mesh_num_x = 0, mesh_num_y = 0; uint8_t dummy_uint8 = 0, mesh_num_x = 0, mesh_num_y = 0;
EEPROM_READ_VAR(i, dummy_uint8); EEPROM_READ_VAR(i, dummy_uint8);
EEPROM_READ_VAR(i, dummy);
EEPROM_READ_VAR(i, mesh_num_x); EEPROM_READ_VAR(i, mesh_num_x);
EEPROM_READ_VAR(i, mesh_num_y); EEPROM_READ_VAR(i, mesh_num_y);
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(MESH_BED_LEVELING)
mbl.active = dummy_uint8; mbl.active = dummy_uint8;
mbl.z_offset = dummy;
if (mesh_num_x == MESH_NUM_X_POINTS && mesh_num_y == MESH_NUM_Y_POINTS) { if (mesh_num_x == MESH_NUM_X_POINTS && mesh_num_y == MESH_NUM_Y_POINTS) {
EEPROM_READ_VAR(i, mbl.z_values); EEPROM_READ_VAR(i, mbl.z_values);
} else { } else {

View file

@ -169,6 +169,9 @@
#ifndef MSG_SPEED #ifndef MSG_SPEED
#define MSG_SPEED "Speed" #define MSG_SPEED "Speed"
#endif #endif
#ifndef MSG_BED_Z
#define MSG_BED_Z "Bed Z"
#endif
#ifndef MSG_NOZZLE #ifndef MSG_NOZZLE
#define MSG_NOZZLE "Nozzle" #define MSG_NOZZLE "Nozzle"
#endif #endif

View file

@ -30,6 +30,7 @@
void mesh_bed_leveling::reset() { void mesh_bed_leveling::reset() {
active = 0; active = 0;
z_offset = 0;
for (int y = 0; y < MESH_NUM_Y_POINTS; y++) for (int y = 0; y < MESH_NUM_Y_POINTS; y++)
for (int x = 0; x < MESH_NUM_X_POINTS; x++) for (int x = 0; x < MESH_NUM_X_POINTS; x++)
z_values[y][x] = 0; z_values[y][x] = 0;

View file

@ -30,6 +30,7 @@
class mesh_bed_leveling { class mesh_bed_leveling {
public: public:
uint8_t active; uint8_t active;
float z_offset;
float z_values[MESH_NUM_Y_POINTS][MESH_NUM_X_POINTS]; float z_values[MESH_NUM_Y_POINTS][MESH_NUM_X_POINTS];
mesh_bed_leveling(); mesh_bed_leveling();
@ -70,7 +71,7 @@
float z0 = calc_z0(y0, float z0 = calc_z0(y0,
get_y(y_index), z1, get_y(y_index), z1,
get_y(y_index + 1), z2); get_y(y_index + 1), z2);
return z0; return z0 + z_offset;
} }
}; };

View file

@ -599,6 +599,11 @@ static void lcd_tune_menu() {
// //
MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999); MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999);
// Manual bed leveling, Bed Z:
#if ENABLED(MANUAL_BED_LEVELING)
MENU_ITEM_EDIT(float43, MSG_BED_Z, &mbl.z_offset, -1, 1);
#endif
// //
// Nozzle: // Nozzle:
// Nozzle [1-4]: // Nozzle [1-4]:
@ -1333,6 +1338,10 @@ static void lcd_control_motion_menu() {
#if ENABLED(AUTO_BED_LEVELING_FEATURE) #if ENABLED(AUTO_BED_LEVELING_FEATURE)
MENU_ITEM_EDIT(float32, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); MENU_ITEM_EDIT(float32, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
#endif #endif
// Manual bed leveling, Bed Z:
#if ENABLED(MANUAL_BED_LEVELING)
MENU_ITEM_EDIT(float43, MSG_BED_Z, &mbl.z_offset, -1, 1);
#endif
MENU_ITEM_EDIT(float5, MSG_ACC, &acceleration, 10, 99000); MENU_ITEM_EDIT(float5, MSG_ACC, &acceleration, 10, 99000);
MENU_ITEM_EDIT(float3, MSG_VXY_JERK, &max_xy_jerk, 1, 990); MENU_ITEM_EDIT(float3, MSG_VXY_JERK, &max_xy_jerk, 1, 990);
#if ENABLED(DELTA) #if ENABLED(DELTA)