Merge branch 'MK3' into MK3
This commit is contained in:
commit
55325a5a32
@ -99,6 +99,8 @@
|
|||||||
#define EEPROM_TMC_X_SG_THRS_LOW (EEPROM_TMC_X + 13) // 1byte, (-64..+63)
|
#define EEPROM_TMC_X_SG_THRS_LOW (EEPROM_TMC_X + 13) // 1byte, (-64..+63)
|
||||||
#define EEPROM_TMC_X_SG_THRS_HIGH (EEPROM_TMC_X + 14) // 1byte, (-64..+63)
|
#define EEPROM_TMC_X_SG_THRS_HIGH (EEPROM_TMC_X + 14) // 1byte, (-64..+63)
|
||||||
|
|
||||||
|
#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)
|
||||||
|
@ -507,4 +507,6 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
|
|||||||
|
|
||||||
#define HEATBED_V2
|
#define HEATBED_V2
|
||||||
|
|
||||||
|
//#define SUPPORT_VERBOSITY
|
||||||
|
|
||||||
#endif //__CONFIGURATION_PRUSA_H
|
#endif //__CONFIGURATION_PRUSA_H
|
||||||
|
@ -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();
|
||||||
|
|
||||||
|
@ -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);
|
||||||
@ -1779,7 +1778,15 @@ void process_commands()
|
|||||||
else if (code_seen("PRN")) {
|
else if (code_seen("PRN")) {
|
||||||
MYSERIAL.println(status_number);
|
MYSERIAL.println(status_number);
|
||||||
|
|
||||||
}else if (code_seen("fn")) {
|
}else if (code_seen("FAN")) {
|
||||||
|
MYSERIAL.print("E0:");
|
||||||
|
MYSERIAL.print(60*fan_speed[0]);
|
||||||
|
MYSERIAL.println(" RPM");
|
||||||
|
MYSERIAL.print("PRN0:");
|
||||||
|
MYSERIAL.print(60*fan_speed[1]);
|
||||||
|
MYSERIAL.println(" RPM");
|
||||||
|
|
||||||
|
}else if (code_seen("fn")) {
|
||||||
if (farm_mode) {
|
if (farm_mode) {
|
||||||
MYSERIAL.println(farm_no);
|
MYSERIAL.println(farm_no);
|
||||||
}
|
}
|
||||||
@ -2965,9 +2972,11 @@ void process_commands()
|
|||||||
current_position[Y_AXIS] = pgm_read_float(bed_ref_points + 1);
|
current_position[Y_AXIS] = pgm_read_float(bed_ref_points + 1);
|
||||||
bool clamped = world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]);
|
bool clamped = world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]);
|
||||||
|
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 1) {
|
if (verbosity_level >= 1) {
|
||||||
clamped ? SERIAL_PROTOCOLPGM("First calibration point clamped.\n") : SERIAL_PROTOCOLPGM("No clamping for first calibration point.\n");
|
clamped ? SERIAL_PROTOCOLPGM("First calibration point clamped.\n") : SERIAL_PROTOCOLPGM("No clamping for first calibration point.\n");
|
||||||
}
|
}
|
||||||
|
#endif //SUPPORT_VERBOSITY
|
||||||
// mbl.get_meas_xy(0, 0, current_position[X_AXIS], current_position[Y_AXIS], false);
|
// mbl.get_meas_xy(0, 0, current_position[X_AXIS], current_position[Y_AXIS], false);
|
||||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS] / 30, active_extruder);
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS] / 30, active_extruder);
|
||||||
// Wait until the move is finished.
|
// Wait until the move is finished.
|
||||||
@ -2982,13 +2991,14 @@ void process_commands()
|
|||||||
int Z_PROBE_FEEDRATE = homing_feedrate[Z_AXIS] / 60;
|
int Z_PROBE_FEEDRATE = homing_feedrate[Z_AXIS] / 60;
|
||||||
int Z_LIFT_FEEDRATE = homing_feedrate[Z_AXIS] / 40;
|
int Z_LIFT_FEEDRATE = homing_feedrate[Z_AXIS] / 40;
|
||||||
bool has_z = is_bed_z_jitter_data_valid(); //checks if we have data from Z calibration (offsets of the Z heiths of the 8 calibration points from the first point)
|
bool has_z = is_bed_z_jitter_data_valid(); //checks if we have data from Z calibration (offsets of the Z heiths of the 8 calibration points from the first point)
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 1) {
|
if (verbosity_level >= 1) {
|
||||||
has_z ? SERIAL_PROTOCOLPGM("Z jitter data from Z cal. valid.\n") : SERIAL_PROTOCOLPGM("Z jitter data from Z cal. not valid.\n");
|
has_z ? SERIAL_PROTOCOLPGM("Z jitter data from Z cal. valid.\n") : SERIAL_PROTOCOLPGM("Z jitter data from Z cal. not valid.\n");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
setup_for_endstop_move(false); //save feedrate and feedmultiply, sets feedmultiply to 100
|
setup_for_endstop_move(false); //save feedrate and feedmultiply, sets feedmultiply to 100
|
||||||
const char *kill_message = NULL;
|
const char *kill_message = NULL;
|
||||||
while (mesh_point != MESH_MEAS_NUM_X_POINTS * MESH_MEAS_NUM_Y_POINTS) {
|
while (mesh_point != MESH_MEAS_NUM_X_POINTS * MESH_MEAS_NUM_Y_POINTS) {
|
||||||
if (verbosity_level >= 1) SERIAL_ECHOLNPGM("");
|
|
||||||
// Get coords of a measuring point.
|
// Get coords of a measuring point.
|
||||||
ix = mesh_point % MESH_MEAS_NUM_X_POINTS; // from 0 to MESH_NUM_X_POINTS - 1
|
ix = mesh_point % MESH_MEAS_NUM_X_POINTS; // from 0 to MESH_NUM_X_POINTS - 1
|
||||||
iy = mesh_point / MESH_MEAS_NUM_X_POINTS;
|
iy = mesh_point / MESH_MEAS_NUM_X_POINTS;
|
||||||
@ -2998,13 +3008,16 @@ void process_commands()
|
|||||||
uint16_t z_offset_u = eeprom_read_word((uint16_t*)(EEPROM_BED_CALIBRATION_Z_JITTER + 2 * (ix + iy * 3 - 1)));
|
uint16_t z_offset_u = eeprom_read_word((uint16_t*)(EEPROM_BED_CALIBRATION_Z_JITTER + 2 * (ix + iy * 3 - 1)));
|
||||||
z0 = mbl.z_values[0][0] + *reinterpret_cast<int16_t*>(&z_offset_u) * 0.01;
|
z0 = mbl.z_values[0][0] + *reinterpret_cast<int16_t*>(&z_offset_u) * 0.01;
|
||||||
//#if 0
|
//#if 0
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 1) {
|
if (verbosity_level >= 1) {
|
||||||
|
SERIAL_ECHOLNPGM("");
|
||||||
SERIAL_ECHOPGM("Bed leveling, point: ");
|
SERIAL_ECHOPGM("Bed leveling, point: ");
|
||||||
MYSERIAL.print(mesh_point);
|
MYSERIAL.print(mesh_point);
|
||||||
SERIAL_ECHOPGM(", calibration z: ");
|
SERIAL_ECHOPGM(", calibration z: ");
|
||||||
MYSERIAL.print(z0, 5);
|
MYSERIAL.print(z0, 5);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3020,12 +3033,13 @@ void process_commands()
|
|||||||
|
|
||||||
|
|
||||||
world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]);
|
world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]);
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 1) {
|
if (verbosity_level >= 1) {
|
||||||
|
|
||||||
SERIAL_PROTOCOL(mesh_point);
|
SERIAL_PROTOCOL(mesh_point);
|
||||||
clamped ? SERIAL_PROTOCOLPGM(": xy clamped.\n") : SERIAL_PROTOCOLPGM(": no xy clamping\n");
|
clamped ? SERIAL_PROTOCOLPGM(": xy clamped.\n") : SERIAL_PROTOCOLPGM(": no xy clamping\n");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], XY_AXIS_FEEDRATE, active_extruder);
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], XY_AXIS_FEEDRATE, active_extruder);
|
||||||
st_synchronize();
|
st_synchronize();
|
||||||
@ -3044,7 +3058,7 @@ void process_commands()
|
|||||||
kill_message = MSG_BED_LEVELING_FAILED_POINT_HIGH;
|
kill_message = MSG_BED_LEVELING_FAILED_POINT_HIGH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10) {
|
if (verbosity_level >= 10) {
|
||||||
SERIAL_ECHOPGM("X: ");
|
SERIAL_ECHOPGM("X: ");
|
||||||
MYSERIAL.print(current_position[X_AXIS], 5);
|
MYSERIAL.print(current_position[X_AXIS], 5);
|
||||||
@ -3053,13 +3067,13 @@ void process_commands()
|
|||||||
MYSERIAL.print(current_position[Y_AXIS], 5);
|
MYSERIAL.print(current_position[Y_AXIS], 5);
|
||||||
SERIAL_PROTOCOLPGM("\n");
|
SERIAL_PROTOCOLPGM("\n");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
float offset_z = 0;
|
float offset_z = 0;
|
||||||
|
|
||||||
#ifdef PINDA_THERMISTOR
|
#ifdef PINDA_THERMISTOR
|
||||||
offset_z = temp_compensation_pinda_thermistor_offset();
|
offset_z = temp_compensation_pinda_thermistor_offset();
|
||||||
#endif //PINDA_THERMISTOR
|
#endif //PINDA_THERMISTOR
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 1) {
|
if (verbosity_level >= 1) {
|
||||||
SERIAL_ECHOPGM("mesh bed leveling: ");
|
SERIAL_ECHOPGM("mesh bed leveling: ");
|
||||||
MYSERIAL.print(current_position[Z_AXIS], 5);
|
MYSERIAL.print(current_position[Z_AXIS], 5);
|
||||||
@ -3067,18 +3081,21 @@ void process_commands()
|
|||||||
MYSERIAL.print(offset_z, 5);
|
MYSERIAL.print(offset_z, 5);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
mbl.set_z(ix, iy, current_position[Z_AXIS] - offset_z); //store measured z values z_values[iy][ix] = z - offset_z;
|
mbl.set_z(ix, iy, current_position[Z_AXIS] - offset_z); //store measured z values z_values[iy][ix] = z - offset_z;
|
||||||
|
|
||||||
custom_message_state--;
|
custom_message_state--;
|
||||||
mesh_point++;
|
mesh_point++;
|
||||||
lcd_update(1);
|
lcd_update(1);
|
||||||
}
|
}
|
||||||
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("Mesh bed leveling while loop finished.");
|
|
||||||
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
|
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
|
SERIAL_ECHOLNPGM("Mesh bed leveling while loop finished.");
|
||||||
SERIAL_ECHOLNPGM("MESH_HOME_Z_SEARCH: ");
|
SERIAL_ECHOLNPGM("MESH_HOME_Z_SEARCH: ");
|
||||||
MYSERIAL.print(current_position[Z_AXIS], 5);
|
MYSERIAL.print(current_position[Z_AXIS], 5);
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], Z_LIFT_FEEDRATE, active_extruder);
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], Z_LIFT_FEEDRATE, active_extruder);
|
||||||
st_synchronize();
|
st_synchronize();
|
||||||
if (mesh_point != MESH_MEAS_NUM_X_POINTS * MESH_MEAS_NUM_Y_POINTS) {
|
if (mesh_point != MESH_MEAS_NUM_X_POINTS * MESH_MEAS_NUM_Y_POINTS) {
|
||||||
@ -3097,10 +3114,11 @@ void process_commands()
|
|||||||
babystep_apply(); // Apply Z height correction aka baby stepping before mesh bed leveing gets activated.
|
babystep_apply(); // Apply Z height correction aka baby stepping before mesh bed leveing gets activated.
|
||||||
SERIAL_ECHOLNPGM("babystep applied");
|
SERIAL_ECHOLNPGM("babystep applied");
|
||||||
bool eeprom_bed_correction_valid = eeprom_read_byte((unsigned char*)EEPROM_BED_CORRECTION_VALID) == 1;
|
bool eeprom_bed_correction_valid = eeprom_read_byte((unsigned char*)EEPROM_BED_CORRECTION_VALID) == 1;
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 1) {
|
if (verbosity_level >= 1) {
|
||||||
eeprom_bed_correction_valid ? SERIAL_PROTOCOLPGM("Bed correction data valid\n") : SERIAL_PROTOCOLPGM("Bed correction data not valid\n");
|
eeprom_bed_correction_valid ? SERIAL_PROTOCOLPGM("Bed correction data valid\n") : SERIAL_PROTOCOLPGM("Bed correction data not valid\n");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 4; ++i) {
|
for (uint8_t i = 0; i < 4; ++i) {
|
||||||
unsigned char codes[4] = { 'L', 'R', 'F', 'B' };
|
unsigned char codes[4] = { 'L', 'R', 'F', 'B' };
|
||||||
@ -6896,6 +6914,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();
|
||||||
@ -6991,6 +7010,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);
|
||||||
}
|
}
|
||||||
|
@ -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 "
|
||||||
|
@ -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 "
|
||||||
|
@ -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 "
|
||||||
|
@ -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"
|
||||||
|
|
||||||
|
@ -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 "
|
||||||
|
@ -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 "
|
||||||
|
@ -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,8 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
|||||||
int8_t verbosity_level
|
int8_t verbosity_level
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
float angleDiff;
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10) {
|
if (verbosity_level >= 10) {
|
||||||
SERIAL_ECHOLNPGM("calculate machine skew and offset LS");
|
SERIAL_ECHOLNPGM("calculate machine skew and offset LS");
|
||||||
|
|
||||||
@ -213,6 +219,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
|||||||
}
|
}
|
||||||
delay_keep_alive(100);
|
delay_keep_alive(100);
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
// Run some iterations of the Gauss-Newton method of non-linear least squares.
|
// Run some iterations of the Gauss-Newton method of non-linear least squares.
|
||||||
// Initial set of parameters:
|
// Initial set of parameters:
|
||||||
@ -313,6 +320,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
|||||||
a1 += h[2];
|
a1 += h[2];
|
||||||
a2 += h[3];
|
a2 += h[3];
|
||||||
|
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOPGM("iteration: ");
|
SERIAL_ECHOPGM("iteration: ");
|
||||||
MYSERIAL.print(int(iter));
|
MYSERIAL.print(int(iter));
|
||||||
@ -336,6 +344,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
|||||||
MYSERIAL.print(180.f * a2 / M_PI, 5);
|
MYSERIAL.print(180.f * a2 / M_PI, 5);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
|
|
||||||
vec_x[0] = cos(a1) * MACHINE_AXIS_SCALE_X;
|
vec_x[0] = cos(a1) * MACHINE_AXIS_SCALE_X;
|
||||||
@ -346,6 +355,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 :
|
||||||
@ -354,7 +364,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
|||||||
fabs(a2) > bed_skew_angle_extreme)
|
fabs(a2) > bed_skew_angle_extreme)
|
||||||
result = BED_SKEW_OFFSET_DETECTION_SKEW_EXTREME;
|
result = BED_SKEW_OFFSET_DETECTION_SKEW_EXTREME;
|
||||||
}
|
}
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 1) {
|
if (verbosity_level >= 1) {
|
||||||
SERIAL_ECHOPGM("correction angles: ");
|
SERIAL_ECHOPGM("correction angles: ");
|
||||||
MYSERIAL.print(180.f * a1 / M_PI, 5);
|
MYSERIAL.print(180.f * a1 / M_PI, 5);
|
||||||
@ -386,7 +396,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
|||||||
|
|
||||||
SERIAL_ECHOLNPGM("Error after correction: ");
|
SERIAL_ECHOLNPGM("Error after correction: ");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
// Measure the error after correction.
|
// Measure the error after correction.
|
||||||
for (uint8_t i = 0; i < npts; ++i) {
|
for (uint8_t i = 0; i < npts; ++i) {
|
||||||
float x = vec_x[0] * measured_pts[i * 2] + vec_y[0] * measured_pts[i * 2 + 1] + cntr[0];
|
float x = vec_x[0] * measured_pts[i * 2] + vec_y[0] * measured_pts[i * 2 + 1] + cntr[0];
|
||||||
@ -394,33 +404,44 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
|||||||
float errX = sqr(pgm_read_float(true_pts + i * 2) - x);
|
float errX = sqr(pgm_read_float(true_pts + i * 2) - x);
|
||||||
float errY = sqr(pgm_read_float(true_pts + i * 2 + 1) - y);
|
float errY = sqr(pgm_read_float(true_pts + i * 2 + 1) - y);
|
||||||
float err = sqrt(errX + errY);
|
float err = sqrt(errX + errY);
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10) {
|
if (verbosity_level >= 10) {
|
||||||
SERIAL_ECHOPGM("point #");
|
SERIAL_ECHOPGM("point #");
|
||||||
MYSERIAL.print(int(i));
|
MYSERIAL.print(int(i));
|
||||||
SERIAL_ECHOLNPGM(":");
|
SERIAL_ECHOLNPGM(":");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
if (point_on_1st_row(i, npts)) {
|
if (point_on_1st_row(i)) {
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if(verbosity_level >= 20) SERIAL_ECHOPGM("Point on first row");
|
if(verbosity_level >= 20) SERIAL_ECHOPGM("Point on first row");
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
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 ||
|
||||||
(w != 0.f && sqrt(errY) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_Y)) {
|
(w != 0.f && sqrt(errY) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_Y)) {
|
||||||
result = BED_SKEW_OFFSET_DETECTION_FITTING_FAILED;
|
result = BED_SKEW_OFFSET_DETECTION_FITTING_FAILED;
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOPGM(", weigth Y: ");
|
SERIAL_ECHOPGM(", weigth Y: ");
|
||||||
MYSERIAL.print(w);
|
MYSERIAL.print(w);
|
||||||
if (sqrt(errX) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_X) SERIAL_ECHOPGM(", error X > max. error X");
|
if (sqrt(errX) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_X) SERIAL_ECHOPGM(", error X > max. error X");
|
||||||
if (w != 0.f && sqrt(errY) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_Y) SERIAL_ECHOPGM(", error Y > max. error Y");
|
if (w != 0.f && sqrt(errY) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_Y) SERIAL_ECHOPGM(", error Y > max. error Y");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if(verbosity_level >=20 ) SERIAL_ECHOPGM("Point not on first row");
|
if(verbosity_level >=20 ) SERIAL_ECHOPGM("Point not on first row");
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
if (err > BED_CALIBRATION_POINT_OFFSET_MAX_EUCLIDIAN) {
|
if (err > BED_CALIBRATION_POINT_OFFSET_MAX_EUCLIDIAN) {
|
||||||
result = BED_SKEW_OFFSET_DETECTION_FITTING_FAILED;
|
result = BED_SKEW_OFFSET_DETECTION_FITTING_FAILED;
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if(verbosity_level >= 20) SERIAL_ECHOPGM(", error > max. error euclidian");
|
if(verbosity_level >= 20) SERIAL_ECHOPGM(", error > max. error euclidian");
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10) {
|
if (verbosity_level >= 10) {
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
SERIAL_ECHOPGM("measured: (");
|
SERIAL_ECHOPGM("measured: (");
|
||||||
@ -445,7 +466,9 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
|||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOLNPGM("Max. errors:");
|
SERIAL_ECHOLNPGM("Max. errors:");
|
||||||
SERIAL_ECHOPGM("Max. error X:");
|
SERIAL_ECHOPGM("Max. error X:");
|
||||||
@ -456,11 +479,14 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
|||||||
MYSERIAL.println(BED_CALIBRATION_POINT_OFFSET_MAX_EUCLIDIAN);
|
MYSERIAL.println(BED_CALIBRATION_POINT_OFFSET_MAX_EUCLIDIAN);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (result == BED_SKEW_OFFSET_DETECTION_PERFECT && fabs(a1) < bed_skew_angle_mild && fabs(a2) < bed_skew_angle_mild) {
|
if (result == BED_SKEW_OFFSET_DETECTION_PERFECT && fabs(a1) < bed_skew_angle_mild && fabs(a2) < bed_skew_angle_mild) {
|
||||||
if (verbosity_level > 0)
|
#ifdef SUPPORT_VERBOSITY
|
||||||
|
if (verbosity_level > 0)
|
||||||
SERIAL_ECHOLNPGM("Very little skew detected. Disabling skew correction.");
|
SERIAL_ECHOLNPGM("Very little skew detected. Disabling skew correction.");
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
// Just disable the skew correction.
|
// Just disable the skew correction.
|
||||||
vec_x[0] = MACHINE_AXIS_SCALE_X;
|
vec_x[0] = MACHINE_AXIS_SCALE_X;
|
||||||
vec_x[1] = 0.f;
|
vec_x[1] = 0.f;
|
||||||
@ -469,9 +495,11 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (result == BED_SKEW_OFFSET_DETECTION_PERFECT) {
|
if (result == BED_SKEW_OFFSET_DETECTION_PERFECT) {
|
||||||
if (verbosity_level > 0)
|
#ifdef SUPPORT_VERBOSITY
|
||||||
|
if (verbosity_level > 0)
|
||||||
SERIAL_ECHOLNPGM("Very little skew detected. Orthogonalizing the axes.");
|
SERIAL_ECHOLNPGM("Very little skew detected. Orthogonalizing the axes.");
|
||||||
// Orthogonalize the axes.
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
// Orthogonalize the axes.
|
||||||
a1 = 0.5f * (a1 + a2);
|
a1 = 0.5f * (a1 + a2);
|
||||||
vec_x[0] = cos(a1) * MACHINE_AXIS_SCALE_X;
|
vec_x[0] = cos(a1) * MACHINE_AXIS_SCALE_X;
|
||||||
vec_x[1] = sin(a1) * MACHINE_AXIS_SCALE_X;
|
vec_x[1] = sin(a1) * MACHINE_AXIS_SCALE_X;
|
||||||
@ -488,6 +516,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
|||||||
float w = point_weight_x(i, npts, y);
|
float w = point_weight_x(i, npts, y);
|
||||||
cntr[0] += w * (pgm_read_float(true_pts + i * 2) - x);
|
cntr[0] += w * (pgm_read_float(true_pts + i * 2) - x);
|
||||||
wx += w;
|
wx += w;
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
MYSERIAL.print(i);
|
MYSERIAL.print(i);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
@ -500,10 +529,11 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
|||||||
SERIAL_ECHOLNPGM("wx:");
|
SERIAL_ECHOLNPGM("wx:");
|
||||||
MYSERIAL.print(wx);
|
MYSERIAL.print(wx);
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
w = point_weight_y(i, npts, y);
|
w = point_weight_y(i, npts, y);
|
||||||
cntr[1] += w * (pgm_read_float(true_pts + i * 2 + 1) - y);
|
cntr[1] += w * (pgm_read_float(true_pts + i * 2 + 1) - y);
|
||||||
wy += w;
|
wy += w;
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
SERIAL_ECHOLNPGM("Weight_y:");
|
SERIAL_ECHOLNPGM("Weight_y:");
|
||||||
@ -517,9 +547,12 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
|||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
}
|
}
|
||||||
cntr[0] /= wx;
|
cntr[0] /= wx;
|
||||||
cntr[1] /= wy;
|
cntr[1] /= wy;
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
SERIAL_ECHOLNPGM("Final cntr values:");
|
SERIAL_ECHOLNPGM("Final cntr values:");
|
||||||
@ -530,7 +563,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
|||||||
MYSERIAL.print(cntr[1]);
|
MYSERIAL.print(cntr[1]);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -552,7 +585,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
|||||||
cntr[0] = cntrInv[0];
|
cntr[0] = cntrInv[0];
|
||||||
cntr[1] = cntrInv[1];
|
cntr[1] = cntrInv[1];
|
||||||
}
|
}
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 1) {
|
if (verbosity_level >= 1) {
|
||||||
// Show the adjusted state, before the fitting.
|
// Show the adjusted state, before the fitting.
|
||||||
SERIAL_ECHOPGM("X vector, adjusted: ");
|
SERIAL_ECHOPGM("X vector, adjusted: ");
|
||||||
@ -607,6 +640,8 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
|
|||||||
}
|
}
|
||||||
delay_keep_alive(100);
|
delay_keep_alive(100);
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -819,8 +854,10 @@ static inline void update_current_position_z()
|
|||||||
// At the current position, find the Z stop.
|
// At the current position, find the Z stop.
|
||||||
inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int verbosity_level)
|
inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int verbosity_level)
|
||||||
{
|
{
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if(verbosity_level >= 10) SERIAL_ECHOLNPGM("find bed induction sensor point z");
|
if(verbosity_level >= 10) SERIAL_ECHOLNPGM("find bed induction sensor point z");
|
||||||
bool endstops_enabled = enable_endstops(true);
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
bool endstops_enabled = enable_endstops(true);
|
||||||
bool endstop_z_enabled = enable_z_endstop(false);
|
bool endstop_z_enabled = enable_z_endstop(false);
|
||||||
float z = 0.f;
|
float z = 0.f;
|
||||||
endstop_z_hit_on_purpose();
|
endstop_z_hit_on_purpose();
|
||||||
@ -874,8 +911,10 @@ error:
|
|||||||
#define FIND_BED_INDUCTION_SENSOR_POINT_Z_STEP (0.2f)
|
#define FIND_BED_INDUCTION_SENSOR_POINT_Z_STEP (0.2f)
|
||||||
inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
|
inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
|
||||||
{
|
{
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if(verbosity_level >= 10) MYSERIAL.println("find bed induction sensor point xy");
|
if(verbosity_level >= 10) MYSERIAL.println("find bed induction sensor point xy");
|
||||||
float feedrate = homing_feedrate[X_AXIS] / 60.f;
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
float feedrate = homing_feedrate[X_AXIS] / 60.f;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -887,19 +926,27 @@ inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
|
|||||||
uint8_t i;
|
uint8_t i;
|
||||||
if (x0 < X_MIN_POS) {
|
if (x0 < X_MIN_POS) {
|
||||||
x0 = X_MIN_POS;
|
x0 = X_MIN_POS;
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("X searching radius lower than X_MIN. Clamping was done.");
|
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("X searching radius lower than X_MIN. Clamping was done.");
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
if (x1 > X_MAX_POS) {
|
if (x1 > X_MAX_POS) {
|
||||||
x1 = X_MAX_POS;
|
x1 = X_MAX_POS;
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("X searching radius higher than X_MAX. Clamping was done.");
|
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("X searching radius higher than X_MAX. Clamping was done.");
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
if (y0 < Y_MIN_POS_FOR_BED_CALIBRATION) {
|
if (y0 < Y_MIN_POS_FOR_BED_CALIBRATION) {
|
||||||
y0 = Y_MIN_POS_FOR_BED_CALIBRATION;
|
y0 = Y_MIN_POS_FOR_BED_CALIBRATION;
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("Y searching radius lower than Y_MIN. Clamping was done.");
|
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("Y searching radius lower than Y_MIN. Clamping was done.");
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
if (y1 > Y_MAX_POS) {
|
if (y1 > Y_MAX_POS) {
|
||||||
y1 = Y_MAX_POS;
|
y1 = Y_MAX_POS;
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("Y searching radius higher than X_MAX. Clamping was done.");
|
if (verbosity_level >= 20) SERIAL_ECHOLNPGM("Y searching radius higher than X_MAX. Clamping was done.");
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
nsteps_y = int(ceil((y1 - y0) / FIND_BED_INDUCTION_SENSOR_POINT_XY_STEP));
|
nsteps_y = int(ceil((y1 - y0) / FIND_BED_INDUCTION_SENSOR_POINT_XY_STEP));
|
||||||
|
|
||||||
@ -1204,11 +1251,13 @@ inline bool improve_bed_induction_sensor_point2(bool lift_z_on_min_y, int8_t ver
|
|||||||
}
|
}
|
||||||
b = current_position[X_AXIS];
|
b = current_position[X_AXIS];
|
||||||
if (b - a < MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
if (b - a < MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
SERIAL_ECHOPGM("Point width too small: ");
|
SERIAL_ECHOPGM("Point width too small: ");
|
||||||
SERIAL_ECHO(b - a);
|
SERIAL_ECHO(b - a);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
// We force the calibration routine to move the Z axis slightly down to make the response more pronounced.
|
// We force the calibration routine to move the Z axis slightly down to make the response more pronounced.
|
||||||
if (b - a < 0.5f * MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
if (b - a < 0.5f * MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
||||||
// Don't use the new X value.
|
// Don't use the new X value.
|
||||||
@ -1219,10 +1268,12 @@ inline bool improve_bed_induction_sensor_point2(bool lift_z_on_min_y, int8_t ver
|
|||||||
point_small = true;
|
point_small = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
debug_output_point(PSTR("left" ), a, current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("left" ), a, current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
debug_output_point(PSTR("right"), b, current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("right"), b, current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
// Go to the center.
|
// Go to the center.
|
||||||
enable_z_endstop(false);
|
enable_z_endstop(false);
|
||||||
@ -1275,11 +1326,13 @@ inline bool improve_bed_induction_sensor_point2(bool lift_z_on_min_y, int8_t ver
|
|||||||
b = current_position[Y_AXIS];
|
b = current_position[Y_AXIS];
|
||||||
if (b - a < MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
if (b - a < MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
||||||
// We force the calibration routine to move the Z axis slightly down to make the response more pronounced.
|
// We force the calibration routine to move the Z axis slightly down to make the response more pronounced.
|
||||||
if (verbosity_level >= 5) {
|
#ifdef SUPPORT_VERBOSITY
|
||||||
|
if (verbosity_level >= 5) {
|
||||||
SERIAL_ECHOPGM("Point height too small: ");
|
SERIAL_ECHOPGM("Point height too small: ");
|
||||||
SERIAL_ECHO(b - a);
|
SERIAL_ECHO(b - a);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
if (b - a < 0.5f * MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
if (b - a < 0.5f * MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
||||||
// Don't use the new Y value.
|
// Don't use the new Y value.
|
||||||
current_position[Y_AXIS] = center_old_y;
|
current_position[Y_AXIS] = center_old_y;
|
||||||
@ -1289,10 +1342,12 @@ inline bool improve_bed_induction_sensor_point2(bool lift_z_on_min_y, int8_t ver
|
|||||||
point_small = true;
|
point_small = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
debug_output_point(PSTR("top" ), current_position[X_AXIS], a, current_position[Z_AXIS]);
|
debug_output_point(PSTR("top" ), current_position[X_AXIS], a, current_position[Z_AXIS]);
|
||||||
debug_output_point(PSTR("bottom"), current_position[X_AXIS], b, current_position[Z_AXIS]);
|
debug_output_point(PSTR("bottom"), current_position[X_AXIS], b, current_position[Z_AXIS]);
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
// Go to the center.
|
// Go to the center.
|
||||||
enable_z_endstop(false);
|
enable_z_endstop(false);
|
||||||
@ -1325,8 +1380,9 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
|||||||
float center_old_y = current_position[Y_AXIS];
|
float center_old_y = current_position[Y_AXIS];
|
||||||
float a, b;
|
float a, b;
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) MYSERIAL.println("Improve bed induction sensor point3");
|
if (verbosity_level >= 20) MYSERIAL.println("Improve bed induction sensor point3");
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
// Was the sensor point detected too far in the minus Y axis?
|
// Was the sensor point detected too far in the minus Y axis?
|
||||||
// If yes, the center of the induction point cannot be reached by the machine.
|
// If yes, the center of the induction point cannot be reached by the machine.
|
||||||
{
|
{
|
||||||
@ -1344,7 +1400,7 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
|||||||
y0 = Y_MIN_POS_FOR_BED_CALIBRATION;
|
y0 = Y_MIN_POS_FOR_BED_CALIBRATION;
|
||||||
if (y1 > Y_MAX_POS)
|
if (y1 > Y_MAX_POS)
|
||||||
y1 = Y_MAX_POS;
|
y1 = Y_MAX_POS;
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOPGM("Initial position: ");
|
SERIAL_ECHOPGM("Initial position: ");
|
||||||
SERIAL_ECHO(center_old_x);
|
SERIAL_ECHO(center_old_x);
|
||||||
@ -1352,6 +1408,7 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
|||||||
SERIAL_ECHO(center_old_y);
|
SERIAL_ECHO(center_old_y);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
// Search in the positive Y direction, until a maximum diameter is found.
|
// Search in the positive Y direction, until a maximum diameter is found.
|
||||||
// (the next diameter is smaller than the current one.)
|
// (the next diameter is smaller than the current one.)
|
||||||
@ -1383,10 +1440,12 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
|||||||
// goto canceled;
|
// goto canceled;
|
||||||
}
|
}
|
||||||
b = current_position[X_AXIS];
|
b = current_position[X_AXIS];
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
debug_output_point(PSTR("left" ), a, current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("left" ), a, current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
debug_output_point(PSTR("right"), b, current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("right"), b, current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
float d = b - a;
|
float d = b - a;
|
||||||
if (d > dmax) {
|
if (d > dmax) {
|
||||||
xmax1 = 0.5f * (a + b);
|
xmax1 = 0.5f * (a + b);
|
||||||
@ -1397,9 +1456,11 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dmax == 0.) {
|
if (dmax == 0.) {
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level > 0)
|
if (verbosity_level > 0)
|
||||||
SERIAL_PROTOCOLPGM("failed - not found\n");
|
SERIAL_PROTOCOLPGM("failed - not found\n");
|
||||||
current_position[X_AXIS] = center_old_x;
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
current_position[X_AXIS] = center_old_x;
|
||||||
current_position[Y_AXIS] = center_old_y;
|
current_position[Y_AXIS] = center_old_y;
|
||||||
goto canceled;
|
goto canceled;
|
||||||
}
|
}
|
||||||
@ -1415,9 +1476,11 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
|||||||
current_position[Y_AXIS] = center_old_y;
|
current_position[Y_AXIS] = center_old_y;
|
||||||
goto canceled;
|
goto canceled;
|
||||||
}
|
}
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5)
|
if (verbosity_level >= 5)
|
||||||
debug_output_point(PSTR("top" ), current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("top" ), current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
y1 = current_position[Y_AXIS];
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
y1 = current_position[Y_AXIS];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y1 <= y0) {
|
if (y1 <= y0) {
|
||||||
@ -1459,10 +1522,12 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
b = current_position[X_AXIS];
|
b = current_position[X_AXIS];
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
debug_output_point(PSTR("left" ), a, current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("left" ), a, current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
debug_output_point(PSTR("right"), b, current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("right"), b, current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
float d = b - a;
|
float d = b - a;
|
||||||
if (d > dmax) {
|
if (d > dmax) {
|
||||||
xmax2 = 0.5f * (a + b);
|
xmax2 = 0.5f * (a + b);
|
||||||
@ -1510,10 +1575,12 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
b = current_position[X_AXIS];
|
b = current_position[X_AXIS];
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
debug_output_point(PSTR("left" ), a, current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("left" ), a, current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
debug_output_point(PSTR("right"), b, current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("right"), b, current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
float d = b - a;
|
float d = b - a;
|
||||||
if (d > dmax) {
|
if (d > dmax) {
|
||||||
xmax = 0.5f * (a + b);
|
xmax = 0.5f * (a + b);
|
||||||
@ -1535,24 +1602,29 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
|||||||
current_position[Y_AXIS] = center_old_y;
|
current_position[Y_AXIS] = center_old_y;
|
||||||
goto canceled;
|
goto canceled;
|
||||||
}
|
}
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5)
|
if (verbosity_level >= 5)
|
||||||
debug_output_point(PSTR("top" ), current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]);
|
debug_output_point(PSTR("top" ), current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||||
if (current_position[Y_AXIS] - Y_MIN_POS_FOR_BED_CALIBRATION < 0.5f * dmax) {
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
if (current_position[Y_AXIS] - Y_MIN_POS_FOR_BED_CALIBRATION < 0.5f * dmax) {
|
||||||
// Probably not even a half circle was detected. The induction point is likely too far in the minus Y direction.
|
// Probably not even a half circle was detected. The induction point is likely too far in the minus Y direction.
|
||||||
// First verify, if the measurement has been done at a sufficient height. If no, lower the Z axis a bit.
|
// First verify, if the measurement has been done at a sufficient height. If no, lower the Z axis a bit.
|
||||||
if (current_position[Y_AXIS] < ymax || dmax < 0.5f * MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
if (current_position[Y_AXIS] < ymax || dmax < 0.5f * MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
||||||
if (verbosity_level >= 5) {
|
#ifdef SUPPORT_VERBOSITY
|
||||||
|
if (verbosity_level >= 5) {
|
||||||
SERIAL_ECHOPGM("Partial point diameter too small: ");
|
SERIAL_ECHOPGM("Partial point diameter too small: ");
|
||||||
SERIAL_ECHO(dmax);
|
SERIAL_ECHO(dmax);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
result = false;
|
result = false;
|
||||||
} else {
|
} else {
|
||||||
// Estimate the circle radius from the maximum diameter and height:
|
// Estimate the circle radius from the maximum diameter and height:
|
||||||
float h = current_position[Y_AXIS] - ymax;
|
float h = current_position[Y_AXIS] - ymax;
|
||||||
float r = dmax * dmax / (8.f * h) + 0.5f * h;
|
float r = dmax * dmax / (8.f * h) + 0.5f * h;
|
||||||
if (r < 0.8f * MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
if (r < 0.8f * MIN_BED_SENSOR_POINT_RESPONSE_DMR) {
|
||||||
if (verbosity_level >= 5) {
|
#ifdef SUPPORT_VERBOSITY
|
||||||
|
if (verbosity_level >= 5) {
|
||||||
SERIAL_ECHOPGM("Partial point estimated radius too small: ");
|
SERIAL_ECHOPGM("Partial point estimated radius too small: ");
|
||||||
SERIAL_ECHO(r);
|
SERIAL_ECHO(r);
|
||||||
SERIAL_ECHOPGM(", dmax:");
|
SERIAL_ECHOPGM(", dmax:");
|
||||||
@ -1561,6 +1633,7 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
|||||||
SERIAL_ECHO(h);
|
SERIAL_ECHO(h);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
result = false;
|
result = false;
|
||||||
} else {
|
} else {
|
||||||
// The point may end up outside of the machine working space.
|
// The point may end up outside of the machine working space.
|
||||||
@ -1587,6 +1660,7 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
|||||||
enable_z_endstop(false);
|
enable_z_endstop(false);
|
||||||
current_position[X_AXIS] = xmax;
|
current_position[X_AXIS] = xmax;
|
||||||
current_position[Y_AXIS] = ymax;
|
current_position[Y_AXIS] = ymax;
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOPGM("Adjusted position: ");
|
SERIAL_ECHOPGM("Adjusted position: ");
|
||||||
SERIAL_ECHO(current_position[X_AXIS]);
|
SERIAL_ECHO(current_position[X_AXIS]);
|
||||||
@ -1594,6 +1668,7 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level)
|
|||||||
SERIAL_ECHO(current_position[Y_AXIS]);
|
SERIAL_ECHO(current_position[Y_AXIS]);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
// Don't clamp current_position[Y_AXIS], because the out-of-reach Y coordinate may actually be true.
|
// Don't clamp current_position[Y_AXIS], because the out-of-reach Y coordinate may actually be true.
|
||||||
// Only clamp the coordinate to go.
|
// Only clamp the coordinate to go.
|
||||||
@ -1684,6 +1759,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
|||||||
|
|
||||||
SERIAL_ECHOPGM("Iteration: ");
|
SERIAL_ECHOPGM("Iteration: ");
|
||||||
MYSERIAL.println(int(iteration + 1));
|
MYSERIAL.println(int(iteration + 1));
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOLNPGM("Vectors: ");
|
SERIAL_ECHOLNPGM("Vectors: ");
|
||||||
|
|
||||||
@ -1706,6 +1782,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
|||||||
MYSERIAL.print(cntr[1], 5);
|
MYSERIAL.print(cntr[1], 5);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
#ifdef MESH_BED_CALIBRATION_SHOW_LCD
|
#ifdef MESH_BED_CALIBRATION_SHOW_LCD
|
||||||
uint8_t next_line;
|
uint8_t next_line;
|
||||||
lcd_display_message_fullscreen_P(MSG_FIND_BED_OFFSET_AND_SKEW_LINE1, next_line);
|
lcd_display_message_fullscreen_P(MSG_FIND_BED_OFFSET_AND_SKEW_LINE1, next_line);
|
||||||
@ -1731,6 +1808,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
|||||||
// Go up to z_initial.
|
// Go up to z_initial.
|
||||||
|
|
||||||
go_to_current(homing_feedrate[Z_AXIS] / 60.f);
|
go_to_current(homing_feedrate[Z_AXIS] / 60.f);
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
// Go to Y0, wait, then go to Y-4.
|
// Go to Y0, wait, then go to Y-4.
|
||||||
current_position[Y_AXIS] = 0.f;
|
current_position[Y_AXIS] = 0.f;
|
||||||
@ -1742,6 +1820,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
|||||||
SERIAL_ECHOLNPGM("At Y-4");
|
SERIAL_ECHOLNPGM("At Y-4");
|
||||||
delay_keep_alive(5000);
|
delay_keep_alive(5000);
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
// Go to the measurement point position.
|
// Go to the measurement point position.
|
||||||
//if (iteration == 0) {
|
//if (iteration == 0) {
|
||||||
current_position[X_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2);
|
current_position[X_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2);
|
||||||
@ -1759,6 +1838,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
|||||||
current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION;
|
current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION;
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOPGM("current_position[X_AXIS]:");
|
SERIAL_ECHOPGM("current_position[X_AXIS]:");
|
||||||
MYSERIAL.print(current_position[X_AXIS], 5);
|
MYSERIAL.print(current_position[X_AXIS], 5);
|
||||||
@ -1770,16 +1850,18 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
|||||||
MYSERIAL.print(current_position[Z_AXIS], 5);
|
MYSERIAL.print(current_position[Z_AXIS], 5);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
go_to_current(homing_feedrate[X_AXIS] / 60.f);
|
go_to_current(homing_feedrate[X_AXIS] / 60.f);
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10)
|
if (verbosity_level >= 10)
|
||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
if (!find_bed_induction_sensor_point_xy(verbosity_level))
|
if (!find_bed_induction_sensor_point_xy(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;
|
||||||
@ -1799,15 +1881,19 @@ 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;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10)
|
if (verbosity_level >= 10)
|
||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
// Save the detected point position and then clamp the Y coordinate, which may have been estimated
|
// Save the detected point position and then clamp the Y coordinate, which may have been estimated
|
||||||
// to lie outside the machine working space.
|
// to lie outside the machine working space.
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOLNPGM("Measured:");
|
SERIAL_ECHOLNPGM("Measured:");
|
||||||
MYSERIAL.println(current_position[X_AXIS]);
|
MYSERIAL.println(current_position[X_AXIS]);
|
||||||
MYSERIAL.println(current_position[Y_AXIS]);
|
MYSERIAL.println(current_position[Y_AXIS]);
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
pt[0] = (pt[0] * iteration) / (iteration + 1);
|
pt[0] = (pt[0] * iteration) / (iteration + 1);
|
||||||
pt[0] += (current_position[X_AXIS]/(iteration + 1)); //count average
|
pt[0] += (current_position[X_AXIS]/(iteration + 1)); //count average
|
||||||
pt[1] = (pt[1] * iteration) / (iteration + 1);
|
pt[1] = (pt[1] * iteration) / (iteration + 1);
|
||||||
@ -1820,6 +1906,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
|||||||
//pt[1] += current_position[Y_AXIS];
|
//pt[1] += current_position[Y_AXIS];
|
||||||
//if (iteration > 0) pt[1] = pt[1] / 2;
|
//if (iteration > 0) pt[1] = pt[1] / 2;
|
||||||
|
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
SERIAL_ECHOPGM("pt[0]:");
|
SERIAL_ECHOPGM("pt[0]:");
|
||||||
@ -1827,6 +1914,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
|||||||
SERIAL_ECHOPGM("pt[1]:");
|
SERIAL_ECHOPGM("pt[1]:");
|
||||||
MYSERIAL.println(pt[1]);
|
MYSERIAL.println(pt[1]);
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
if (current_position[Y_AXIS] < Y_MIN_POS)
|
if (current_position[Y_AXIS] < Y_MIN_POS)
|
||||||
current_position[Y_AXIS] = Y_MIN_POS;
|
current_position[Y_AXIS] = Y_MIN_POS;
|
||||||
@ -1834,14 +1922,17 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
|||||||
current_position[Z_AXIS] += 3.f + FIND_BED_INDUCTION_SENSOR_POINT_Z_STEP * iteration * 0.3;
|
current_position[Z_AXIS] += 3.f + FIND_BED_INDUCTION_SENSOR_POINT_Z_STEP * iteration * 0.3;
|
||||||
//cntr[0] += pt[0];
|
//cntr[0] += pt[0];
|
||||||
//cntr[1] += pt[1];
|
//cntr[1] += pt[1];
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10 && k == 0) {
|
if (verbosity_level >= 10 && k == 0) {
|
||||||
// Show the zero. Test, whether the Y motor skipped steps.
|
// Show the zero. Test, whether the Y motor skipped steps.
|
||||||
current_position[Y_AXIS] = MANUAL_Y_HOME_POS;
|
current_position[Y_AXIS] = MANUAL_Y_HOME_POS;
|
||||||
go_to_current(homing_feedrate[X_AXIS] / 60.f);
|
go_to_current(homing_feedrate[X_AXIS] / 60.f);
|
||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
// 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);
|
||||||
@ -1856,7 +1947,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
|||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
if (pts[1] < Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH) {
|
if (pts[1] < Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH) {
|
||||||
too_far_mask |= 1 << 1; //front center point is out of reach
|
too_far_mask |= 1 << 1; //front center point is out of reach
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
@ -1878,6 +1969,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
|||||||
eeprom_update_float((float*)(EEPROM_BED_CALIBRATION_VEC_Y + 0), vec_y[0]);
|
eeprom_update_float((float*)(EEPROM_BED_CALIBRATION_VEC_Y + 0), vec_y[0]);
|
||||||
eeprom_update_float((float*)(EEPROM_BED_CALIBRATION_VEC_Y + 4), vec_y[1]);
|
eeprom_update_float((float*)(EEPROM_BED_CALIBRATION_VEC_Y + 4), vec_y[1]);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10) {
|
if (verbosity_level >= 10) {
|
||||||
// Length of the vec_x
|
// Length of the vec_x
|
||||||
float l = sqrt(vec_x[0] * vec_x[0] + vec_x[1] * vec_x[1]);
|
float l = sqrt(vec_x[0] * vec_x[0] + vec_x[1] * vec_x[1]);
|
||||||
@ -1899,10 +1991,11 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
|||||||
MYSERIAL.println(fabs(l));
|
MYSERIAL.println(fabs(l));
|
||||||
SERIAL_ECHOLNPGM("Saving bed calibration vectors to EEPROM");
|
SERIAL_ECHOLNPGM("Saving bed calibration vectors to EEPROM");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
// Correct the current_position to match the transformed coordinate system after world2machine_rotation_and_skew and world2machine_shift were set.
|
// Correct the current_position to match the transformed coordinate system after world2machine_rotation_and_skew and world2machine_shift were set.
|
||||||
world2machine_update_current();
|
world2machine_update_current();
|
||||||
|
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
// 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);
|
||||||
@ -1917,6 +2010,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
|||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (result == BED_SKEW_OFFSET_DETECTION_FITTING_FAILED && too_far_mask == 2) return result; //if fitting failed and front center point is out of reach, terminate calibration and inform user
|
if (result == BED_SKEW_OFFSET_DETECTION_FITTING_FAILED && too_far_mask == 2) return result; //if fitting failed and front center point is out of reach, terminate calibration and inform user
|
||||||
@ -1940,9 +2034,9 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
|||||||
float *vec_y = vec_x + 2;
|
float *vec_y = vec_x + 2;
|
||||||
float *cntr = vec_y + 2;
|
float *cntr = vec_y + 2;
|
||||||
memset(pts, 0, sizeof(float) * 7 * 7);
|
memset(pts, 0, sizeof(float) * 7 * 7);
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10) SERIAL_ECHOLNPGM("Improving bed offset and skew");
|
if (verbosity_level >= 10) SERIAL_ECHOLNPGM("Improving bed offset and skew");
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
// Cache the current correction matrix.
|
// Cache the current correction matrix.
|
||||||
world2machine_initialize();
|
world2machine_initialize();
|
||||||
vec_x[0] = world2machine_rotation_and_skew[0][0];
|
vec_x[0] = world2machine_rotation_and_skew[0][0];
|
||||||
@ -1966,7 +2060,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.
|
||||||
@ -1980,6 +2074,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
|||||||
enable_endstops(false);
|
enable_endstops(false);
|
||||||
enable_z_endstop(false);
|
enable_z_endstop(false);
|
||||||
go_to_current(homing_feedrate[Z_AXIS]/60);
|
go_to_current(homing_feedrate[Z_AXIS]/60);
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
// Go to Y0, wait, then go to Y-4.
|
// Go to Y0, wait, then go to Y-4.
|
||||||
current_position[Y_AXIS] = 0.f;
|
current_position[Y_AXIS] = 0.f;
|
||||||
@ -1991,32 +2086,40 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
|||||||
SERIAL_ECHOLNPGM("At Y_MIN_POS");
|
SERIAL_ECHOLNPGM("At Y_MIN_POS");
|
||||||
delay_keep_alive(5000);
|
delay_keep_alive(5000);
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
// 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;
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOPGM("Calibration point ");
|
SERIAL_ECHOPGM("Calibration point ");
|
||||||
SERIAL_ECHO(mesh_point);
|
SERIAL_ECHO(mesh_point);
|
||||||
SERIAL_ECHOPGM("lower than Ymin. Y coordinate clamping was used.");
|
SERIAL_ECHOPGM("lower than Ymin. Y coordinate clamping was used.");
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
go_to_current(homing_feedrate[X_AXIS]/60);
|
go_to_current(homing_feedrate[X_AXIS]/60);
|
||||||
// Find its Z position by running the normal vertical search.
|
// Find its Z position by running the normal vertical search.
|
||||||
if (verbosity_level >= 10)
|
#ifdef SUPPORT_VERBOSITY
|
||||||
|
if (verbosity_level >= 10)
|
||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
find_bed_induction_sensor_point_z();
|
#endif // SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10)
|
find_bed_induction_sensor_point_z();
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
|
if (verbosity_level >= 10)
|
||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
// Try to move the Z axis down a bit to increase a chance of the sensor to trigger.
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
// Try to move the Z axis down a bit to increase a chance of the sensor to trigger.
|
||||||
current_position[Z_AXIS] -= 0.025f;
|
current_position[Z_AXIS] -= 0.025f;
|
||||||
// Improve the point position by searching its center in a current plane.
|
// Improve the point position by searching its center in a current plane.
|
||||||
int8_t n_errors = 3;
|
int8_t n_errors = 3;
|
||||||
for (int8_t iter = 0; iter < 8; ) {
|
for (int8_t iter = 0; iter < 8; ) {
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level > 20) {
|
if (verbosity_level > 20) {
|
||||||
SERIAL_ECHOPGM("Improving bed point ");
|
SERIAL_ECHOPGM("Improving bed point ");
|
||||||
SERIAL_ECHO(mesh_point);
|
SERIAL_ECHO(mesh_point);
|
||||||
@ -2026,8 +2129,9 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
|||||||
MYSERIAL.print(current_position[Z_AXIS], 5);
|
MYSERIAL.print(current_position[Z_AXIS], 5);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
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 +2140,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2059,6 +2163,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
|||||||
enable_endstops(false);
|
enable_endstops(false);
|
||||||
enable_z_endstop(false);
|
enable_z_endstop(false);
|
||||||
go_to_current(homing_feedrate[Z_AXIS]);
|
go_to_current(homing_feedrate[Z_AXIS]);
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
SERIAL_ECHOPGM("Improving bed point ");
|
SERIAL_ECHOPGM("Improving bed point ");
|
||||||
SERIAL_ECHO(mesh_point);
|
SERIAL_ECHO(mesh_point);
|
||||||
@ -2068,25 +2173,29 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
|||||||
MYSERIAL.print(current_position[Z_AXIS], 5);
|
MYSERIAL.print(current_position[Z_AXIS], 5);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 10)
|
if (verbosity_level >= 10)
|
||||||
delay_keep_alive(3000);
|
delay_keep_alive(3000);
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
}
|
}
|
||||||
// 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();
|
||||||
|
|
||||||
// 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);
|
||||||
enable_z_endstop(false);
|
enable_z_endstop(false);
|
||||||
|
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
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.
|
||||||
@ -2106,21 +2215,23 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
|||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
{
|
{
|
||||||
// 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);
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 20) {
|
if (verbosity_level >= 20) {
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
SERIAL_ECHOPGM("Distance from min:");
|
SERIAL_ECHOPGM("Distance from min:");
|
||||||
@ -2130,6 +2241,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
|||||||
MYSERIAL.print(y);
|
MYSERIAL.print(y);
|
||||||
SERIAL_ECHOLNPGM("");
|
SERIAL_ECHOLNPGM("");
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
if (y < Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH)
|
if (y < Y_MIN_POS_CALIBRATION_POINT_OUT_OF_REACH)
|
||||||
too_far_mask |= 1 << mesh_point;
|
too_far_mask |= 1 << mesh_point;
|
||||||
}
|
}
|
||||||
@ -2151,18 +2263,18 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
|||||||
|
|
||||||
enable_endstops(false);
|
enable_endstops(false);
|
||||||
enable_z_endstop(false);
|
enable_z_endstop(false);
|
||||||
|
#ifdef SUPPORT_VERBOSITY
|
||||||
if (verbosity_level >= 5) {
|
if (verbosity_level >= 5) {
|
||||||
// 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);
|
||||||
@ -2180,6 +2292,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // SUPPORT_VERBOSITY
|
||||||
|
|
||||||
// Sample Z heights for the mesh bed leveling.
|
// Sample Z heights for the mesh bed leveling.
|
||||||
// In addition, store the results into an eeprom, to be used later for verification of the bed leveling process.
|
// In addition, store the results into an eeprom, to be used later for verification of the bed leveling process.
|
||||||
@ -2483,9 +2596,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user