Merge pull request #63 from XPila/MK3

Maker Faire brainstorm 2.0 (2)
This commit is contained in:
XPila 2017-09-26 06:12:33 +02:00 committed by GitHub
commit 7b3060eb59
3 changed files with 48 additions and 7 deletions

View File

@ -140,8 +140,8 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define TMC2130_TPWMTHRS 0 // TPWMTHRS - Sets the switching speed threshold based on TSTEP from stealthChop to spreadCycle mode #define TMC2130_TPWMTHRS 0 // TPWMTHRS - Sets the switching speed threshold based on TSTEP from stealthChop to spreadCycle mode
#define TMC2130_THIGH 0 // THIGH - unused #define TMC2130_THIGH 0 // THIGH - unused
#define TMC2130_TCOOLTHRS_X 400 // TCOOLTHRS - coolstep treshold #define TMC2130_TCOOLTHRS_X 450 // TCOOLTHRS - coolstep treshold
#define TMC2130_TCOOLTHRS_Y 400 // TCOOLTHRS - coolstep treshold #define TMC2130_TCOOLTHRS_Y 450 // TCOOLTHRS - coolstep treshold
#define TMC2130_TCOOLTHRS_Z 500 // TCOOLTHRS - coolstep treshold #define TMC2130_TCOOLTHRS_Z 500 // TCOOLTHRS - coolstep treshold
#define TMC2130_TCOOLTHRS_E 500 // TCOOLTHRS - coolstep treshold #define TMC2130_TCOOLTHRS_E 500 // TCOOLTHRS - coolstep treshold
@ -494,6 +494,8 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
// At 400 microsteps per mm, a full step lifts the Z axis by 0.04mm, and a stepper driver cycle is 0.16mm. // At 400 microsteps per mm, a full step lifts the Z axis by 0.04mm, and a stepper driver cycle is 0.16mm.
// The following example, 12 * (4 * 16 / 400) = 12 * 0.16mm = 1.92mm. // The following example, 12 * (4 * 16 / 400) = 12 * 0.16mm = 1.92mm.
#define UVLO_Z_AXIS_SHIFT 1.92 #define UVLO_Z_AXIS_SHIFT 1.92
// If power panic occured, and the current temperature is higher then target temperature before interrupt minus this offset, print will be recovered automatically.
#define AUTOMATIC_UVLO_BED_TEMP_OFFSET 5
#define HEATBED_V2 #define HEATBED_V2

View File

@ -370,7 +370,6 @@ void wait_for_heater(long codenum);
void serialecho_temperatures(); void serialecho_temperatures();
void uvlo_(); void uvlo_();
void recover_print();
void recover_print(uint8_t automatic); void recover_print(uint8_t automatic);
void setup_uvlo_interrupt(); void setup_uvlo_interrupt();

View File

@ -1126,6 +1126,7 @@ void setup()
// so the next time the firmware gets updated, it will know from which version it has been updated. // so the next time the firmware gets updated, it will know from which version it has been updated.
update_current_firmware_version_to_eeprom(); update_current_firmware_version_to_eeprom();
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) == 1) { //previous print was terminated by UVLO if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) == 1) { //previous print was terminated by UVLO
/*
if (lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_RECOVER_PRINT, false)) recover_print(); if (lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_RECOVER_PRINT, false)) recover_print();
else { else {
eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0); eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0);
@ -1133,6 +1134,35 @@ void setup()
lcd_update(2); lcd_update(2);
lcd_setstatuspgm(WELCOME_MSG); lcd_setstatuspgm(WELCOME_MSG);
} }
*/
manage_heater(); // Update temperatures
#ifdef DEBUG_UVLO_AUTOMATIC_RECOVER
MYSERIAL.println("Power panic detected!");
MYSERIAL.print("Current bed temp:");
MYSERIAL.println(degBed());
MYSERIAL.print("Saved bed temp:");
MYSERIAL.println((float)eeprom_read_byte((uint8_t*)EEPROM_UVLO_TARGET_BED));
#endif
if ( degBed() > ( (float)eeprom_read_byte((uint8_t*)EEPROM_UVLO_TARGET_BED) - AUTOMATIC_UVLO_BED_TEMP_OFFSET) ){
#ifdef DEBUG_UVLO_AUTOMATIC_RECOVER
MYSERIAL.println("Automatic recovery!");
#endif
recover_print(1);
}
else{
#ifdef DEBUG_UVLO_AUTOMATIC_RECOVER
MYSERIAL.println("Normal recovery!");
#endif
if ( lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_RECOVER_PRINT, false) ) recover_print(0);
else {
eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0);
lcd_update_enable(true);
lcd_update(2);
lcd_setstatuspgm(WELCOME_MSG);
}
}
} }
} }
@ -7061,7 +7091,7 @@ ISR(INT4_vect) {
if (IS_SD_PRINTING) uvlo_(); if (IS_SD_PRINTING) uvlo_();
} }
void recover_print() { void recover_print(uint8_t automatic) {
char cmd[30]; char cmd[30];
lcd_update_enable(true); lcd_update_enable(true);
lcd_update(2); lcd_update(2);
@ -7069,18 +7099,28 @@ void recover_print() {
recover_machine_state_after_power_panic(); recover_machine_state_after_power_panic();
// Set the target bed and nozzle temperatures.
sprintf_P(cmd, PSTR("M104 S%d"), target_temperature[active_extruder]);
enquecommand(cmd);
sprintf_P(cmd, PSTR("M140 S%d"), target_temperature_bed);
enquecommand(cmd);
// Lift the print head, so one may remove the excess priming material. // Lift the print head, so one may remove the excess priming material.
if (current_position[Z_AXIS] < 25) if (current_position[Z_AXIS] < 25)
enquecommand_P(PSTR("G1 Z25 F800")); enquecommand_P(PSTR("G1 Z25 F800"));
// Home X and Y axes. Homing just X and Y shall not touch the babystep and the world2machine transformation status. // Home X and Y axes. Homing just X and Y shall not touch the babystep and the world2machine transformation status.
enquecommand_P(PSTR("G28 X Y")); enquecommand_P(PSTR("G28 X Y"));
// Set the target bed and nozzle temperatures. // Set the target bed and nozzle temperatures and wait.
sprintf_P(cmd, PSTR("M109 S%d"), target_temperature[active_extruder]); sprintf_P(cmd, PSTR("M109 S%d"), target_temperature[active_extruder]);
enquecommand(cmd); enquecommand(cmd);
sprintf_P(cmd, PSTR("M190 S%d"), target_temperature_bed); sprintf_P(cmd, PSTR("M190 S%d"), target_temperature_bed);
enquecommand(cmd); enquecommand(cmd);
enquecommand_P(PSTR("M83")); //E axis relative mode enquecommand_P(PSTR("M83")); //E axis relative mode
//enquecommand_P(PSTR("G1 E5 F120")); //Extrude some filament to stabilize pessure
// If not automatically recoreverd (long power loss), extrude extra filament to stabilize
if(automatic == 0){
enquecommand_P(PSTR("G1 E5 F120")); //Extrude some filament to stabilize pessure enquecommand_P(PSTR("G1 E5 F120")); //Extrude some filament to stabilize pessure
}
enquecommand_P(PSTR("G1 E" STRINGIFY(-DEFAULT_RETRACTION)" F480")); enquecommand_P(PSTR("G1 E" STRINGIFY(-DEFAULT_RETRACTION)" F480"));
// Mark the power panic status as inactive. // Mark the power panic status as inactive.
eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0); eeprom_update_byte((uint8_t*)EEPROM_UVLO, 0);
@ -7378,7 +7418,7 @@ void restore_print_from_ram_and_continue(float e_move)
feedrate = saved_feedrate2; //restore feedrate feedrate = saved_feedrate2; //restore feedrate
float e = saved_pos[E_AXIS] - e_move; float e = saved_pos[E_AXIS] - e_move;
plan_set_e_position(e); plan_set_e_position(e);
plan_buffer_line(saved_pos[X_AXIS], saved_pos[Y_AXIS], saved_pos[Z_AXIS], saved_pos[E_AXIS], homing_feedrate[Z_AXIS]/10, active_extruder); plan_buffer_line(saved_pos[X_AXIS], saved_pos[Y_AXIS], saved_pos[Z_AXIS], saved_pos[E_AXIS], homing_feedrate[Z_AXIS]/13, active_extruder);
st_synchronize(); st_synchronize();
memcpy(current_position, saved_pos, sizeof(saved_pos)); memcpy(current_position, saved_pos, sizeof(saved_pos));
memcpy(destination, current_position, sizeof(destination)); memcpy(destination, current_position, sizeof(destination));