From c441b4acdb55e7af49d6892b718f028a1fb81be0 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Mon, 27 Feb 2017 17:24:26 +0100 Subject: [PATCH 01/11] temp calibration initial version --- Firmware/Configuration.h | 2 + Firmware/Marlin.h | 4 +- Firmware/Marlin_main.cpp | 177 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 182 insertions(+), 1 deletion(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 27a399130..3ac6ec213 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -34,6 +34,8 @@ #define EEPROM_FARM_MODE (EEPROM_BED_CALIBRATION_Z_JITTER-4) +#define EEPROM_PROBE_TEMP_SHIFT (EEPROM_FARM_MODE - 2*5) //5 x int for storing pinda probe temp shift relative to 50 C; unit: motor steps + // Correction of the bed leveling, in micrometers. // Maximum 50 micrometers allowed. // Bed correction is valid if set to 1. If set to zero or 255, the successive 4 bytes are invalid. diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index adcf8f201..466805b07 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -326,4 +326,6 @@ void d_setup(); float d_ReadData(); void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_points_num, float shift_x, float shift_y); -#endif \ No newline at end of file +#endif +float temp_comp_interpolation(float temperature); +void temp_compensation_apply(); \ No newline at end of file diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 41328c2e1..c0b00713b 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2767,6 +2767,87 @@ void process_commands() * */ + case 76: //PINDA probe temperature compensation + { + setTargetBed(PINDA_MIN_T); + float zero_z; + int z_shift = 0; //unit: steps + int t_c; // temperature + + if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS])) { + // We don't know where we are! HOME! + // Push the commands to the front of the message queue in the reverse order! + // There shall be always enough space reserved for these commands. + repeatcommand_front(); // repeat G76 with all its parameters + enquecommand_front_P((PSTR("G28 W0"))); + break; + } + current_position[X_AXIS] = PINDA_PREHEAT_X; + current_position[Y_AXIS] = PINDA_PREHEAT_Y; + current_position[Z_AXIS] = 0; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); + st_synchronize(); + + while (degBed() < PINDA_MIN_T) delay_keep_alive(1000); + + //enquecommand_P(PSTR("M190 S50")); + + delay_keep_alive(PINDA_HEAT_T * 1000); + + current_position[Z_AXIS] = 5; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); + + current_position[X_AXIS] = pgm_read_float(bed_ref_points); + current_position[Y_AXIS] = pgm_read_float(bed_ref_points + 1); + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); + st_synchronize(); + + find_bed_induction_sensor_point_z(-1.f); + zero_z = current_position[Z_AXIS]; + + //current_position[Z_AXIS] + SERIAL_ECHOLNPGM(""); + SERIAL_ECHOPGM("ZERO: "); + MYSERIAL.print(current_position[Z_AXIS]); + SERIAL_ECHOLNPGM(""); + + for (int i = 0; i<5; i++) { + + t_c = 60 + i * 10; + + setTargetBed(t_c); + current_position[X_AXIS] = PINDA_PREHEAT_X; + current_position[Y_AXIS] = PINDA_PREHEAT_Y; + current_position[Z_AXIS] = 0; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); + st_synchronize(); + while (degBed() < t_c) delay_keep_alive(1000); + delay_keep_alive(PINDA_HEAT_T * 1000); + current_position[Z_AXIS] = 5; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); + current_position[X_AXIS] = pgm_read_float(bed_ref_points); + current_position[Y_AXIS] = pgm_read_float(bed_ref_points + 1); + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); + st_synchronize(); + find_bed_induction_sensor_point_z(-1.f); + z_shift = (int)((current_position[Z_AXIS] - zero_z)*axis_steps_per_unit[Z_AXIS]); + + SERIAL_ECHOLNPGM(""); + SERIAL_ECHOPGM("Temperature: "); + MYSERIAL.print(t_c); + SERIAL_ECHOPGM(" Z shift (mm):"); + MYSERIAL.print(current_position[Z_AXIS] - zero_z); + SERIAL_ECHOLNPGM(""); + + EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i*2, &z_shift); + + + } + setTargetBed(0); //set bed target temperature back to 0 + + } + break; + #ifdef DIS case 77: { @@ -2908,6 +2989,9 @@ void process_commands() } clean_up_after_endstop_move(); + + temp_compensation_apply(); //apply PINDA temperature compensation + // Apply Z height correction aka baby stepping before mesh bed leveing gets activated. babystep_apply(); @@ -6063,4 +6147,97 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ } +void temp_compensation_apply() { + int i_add; + int compensation_value; + int z_shift = 0; + float z_shift_mm; + + current_position[X_AXIS] = PINDA_PREHEAT_X; + current_position[Y_AXIS] = PINDA_PREHEAT_Y; + current_position[Z_AXIS] = 0; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); + st_synchronize(); + + while (fabs(degBed() - target_temperature_bed) > 3) delay_keep_alive(1000); + + delay_keep_alive(PINDA_HEAT_T * 1000); + + if (target_temperature_bed % 10 == 0 && target_temperature_bed >= 60 && target_temperature_bed <= 100) { + i_add = (target_temperature_bed - 60) / 10; + EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + i_add * 2, &z_shift); + z_shift_mm = z_shift / axis_steps_per_unit[Z_AXIS]; + } + else { + //interpolation + z_shift_mm = temp_comp_interpolation(target_temperature_bed) / axis_steps_per_unit[Z_AXIS]; + } + SERIAL_PROTOCOLPGM("\n"); + SERIAL_PROTOCOLPGM("Z shift applied:"); + MYSERIAL.print(z_shift_mm); + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] - z_shift_mm, current_position[E_AXIS], homing_feedrate[Z_AXIS] / 40, active_extruder); + st_synchronize(); + plan_set_z_position(current_position[Z_AXIS]); +} + +float temp_comp_interpolation(float temperature) { + //cubic spline interpolation + + int i; + int shift[6]; + float shift_f[6]; + float temp_C[6]; + + shift[0] = 0; //shift for 50 C is 0 + + int n, j, k; + float h[10], a, b, c, d, sum, s[10] = { 0 }, x[10], F[10], f[10], p, m[10][10] = { 0 }, temp; + + + for (i = 0; i < 6; i++) { + EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &shift[i + 1]); //read shift in steps from EEPROM + temp_C[i] = 50 + i * 10; //temperature in C + shift_f[i] = (float)shift[i]; + + } + for (i = 5; i > 0; i--) { + F[i] = (shift_f[i] - shift_f[i - 1]) / (temp_C[i] - temp_C[i - 1]); + h[i - 1] = temp_C[i] - temp_C[i - 1]; + } + + //*********** formation of h, s , f matrix **************// + for (i = 1; i<5; i++) { + m[i][i] = 2 * (h[i - 1] + h[i]); + if (i != 1) { + m[i][i - 1] = h[i - 1]; + m[i - 1][i] = h[i - 1]; + } + m[i][5] = 6 * (F[i + 1] - F[i]); + } + //*********** forward elimination **************// + for (i = 1; i<4; i++) { + temp = (m[i + 1][i] / m[i][i]); + for (j = 1; j <= 5; j++) + m[i + 1][j] -= temp*m[i][j]; + } + //*********** backward substitution *********// + for (i = 4; i>0; i--) { + sum = 0; + for (j = i; j <= 4; j++) + sum += m[i][j] * s[j]; + s[i] = (m[i][n - 1] - sum) / m[i][i]; + } + + for (i = 0; i<5; i++) + if (temp_C[i] <= temperature&&temperature <= temp_C[i + 1]) { + a = (s[i + 1] - s[i]) / (6 * h[i]); + b = s[i] / 2; + c = (shift[i + 1] - shift[i]) / h[i] - (2 * h[i] * s[i] + s[i + 1] * h[i]) / 6; + d = shift[i]; + sum = a*pow((p - temp_C[i]), 3) + b*pow((p - temp_C[i]), 2) + c*(p - temp_C[i]) + d; + } + return(sum); +} + + #endif \ No newline at end of file From fd3bb9c7e58dfad971c8c18cf59290ca83fd64e1 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 1 Mar 2017 11:10:29 +0100 Subject: [PATCH 02/11] delay_keep_alive function fixed, induction probe temperature calibration --- Firmware/Configuration.h | 2 +- Firmware/Marlin.h | 5 +++-- Firmware/Marlin_main.cpp | 29 ++++++++++++++++------------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 3ac6ec213..fe5c18b7b 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -5,7 +5,7 @@ #include "Configuration_prusa.h" // Firmware version -#define FW_version "3.0.10" +#define FW_version "3.0.11" #define FW_PRUSA3D_MAGIC "PRUSA3DFW" #define FW_PRUSA3D_MAGIC_LEN 10 diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 466805b07..c9a20ac8d 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -316,7 +316,7 @@ extern void calculate_volumetric_multipliers(); // Similar to the default Arduino delay function, // but it keeps the background tasks running. -extern void delay_keep_alive(int ms); +extern void delay_keep_alive(unsigned int ms); extern void check_babystep(); @@ -328,4 +328,5 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ #endif float temp_comp_interpolation(float temperature); -void temp_compensation_apply(); \ No newline at end of file +void temp_compensation_apply(); +void temp_compensation_start(); \ No newline at end of file diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index c0b00713b..ae54d136f 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2791,8 +2791,7 @@ void process_commands() while (degBed() < PINDA_MIN_T) delay_keep_alive(1000); //enquecommand_P(PSTR("M190 S50")); - - delay_keep_alive(PINDA_HEAT_T * 1000); + for (int i = 0; i < PINDA_HEAT_T; i++) delay_keep_alive(1000); current_position[Z_AXIS] = 5; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); @@ -2822,7 +2821,7 @@ void process_commands() plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); st_synchronize(); while (degBed() < t_c) delay_keep_alive(1000); - delay_keep_alive(PINDA_HEAT_T * 1000); + for (int i = 0; i < PINDA_HEAT_T; i++) delay_keep_alive(1000); current_position[Z_AXIS] = 5; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); current_position[X_AXIS] = pgm_read_float(bed_ref_points); @@ -2890,7 +2889,7 @@ void process_commands() enquecommand_front_P((PSTR("G28 W0"))); break; } - + temp_compensation_start(); // Save custom message state, set a new custom message state to display: Calibrating point 9. bool custom_message_old = custom_message; unsigned int custom_message_type_old = custom_message_type; @@ -5880,7 +5879,7 @@ void calculate_volumetric_multipliers() { #endif } -void delay_keep_alive(int ms) +void delay_keep_alive(unsigned int ms) { for (;;) { manage_heater(); @@ -6147,12 +6146,7 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ } -void temp_compensation_apply() { - int i_add; - int compensation_value; - int z_shift = 0; - float z_shift_mm; - +void temp_compensation_start() { current_position[X_AXIS] = PINDA_PREHEAT_X; current_position[Y_AXIS] = PINDA_PREHEAT_Y; current_position[Z_AXIS] = 0; @@ -6161,7 +6155,16 @@ void temp_compensation_apply() { while (fabs(degBed() - target_temperature_bed) > 3) delay_keep_alive(1000); - delay_keep_alive(PINDA_HEAT_T * 1000); + for(int i = 0; i < PINDA_HEAT_T; i++) delay_keep_alive(1000); + + +} + +void temp_compensation_apply() { + int i_add; + int compensation_value; + int z_shift = 0; + float z_shift_mm; if (target_temperature_bed % 10 == 0 && target_temperature_bed >= 60 && target_temperature_bed <= 100) { i_add = (target_temperature_bed - 60) / 10; @@ -6170,7 +6173,7 @@ void temp_compensation_apply() { } else { //interpolation - z_shift_mm = temp_comp_interpolation(target_temperature_bed) / axis_steps_per_unit[Z_AXIS]; + //z_shift_mm = temp_comp_interpolation(target_temperature_bed) / axis_steps_per_unit[Z_AXIS]; } SERIAL_PROTOCOLPGM("\n"); SERIAL_PROTOCOLPGM("Z shift applied:"); From d31d73c56534b066ded6a0e7223ffdcf55b16aea Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 3 Mar 2017 14:12:37 +0100 Subject: [PATCH 03/11] changed eeprom address for temp shift, verbosity level for mesh bed leveling added, added debuging functions for temp calibration --- Firmware/Configuration.h | 3 +- Firmware/Marlin_main.cpp | 445 +++++++++++++++++++++++---------------- 2 files changed, 264 insertions(+), 184 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index fe5c18b7b..a0870ec60 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -34,8 +34,6 @@ #define EEPROM_FARM_MODE (EEPROM_BED_CALIBRATION_Z_JITTER-4) -#define EEPROM_PROBE_TEMP_SHIFT (EEPROM_FARM_MODE - 2*5) //5 x int for storing pinda probe temp shift relative to 50 C; unit: motor steps - // Correction of the bed leveling, in micrometers. // Maximum 50 micrometers allowed. // Bed correction is valid if set to 1. If set to zero or 255, the successive 4 bytes are invalid. @@ -46,6 +44,7 @@ #define EEPROM_BED_CORRECTION_REAR (EEPROM_BED_CORRECTION_FRONT-1) #define EEPROM_TOSHIBA_FLASH_AIR_COMPATIBLITY (EEPROM_BED_CORRECTION_REAR-1) #define EEPROM_PRINT_FLAG (EEPROM_TOSHIBA_FLASH_AIR_COMPATIBLITY-1) +#define EEPROM_PROBE_TEMP_SHIFT (EEPROM_PRINT_FLAG - 2*5) //5 x int for storing pinda probe temp shift relative to 50 C; unit: motor steps // Currently running firmware, each digit stored as uint16_t. // The flavor differentiates a dev, alpha, beta, release candidate or a release version. diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index ae54d136f..b606a0697 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -27,14 +27,6 @@ http://reprap.org/pipermail/reprap-dev/2011-May/003323.html */ - - - - - - - - #include "Marlin.h" #ifdef ENABLE_AUTO_BED_LEVELING @@ -62,6 +54,7 @@ #include "pins_arduino.h" #include "math.h" #include "util.h" +//#include "spline.h" #ifdef BLINKM #include "BlinkM.h" @@ -2767,6 +2760,25 @@ void process_commands() * */ + case 73: + { + int i, read; + for (i = 0; i < 5; i++) { + EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &read); + MYSERIAL.print(read); + SERIAL_ECHOLNPGM(" "); + } + }break; + + case 74: + { + float result, temp; + if (code_seen('X')) temp = code_value(); + result = temp_comp_interpolation(temp); + MYSERIAL.print(result); + + }break; + case 76: //PINDA probe temperature compensation { setTargetBed(PINDA_MIN_T); @@ -2847,6 +2859,12 @@ void process_commands() } break; + case 75: + { + temp_compensation_start(); + } + break; + #ifdef DIS case 77: { @@ -2877,184 +2895,236 @@ void process_commands() #endif - case 80: - case_G80: - { - // Firstly check if we know where we are - if ( !( axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS] ) ){ - // We don't know where we are! HOME! - // Push the commands to the front of the message queue in the reverse order! - // There shall be always enough space reserved for these commands. - repeatcommand_front(); // repeat G80 with all its parameters - enquecommand_front_P((PSTR("G28 W0"))); - break; - } - temp_compensation_start(); - // Save custom message state, set a new custom message state to display: Calibrating point 9. - bool custom_message_old = custom_message; - unsigned int custom_message_type_old = custom_message_type; - unsigned int custom_message_state_old = custom_message_state; - custom_message = true; - custom_message_type = 1; - custom_message_state = (MESH_MEAS_NUM_X_POINTS * MESH_MEAS_NUM_Y_POINTS) + 10; - lcd_update(1); - - mbl.reset(); - // Reset baby stepping to zero, if the babystepping has already been loaded before. The babystepsTodo value will be - // consumed during the first movements following this statement. - babystep_undo(); + case 80: + case_G80: + { + int8_t verbosity_level = 0; + if (code_seen('V')) { + // Just 'V' without a number counts as V1. + char c = strchr_pointer[1]; + verbosity_level = (c == ' ' || c == '\t' || c == 0) ? 1 : code_value_short(); + } + // Firstly check if we know where we are + if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS])) { + // We don't know where we are! HOME! + // Push the commands to the front of the message queue in the reverse order! + // There shall be always enough space reserved for these commands. + repeatcommand_front(); // repeat G80 with all its parameters + enquecommand_front_P((PSTR("G28 W0"))); + break; + } - // Cycle through all points and probe them - // First move up. During this first movement, the babystepping will be reverted. - current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder); - // The move to the first calibration point. - current_position[X_AXIS] = pgm_read_float(bed_ref_points); - current_position[Y_AXIS] = pgm_read_float(bed_ref_points+1); - world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); -// 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); - // Wait until the move is finished. - st_synchronize(); - - int mesh_point = 0; - - int ix = 0; - int iy = 0; - - int XY_AXIS_FEEDRATE = homing_feedrate[X_AXIS]/20; - int Z_PROBE_FEEDRATE = homing_feedrate[Z_AXIS]/60; - int Z_LIFT_FEEDRATE = homing_feedrate[Z_AXIS]/40; - bool has_z = is_bed_z_jitter_data_valid(); - setup_for_endstop_move(false); - const char *kill_message = NULL; - while (mesh_point != MESH_MEAS_NUM_X_POINTS * MESH_MEAS_NUM_Y_POINTS) { - // Get coords of a measuring point. - ix = mesh_point % MESH_MEAS_NUM_X_POINTS; - iy = mesh_point / MESH_MEAS_NUM_X_POINTS; - if (iy & 1) ix = (MESH_MEAS_NUM_X_POINTS - 1) - ix; // Zig zag - float z0 = 0.f; - if (has_z && mesh_point > 0) { - 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(&z_offset_u) * 0.01; - #if 0 - SERIAL_ECHOPGM("Bed leveling, point: "); - MYSERIAL.print(mesh_point); - SERIAL_ECHOPGM(", calibration z: "); - MYSERIAL.print(z0, 5); - SERIAL_ECHOLNPGM(""); - #endif - } - - // Move Z up to MESH_HOME_Z_SEARCH. - current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; - 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(); + // Save custom message state, set a new custom message state to display: Calibrating point 9. + bool custom_message_old = custom_message; + unsigned int custom_message_type_old = custom_message_type; + unsigned int custom_message_state_old = custom_message_state; + custom_message = true; + custom_message_type = 1; + custom_message_state = (MESH_MEAS_NUM_X_POINTS * MESH_MEAS_NUM_Y_POINTS) + 10; + lcd_update(1); - // Move to XY position of the sensor point. - current_position[X_AXIS] = pgm_read_float(bed_ref_points+2*mesh_point); - current_position[Y_AXIS] = pgm_read_float(bed_ref_points+2*mesh_point+1); - world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); - 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(); - - // Go down until endstop is hit - const float Z_CALIBRATION_THRESHOLD = 1.f; - if (! find_bed_induction_sensor_point_z((has_z && mesh_point > 0) ? z0 - Z_CALIBRATION_THRESHOLD : -10.f)) { - kill_message = MSG_BED_LEVELING_FAILED_POINT_LOW; - break; - } - if (MESH_HOME_Z_SEARCH - current_position[Z_AXIS] < 0.1f) { - kill_message = MSG_BED_LEVELING_FAILED_PROBE_DISCONNECTED; - break; - } - if (has_z && fabs(z0 - current_position[Z_AXIS]) > Z_CALIBRATION_THRESHOLD) { - kill_message = MSG_BED_LEVELING_FAILED_POINT_HIGH; - break; - } + mbl.reset(); //reset mesh bed leveling - mbl.set_z(ix, iy, current_position[Z_AXIS]); + // Reset baby stepping to zero, if the babystepping has already been loaded before. The babystepsTodo value will be + // consumed during the first movements following this statement. + babystep_undo(); - custom_message_state--; - mesh_point++; - lcd_update(1); - } - current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; - 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(); - if (mesh_point != MESH_MEAS_NUM_X_POINTS * MESH_MEAS_NUM_Y_POINTS) { - kill(kill_message); - } - clean_up_after_endstop_move(); + // Cycle through all points and probe them + // First move up. During this first movement, the babystepping will be reverted. + current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS] / 60, active_extruder); + // The move to the first calibration point. + current_position[X_AXIS] = pgm_read_float(bed_ref_points); + current_position[Y_AXIS] = pgm_read_float(bed_ref_points + 1); + bool clamped = world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); + + if (verbosity_level >= 1) { + clamped ? SERIAL_PROTOCOLPGM("First calibration point clamped.\n") : SERIAL_PROTOCOLPGM("No clamping for first calibration point.\n"); + } + // 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); + // Wait until the move is finished. + st_synchronize(); + + int mesh_point = 0; //index number of calibration point + + int ix = 0; + int iy = 0; + + int XY_AXIS_FEEDRATE = homing_feedrate[X_AXIS] / 20; + int Z_PROBE_FEEDRATE = homing_feedrate[Z_AXIS] / 60; + 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) + 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"); + } + setup_for_endstop_move(false); //save feedrate and feedmultiply, sets feedmultiply to 100 + const char *kill_message = NULL; + 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. + ix = mesh_point % MESH_MEAS_NUM_X_POINTS; // from 0 to MESH_NUM_X_POINTS - 1 + iy = mesh_point / MESH_MEAS_NUM_X_POINTS; + if (iy & 1) ix = (MESH_MEAS_NUM_X_POINTS - 1) - ix; // Zig zag + float z0 = 0.f; + if (has_z && mesh_point > 0) { + 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(&z_offset_u) * 0.01; + //#if 0 + if (verbosity_level >= 1) { + SERIAL_ECHOPGM("Bed leveling, point: "); + MYSERIAL.print(mesh_point); + SERIAL_ECHOPGM(", calibration z: "); + MYSERIAL.print(z0, 5); + SERIAL_ECHOLNPGM(""); + } + //#endif + } + + // Move Z up to MESH_HOME_Z_SEARCH. + current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; + 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(); + + // Move to XY position of the sensor point. + current_position[X_AXIS] = pgm_read_float(bed_ref_points + 2 * mesh_point); + current_position[Y_AXIS] = pgm_read_float(bed_ref_points + 2 * mesh_point + 1); - temp_compensation_apply(); //apply PINDA temperature compensation - // Apply Z height correction aka baby stepping before mesh bed leveing gets activated. - babystep_apply(); + world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); + if (verbosity_level >= 1) { - bool eeprom_bed_correction_valid = eeprom_read_byte((unsigned char*)EEPROM_BED_CORRECTION_VALID) == 1; - for (uint8_t i = 0; i < 4; ++ i) { - unsigned char codes[4] = { 'L', 'R', 'F', 'B' }; - long correction = 0; - if (code_seen(codes[i])) - correction = code_value_long(); - else if (eeprom_bed_correction_valid) { - unsigned char *addr = (i < 2) ? - ((i == 0) ? (unsigned char*)EEPROM_BED_CORRECTION_LEFT : (unsigned char*)EEPROM_BED_CORRECTION_RIGHT) : - ((i == 2) ? (unsigned char*)EEPROM_BED_CORRECTION_FRONT : (unsigned char*)EEPROM_BED_CORRECTION_REAR); - correction = eeprom_read_int8(addr); - } - if (correction == 0) - continue; - float offset = float(correction) * 0.001f; - if (fabs(offset) > 0.101f) { - SERIAL_ERROR_START; - SERIAL_ECHOPGM("Excessive bed leveling correction: "); - SERIAL_ECHO(offset); - SERIAL_ECHOLNPGM(" microns"); - } else { - switch (i) { - case 0: - for (uint8_t row = 0; row < 3; ++ row) { - mbl.z_values[row][1] += 0.5f * offset; - mbl.z_values[row][0] += offset; - } - break; - case 1: - for (uint8_t row = 0; row < 3; ++ row) { - mbl.z_values[row][1] += 0.5f * offset; - mbl.z_values[row][2] += offset; - } - break; - case 2: - for (uint8_t col = 0; col < 3; ++ col) { - mbl.z_values[1][col] += 0.5f * offset; - mbl.z_values[0][col] += offset; - } - break; - case 3: - for (uint8_t col = 0; col < 3; ++ col) { - mbl.z_values[1][col] += 0.5f * offset; - mbl.z_values[2][col] += offset; - } - break; - } - } - } + SERIAL_PROTOCOL(mesh_point); + clamped ? SERIAL_PROTOCOLPGM(": xy clamped.\n") : SERIAL_PROTOCOLPGM(": no xy clamping\n"); + } - mbl.upsample_3x3(); - mbl.active = 1; - go_home_with_z_lift(); - // Restore custom message state - custom_message = custom_message_old; - custom_message_type = custom_message_type_old; - custom_message_state = custom_message_state_old; - lcd_update(1); - } - break; + 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(); + + // Go down until endstop is hit + const float Z_CALIBRATION_THRESHOLD = 1.f; + if (!find_bed_induction_sensor_point_z((has_z && mesh_point > 0) ? z0 - Z_CALIBRATION_THRESHOLD : -10.f)) { //if we have data from z calibration max allowed difference is 1mm for each point, if we dont have data max difference is 10mm from initial point + kill_message = MSG_BED_LEVELING_FAILED_POINT_LOW; + break; + } + if (MESH_HOME_Z_SEARCH - current_position[Z_AXIS] < 0.1f) { + kill_message = MSG_BED_LEVELING_FAILED_PROBE_DISCONNECTED; + break; + } + if (has_z && fabs(z0 - current_position[Z_AXIS]) > Z_CALIBRATION_THRESHOLD) { //if we have data from z calibration, max. allowed difference is 1mm for each point + kill_message = MSG_BED_LEVELING_FAILED_POINT_HIGH; + break; + } + + if (verbosity_level >= 10) { + SERIAL_ECHOPGM("X: "); + MYSERIAL.print(current_position[X_AXIS], 5); + SERIAL_ECHOLNPGM(""); + SERIAL_ECHOPGM("Y: "); + MYSERIAL.print(current_position[Y_AXIS], 5); + SERIAL_PROTOCOLPGM("\n"); + } + + if (verbosity_level >= 1) { + SERIAL_ECHOPGM("mesh bed leveling: "); + MYSERIAL.print(current_position[Z_AXIS], 5); + SERIAL_ECHOLNPGM(""); + } + mbl.set_z(ix, iy, current_position[Z_AXIS]); //store measured z values z_values[iy][ix] = z; + + custom_message_state--; + mesh_point++; + lcd_update(1); + } + if (verbosity_level >= 20) SERIAL_ECHOLNPGM("Mesh bed leveling while loop finished."); + current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; + if (verbosity_level >= 20) { + SERIAL_ECHOLNPGM("MESH_HOME_Z_SEARCH: "); + MYSERIAL.print(current_position[Z_AXIS], 5); + } + 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(); + if (mesh_point != MESH_MEAS_NUM_X_POINTS * MESH_MEAS_NUM_Y_POINTS) { + kill(kill_message); + SERIAL_ECHOLNPGM("killed"); + } + clean_up_after_endstop_move(); + SERIAL_ECHOLNPGM("clean up finished "); + temp_compensation_apply(); //apply PINDA temperature compensation + babystep_apply(); // Apply Z height correction aka baby stepping before mesh bed leveing gets activated. + SERIAL_ECHOLNPGM("babystep applied"); + bool eeprom_bed_correction_valid = eeprom_read_byte((unsigned char*)EEPROM_BED_CORRECTION_VALID) == 1; + + if (verbosity_level >= 1) { + eeprom_bed_correction_valid ? SERIAL_PROTOCOLPGM("Bed correction data valid\n") : SERIAL_PROTOCOLPGM("Bed correction data not valid\n"); + } + + for (uint8_t i = 0; i < 4; ++i) { + unsigned char codes[4] = { 'L', 'R', 'F', 'B' }; + long correction = 0; + if (code_seen(codes[i])) + correction = code_value_long(); + else if (eeprom_bed_correction_valid) { + unsigned char *addr = (i < 2) ? + ((i == 0) ? (unsigned char*)EEPROM_BED_CORRECTION_LEFT : (unsigned char*)EEPROM_BED_CORRECTION_RIGHT) : + ((i == 2) ? (unsigned char*)EEPROM_BED_CORRECTION_FRONT : (unsigned char*)EEPROM_BED_CORRECTION_REAR); + correction = eeprom_read_int8(addr); + } + if (correction == 0) + continue; + float offset = float(correction) * 0.001f; + if (fabs(offset) > 0.101f) { + SERIAL_ERROR_START; + SERIAL_ECHOPGM("Excessive bed leveling correction: "); + SERIAL_ECHO(offset); + SERIAL_ECHOLNPGM(" microns"); + } + else { + switch (i) { + case 0: + for (uint8_t row = 0; row < 3; ++row) { + mbl.z_values[row][1] += 0.5f * offset; + mbl.z_values[row][0] += offset; + } + break; + case 1: + for (uint8_t row = 0; row < 3; ++row) { + mbl.z_values[row][1] += 0.5f * offset; + mbl.z_values[row][2] += offset; + } + break; + case 2: + for (uint8_t col = 0; col < 3; ++col) { + mbl.z_values[1][col] += 0.5f * offset; + mbl.z_values[0][col] += offset; + } + break; + case 3: + for (uint8_t col = 0; col < 3; ++col) { + mbl.z_values[1][col] += 0.5f * offset; + mbl.z_values[2][col] += offset; + } + break; + } + } + } + SERIAL_ECHOLNPGM("Bed leveling correction finished"); + mbl.upsample_3x3(); //bilinear interpolation from 3x3 to 7x7 points while using the same array z_values[iy][ix] for storing (just coppying measured data to new destination and interpolating between them) + SERIAL_ECHOLNPGM("Upsample finished"); + mbl.active = 1; //activate mesh bed leveling + SERIAL_ECHOLNPGM("Mesh bed leveling activated"); + go_home_with_z_lift(); + SERIAL_ECHOLNPGM("Go home finished"); + // Restore custom message state + custom_message = custom_message_old; + custom_message_type = custom_message_type_old; + custom_message_state = custom_message_state_old; + lcd_update(1); + } + break; /** * G81: Print mesh bed leveling status and bed profile if activated @@ -6166,14 +6236,14 @@ void temp_compensation_apply() { int z_shift = 0; float z_shift_mm; - if (target_temperature_bed % 10 == 0 && target_temperature_bed >= 60 && target_temperature_bed <= 100) { + if (target_temperature_bed % 10 == 0 && target_temperature_bed >= 50 && target_temperature_bed <= 100) { i_add = (target_temperature_bed - 60) / 10; EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + i_add * 2, &z_shift); z_shift_mm = z_shift / axis_steps_per_unit[Z_AXIS]; } else { //interpolation - //z_shift_mm = temp_comp_interpolation(target_temperature_bed) / axis_steps_per_unit[Z_AXIS]; + z_shift_mm = temp_comp_interpolation(target_temperature_bed) / axis_steps_per_unit[Z_AXIS]; } SERIAL_PROTOCOLPGM("\n"); SERIAL_PROTOCOLPGM("Z shift applied:"); @@ -6183,6 +6253,12 @@ void temp_compensation_apply() { plan_set_z_position(current_position[Z_AXIS]); } +/*float temp_comp_interpolation(float temperature) { + +}*/ + + + float temp_comp_interpolation(float temperature) { //cubic spline interpolation @@ -6196,19 +6272,24 @@ float temp_comp_interpolation(float temperature) { int n, j, k; float h[10], a, b, c, d, sum, s[10] = { 0 }, x[10], F[10], f[10], p, m[10][10] = { 0 }, temp; - - for (i = 0; i < 6; i++) { + /*SERIAL_ECHOLNPGM("Reading shift data:"); + MYSERIAL.print(shift[i]);*/ + for (i = 0; i < 5; i++) { EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &shift[i + 1]); //read shift in steps from EEPROM + + //SERIAL_ECHOLNPGM(" "); + //MYSERIAL.print(shift[i + 1]); temp_C[i] = 50 + i * 10; //temperature in C shift_f[i] = (float)shift[i]; } + for (i = 5; i > 0; i--) { F[i] = (shift_f[i] - shift_f[i - 1]) / (temp_C[i] - temp_C[i - 1]); h[i - 1] = temp_C[i] - temp_C[i - 1]; } - //*********** formation of h, s , f matrix **************// + //*********** formation of h, s , f matrix ************* for (i = 1; i<5; i++) { m[i][i] = 2 * (h[i - 1] + h[i]); if (i != 1) { @@ -6217,13 +6298,13 @@ float temp_comp_interpolation(float temperature) { } m[i][5] = 6 * (F[i + 1] - F[i]); } - //*********** forward elimination **************// + //*********** forward elimination ************** for (i = 1; i<4; i++) { temp = (m[i + 1][i] / m[i][i]); for (j = 1; j <= 5; j++) m[i + 1][j] -= temp*m[i][j]; } - //*********** backward substitution *********// + //*********** backward substitution ********* for (i = 4; i>0; i--) { sum = 0; for (j = i; j <= 4; j++) From 7b4c79b4d04d29af4cd3293f86151c50249dc6cb Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Mon, 6 Mar 2017 11:19:21 +0100 Subject: [PATCH 04/11] Storing status for pinda probe calibration --- Firmware/Configuration.h | 19 ++-- Firmware/Marlin_main.cpp | 144 +++++++++++++----------------- Firmware/language_all.cpp | 10 +++ Firmware/language_all.h | 4 + Firmware/language_en.h | 3 + Firmware/mesh_bed_calibration.cpp | 2 +- Firmware/ultralcd.cpp | 7 ++ Firmware/ultralcd.h | 2 + 8 files changed, 99 insertions(+), 92 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index a0870ec60..4ff6d959d 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -700,17 +700,20 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of // (unsigned char*)EEPROM_CALIBRATION_STATUS enum CalibrationStatus { - // Freshly assembled, needs to peform a self-test and the XYZ calibration. - CALIBRATION_STATUS_ASSEMBLED = 255, + // Freshly assembled, needs to peform a self-test and the XYZ calibration. + CALIBRATION_STATUS_ASSEMBLED = 255, - // For the wizard: self test has been performed, now the XYZ calibration is needed. - // CALIBRATION_STATUS_XYZ_CALIBRATION = 250, + // For the wizard: self test has been performed, now the XYZ calibration is needed. + // CALIBRATION_STATUS_XYZ_CALIBRATION = 250, - // For the wizard: factory assembled, needs to run Z calibration. - CALIBRATION_STATUS_Z_CALIBRATION = 240, + // For the wizard: factory assembled, needs to run Z calibration. + CALIBRATION_STATUS_Z_CALIBRATION = 240, - // The XYZ calibration has been performed, now it remains to run the V2Calibration.gcode. - CALIBRATION_STATUS_LIVE_ADJUST = 230, + // The XYZ calibration has been performed, now it remains to run the V2Calibration.gcode. + CALIBRATION_STATUS_LIVE_ADJUST = 230, + + //V2 calibration has been run, now run PINDA probe temperature calibration + CALIBRATION_STATUS_PINDA = 220, // Calibrated, ready to print. CALIBRATION_STATUS_CALIBRATED = 1, diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index b606a0697..c85d6683d 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1162,6 +1162,9 @@ void setup() // Show the message. lcd_show_fullscreen_message_and_wait_P(MSG_BABYSTEP_Z_NOT_SET); lcd_update_enable(true); + } else if (calibration_status() == CALIBRATION_STATUS_PINDA) { + lcd_show_fullscreen_message_and_wait_P(MSG_PINDA_NOT_CALIBRATED); + lcd_update_enable(true); } else if (calibration_status() == CALIBRATION_STATUS_Z_CALIBRATION) { // Show the message. lcd_show_fullscreen_message_and_wait_P(MSG_FOLLOW_CALIBRATION_FLOW); @@ -2760,26 +2763,7 @@ void process_commands() * */ - case 73: - { - int i, read; - for (i = 0; i < 5; i++) { - EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &read); - MYSERIAL.print(read); - SERIAL_ECHOLNPGM(" "); - } - }break; - - case 74: - { - float result, temp; - if (code_seen('X')) temp = code_value(); - result = temp_comp_interpolation(temp); - MYSERIAL.print(result); - - }break; - - case 76: //PINDA probe temperature compensation + case 76: //PINDA probe temperature calibration { setTargetBed(PINDA_MIN_T); float zero_z; @@ -2854,17 +2838,12 @@ void process_commands() } + calibration_status_store(CALIBRATION_STATUS_CALIBRATED); setTargetBed(0); //set bed target temperature back to 0 } break; - case 75: - { - temp_compensation_start(); - } - break; - #ifdef DIS case 77: { @@ -2914,6 +2893,7 @@ void process_commands() enquecommand_front_P((PSTR("G28 W0"))); break; } + temp_compensation_start(); // Save custom message state, set a new custom message state to display: Calibrating point 9. bool custom_message_old = custom_message; @@ -3220,7 +3200,7 @@ void process_commands() * This G-code will be performed at the end of a calibration script. */ case 87: - calibration_status_store(CALIBRATION_STATUS_CALIBRATED); + calibration_status_store(CALIBRATION_STATUS_PINDA); break; /** @@ -6215,6 +6195,7 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ card.closefile(); } +#endif void temp_compensation_start() { current_position[X_AXIS] = PINDA_PREHEAT_X; @@ -6236,92 +6217,89 @@ void temp_compensation_apply() { int z_shift = 0; float z_shift_mm; - if (target_temperature_bed % 10 == 0 && target_temperature_bed >= 50 && target_temperature_bed <= 100) { - i_add = (target_temperature_bed - 60) / 10; - EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + i_add * 2, &z_shift); - z_shift_mm = z_shift / axis_steps_per_unit[Z_AXIS]; + if (calibration_status() == CALIBRATION_STATUS_CALIBRATED) { + if (target_temperature_bed % 10 == 0 && target_temperature_bed >= 50 && target_temperature_bed <= 100) { + i_add = (target_temperature_bed - 60) / 10; + EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + i_add * 2, &z_shift); + z_shift_mm = z_shift / axis_steps_per_unit[Z_AXIS]; + } + else { + //interpolation + z_shift_mm = temp_comp_interpolation(target_temperature_bed) / axis_steps_per_unit[Z_AXIS]; + } + SERIAL_PROTOCOLPGM("\n"); + SERIAL_PROTOCOLPGM("Z shift applied:"); + MYSERIAL.print(z_shift_mm); + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] - z_shift_mm, current_position[E_AXIS], homing_feedrate[Z_AXIS] / 40, active_extruder); + st_synchronize(); + plan_set_z_position(current_position[Z_AXIS]); } else { - //interpolation - z_shift_mm = temp_comp_interpolation(target_temperature_bed) / axis_steps_per_unit[Z_AXIS]; + //message that we have no temp compensation data } - SERIAL_PROTOCOLPGM("\n"); - SERIAL_PROTOCOLPGM("Z shift applied:"); - MYSERIAL.print(z_shift_mm); - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] - z_shift_mm, current_position[E_AXIS], homing_feedrate[Z_AXIS] / 40, active_extruder); - st_synchronize(); - plan_set_z_position(current_position[Z_AXIS]); } -/*float temp_comp_interpolation(float temperature) { - -}*/ +float temp_comp_interpolation(float inp_temperature) { - - -float temp_comp_interpolation(float temperature) { //cubic spline interpolation - - int i; - int shift[6]; - float shift_f[6]; - float temp_C[6]; - - shift[0] = 0; //shift for 50 C is 0 - int n, j, k; + int n, i, j, k; float h[10], a, b, c, d, sum, s[10] = { 0 }, x[10], F[10], f[10], p, m[10][10] = { 0 }, temp; + int shift[10]; + int temp_C[10]; - /*SERIAL_ECHOLNPGM("Reading shift data:"); - MYSERIAL.print(shift[i]);*/ - for (i = 0; i < 5; i++) { - EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &shift[i + 1]); //read shift in steps from EEPROM + p = inp_temperature; + n = 6; //number of measured points - //SERIAL_ECHOLNPGM(" "); - //MYSERIAL.print(shift[i + 1]); + shift[0] = 0; + for (i = 0; i < n; i++) { + //scanf_s("%f%f", &x[i], &f[i]); + if (i>0) EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + (i-1) * 2, &shift[i]); //read shift in steps from EEPROM temp_C[i] = 50 + i * 10; //temperature in C - shift_f[i] = (float)shift[i]; - + + x[i] = (float)temp_C[i]; + f[i] = (float)shift[i]; } - for (i = 5; i > 0; i--) { - F[i] = (shift_f[i] - shift_f[i - 1]) / (temp_C[i] - temp_C[i - 1]); - h[i - 1] = temp_C[i] - temp_C[i - 1]; - } - //*********** formation of h, s , f matrix ************* - for (i = 1; i<5; i++) { + + for (i = n - 1; i>0; i--) { + F[i] = (f[i] - f[i - 1]) / (x[i] - x[i - 1]); + h[i - 1] = x[i] - x[i - 1]; + } + //*********** formation of h, s , f matrix ************** + for (i = 1; i0; i--) { + for (i = n - 2; i>0; i--) { sum = 0; - for (j = i; j <= 4; j++) + for (j = i; j <= n - 2; j++) sum += m[i][j] * s[j]; s[i] = (m[i][n - 1] - sum) / m[i][i]; } - for (i = 0; i<5; i++) - if (temp_C[i] <= temperature&&temperature <= temp_C[i + 1]) { - a = (s[i + 1] - s[i]) / (6 * h[i]); - b = s[i] / 2; - c = (shift[i + 1] - shift[i]) / h[i] - (2 * h[i] * s[i] + s[i + 1] * h[i]) / 6; - d = shift[i]; - sum = a*pow((p - temp_C[i]), 3) + b*pow((p - temp_C[i]), 2) + c*(p - temp_C[i]) + d; - } - return(sum); + for (i = 0; i Date: Mon, 6 Mar 2017 12:14:08 +0100 Subject: [PATCH 05/11] G80 - pinda heating and autohome added --- Firmware/Marlin_main.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index c85d6683d..8a944aa77 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2879,6 +2879,8 @@ void process_commands() case_G80: { int8_t verbosity_level = 0; + static bool run = false; + if (code_seen('V')) { // Just 'V' without a number counts as V1. char c = strchr_pointer[1]; @@ -2893,7 +2895,15 @@ void process_commands() enquecommand_front_P((PSTR("G28 W0"))); break; } - temp_compensation_start(); + + if (run == false) { + temp_compensation_start(); + run = true; + repeatcommand_front(); // repeat G80 with all its parameters + enquecommand_front_P((PSTR("G28 W0"))); + break; + } + run = false; // Save custom message state, set a new custom message state to display: Calibrating point 9. bool custom_message_old = custom_message; From 4eb45fadedc70913f850605390a1411b60492698 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Mon, 6 Mar 2017 16:24:23 +0100 Subject: [PATCH 06/11] changed version, pinda probe calibration menu --- Firmware/Configuration.h | 2 +- Firmware/ultralcd.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 4ff6d959d..7d99543dc 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -5,7 +5,7 @@ #include "Configuration_prusa.h" // Firmware version -#define FW_version "3.0.11" +#define FW_version "3.0.11-alpha" #define FW_PRUSA3D_MAGIC "PRUSA3DFW" #define FW_PRUSA3D_MAGIC_LEN 10 diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index c4839100d..16f4813fe 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2230,7 +2230,7 @@ void lcd_mesh_calibration_z() void lcd_pinda_calibration() { - enquecommand_P(PSTR("M76")); + enquecommand_P(PSTR("G76")); lcd_return_to_status(); } From af962b74733991cdf9582cbc1be16b70eedc4735 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 15 Mar 2017 15:56:42 +0100 Subject: [PATCH 07/11] none --- Firmware/ConfigurationStore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/ConfigurationStore.cpp b/Firmware/ConfigurationStore.cpp index 7c900bd45..c67e35359 100644 --- a/Firmware/ConfigurationStore.cpp +++ b/Firmware/ConfigurationStore.cpp @@ -119,7 +119,7 @@ void Config_StoreSettings() EEPROM_WRITE_VAR(i, filament_size[2]); #endif #endif - + /*MYSERIAL.print("Top address used:\n"); MYSERIAL.print(i); MYSERIAL.print("\n"); From abadaa5885979c8627edaf283ac5d33b0e756168 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 6 Apr 2017 13:14:30 +0200 Subject: [PATCH 08/11] added retraction to preheat, no waiting when running mesh bed leveling from calibration menu --- Firmware/Marlin_main.cpp | 14 ++++++++++---- Firmware/language_all.cpp | 5 +++++ Firmware/language_all.h | 2 ++ Firmware/language_en.h | 1 + Firmware/language_it.h | 3 ++- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 8a944aa77..d10450c7f 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2894,9 +2894,9 @@ void process_commands() repeatcommand_front(); // repeat G80 with all its parameters enquecommand_front_P((PSTR("G28 W0"))); break; - } + } - if (run == false) { + if (run == false && card.sdprinting == true) { temp_compensation_start(); run = true; repeatcommand_front(); // repeat G80 with all its parameters @@ -3108,6 +3108,11 @@ void process_commands() SERIAL_ECHOLNPGM("Mesh bed leveling activated"); go_home_with_z_lift(); SERIAL_ECHOLNPGM("Go home finished"); + //unretract (after PINDA preheat retraction) + if (card.sdprinting == true && degHotend(active_extruder) > EXTRUDE_MINTEMP) { + current_position[E_AXIS] += DEFAULT_RETRACTION; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400, active_extruder); + } // Restore custom message state custom_message = custom_message_old; custom_message_type = custom_message_type_old; @@ -6208,6 +6213,9 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ #endif void temp_compensation_start() { + if (degHotend(active_extruder)>EXTRUDE_MINTEMP) current_position[E_AXIS] -= DEFAULT_RETRACTION; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400, active_extruder); + current_position[X_AXIS] = PINDA_PREHEAT_X; current_position[Y_AXIS] = PINDA_PREHEAT_Y; current_position[Z_AXIS] = 0; @@ -6217,8 +6225,6 @@ void temp_compensation_start() { while (fabs(degBed() - target_temperature_bed) > 3) delay_keep_alive(1000); for(int i = 0; i < PINDA_HEAT_T; i++) delay_keep_alive(1000); - - } void temp_compensation_apply() { diff --git a/Firmware/language_all.cpp b/Firmware/language_all.cpp index 8adb002c0..eddaa8ef2 100644 --- a/Firmware/language_all.cpp +++ b/Firmware/language_all.cpp @@ -1741,6 +1741,11 @@ const char * const MSG_PINDA_NOT_CALIBRATED_LANG_TABLE[1] PROGMEM = { MSG_PINDA_NOT_CALIBRATED_EN }; +const char MSG_PINDA_PREHEAT_EN[] PROGMEM = "Preheating"; +const char * const MSG_PINDA_PREHEAT_LANG_TABLE[1] PROGMEM = { + MSG_PINDA_PREHEAT_EN +}; + const char MSG_PLANNER_BUFFER_BYTES_EN[] PROGMEM = " PlannerBufferBytes: "; const char * const MSG_PLANNER_BUFFER_BYTES_LANG_TABLE[1] PROGMEM = { MSG_PLANNER_BUFFER_BYTES_EN diff --git a/Firmware/language_all.h b/Firmware/language_all.h index 1386a7602..a49d098e1 100644 --- a/Firmware/language_all.h +++ b/Firmware/language_all.h @@ -347,6 +347,8 @@ extern const char* const MSG_PICK_Z_LANG_TABLE[LANG_NUM]; #define MSG_PICK_Z LANG_TABLE_SELECT(MSG_PICK_Z_LANG_TABLE) extern const char* const MSG_PINDA_NOT_CALIBRATED_LANG_TABLE[1]; #define MSG_PINDA_NOT_CALIBRATED LANG_TABLE_SELECT_EXPLICIT(MSG_PINDA_NOT_CALIBRATED_LANG_TABLE, 0) +extern const char* const MSG_PINDA_PREHEAT_LANG_TABLE[1]; +#define MSG_PINDA_PREHEAT LANG_TABLE_SELECT_EXPLICIT(MSG_PINDA_PREHEAT_LANG_TABLE, 0) extern const char* const MSG_PLANNER_BUFFER_BYTES_LANG_TABLE[1]; #define MSG_PLANNER_BUFFER_BYTES LANG_TABLE_SELECT_EXPLICIT(MSG_PLANNER_BUFFER_BYTES_LANG_TABLE, 0) extern const char* const MSG_PLEASE_WAIT_LANG_TABLE[LANG_NUM]; diff --git a/Firmware/language_en.h b/Firmware/language_en.h index be262e261..3793f8b70 100644 --- a/Firmware/language_en.h +++ b/Firmware/language_en.h @@ -268,3 +268,4 @@ #define MSG_CALIBRATE_PINDA "Calibrate PINDA" #define MSG_PINDA_NOT_CALIBRATED "PINDA probe has not been calibrated" +#define MSG_PINDA_PREHEAT "Preheating" \ No newline at end of file diff --git a/Firmware/language_it.h b/Firmware/language_it.h index dc9e2a3a2..fcb40120d 100644 --- a/Firmware/language_it.h +++ b/Firmware/language_it.h @@ -248,4 +248,5 @@ #define MSG_WAITING_TEMP "In attesa del raffreddamento della testina e del piatto" #define MSG_FILAMENT_CLEAN "Il colore e' nitido?" #define MSG_UNLOADING_FILAMENT "Rilasc. filamento" -#define MSG_PAPER "Porre un foglio sotto l'ugello durante la calibrazione dei primi 4 punti. In caso l'ugello muova il foglio spegnere prontamente la stampante." \ No newline at end of file +#define MSG_PAPER "Porre un foglio sotto l'ugello durante la calibrazione dei primi 4 punti. In caso l'ugello muova il foglio spegnere prontamente la stampante." + From 08a59f7fef61faea8bf3a00ea1bdda10ad69eead Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 6 Apr 2017 18:57:11 +0200 Subject: [PATCH 09/11] status messages for temp calibration added, initial versoin of temp calibration on/off from menu --- Firmware/Marlin.h | 1 + Firmware/Marlin_main.cpp | 52 +++++++++++++------ Firmware/language_all.cpp | 29 ++++++++++- Firmware/language_all.h | 10 ++++ Firmware/language_en.h | 11 ++-- Firmware/ultralcd.cpp | 24 ++++++++- Firmware/ultralcd.h | 4 +- .../ultralcd_implementation_hitachi_HD44780.h | 16 ++++++ 8 files changed, 122 insertions(+), 25 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index c9a20ac8d..82e40a9ee 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -284,6 +284,7 @@ extern unsigned long starttime; extern unsigned long stoptime; extern bool is_usb_printing; extern bool homing_flag; +extern bool temp_cal_active; extern bool loading_flag; extern unsigned int usb_printing_counter; diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index d10450c7f..4abe0ba17 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -250,6 +250,8 @@ int extruder_multiply[EXTRUDERS] = {100 bool is_usb_printing = false; bool homing_flag = false; +bool temp_cal_active = false; + unsigned long kicktime = millis()+100000; unsigned int usb_printing_counter; @@ -2750,18 +2752,6 @@ void process_commands() } break; - /** - * G80: Mesh-based Z probe, probes a grid and produces a - * mesh to compensate for variable bed height - * - * The S0 report the points as below - * - * +----> X-axis - * | - * | - * v Y-axis - * - */ case 76: //PINDA probe temperature calibration { @@ -2777,7 +2767,11 @@ void process_commands() repeatcommand_front(); // repeat G76 with all its parameters enquecommand_front_P((PSTR("G28 W0"))); break; - } + } + custom_message = true; + custom_message_type = 4; + custom_message_state = 1; + custom_message = MSG_TEMP_CALIBRATION; current_position[X_AXIS] = PINDA_PREHEAT_X; current_position[Y_AXIS] = PINDA_PREHEAT_Y; current_position[Z_AXIS] = 0; @@ -2807,7 +2801,7 @@ void process_commands() SERIAL_ECHOLNPGM(""); for (int i = 0; i<5; i++) { - + custom_message_state = i + 2; t_c = 60 + i * 10; setTargetBed(t_c); @@ -2838,7 +2832,14 @@ void process_commands() } + custom_message_type = 0; + custom_message = false; + calibration_status_store(CALIBRATION_STATUS_CALIBRATED); + lcd_show_fullscreen_message_and_wait_P(MSG_TEMP_CALIBRATION_DONE); + lcd_update_enable(true); + lcd_update(2); + setTargetBed(0); //set bed target temperature back to 0 } @@ -2874,6 +2875,18 @@ void process_commands() #endif + /** + * G80: Mesh-based Z probe, probes a grid and produces a + * mesh to compensate for variable bed height + * + * The S0 report the points as below + * + * +----> X-axis + * | + * | + * v Y-axis + * + */ case 80: case_G80: @@ -2896,7 +2909,7 @@ void process_commands() break; } - if (run == false && card.sdprinting == true) { + if (run == false && card.sdprinting == true && temp_cal_active == true) { temp_compensation_start(); run = true; repeatcommand_front(); // repeat G80 with all its parameters @@ -3043,7 +3056,7 @@ void process_commands() } clean_up_after_endstop_move(); SERIAL_ECHOLNPGM("clean up finished "); - temp_compensation_apply(); //apply PINDA temperature compensation + if(temp_cal_active == true) temp_compensation_apply(); //apply PINDA temperature compensation babystep_apply(); // Apply Z height correction aka baby stepping before mesh bed leveing gets activated. SERIAL_ECHOLNPGM("babystep applied"); bool eeprom_bed_correction_valid = eeprom_read_byte((unsigned char*)EEPROM_BED_CORRECTION_VALID) == 1; @@ -3109,7 +3122,7 @@ void process_commands() go_home_with_z_lift(); SERIAL_ECHOLNPGM("Go home finished"); //unretract (after PINDA preheat retraction) - if (card.sdprinting == true && degHotend(active_extruder) > EXTRUDE_MINTEMP) { + if (card.sdprinting == true && degHotend(active_extruder) > EXTRUDE_MINTEMP && temp_cal_active == true) { current_position[E_AXIS] += DEFAULT_RETRACTION; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400, active_extruder); } @@ -6213,6 +6226,8 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ #endif void temp_compensation_start() { + custom_message = true; + custom_message_type = 5; if (degHotend(active_extruder)>EXTRUDE_MINTEMP) current_position[E_AXIS] -= DEFAULT_RETRACTION; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400, active_extruder); @@ -6225,6 +6240,9 @@ void temp_compensation_start() { while (fabs(degBed() - target_temperature_bed) > 3) delay_keep_alive(1000); for(int i = 0; i < PINDA_HEAT_T; i++) delay_keep_alive(1000); + + custom_message_type = 0; + custom_message = false; } void temp_compensation_apply() { diff --git a/Firmware/language_all.cpp b/Firmware/language_all.cpp index eddaa8ef2..a9a79a78d 100644 --- a/Firmware/language_all.cpp +++ b/Firmware/language_all.cpp @@ -494,11 +494,16 @@ const char * const MSG_CALIBRATE_E_LANG_TABLE[LANG_NUM] PROGMEM = { MSG_CALIBRATE_E_DE }; -const char MSG_CALIBRATE_PINDA_EN[] PROGMEM = "Calibrate PINDA"; +const char MSG_CALIBRATE_PINDA_EN[] PROGMEM = "Temp. calibration"; const char * const MSG_CALIBRATE_PINDA_LANG_TABLE[1] PROGMEM = { MSG_CALIBRATE_PINDA_EN }; +const char MSG_CALIBRATION_PINDA_MENU_EN[] PROGMEM = "Temp. calibration"; +const char * const MSG_CALIBRATION_PINDA_MENU_LANG_TABLE[1] PROGMEM = { + MSG_CALIBRATION_PINDA_MENU_EN +}; + const char MSG_CARD_MENU_EN[] PROGMEM = "Print from SD"; const char MSG_CARD_MENU_CZ[] PROGMEM = "Tisk z SD"; const char MSG_CARD_MENU_IT[] PROGMEM = "Stampa da SD"; @@ -1736,7 +1741,7 @@ const char * const MSG_PICK_Z_LANG_TABLE[LANG_NUM] PROGMEM = { MSG_PICK_Z_DE }; -const char MSG_PINDA_NOT_CALIBRATED_EN[] PROGMEM = "PINDA probe has not been calibrated"; +const char MSG_PINDA_NOT_CALIBRATED_EN[] PROGMEM = "Temperature calibration has not been run yet"; const char * const MSG_PINDA_NOT_CALIBRATED_LANG_TABLE[1] PROGMEM = { MSG_PINDA_NOT_CALIBRATED_EN }; @@ -2693,6 +2698,26 @@ const char * const MSG_TEMPERATURE_LANG_TABLE[LANG_NUM] PROGMEM = { MSG_TEMPERATURE_DE }; +const char MSG_TEMP_CALIBRATION_EN[] PROGMEM = "Temp. calibration "; +const char * const MSG_TEMP_CALIBRATION_LANG_TABLE[1] PROGMEM = { + MSG_TEMP_CALIBRATION_EN +}; + +const char MSG_TEMP_CALIBRATION_DONE_EN[] PROGMEM = "Temperature calibration is finished. Click to continue."; +const char * const MSG_TEMP_CALIBRATION_DONE_LANG_TABLE[1] PROGMEM = { + MSG_TEMP_CALIBRATION_DONE_EN +}; + +const char MSG_TEMP_CALIBRATION_OFF_EN[] PROGMEM = "Temp. cal. [OFF]"; +const char * const MSG_TEMP_CALIBRATION_OFF_LANG_TABLE[1] PROGMEM = { + MSG_TEMP_CALIBRATION_OFF_EN +}; + +const char MSG_TEMP_CALIBRATION_ON_EN[] PROGMEM = "Temp. cal. [ON]"; +const char * const MSG_TEMP_CALIBRATION_ON_LANG_TABLE[1] PROGMEM = { + MSG_TEMP_CALIBRATION_ON_EN +}; + const char MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_EN[] PROGMEM = "SD card [normal]"; const char MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_PL[] PROGMEM = "karta SD [normal]"; const char * const MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_LANG_TABLE[LANG_NUM] PROGMEM = { diff --git a/Firmware/language_all.h b/Firmware/language_all.h index a49d098e1..49211d762 100644 --- a/Firmware/language_all.h +++ b/Firmware/language_all.h @@ -109,6 +109,8 @@ extern const char* const MSG_CALIBRATE_E_LANG_TABLE[LANG_NUM]; #define MSG_CALIBRATE_E LANG_TABLE_SELECT(MSG_CALIBRATE_E_LANG_TABLE) extern const char* const MSG_CALIBRATE_PINDA_LANG_TABLE[1]; #define MSG_CALIBRATE_PINDA LANG_TABLE_SELECT_EXPLICIT(MSG_CALIBRATE_PINDA_LANG_TABLE, 0) +extern const char* const MSG_CALIBRATION_PINDA_MENU_LANG_TABLE[1]; +#define MSG_CALIBRATION_PINDA_MENU LANG_TABLE_SELECT_EXPLICIT(MSG_CALIBRATION_PINDA_MENU_LANG_TABLE, 0) extern const char* const MSG_CARD_MENU_LANG_TABLE[LANG_NUM]; #define MSG_CARD_MENU LANG_TABLE_SELECT(MSG_CARD_MENU_LANG_TABLE) extern const char* const MSG_CHANGE_EXTR_LANG_TABLE[LANG_NUM]; @@ -521,6 +523,14 @@ extern const char* const MSG_TAKE_EFFECT_LANG_TABLE[LANG_NUM]; #define MSG_TAKE_EFFECT LANG_TABLE_SELECT(MSG_TAKE_EFFECT_LANG_TABLE) extern const char* const MSG_TEMPERATURE_LANG_TABLE[LANG_NUM]; #define MSG_TEMPERATURE LANG_TABLE_SELECT(MSG_TEMPERATURE_LANG_TABLE) +extern const char* const MSG_TEMP_CALIBRATION_LANG_TABLE[1]; +#define MSG_TEMP_CALIBRATION LANG_TABLE_SELECT_EXPLICIT(MSG_TEMP_CALIBRATION_LANG_TABLE, 0) +extern const char* const MSG_TEMP_CALIBRATION_DONE_LANG_TABLE[1]; +#define MSG_TEMP_CALIBRATION_DONE LANG_TABLE_SELECT_EXPLICIT(MSG_TEMP_CALIBRATION_DONE_LANG_TABLE, 0) +extern const char* const MSG_TEMP_CALIBRATION_OFF_LANG_TABLE[1]; +#define MSG_TEMP_CALIBRATION_OFF LANG_TABLE_SELECT_EXPLICIT(MSG_TEMP_CALIBRATION_OFF_LANG_TABLE, 0) +extern const char* const MSG_TEMP_CALIBRATION_ON_LANG_TABLE[1]; +#define MSG_TEMP_CALIBRATION_ON LANG_TABLE_SELECT_EXPLICIT(MSG_TEMP_CALIBRATION_ON_LANG_TABLE, 0) extern const char* const MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_LANG_TABLE[LANG_NUM]; #define MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF LANG_TABLE_SELECT(MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_LANG_TABLE) extern const char* const MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_ON_LANG_TABLE[LANG_NUM]; diff --git a/Firmware/language_en.h b/Firmware/language_en.h index 3793f8b70..920ea7860 100644 --- a/Firmware/language_en.h +++ b/Firmware/language_en.h @@ -266,6 +266,11 @@ #define MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF "SD card [normal]" #define MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_ON "SD card [FlshAir]" -#define MSG_CALIBRATE_PINDA "Calibrate PINDA" -#define MSG_PINDA_NOT_CALIBRATED "PINDA probe has not been calibrated" -#define MSG_PINDA_PREHEAT "Preheating" \ No newline at end of file +#define MSG_CALIBRATE_PINDA "Temp. calibration" +#define MSG_CALIBRATION_PINDA_MENU "Temp. calibration" +#define MSG_PINDA_NOT_CALIBRATED "Temperature calibration has not been run yet" +#define MSG_PINDA_PREHEAT "Preheating" +#define MSG_TEMP_CALIBRATION "Temp. calibration " +#define MSG_TEMP_CALIBRATION_DONE "Temperature calibration is finished. Click to continue." +#define MSG_TEMP_CALIBRATION_ON "Temp. cal. [ON]" +#define MSG_TEMP_CALIBRATION_OFF "Temp. cal. [OFF]" \ No newline at end of file diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 16f4813fe..593e82c2a 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2228,8 +2228,28 @@ void lcd_mesh_calibration_z() lcd_return_to_status(); } -void lcd_pinda_calibration() +void lcd_pinda_calibration_menu() { + START_MENU(); + MENU_ITEM(back, MSG_MENU_CALIBRATION, lcd_calibration_menu); + MENU_ITEM(submenu, MSG_CALIBRATE_PINDA, lcd_calibrate_pinda); + //MENU_ITEM(back, MSG_SETTINGS, lcd_settings_menu); + if (temp_cal_active == false) { + MENU_ITEM(function, MSG_TEMP_CALIBRATION_OFF, lcd_temp_calibration_set); + } + else { + MENU_ITEM(function, MSG_TEMP_CALIBRATION_ON, lcd_temp_calibration_set); + } + END_MENU(); +} + +void lcd_temp_calibration_set() { + temp_cal_active = !temp_cal_active; + digipot_init(); + lcd_goto_menu(lcd_pinda_calibration_menu, 2); +} + +void lcd_calibrate_pinda() { enquecommand_P(PSTR("G76")); lcd_return_to_status(); } @@ -2396,7 +2416,7 @@ static void lcd_calibration_menu() MENU_ITEM(function, MSG_CALIBRATE_BED, lcd_mesh_calibration); // "Calibrate Z" with storing the reference values to EEPROM. MENU_ITEM(submenu, MSG_HOMEYZ, lcd_mesh_calibration_z); - MENU_ITEM(submenu, MSG_CALIBRATE_PINDA, lcd_pinda_calibration); + MENU_ITEM(submenu, MSG_CALIBRATION_PINDA_MENU, lcd_pinda_calibration_menu); #ifndef SNMM //MENU_ITEM(function, MSG_CALIBRATE_E, lcd_calibrate_extruder); #endif diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 658767cd8..1e234946b 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -232,5 +232,7 @@ union MenuData; char reset_menu(); -void lcd_pinda_calibration(); +void lcd_pinda_calibration_menu(); +void lcd_calibrate_pinda(); +void lcd_temp_calibration_set(); #endif //ULTRALCD_H \ No newline at end of file diff --git a/Firmware/ultralcd_implementation_hitachi_HD44780.h b/Firmware/ultralcd_implementation_hitachi_HD44780.h index 66bfc9e9e..e34f08cb5 100644 --- a/Firmware/ultralcd_implementation_hitachi_HD44780.h +++ b/Firmware/ultralcd_implementation_hitachi_HD44780.h @@ -944,6 +944,22 @@ static void lcd_implementation_status_screen() { lcd.print(lcd_status_message); } + // PINDA temp calibration in progress + if (custom_message_type == 4) { + char progress[4]; + lcd.setCursor(0, 3); + lcd_printPGM(MSG_TEMP_CALIBRATION); + lcd.setCursor(17, 3); + sprintf(progress, "%d/6", custom_message_state); + lcd.print(progress); + } + // temp compensation preheat + if (custom_message_type == 5) { + lcd.setCursor(0, 3); + lcd_printPGM(MSG_PINDA_PREHEAT); + } + + } else { From ccdf5e9c41cff79cb7106e24880df12aa0f67398 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 6 Apr 2017 19:44:03 +0200 Subject: [PATCH 10/11] Message that temp calibration has not been run yet is displayed only if temp. calibration is activated --- Firmware/Marlin_main.cpp | 8 ++++---- Firmware/mesh_bed_calibration.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 4abe0ba17..bbca8105e 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1164,7 +1164,7 @@ void setup() // Show the message. lcd_show_fullscreen_message_and_wait_P(MSG_BABYSTEP_Z_NOT_SET); lcd_update_enable(true); - } else if (calibration_status() == CALIBRATION_STATUS_PINDA) { + } else if (calibration_status() == CALIBRATION_STATUS_PINDA && temp_cal_active == true) { lcd_show_fullscreen_message_and_wait_P(MSG_PINDA_NOT_CALIBRATED); lcd_update_enable(true); } else if (calibration_status() == CALIBRATION_STATUS_Z_CALIBRATION) { @@ -3228,7 +3228,7 @@ void process_commands() * This G-code will be performed at the end of a calibration script. */ case 87: - calibration_status_store(CALIBRATION_STATUS_PINDA); + calibration_status_store(CALIBRATION_STATUS_PINDA); break; /** @@ -6268,8 +6268,8 @@ void temp_compensation_apply() { st_synchronize(); plan_set_z_position(current_position[Z_AXIS]); } - else { - //message that we have no temp compensation data + else { + //message that we have no temp compensation data ? } } diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 4113fd499..021922865 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -2155,7 +2155,7 @@ void babystep_apply() { // Apply Z height correction aka baby stepping before mesh bed leveling gets activated. if(calibration_status() <= CALIBRATION_STATUS_PINDA) - { + { check_babystep(); //checking if babystep is in allowed range, otherwise setting babystep to 0 // End of G80: Apply the baby stepping value. From fab71ff7cf6066fdd7e5bf1efa54ca2957e7df15 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 6 Apr 2017 19:56:01 +0200 Subject: [PATCH 11/11] information that temp calibration active is active is stored to eeprom --- Firmware/Configuration.h | 1 + Firmware/Marlin_main.cpp | 3 ++- Firmware/ultralcd.cpp | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 7d99543dc..f7e216984 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -45,6 +45,7 @@ #define EEPROM_TOSHIBA_FLASH_AIR_COMPATIBLITY (EEPROM_BED_CORRECTION_REAR-1) #define EEPROM_PRINT_FLAG (EEPROM_TOSHIBA_FLASH_AIR_COMPATIBLITY-1) #define EEPROM_PROBE_TEMP_SHIFT (EEPROM_PRINT_FLAG - 2*5) //5 x int for storing pinda probe temp shift relative to 50 C; unit: motor steps +#define EEPROM_TEMP_CAL_ACTIVE (EEPROM_PROBE_TEMP_SHIFT - 1) // Currently running firmware, each digit stored as uint16_t. // The flavor differentiates a dev, alpha, beta, release candidate or a release version. diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index bbca8105e..ff76a8e5e 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1141,6 +1141,7 @@ void setup() // EEPROM_LANG to number lower than 0x0ff. // 1) Set a high power mode. eeprom_write_byte((uint8_t*)EEPROM_SILENT, 0); + eeprom_write_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE, 0); } // In the future, somewhere here would one compare the current firmware version against the firmware version stored in the EEPROM. @@ -1150,7 +1151,7 @@ void setup() if (lang_selected >= LANG_NUM){ lcd_mylang(); } - + temp_cal_active = eeprom_read_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE); check_babystep(); //checking if Z babystep is in allowed range if (calibration_status() == CALIBRATION_STATUS_ASSEMBLED || diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 593e82c2a..5f794d67e 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2245,6 +2245,7 @@ void lcd_pinda_calibration_menu() void lcd_temp_calibration_set() { temp_cal_active = !temp_cal_active; + eeprom_update_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE, temp_cal_active); digipot_init(); lcd_goto_menu(lcd_pinda_calibration_menu, 2); }