Browse Source

Merge pull request #1774 from epatel/Development

Mesh bed leveling: Added G29 S3 + finer display steps during manual input + bug fix
pull/1/head
Scott Lahteine 10 years ago
parent
commit
e03da4805b
  1. 12
      Documentation/MeshBedLeveling.md
  2. 4
      Marlin/Configuration.h
  3. 54
      Marlin/Marlin_main.cpp
  4. 12
      Marlin/SanityCheck.h
  5. 4
      Marlin/configurator/config/Configuration.h
  6. 4
      Marlin/example_configurations/Felix/Configuration.h
  7. 4
      Marlin/example_configurations/Hephestos/Configuration.h
  8. 4
      Marlin/example_configurations/K8200/Configuration.h
  9. 4
      Marlin/example_configurations/SCARA/Configuration.h
  10. 4
      Marlin/example_configurations/WITBOX/Configuration.h
  11. 4
      Marlin/example_configurations/delta/generic/Configuration.h
  12. 4
      Marlin/example_configurations/delta/kossel_mini/Configuration.h
  13. 4
      Marlin/example_configurations/makibox/Configuration.h
  14. 4
      Marlin/example_configurations/tvrrug/Round2/Configuration.h
  15. 7
      Marlin/ultralcd.cpp

12
Documentation/MeshBedLeveling.md

@ -7,7 +7,7 @@ Background
This mesh based method of leveling/compensating can compensate for an non-flat bed. There are various opinions about doing this. It was primarily written to compensate a RigidBot BIG bed (40x30cm) that was somewhat bent.
Currently there is no automatic way to probe the bed like the Auto Bed Leveling feature. This might soon be implemented though, stay tuned.
Currently there is no automatic way to probe the bed like the Auto Bed Leveling feature. So, you can not enable `ENABLE_AUTO_BED_LEVELING` at the same time. This might soon be implemented though, stay tuned.
Theory
------
@ -28,6 +28,10 @@ In `Configuration.h` there are two options that can be enabled.
There are also some values that can be set.
The following will set the step distance used when manually turning the display encoder. Default is 0.025
`MBL_Z_STEP`
Following four define the area to cover. Default 10mm from max bed size
`MESH_MIN_X`<br/>
@ -55,14 +59,14 @@ When selecting this option the printer will first do a homing, and then travel t
If the EEPROM has been enable it can be good to issue a `M500` to get these points saved.
Issuing a `G29` will return the state of the mesh leveling.
Issuing a `G29` will return the state of the mesh leveling and report the probed points.
Probing the bed with G-codes
----------------------------
Probing the bed by G-codes follows the sequence much like doing it with the display.
`G29` or `G29 S0` will return the state bed leveling.
`G29` or `G29 S0` will return the state of the bed leveling and report the probed points. Where X=1 Y=1 is the top-left value and X=MESH_NUM_X_POINTS Y=MESH_NUM_Y_POINTS is bottom-right value. X per column and Y per row.
`G29 S1` will initiate the bed leveling, homing and traveling to the first point to probe.
@ -70,6 +74,8 @@ Then use your preferred Printer controller program, i.e. Printrun, to lower the
`G29 S2` will store the point and travel to the next point until last point has been probed.
`G29 S3 Xn Yn Zn.nn` will modify a single probed point. This can be used to tweak a badly probed point. Specify probe point where `Xn` and `Yn`, where `n` in `Xn` is between 1 and `MESH_NUM_X_POINTS`. Likewise for `Yn`. `Zn.nn` is the new Z value in that probed point.
Note
----

4
Marlin/Configuration.h

@ -426,6 +426,10 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
// #define MANUAL_BED_LEVELING // Add display menu option for bed leveling
// #define MESH_BED_LEVELING // Enable mesh bed leveling
#ifdef MANUAL_BED_LEVELING
#define MBL_Z_STEP 0.025 // Step size while manually probing Z axis
#endif // MANUAL_BED_LEVELING
#ifdef MESH_BED_LEVELING
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

54
Marlin/Marlin_main.cpp

@ -2013,7 +2013,7 @@ inline void gcode_G28() {
#ifdef MESH_BED_LEVELING
enum MeshLevelingState { MeshReport, MeshStart, MeshNext };
enum MeshLevelingState { MeshReport, MeshStart, MeshNext, MeshSet };
/**
* G29: Mesh-based Z-Probe, probes a grid and produces a
@ -2021,20 +2021,31 @@ inline void gcode_G28() {
*
* Parameters With MESH_BED_LEVELING:
*
* S0 Produce a mesh report
* S1 Start probing mesh points
* S2 Probe the next mesh point
* S0 Produce a mesh report
* S1 Start probing mesh points
* S2 Probe the next mesh point
* S3 Xn Yn Zn.nn Manually modify a single point
*
* The S0 report the points as below
*
* +----> X-axis
* |
* |
* v Y-axis
*
*/
inline void gcode_G29() {
static int probe_point = -1;
MeshLevelingState state = code_seen('S') || code_seen('s') ? (MeshLevelingState)code_value_short() : MeshReport;
if (state < 0 || state > 2) {
SERIAL_PROTOCOLLNPGM("S out of range (0-2).");
if (state < 0 || state > 3) {
SERIAL_PROTOCOLLNPGM("S out of range (0-3).");
return;
}
int ix, iy;
float z;
switch(state) {
case MeshReport:
if (mbl.active) {
@ -2068,7 +2079,6 @@ inline void gcode_G28() {
SERIAL_PROTOCOLLNPGM("Start mesh probing with \"G29 S1\" first.");
return;
}
int ix, iy;
if (probe_point == 0) {
// Set Z to a positive value before recording the first Z.
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
@ -2102,6 +2112,36 @@ inline void gcode_G28() {
mbl.active = 1;
enquecommands_P(PSTR("G28"));
}
break;
case MeshSet:
if (code_seen('X') || code_seen('x')) {
ix = code_value_long()-1;
if (ix < 0 || ix >= MESH_NUM_X_POINTS) {
SERIAL_PROTOCOLPGM("X out of range (1-" STRINGIFY(MESH_NUM_X_POINTS) ").\n");
return;
}
} else {
SERIAL_PROTOCOLPGM("X not entered.\n");
return;
}
if (code_seen('Y') || code_seen('y')) {
iy = code_value_long()-1;
if (iy < 0 || iy >= MESH_NUM_Y_POINTS) {
SERIAL_PROTOCOLPGM("Y out of range (1-" STRINGIFY(MESH_NUM_Y_POINTS) ").\n");
return;
}
} else {
SERIAL_PROTOCOLPGM("Y not entered.\n");
return;
}
if (code_seen('Z') || code_seen('z')) {
z = code_value();
} else {
SERIAL_PROTOCOLPGM("Z not entered.\n");
return;
}
mbl.z_values[iy][ix] = z;
} // switch(state)
}

12
Marlin/SanityCheck.h

@ -91,6 +91,18 @@
#error You must enable either DISPLAY_CHARSET_HD44780_JAPAN or DISPLAY_CHARSET_HD44780_WESTERN for your LCD controller.
#endif
/**
* Mesh Bed Leveling
*/
#ifdef MESH_BED_LEVELING
#ifdef DELTA
#error MESH_BED_LEVELING does not yet support DELTA printers
#endif
#ifdef ENABLE_AUTO_BED_LEVELING
#error Select ENABLE_AUTO_BED_LEVELING or MESH_BED_LEVELING, not both
#endif
#endif
/**
* Auto Bed Leveling
*/

4
Marlin/configurator/config/Configuration.h

@ -426,6 +426,10 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
// #define MANUAL_BED_LEVELING // Add display menu option for bed leveling
// #define MESH_BED_LEVELING // Enable mesh bed leveling
#ifdef MANUAL_BED_LEVELING
#define MBL_Z_STEP 0.025
#endif // MANUAL_BED_LEVELING
#ifdef MESH_BED_LEVELING
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

4
Marlin/example_configurations/Felix/Configuration.h

@ -364,6 +364,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
// #define MANUAL_BED_LEVELING // Add display menu option for bed leveling
// #define MESH_BED_LEVELING // Enable mesh bed leveling
#ifdef MANUAL_BED_LEVELING
#define MBL_Z_STEP 0.025
#endif // MANUAL_BED_LEVELING
#ifdef MESH_BED_LEVELING
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

4
Marlin/example_configurations/Hephestos/Configuration.h

@ -387,6 +387,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
// #define MANUAL_BED_LEVELING // Add display menu option for bed leveling
// #define MESH_BED_LEVELING // Enable mesh bed leveling
#ifdef MANUAL_BED_LEVELING
#define MBL_Z_STEP 0.025
#endif // MANUAL_BED_LEVELING
#ifdef MESH_BED_LEVELING
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

4
Marlin/example_configurations/K8200/Configuration.h

@ -392,6 +392,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
// #define MANUAL_BED_LEVELING // Add display menu option for bed leveling
// #define MESH_BED_LEVELING // Enable mesh bed leveling
#ifdef MANUAL_BED_LEVELING
#define MBL_Z_STEP 0.025
#endif // MANUAL_BED_LEVELING
#ifdef MESH_BED_LEVELING
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

4
Marlin/example_configurations/SCARA/Configuration.h

@ -416,6 +416,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
// #define MANUAL_BED_LEVELING // Add display menu option for bed leveling
// #define MESH_BED_LEVELING // Enable mesh bed leveling
#ifdef MANUAL_BED_LEVELING
#define MBL_Z_STEP 0.025
#endif // MANUAL_BED_LEVELING
#ifdef MESH_BED_LEVELING
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

4
Marlin/example_configurations/WITBOX/Configuration.h

@ -386,6 +386,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
// #define MANUAL_BED_LEVELING // Add display menu option for bed leveling
// #define MESH_BED_LEVELING // Enable mesh bed leveling
#ifdef MANUAL_BED_LEVELING
#define MBL_Z_STEP 0.025
#endif // MANUAL_BED_LEVELING
#ifdef MESH_BED_LEVELING
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

4
Marlin/example_configurations/delta/generic/Configuration.h

@ -414,6 +414,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
// #define MANUAL_BED_LEVELING // Add display menu option for bed leveling
// #define MESH_BED_LEVELING // Enable mesh bed leveling
#ifdef MANUAL_BED_LEVELING
#define MBL_Z_STEP 0.025
#endif // MANUAL_BED_LEVELING
#ifdef MESH_BED_LEVELING
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

4
Marlin/example_configurations/delta/kossel_mini/Configuration.h

@ -414,6 +414,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o
// #define MANUAL_BED_LEVELING // Add display menu option for bed leveling
// #define MESH_BED_LEVELING // Enable mesh bed leveling
#ifdef MANUAL_BED_LEVELING
#define MBL_Z_STEP 0.025
#endif // MANUAL_BED_LEVELING
#ifdef MESH_BED_LEVELING
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

4
Marlin/example_configurations/makibox/Configuration.h

@ -384,6 +384,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
// #define MANUAL_BED_LEVELING // Add display menu option for bed leveling
// #define MESH_BED_LEVELING // Enable mesh bed leveling
#ifdef MANUAL_BED_LEVELING
#define MBL_Z_STEP 0.025
#endif // MANUAL_BED_LEVELING
#ifdef MESH_BED_LEVELING
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

4
Marlin/example_configurations/tvrrug/Round2/Configuration.h

@ -386,6 +386,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
// #define MANUAL_BED_LEVELING // Add display menu option for bed leveling
// #define MESH_BED_LEVELING // Enable mesh bed leveling
#ifdef MANUAL_BED_LEVELING
#define MBL_Z_STEP 0.025
#endif // MANUAL_BED_LEVELING
#ifdef MESH_BED_LEVELING
#define MESH_MIN_X 10
#define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

7
Marlin/ultralcd.cpp

@ -1800,20 +1800,23 @@ static void _lcd_level_bed()
{
if (encoderPosition != 0) {
refresh_cmd_timeout();
current_position[Z_AXIS] += float((int)encoderPosition) * 0.05;
current_position[Z_AXIS] += float((int)encoderPosition) * MBL_Z_STEP;
if (min_software_endstops && current_position[Z_AXIS] < Z_MIN_POS) current_position[Z_AXIS] = Z_MIN_POS;
if (max_software_endstops && current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS;
encoderPosition = 0;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[Z_AXIS]/60, active_extruder);
lcdDrawUpdate = 1;
}
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("Z"), ftostr32(current_position[Z_AXIS]));
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("Z"), ftostr43(current_position[Z_AXIS]));
static bool debounce_click = false;
if (LCD_CLICKED) {
if (!debounce_click) {
debounce_click = true;
int ix = _lcd_level_bed_position % MESH_NUM_X_POINTS;
int iy = _lcd_level_bed_position / MESH_NUM_X_POINTS;
if (iy&1) { // Zig zag
ix = (MESH_NUM_X_POINTS - 1) - ix;
}
mbl.set_z(ix, iy, current_position[Z_AXIS]);
_lcd_level_bed_position++;
if (_lcd_level_bed_position == MESH_NUM_X_POINTS*MESH_NUM_Y_POINTS) {

Loading…
Cancel
Save