Merge pull request #78 from PavelSindler/4point_xyz_cal

4point xyz cal.
This commit is contained in:
PavelSindler 2017-11-07 10:02:32 +01:00 committed by GitHub
commit 461675b806
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 52 additions and 43 deletions

View File

@ -77,6 +77,8 @@
// Power loss errors // Power loss errors
#define EEPROM_POWER_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-17) #define EEPROM_POWER_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-17)
#define EEPROM_XYZ_CAL_SKEW (EEPROM_POWER_COUNT - 4) //float for skew backup
// Currently running firmware, each digit stored as uint16_t. // Currently running firmware, each digit stored as uint16_t.
// The flavor differentiates a dev, alpha, beta, release candidate or a release version. // The flavor differentiates a dev, alpha, beta, release candidate or a release version.
#define EEPROM_FIRMWARE_VERSION_END (FW_PRUSA3D_MAGIC_LEN+8) #define EEPROM_FIRMWARE_VERSION_END (FW_PRUSA3D_MAGIC_LEN+8)

View File

@ -339,8 +339,7 @@ extern unsigned long t_fan_rising_edge;
extern bool mesh_bed_leveling_flag; extern bool mesh_bed_leveling_flag;
extern bool mesh_bed_run_from_menu; extern bool mesh_bed_run_from_menu;
extern float distance_from_min[3]; extern float distance_from_min[2];
extern float angleDiff;
extern void calculate_volumetric_multipliers(); extern void calculate_volumetric_multipliers();

View File

@ -313,8 +313,7 @@ unsigned int custom_message_type;
unsigned int custom_message_state; unsigned int custom_message_state;
char snmm_filaments_used = 0; char snmm_filaments_used = 0;
float distance_from_min[3]; float distance_from_min[2];
float angleDiff;
bool fan_state[2]; bool fan_state[2];
int fan_edge_counter[2]; int fan_edge_counter[2];
@ -1454,7 +1453,7 @@ inline void gcode_M900() {
#ifdef TMC2130 #ifdef TMC2130
bool calibrate_z_auto() bool calibrate_z_auto()
{ {
lcd_display_message_fullscreen_P(MSG_CALIBRATE_Z_AUTO); //lcd_display_message_fullscreen_P(MSG_CALIBRATE_Z_AUTO);
bool endstops_enabled = enable_endstops(true); bool endstops_enabled = enable_endstops(true);
int axis_up_dir = -home_dir(Z_AXIS); int axis_up_dir = -home_dir(Z_AXIS);
tmc2130_home_enter(Z_AXIS_MASK); tmc2130_home_enter(Z_AXIS_MASK);
@ -6903,6 +6902,7 @@ extern uint32_t sdpos_atomic;
void uvlo_() void uvlo_()
{ {
unsigned long time_start = millis();
// Conserve power as soon as possible. // Conserve power as soon as possible.
disable_x(); disable_x();
disable_y(); disable_y();
@ -6998,6 +6998,7 @@ void uvlo_()
eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, power_count); eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, power_count);
SERIAL_ECHOLNPGM("UVLO - end"); SERIAL_ECHOLNPGM("UVLO - end");
MYSERIAL.println(millis() - time_start);
cli(); cli();
while(1); while(1);
} }

View File

@ -219,7 +219,7 @@
#define MSG_FIND_BED_OFFSET_AND_SKEW_LINE1 "Hledam kalibracni bod podlozky" #define MSG_FIND_BED_OFFSET_AND_SKEW_LINE1 "Hledam kalibracni bod podlozky"
#define MSG_FIND_BED_OFFSET_AND_SKEW_LINE2 " z 4" #define MSG_FIND_BED_OFFSET_AND_SKEW_LINE2 " z 4"
#define MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE1 "Zlepsuji presnost kalibracniho bodu" #define MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE1 "Zlepsuji presnost kalibracniho bodu"
#define MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE2 " z 9" #define MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE2 " z 4"
#define MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1 "Merim referencni vysku kalibracniho bodu" #define MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1 "Merim referencni vysku kalibracniho bodu"
#define MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2 " z 9" #define MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2 " z 9"
#define MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION "Iterace " #define MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION "Iterace "

View File

@ -206,7 +206,7 @@
+#define(length = 60) MSG_FIND_BED_OFFSET_AND_SKEW_LINE1 "Suchen Bed Kalibrierpunkt" +#define(length = 60) MSG_FIND_BED_OFFSET_AND_SKEW_LINE1 "Suchen Bed Kalibrierpunkt"
+ #define(length = 14) MSG_FIND_BED_OFFSET_AND_SKEW_LINE2 " von 4" + #define(length = 14) MSG_FIND_BED_OFFSET_AND_SKEW_LINE2 " von 4"
+ #define(length = 60) MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE1 "Verbesserung Bed Kalibrierpunkt" + #define(length = 60) MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE1 "Verbesserung Bed Kalibrierpunkt"
+ #define(length = 14) MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE2 " von 9" + #define(length = 14) MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE2 " von 4"
+ #define(length = 60) MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1 "Messen der Referenzhoehe des Kalibrierpunktes" + #define(length = 60) MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1 "Messen der Referenzhoehe des Kalibrierpunktes"
+ #define(length = 14) MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2 " von 9" + #define(length = 14) MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2 " von 9"
#define MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION "Iteration " #define MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION "Iteration "

View File

@ -218,7 +218,7 @@
#define(length=60) MSG_FIND_BED_OFFSET_AND_SKEW_LINE1 "Searching bed calibration point" #define(length=60) MSG_FIND_BED_OFFSET_AND_SKEW_LINE1 "Searching bed calibration point"
#define(length=14) MSG_FIND_BED_OFFSET_AND_SKEW_LINE2 " of 4" #define(length=14) MSG_FIND_BED_OFFSET_AND_SKEW_LINE2 " of 4"
#define(length=60) MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE1 "Improving bed calibration point" #define(length=60) MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE1 "Improving bed calibration point"
#define(length=14) MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE2 " of 9" #define(length=14) MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE2 " of 4"
#define(length=60) MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1 "Measuring reference height of calibration point" #define(length=60) MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1 "Measuring reference height of calibration point"
#define(length=14) MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2 " of 9" #define(length=14) MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2 " of 9"
#define(length=20) MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION "Iteration " #define(length=20) MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION "Iteration "

View File

@ -202,7 +202,7 @@
#define MSG_FIND_BED_OFFSET_AND_SKEW_LINE1 "Buscando cama punto de calibracion" #define MSG_FIND_BED_OFFSET_AND_SKEW_LINE1 "Buscando cama punto de calibracion"
#define MSG_FIND_BED_OFFSET_AND_SKEW_LINE2 " de 4" #define MSG_FIND_BED_OFFSET_AND_SKEW_LINE2 " de 4"
#define MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE1 "Mejorando cama punto de calibracion" #define MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE1 "Mejorando cama punto de calibracion"
#define MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE2 " de 9" #define MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE2 " de 4"
#define MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1 "Medir la altura del punto de la calibracion" #define MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1 "Medir la altura del punto de la calibracion"
#define MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2 " de 9" #define MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2 " de 9"

View File

@ -193,7 +193,7 @@
#define MSG_FIND_BED_OFFSET_AND_SKEW_LINE1 "Ricerca del letto punto di calibraz." #define MSG_FIND_BED_OFFSET_AND_SKEW_LINE1 "Ricerca del letto punto di calibraz."
#define MSG_FIND_BED_OFFSET_AND_SKEW_LINE2 " su 4" #define MSG_FIND_BED_OFFSET_AND_SKEW_LINE2 " su 4"
#define MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE1 "Perfezion. il letto punto di calibraz." #define MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE1 "Perfezion. il letto punto di calibraz."
#define MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE2 " su 9" #define MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE2 " su 4"
#define MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1 "Misurare l'altezza di riferimento del punto di calibrazione" #define MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1 "Misurare l'altezza di riferimento del punto di calibrazione"
#define MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2 " su 9" #define MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2 " su 9"
#define MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION "Reiterazione " #define MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION "Reiterazione "

View File

@ -208,7 +208,7 @@
#define MSG_FIND_BED_OFFSET_AND_SKEW_LINE1 "Szukam punktu kalibracyjnego podkladki" #define MSG_FIND_BED_OFFSET_AND_SKEW_LINE1 "Szukam punktu kalibracyjnego podkladki"
#define MSG_FIND_BED_OFFSET_AND_SKEW_LINE2 " z 4" #define MSG_FIND_BED_OFFSET_AND_SKEW_LINE2 " z 4"
#define MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE1 "Poprawiam precyzyjnosc punktu kalibracyjnego" #define MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE1 "Poprawiam precyzyjnosc punktu kalibracyjnego"
#define MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE2 " z 9" #define MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE2 " z 4"
#define MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1 "Okreslam wysokosc odniesienia punktu kalibracyjnego" #define MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1 "Okreslam wysokosc odniesienia punktu kalibracyjnego"
#define MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2 " z 9" #define MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2 " z 9"
#define MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION "Iteracja " #define MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION "Iteracja "

View File

@ -56,10 +56,15 @@ const float bed_skew_angle_extreme = (0.25f * M_PI / 180.f);
// Positions of the bed reference points in the machine coordinates, referenced to the P.I.N.D.A sensor. // Positions of the bed reference points in the machine coordinates, referenced to the P.I.N.D.A sensor.
// The points are the following: center front, center right, center rear, center left. // The points are the following: center front, center right, center rear, center left.
const float bed_ref_points_4[] PROGMEM = { const float bed_ref_points_4[] PROGMEM = {
115.f - BED_ZERO_REF_X, 8.4f - BED_ZERO_REF_Y, //115.f - BED_ZERO_REF_X, 8.4f - BED_ZERO_REF_Y,
216.f - BED_ZERO_REF_X, 104.4f - BED_ZERO_REF_Y, //216.f - BED_ZERO_REF_X, 104.4f - BED_ZERO_REF_Y,
115.f - BED_ZERO_REF_X, 200.4f - BED_ZERO_REF_Y, //115.f - BED_ZERO_REF_X, 200.4f - BED_ZERO_REF_Y,
13.f - BED_ZERO_REF_X, 104.4f - BED_ZERO_REF_Y //13.f - BED_ZERO_REF_X, 104.4f - BED_ZERO_REF_Y
13.f - BED_ZERO_REF_X, 8.4f - BED_ZERO_REF_Y,
221.f - BED_ZERO_REF_X, 8.4f - BED_ZERO_REF_Y,
221.f - BED_ZERO_REF_X, 200.4f - BED_ZERO_REF_Y,
13.f - BED_ZERO_REF_X, 200.4f - BED_ZERO_REF_Y
}; };
const float bed_ref_points[] PROGMEM = { const float bed_ref_points[] PROGMEM = {
@ -104,10 +109,9 @@ const float bed_ref_points[] PROGMEM = {
static inline float sqr(float x) { return x * x; } static inline float sqr(float x) { return x * x; }
static inline bool point_on_1st_row(const uint8_t i, const uint8_t npts) static inline bool point_on_1st_row(const uint8_t i)
{ {
if (npts == 4) return (i == 0); return (i < 2);
else return (i < 3);
} }
// Weight of a point coordinate in a least squares optimization. // Weight of a point coordinate in a least squares optimization.
@ -117,7 +121,7 @@ static inline bool point_on_1st_row(const uint8_t i, const uint8_t npts)
static inline float point_weight_x(const uint8_t i, const uint8_t npts, const float &y) static inline float point_weight_x(const uint8_t i, const uint8_t npts, const float &y)
{ {
float w = 1.f; float w = 1.f;
if (point_on_1st_row(i, npts)) { if (point_on_1st_row(i)) {
if (y >= Y_MIN_POS_CALIBRATION_POINT_ACCURATE) { if (y >= Y_MIN_POS_CALIBRATION_POINT_ACCURATE) {
w = WEIGHT_FIRST_ROW_X_HIGH; w = WEIGHT_FIRST_ROW_X_HIGH;
} else if (y < Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH) { } else if (y < Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH) {
@ -139,7 +143,7 @@ static inline float point_weight_x(const uint8_t i, const uint8_t npts, const fl
static inline float point_weight_y(const uint8_t i, const uint8_t npts, const float &y) static inline float point_weight_y(const uint8_t i, const uint8_t npts, const float &y)
{ {
float w = 1.f; float w = 1.f;
if (point_on_1st_row(i, npts)) { if (point_on_1st_row(i)) {
if (y >= Y_MIN_POS_CALIBRATION_POINT_ACCURATE) { if (y >= Y_MIN_POS_CALIBRATION_POINT_ACCURATE) {
w = WEIGHT_FIRST_ROW_Y_HIGH; w = WEIGHT_FIRST_ROW_Y_HIGH;
} else if (y < Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH) { } else if (y < Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH) {
@ -172,6 +176,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
int8_t verbosity_level int8_t verbosity_level
) )
{ {
float angleDiff;
if (verbosity_level >= 10) { if (verbosity_level >= 10) {
SERIAL_ECHOLNPGM("calculate machine skew and offset LS"); SERIAL_ECHOLNPGM("calculate machine skew and offset LS");
@ -346,6 +351,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
BedSkewOffsetDetectionResultType result = BED_SKEW_OFFSET_DETECTION_PERFECT; BedSkewOffsetDetectionResultType result = BED_SKEW_OFFSET_DETECTION_PERFECT;
{ {
angleDiff = fabs(a2 - a1); angleDiff = fabs(a2 - a1);
eeprom_update_float((float*)(EEPROM_XYZ_CAL_SKEW), angleDiff); //storing xyz cal. skew to be able to show in support menu later
if (angleDiff > bed_skew_angle_mild) if (angleDiff > bed_skew_angle_mild)
result = (angleDiff > bed_skew_angle_extreme) ? result = (angleDiff > bed_skew_angle_extreme) ?
BED_SKEW_OFFSET_DETECTION_SKEW_EXTREME : BED_SKEW_OFFSET_DETECTION_SKEW_EXTREME :
@ -400,7 +406,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
SERIAL_ECHOLNPGM(":"); SERIAL_ECHOLNPGM(":");
} }
if (point_on_1st_row(i, npts)) { if (point_on_1st_row(i)) {
if(verbosity_level >= 20) SERIAL_ECHOPGM("Point on first row"); if(verbosity_level >= 20) SERIAL_ECHOPGM("Point on first row");
float w = point_weight_y(i, npts, measured_pts[2 * i + 1]); float w = point_weight_y(i, npts, measured_pts[2 * i + 1]);
if (sqrt(errX) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_X || if (sqrt(errX) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_X ||
@ -1779,7 +1785,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND; return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND;
#if 1 #if 1
if (k == 0) { if (k == 0 || k == 1) {
// Improve the position of the 1st row sensor points by a zig-zag movement. // Improve the position of the 1st row sensor points by a zig-zag movement.
find_bed_induction_sensor_point_z(); find_bed_induction_sensor_point_z();
int8_t i = 4; int8_t i = 4;
@ -1966,7 +1972,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
// Collect a matrix of 9x9 points. // Collect a matrix of 9x9 points.
BedSkewOffsetDetectionResultType result = BED_SKEW_OFFSET_DETECTION_PERFECT; BedSkewOffsetDetectionResultType result = BED_SKEW_OFFSET_DETECTION_PERFECT;
for (int8_t mesh_point = 0; mesh_point < 9; ++ mesh_point) { for (int8_t mesh_point = 0; mesh_point < 4; ++ mesh_point) {
// Don't let the manage_inactivity() function remove power from the motors. // Don't let the manage_inactivity() function remove power from the motors.
refresh_cmd_timeout(); refresh_cmd_timeout();
// Print the decrasing ID of the measurement point. // Print the decrasing ID of the measurement point.
@ -1993,8 +1999,8 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
} }
// Go to the measurement point. // Go to the measurement point.
// Use the coorrected coordinate, which is a result of find_bed_offset_and_skew(). // Use the coorrected coordinate, which is a result of find_bed_offset_and_skew().
current_position[X_AXIS] = vec_x[0] * pgm_read_float(bed_ref_points+mesh_point*2) + vec_y[0] * pgm_read_float(bed_ref_points+mesh_point*2+1) + cntr[0]; current_position[X_AXIS] = vec_x[0] * pgm_read_float(bed_ref_points_4+mesh_point*2) + vec_y[0] * pgm_read_float(bed_ref_points_4+mesh_point*2+1) + cntr[0];
current_position[Y_AXIS] = vec_x[1] * pgm_read_float(bed_ref_points+mesh_point*2) + vec_y[1] * pgm_read_float(bed_ref_points+mesh_point*2+1) + cntr[1]; current_position[Y_AXIS] = vec_x[1] * pgm_read_float(bed_ref_points_4+mesh_point*2) + vec_y[1] * pgm_read_float(bed_ref_points_4+mesh_point*2+1) + cntr[1];
// The calibration points are very close to the min Y. // The calibration points are very close to the min Y.
if (current_position[Y_AXIS] < Y_MIN_POS_FOR_BED_CALIBRATION){ if (current_position[Y_AXIS] < Y_MIN_POS_FOR_BED_CALIBRATION){
current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION; current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION;
@ -2027,7 +2033,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
SERIAL_ECHOLNPGM(""); SERIAL_ECHOLNPGM("");
} }
bool found = false; bool found = false;
if (mesh_point < 3) { if (mesh_point < 2) {
// Because the sensor cannot move in front of the first row // Because the sensor cannot move in front of the first row
// of the sensor points, the y position cannot be measured // of the sensor points, the y position cannot be measured
// by a cross center method. // by a cross center method.
@ -2036,7 +2042,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
} else { } else {
switch (method) { switch (method) {
case 0: found = improve_bed_induction_sensor_point(); break; case 0: found = improve_bed_induction_sensor_point(); break;
case 1: found = improve_bed_induction_sensor_point2(mesh_point < 3, verbosity_level); break; case 1: found = improve_bed_induction_sensor_point2(mesh_point < 2, verbosity_level); break;
default: break; default: break;
} }
} }
@ -2077,7 +2083,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
refresh_cmd_timeout(); refresh_cmd_timeout();
// Average the last 4 measurements. // Average the last 4 measurements.
for (int8_t i = 0; i < 18; ++ i) for (int8_t i = 0; i < 8; ++ i)
pts[i] *= (1.f/4.f); pts[i] *= (1.f/4.f);
enable_endstops(false); enable_endstops(false);
@ -2086,7 +2092,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
if (verbosity_level >= 5) { if (verbosity_level >= 5) {
// Test the positions. Are the positions reproducible? // Test the positions. Are the positions reproducible?
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
for (int8_t mesh_point = 0; mesh_point < 9; ++ mesh_point) { for (int8_t mesh_point = 0; mesh_point < 4; ++ mesh_point) {
// Don't let the manage_inactivity() function remove power from the motors. // Don't let the manage_inactivity() function remove power from the motors.
refresh_cmd_timeout(); refresh_cmd_timeout();
// Go to the measurement point. // Go to the measurement point.
@ -2109,17 +2115,17 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
{ {
// First fill in the too_far_mask from the measured points. // First fill in the too_far_mask from the measured points.
for (uint8_t mesh_point = 0; mesh_point < 3; ++ mesh_point) for (uint8_t mesh_point = 0; mesh_point < 2; ++ mesh_point)
if (pts[mesh_point * 2 + 1] < Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH) if (pts[mesh_point * 2 + 1] < Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH)
too_far_mask |= 1 << mesh_point; too_far_mask |= 1 << mesh_point;
result = calculate_machine_skew_and_offset_LS(pts, 9, bed_ref_points, vec_x, vec_y, cntr, verbosity_level); result = calculate_machine_skew_and_offset_LS(pts, 4, bed_ref_points_4, vec_x, vec_y, cntr, verbosity_level);
if (result < 0) { if (result < 0) {
SERIAL_ECHOLNPGM("Calculation of the machine skew and offset failed."); SERIAL_ECHOLNPGM("Calculation of the machine skew and offset failed.");
goto canceled; goto canceled;
} }
// In case of success, update the too_far_mask from the calculated points. // In case of success, update the too_far_mask from the calculated points.
for (uint8_t mesh_point = 0; mesh_point < 3; ++ mesh_point) { for (uint8_t mesh_point = 0; mesh_point < 2; ++ mesh_point) {
float y = vec_x[1] * pgm_read_float(bed_ref_points+mesh_point*2) + vec_y[1] * pgm_read_float(bed_ref_points+mesh_point*2+1) + cntr[1]; float y = vec_x[1] * pgm_read_float(bed_ref_points_4+mesh_point*2) + vec_y[1] * pgm_read_float(bed_ref_points_4+mesh_point*2+1) + cntr[1];
distance_from_min[mesh_point] = (y - Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH); distance_from_min[mesh_point] = (y - Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH);
if (verbosity_level >= 20) { if (verbosity_level >= 20) {
SERIAL_ECHOLNPGM(""); SERIAL_ECHOLNPGM("");
@ -2156,13 +2162,13 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
// Test the positions. Are the positions reproducible? Now the calibration is active in the planner. // Test the positions. Are the positions reproducible? Now the calibration is active in the planner.
delay_keep_alive(3000); delay_keep_alive(3000);
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
for (int8_t mesh_point = 0; mesh_point < 9; ++ mesh_point) { for (int8_t mesh_point = 0; mesh_point < 4; ++ mesh_point) {
// Don't let the manage_inactivity() function remove power from the motors. // Don't let the manage_inactivity() function remove power from the motors.
refresh_cmd_timeout(); refresh_cmd_timeout();
// Go to the measurement point. // Go to the measurement point.
// Use the coorrected coordinate, which is a result of find_bed_offset_and_skew(). // Use the coorrected coordinate, which is a result of find_bed_offset_and_skew().
current_position[X_AXIS] = pgm_read_float(bed_ref_points+mesh_point*2); current_position[X_AXIS] = pgm_read_float(bed_ref_points_4+mesh_point*2);
current_position[Y_AXIS] = pgm_read_float(bed_ref_points+mesh_point*2+1); current_position[Y_AXIS] = pgm_read_float(bed_ref_points_4+mesh_point*2+1);
if (verbosity_level >= 10) { if (verbosity_level >= 10) {
go_to_current(homing_feedrate[X_AXIS]/60); go_to_current(homing_feedrate[X_AXIS]/60);
delay_keep_alive(3000); delay_keep_alive(3000);
@ -2483,9 +2489,9 @@ void count_xyz_details() {
}; };
a2 = -1 * asin(vec_y[0] / MACHINE_AXIS_SCALE_Y); a2 = -1 * asin(vec_y[0] / MACHINE_AXIS_SCALE_Y);
a1 = asin(vec_x[1] / MACHINE_AXIS_SCALE_X); a1 = asin(vec_x[1] / MACHINE_AXIS_SCALE_X);
angleDiff = fabs(a2 - a1); //angleDiff = fabs(a2 - a1);
for (uint8_t mesh_point = 0; mesh_point < 3; ++mesh_point) { for (uint8_t mesh_point = 0; mesh_point < 2; ++mesh_point) {
float y = vec_x[1] * pgm_read_float(bed_ref_points + mesh_point * 2) + vec_y[1] * pgm_read_float(bed_ref_points + mesh_point * 2 + 1) + cntr[1]; float y = vec_x[1] * pgm_read_float(bed_ref_points_4 + mesh_point * 2) + vec_y[1] * pgm_read_float(bed_ref_points_4 + mesh_point * 2 + 1) + cntr[1];
distance_from_min[mesh_point] = (y - Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH); distance_from_min[mesh_point] = (y - Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH);
} }
} }

View File

@ -1536,15 +1536,16 @@ static void lcd_move_e()
} }
void lcd_service_mode_show_result() { void lcd_service_mode_show_result() {
float angleDiff;
lcd_set_custom_characters_degree(); lcd_set_custom_characters_degree();
count_xyz_details(); count_xyz_details();
angleDiff = eeprom_read_float((float*)(EEPROM_XYZ_CAL_SKEW));
lcd_update_enable(false); lcd_update_enable(false);
lcd_implementation_clear(); lcd_implementation_clear();
lcd_printPGM(PSTR("Y distance from min:")); lcd_printPGM(PSTR("Y distance from min:"));
lcd_print_at_PGM(0, 1, PSTR("Left:")); lcd_print_at_PGM(0, 1, PSTR("Left:"));
lcd_print_at_PGM(0, 2, PSTR("Center:"));
lcd_print_at_PGM(0, 3, PSTR("Right:")); lcd_print_at_PGM(0, 3, PSTR("Right:"));
for (int i = 0; i < 3; i++) { for (int i = 0; i < 2; i++) {
if(distance_from_min[i] < 200) { if(distance_from_min[i] < 200) {
lcd_print_at_PGM(8, i + 1, PSTR("")); lcd_print_at_PGM(8, i + 1, PSTR(""));
lcd.print(distance_from_min[i]); lcd.print(distance_from_min[i]);
@ -2818,11 +2819,11 @@ static void lcd_settings_menu()
MENU_ITEM(gcode, MSG_DISABLE_STEPPERS, PSTR("M84")); MENU_ITEM(gcode, MSG_DISABLE_STEPPERS, PSTR("M84"));
} }
if (FSensorStateMenu == 0) { /*if (FSensorStateMenu == 0) {
MENU_ITEM(function, MSG_FSENSOR_OFF, lcd_fsensor_state_set); MENU_ITEM(function, MSG_FSENSOR_OFF, lcd_fsensor_state_set);
} else { } else {
MENU_ITEM(function, MSG_FSENSOR_ON, lcd_fsensor_state_set); MENU_ITEM(function, MSG_FSENSOR_ON, lcd_fsensor_state_set);
} }*/
if (SilentModeMenu == 0) { if (SilentModeMenu == 0) {
MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set); MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set);