Improve Delta probing / calibration (#15887)

This commit is contained in:
Jason Smith
2019-11-21 01:26:00 -08:00
committed by Scott Lahteine
parent 4ede13e36a
commit b904ba0f29
26 changed files with 152 additions and 187 deletions

View File

@ -37,7 +37,7 @@
*/
// Change EEPROM version if the structure changes
#define EEPROM_VERSION "V71"
#define EEPROM_VERSION "V72"
#define EEPROM_OFFSET 100
// Check the integrity of data offsets.
@ -223,8 +223,7 @@ typedef struct SettingsDataStruct {
abc_float_t delta_endstop_adj; // M666 XYZ
float delta_radius, // M665 R
delta_diagonal_rod, // M665 L
delta_segments_per_second, // M665 S
delta_calibration_radius; // M665 B
delta_segments_per_second; // M665 S
abc_float_t delta_tower_angle_trim; // M665 XYZ
#elif EITHER(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
float x2_endstop_adj, // M666 X
@ -724,7 +723,6 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(delta_radius); // 1 float
EEPROM_WRITE(delta_diagonal_rod); // 1 float
EEPROM_WRITE(delta_segments_per_second); // 1 float
EEPROM_WRITE(delta_calibration_radius); // 1 float
EEPROM_WRITE(delta_tower_angle_trim); // 3 floats
#elif EITHER(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
@ -1534,7 +1532,6 @@ void MarlinSettings::postprocess() {
EEPROM_READ(delta_radius); // 1 float
EEPROM_READ(delta_diagonal_rod); // 1 float
EEPROM_READ(delta_segments_per_second); // 1 float
EEPROM_READ(delta_calibration_radius); // 1 float
EEPROM_READ(delta_tower_angle_trim); // 3 floats
#elif EITHER(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
@ -2375,7 +2372,6 @@ void MarlinSettings::reset() {
delta_radius = DELTA_RADIUS;
delta_diagonal_rod = DELTA_DIAGONAL_ROD;
delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
delta_calibration_radius = DELTA_CALIBRATION_RADIUS;
delta_tower_angle_trim = dta;
#elif EITHER(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
@ -2939,14 +2935,13 @@ void MarlinSettings::reset() {
, " Z", LINEAR_UNIT(delta_endstop_adj.c)
);
CONFIG_ECHO_HEADING("Delta settings: L<diagonal_rod> R<radius> H<height> S<segments_per_s> B<calibration radius> XYZ<tower angle corrections>");
CONFIG_ECHO_HEADING("Delta settings: L<diagonal_rod> R<radius> H<height> S<segments_per_s> XYZ<tower angle corrections>");
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR(
" M665 L", LINEAR_UNIT(delta_diagonal_rod)
, " R", LINEAR_UNIT(delta_radius)
, " H", LINEAR_UNIT(delta_height)
, " S", delta_segments_per_second
, " B", LINEAR_UNIT(delta_calibration_radius)
, " X", LINEAR_UNIT(delta_tower_angle_trim.a)
, " Y", LINEAR_UNIT(delta_tower_angle_trim.b)
, " Z", LINEAR_UNIT(delta_tower_angle_trim.c)

View File

@ -54,8 +54,7 @@ float delta_height;
abc_float_t delta_endstop_adj{0};
float delta_radius,
delta_diagonal_rod,
delta_segments_per_second,
delta_calibration_radius;
delta_segments_per_second;
abc_float_t delta_tower_angle_trim;
xy_float_t delta_tower[ABC];
abc_float_t delta_diagonal_rod_2_tower;
@ -83,6 +82,24 @@ void recalc_delta_settings() {
set_all_unhomed();
}
/**
* Get a safe radius for calibration
*/
#if ENABLED(DELTA_AUTO_CALIBRATION)
float calibration_radius_factor = 1;
#endif
float delta_calibration_radius() {
return FLOOR((DELTA_PRINTABLE_RADIUS - (
#if HAS_BED_PROBE
_MAX(HYPOT(probe_offset.x, probe_offset.y), MIN_PROBE_EDGE)
#else
MIN_PROBE_EDGE
#endif
)) * calibration_radius_factor);
}
/**
* Delta Inverse Kinematics
*

View File

@ -31,8 +31,7 @@ extern float delta_height;
extern abc_float_t delta_endstop_adj;
extern float delta_radius,
delta_diagonal_rod,
delta_segments_per_second,
delta_calibration_radius;
delta_segments_per_second;
extern abc_float_t delta_tower_angle_trim;
extern xy_float_t delta_tower[ABC];
extern abc_float_t delta_diagonal_rod_2_tower;
@ -44,6 +43,17 @@ extern float delta_clip_start_height;
*/
void recalc_delta_settings();
/**
* Get a safe radius for calibration
*/
#if ENABLED(DELTA_AUTO_CALIBRATION)
extern float calibration_radius_factor;
#else
constexpr float calibration_radius_factor = 1;
#endif
float delta_calibration_radius();
/**
* Delta Inverse Kinematics
*

View File

@ -60,48 +60,81 @@
#endif
#if HAS_LEVELING && (HAS_BED_PROBE || ENABLED(PROBE_MANUALLY))
inline float probe_min_x() {
return _MAX(
#if IS_KINEMATIC
PROBE_X_MIN, MESH_MIN_X
#else
(X_MIN_BED) + (MIN_PROBE_EDGE_LEFT), (X_MIN_POS) + probe_offset.x
#if HAS_BED_PROBE || ENABLED(PROBE_MANUALLY)
#if IS_KINEMATIC
constexpr float printable_radius =
#if ENABLED(DELTA)
DELTA_PRINTABLE_RADIUS;
#elif IS_SCARA
SCARA_PRINTABLE_RADIUS;
#endif
inline float probe_radius() {
return printable_radius -
#if HAS_BED_PROBE
_MAX(MIN_PROBE_EDGE, HYPOT(probe_offset.x, probe_offset.y));
#else
MIN_PROBE_EDGE;
#endif
}
#endif
inline float probe_min_x() {
return
#if IS_KINEMATIC
(X_CENTER) - probe_radius();
#else
_MAX((X_MIN_BED) + (MIN_PROBE_EDGE_LEFT), (X_MIN_POS) + probe_offset.x);
#endif
);
}
inline float probe_max_x() {
return _MIN(
return
#if IS_KINEMATIC
PROBE_X_MAX, MESH_MAX_X
(X_CENTER) + probe_radius();
#else
(X_MAX_BED) - (MIN_PROBE_EDGE_RIGHT), (X_MAX_POS) + probe_offset.x
_MIN((X_MAX_BED) - (MIN_PROBE_EDGE_RIGHT), (X_MAX_POS) + probe_offset.x);
#endif
);
}
inline float probe_min_y() {
return _MAX(
return
#if IS_KINEMATIC
PROBE_Y_MIN, MESH_MIN_Y
(Y_CENTER) - probe_radius();
#else
(Y_MIN_BED) + (MIN_PROBE_EDGE_FRONT), (Y_MIN_POS) + probe_offset.y
_MAX((Y_MIN_BED) + (MIN_PROBE_EDGE_FRONT), (Y_MIN_POS) + probe_offset.y);
#endif
);
}
inline float probe_max_y() {
return _MIN(
return
#if IS_KINEMATIC
PROBE_Y_MAX, MESH_MAX_Y
(Y_CENTER) + probe_radius();
#else
(Y_MAX_BED) - (MIN_PROBE_EDGE_BACK), (Y_MAX_POS) + probe_offset.y
_MIN((Y_MAX_BED) - (MIN_PROBE_EDGE_BACK), (Y_MAX_POS) + probe_offset.y);
#endif
);
}
#else
inline float probe_min_x() { return 0; };
inline float probe_max_x() { return 0; };
inline float probe_min_y() { return 0; };
inline float probe_max_y() { return 0; };
#if NEEDS_THREE_PROBE_POINTS
// Retrieve three points to probe the bed. Any type exposing set(X,Y) may be used.
template <typename T>
inline void get_three_probe_points(T points[3]) {
#if ENABLED(HAS_FIXED_3POINT)
points[0].set(PROBE_PT_1_X, PROBE_PT_1_Y);
points[1].set(PROBE_PT_2_X, PROBE_PT_2_Y);
points[2].set(PROBE_PT_3_X, PROBE_PT_3_Y);
#else
#if IS_KINEMATIC
constexpr float SIN0 = 0.0, SIN120 = 0.866025, SIN240 = -0.866025,
COS0 = 1.0, COS120 = -0.5 , COS240 = -0.5;
points[0].set((X_CENTER) + probe_radius() * COS0, (Y_CENTER) + probe_radius() * SIN0);
points[1].set((X_CENTER) + probe_radius() * COS120, (Y_CENTER) + probe_radius() * SIN120);
points[2].set((X_CENTER) + probe_radius() * COS240, (Y_CENTER) + probe_radius() * SIN240);
#else
points[0].set(probe_min_x(), probe_min_y());
points[1].set(probe_max_x(), probe_min_y());
points[2].set((probe_max_x() - probe_min_x()) / 2, probe_max_y());
#endif
#endif
}
#endif
#endif
#if HAS_Z_SERVO_PROBE