Add option to disable skew correction if XY calibration error is near perfect

This commit is contained in:
Ted Hess 2017-12-29 15:47:44 -05:00
parent ab16ff24f0
commit b381e51a13
6 changed files with 90 additions and 76 deletions

View File

@ -66,7 +66,7 @@
// E^2 address of custom MBC offsets array.
// Correction of the bed leveling, in micrometers.
// Current Range is: +/- 500um (stored as int16).
#define EEPROM_BED_CORRECTION_VALID 999
#define EEPROM_BED_CORRECTION_VALID 499
#define EEPROM_BED_CORRECTION_OFFSETS (EEPROM_BED_CORRECTION_VALID - 16)
// Currently running firmware, each digit stored as uint16_t.

View File

@ -130,10 +130,11 @@ void Config_StoreSettings()
EEPROM_WRITE_VAR(i, filament_size[2]);
#endif
#endif
/*MYSERIAL.print("Top address used:\n");
MYSERIAL.print(i);
MYSERIAL.print("\n");
*/
#if 0
SERIAL_ECHO_START;
SERIAL_ECHOPAIR("Top address used: ", (unsigned long)i);
SERIAL_ECHOLN("");
#endif
char ver2[4]=EEPROM_VERSION;
i=EEPROM_OFFSET;
EEPROM_WRITE_VAR(i,ver2); // validate data

View File

@ -3077,6 +3077,11 @@ const char * const MSG_SILENT_MODE_ON_LANG_TABLE[LANG_NUM] PROGMEM = {
MSG_SILENT_MODE_ON_DE
};
const char MSG_SKEW_CORRECTION_EN[] PROGMEM = "Very small XY skew. Disable skew correction?";
const char * const MSG_SKEW_CORRECTION_LANG_TABLE[1] PROGMEM = {
MSG_SKEW_CORRECTION_EN
};
const char MSG_SLIGHT_SKEW_EN[] PROGMEM = "Slight skew:";
const char MSG_SLIGHT_SKEW_CZ[] PROGMEM = "Lehke zkoseni:";
const char MSG_SLIGHT_SKEW_IT[] PROGMEM = "Incl. leggera:";

View File

@ -562,6 +562,8 @@ extern const char* const MSG_SILENT_MODE_OFF_LANG_TABLE[LANG_NUM];
#define MSG_SILENT_MODE_OFF LANG_TABLE_SELECT(MSG_SILENT_MODE_OFF_LANG_TABLE)
extern const char* const MSG_SILENT_MODE_ON_LANG_TABLE[LANG_NUM];
#define MSG_SILENT_MODE_ON LANG_TABLE_SELECT(MSG_SILENT_MODE_ON_LANG_TABLE)
extern const char* const MSG_SKEW_CORRECTION_LANG_TABLE[1];
#define MSG_SKEW_CORRECTION LANG_TABLE_SELECT_EXPLICIT(MSG_SKEW_CORRECTION_LANG_TABLE, 0)
extern const char* const MSG_SLIGHT_SKEW_LANG_TABLE[LANG_NUM];
#define MSG_SLIGHT_SKEW LANG_TABLE_SELECT(MSG_SLIGHT_SKEW_LANG_TABLE)
extern const char* const MSG_SOFTWARE_RESET_LANG_TABLE[1];

View File

@ -352,4 +352,5 @@
#define(lenght=20, lines=2) MSG_PLA_FILAMENT_LOADED "Is PLA filament loaded?"
#define(lenght=20, lines=4) MSG_PLEASE_LOAD_PLA "Please load PLA filament first."
#define(length=20, lines=8) MSG_FILE_CNT "Some files will not be sorted. Max. No. of files in 1 folder for sorting is 100."
#define(length=25, lines=1) MSG_M117_V2_CALIBRATION "M117 First layer cal."
#define(length=25, lines=1) MSG_M117_V2_CALIBRATION "M117 First layer cal."
#define(length=20, lines=3) MSG_SKEW_CORRECTION "Very little skew detected. Disable correction?"

View File

@ -451,90 +451,95 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
}
#endif // SUPPORT_VERBOSITY
#if 1
if (result == BED_SKEW_OFFSET_DETECTION_PERFECT) {
if (verbosity_level > 0)
SERIAL_ECHOLNPGM("Very little skew detected. Disabling skew correction.");
// Just disable the skew correction.
vec_x[0] = MACHINE_AXIS_SCALE_X;
vec_x[1] = 0.f;
vec_y[0] = 0.f;
vec_y[1] = MACHINE_AXIS_SCALE_Y;
}
#else
if (result == BED_SKEW_OFFSET_DETECTION_PERFECT) {
#ifdef SUPPORT_VERBOSITY
if (verbosity_level > 0)
SERIAL_ECHOLNPGM("Very little skew detected. Orthogonalizing the axes.");
#endif // SUPPORT_VERBOSITY
// Orthogonalize the axes.
a1 = 0.5f * (a1 + a2);
vec_x[0] = cos(a1) * MACHINE_AXIS_SCALE_X;
vec_x[1] = sin(a1) * MACHINE_AXIS_SCALE_X;
vec_y[0] = -sin(a1) * MACHINE_AXIS_SCALE_Y;
vec_y[1] = cos(a1) * MACHINE_AXIS_SCALE_Y;
// Refresh the offset.
cntr[0] = 0.f;
cntr[1] = 0.f;
float wx = 0.f;
float wy = 0.f;
for (int8_t i = 0; i < npts; ++ i) {
float x = vec_x[0] * measured_pts[i * 2] + vec_y[0] * measured_pts[i * 2 + 1];
float y = vec_x[1] * measured_pts[i * 2] + vec_y[1] * measured_pts[i * 2 + 1];
float w = point_weight_x(i, npts, y);
cntr[0] += w * (pgm_read_float(true_pts + i * 2) - x);
wx += w;
#ifdef SUPPORT_VERBOSITY
if (verbosity_level >= 20) {
MYSERIAL.print(i);
SERIAL_ECHOLNPGM("");
SERIAL_ECHOLNPGM("Weight_x:");
MYSERIAL.print(w);
SERIAL_ECHOLNPGM("");
SERIAL_ECHOLNPGM("cntr[0]:");
MYSERIAL.print(cntr[0]);
SERIAL_ECHOLNPGM("");
SERIAL_ECHOLNPGM("wx:");
MYSERIAL.print(wx);
}
#endif // SUPPORT_VERBOSITY
w = point_weight_y(i, npts, y);
cntr[1] += w * (pgm_read_float(true_pts + i * 2 + 1) - y);
wy += w;
bool skew_correction = lcd_show_multiscreen_message_yes_no_and_wait_P(MSG_SKEW_CORRECTION, false, false);
#ifdef SUPPORT_VERBOSITY
if (verbosity_level >= 20) {
SERIAL_ECHOLNPGM("");
SERIAL_ECHOLNPGM("Weight_y:");
MYSERIAL.print(w);
SERIAL_ECHOLNPGM("");
SERIAL_ECHOLNPGM("cntr[1]:");
MYSERIAL.print(cntr[1]);
SERIAL_ECHOLNPGM("");
SERIAL_ECHOLNPGM("wy:");
MYSERIAL.print(wy);
SERIAL_ECHOLNPGM("");
SERIAL_ECHOLNPGM("");
}
#endif // SUPPORT_VERBOSITY
lcd_update_enable(true);
lcd_update(2);
if (skew_correction) {
#ifdef SUPPORT_VERBOSITY
if (verbosity_level > 0)
SERIAL_ECHOLNPGM("Very little skew detected. Disabling skew correction.");
#endif
// Just disable the skew correction.
vec_x[0] = MACHINE_AXIS_SCALE_X;
vec_x[1] = 0.f;
vec_y[0] = 0.f;
vec_y[1] = MACHINE_AXIS_SCALE_Y;
} else {
#ifdef SUPPORT_VERBOSITY
if (verbosity_level > 0)
SERIAL_ECHOLNPGM("Very little skew detected. Orthogonalizing the axes.");
#endif
// Orthogonalize the axes.
a1 = 0.5f * (a1 + a2);
vec_x[0] = cos(a1) * MACHINE_AXIS_SCALE_X;
vec_x[1] = sin(a1) * MACHINE_AXIS_SCALE_X;
vec_y[0] = -sin(a1) * MACHINE_AXIS_SCALE_Y;
vec_y[1] = cos(a1) * MACHINE_AXIS_SCALE_Y;
// Refresh the offset.
cntr[0] = 0.f;
cntr[1] = 0.f;
float wx = 0.f;
float wy = 0.f;
for (int8_t i = 0; i < npts; ++ i) {
float x = vec_x[0] * measured_pts[i * 2] + vec_y[0] * measured_pts[i * 2 + 1];
float y = vec_x[1] * measured_pts[i * 2] + vec_y[1] * measured_pts[i * 2 + 1];
float w = point_weight_x(i, npts, y);
cntr[0] += w * (pgm_read_float(true_pts + i * 2) - x);
wx += w;
#ifdef SUPPORT_VERBOSITY
if (verbosity_level >= 20) {
MYSERIAL.print(i);
SERIAL_ECHOLNPGM("");
SERIAL_ECHOLNPGM("Weight_x:");
MYSERIAL.print(w);
SERIAL_ECHOLNPGM("");
SERIAL_ECHOLNPGM("cntr[0]:");
MYSERIAL.print(cntr[0]);
SERIAL_ECHOLNPGM("");
SERIAL_ECHOLNPGM("wx:");
MYSERIAL.print(wx);
}
cntr[0] /= wx;
cntr[1] /= wy;
#endif // SUPPORT_VERBOSITY
w = point_weight_y(i, npts, y);
cntr[1] += w * (pgm_read_float(true_pts + i * 2 + 1) - y);
wy += w;
#ifdef SUPPORT_VERBOSITY
if (verbosity_level >= 20) {
SERIAL_ECHOLNPGM("");
SERIAL_ECHOLNPGM("Final cntr values:");
SERIAL_ECHOLNPGM("cntr[0]:");
MYSERIAL.print(cntr[0]);
SERIAL_ECHOLNPGM("Weight_y:");
MYSERIAL.print(w);
SERIAL_ECHOLNPGM("");
SERIAL_ECHOLNPGM("cntr[1]:");
MYSERIAL.print(cntr[1]);
SERIAL_ECHOLNPGM("");
SERIAL_ECHOLNPGM("wy:");
MYSERIAL.print(wy);
SERIAL_ECHOLNPGM("");
SERIAL_ECHOLNPGM("");
}
#endif // SUPPORT_VERBOSITY
}
cntr[0] /= wx;
cntr[1] /= wy;
#ifdef SUPPORT_VERBOSITY
if (verbosity_level >= 20) {
SERIAL_ECHOLNPGM("");
SERIAL_ECHOLNPGM("Final cntr values:");
SERIAL_ECHOLNPGM("cntr[0]:");
MYSERIAL.print(cntr[0]);
SERIAL_ECHOLNPGM("");
SERIAL_ECHOLNPGM("cntr[1]:");
MYSERIAL.print(cntr[1]);
SERIAL_ECHOLNPGM("");
}
#endif // SUPPORT_VERBOSITY
}
}
#endif
// Invert the transformation matrix made of vec_x, vec_y and cntr.
{