Restore the last E axis position correctly after powerpanic
- Initially restore the last E position from the eeprom in any case, not just when using absolute mode (although unnecessary: since it will be reset later), fixing a possible unitialized position and crash during recovery (thanks to @leptun) - Remove useless extra calls to put the extruder in relative mode: the extruder already starts in relative mode and is later switched to absolute. - Replace incorrect calls to STRINGIFY with sprintf_P - Retract after pressure has been restored in uvlo_tiny, to be consistent with a regular uvlo (remove the bogus double unretract as a result). - Set the real E position prior to the panic *after* the retraction, using the now-fixed G92.
This commit is contained in:
parent
4c8f1e8b89
commit
7f3d4a8491
1 changed files with 21 additions and 20 deletions
|
@ -10778,12 +10778,15 @@ void recover_print(uint8_t automatic) {
|
|||
enquecommand(cmd);
|
||||
|
||||
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 E" STRINGIFY(-default_retraction)" F480"));
|
||||
|
||||
// If not automatically recoreverd (long power loss)
|
||||
if(automatic == 0){
|
||||
//Extrude some filament to stabilize the pressure
|
||||
enquecommand_P(PSTR("G1 E5 F120"));
|
||||
// Retract to be consistent with a short pause
|
||||
sprintf_P(cmd, PSTR("G1 E%-0.3f F2700"), default_retraction);
|
||||
enquecommand(cmd);
|
||||
}
|
||||
|
||||
printf_P(_N("After waiting for temp:\nCurrent pos X_AXIS:%.3f\nCurrent pos Y_AXIS:%.3f\n"), current_position[X_AXIS], current_position[Y_AXIS]);
|
||||
|
||||
|
@ -10794,7 +10797,6 @@ void recover_print(uint8_t automatic) {
|
|||
|
||||
void recover_machine_state_after_power_panic(bool bTiny)
|
||||
{
|
||||
char cmd[30];
|
||||
// 1) Recover the logical cordinates at the time of the power panic.
|
||||
// The logical XY coordinates are needed to recover the machine Z coordinate corrected by the mesh bed leveling.
|
||||
current_position[X_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0));
|
||||
|
@ -10829,12 +10831,9 @@ void recover_machine_state_after_power_panic(bool bTiny)
|
|||
UVLO_Z_AXIS_SHIFT + float((1024 - eeprom_read_word((uint16_t*)(EEPROM_UVLO_Z_MICROSTEPS))
|
||||
+ 7) >> 4) / cs.axis_steps_per_unit[Z_AXIS];
|
||||
}
|
||||
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_E_ABS)) {
|
||||
current_position[E_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_E));
|
||||
sprintf_P(cmd, PSTR("G92 E"));
|
||||
dtostrf(current_position[E_AXIS], 6, 3, cmd + strlen(cmd));
|
||||
enquecommand(cmd);
|
||||
}
|
||||
|
||||
// Recover last E axis position
|
||||
current_position[E_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_E));
|
||||
|
||||
memcpy(destination, current_position, sizeof(destination));
|
||||
|
||||
|
@ -10929,8 +10928,6 @@ void restore_print_from_eeprom() {
|
|||
uint32_t position = eeprom_read_dword((uint32_t*)(EEPROM_FILE_POSITION));
|
||||
SERIAL_ECHOPGM("Position read from eeprom:");
|
||||
MYSERIAL.println(position);
|
||||
// E axis relative mode.
|
||||
enquecommand_P(PSTR("M83"));
|
||||
// Move to the XY print position in logical coordinates, where the print has been killed.
|
||||
strcpy_P(cmd, PSTR("G1 X")); strcat(cmd, ftostr32(eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0))));
|
||||
strcat_P(cmd, PSTR(" Y")); strcat(cmd, ftostr32(eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4))));
|
||||
|
@ -10942,16 +10939,20 @@ void restore_print_from_eeprom() {
|
|||
strcpy_P(cmd, PSTR("G1 Z")); strcat(cmd, ftostr32(eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z))));
|
||||
enquecommand(cmd);
|
||||
// Unretract.
|
||||
enquecommand_P(PSTR("G1 E" STRINGIFY(2*default_retraction)" F480"));
|
||||
sprintf_P(cmd, PSTR("G1 E%0.3f F2700"), default_retraction);
|
||||
enquecommand(cmd);
|
||||
// Recover final E axis position and mode
|
||||
float pos_e = eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_E));
|
||||
sprintf_P(cmd, PSTR("G92 E"));
|
||||
dtostrf(pos_e, 6, 3, cmd + strlen(cmd));
|
||||
enquecommand(cmd);
|
||||
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_E_ABS))
|
||||
enquecommand_P(PSTR("M82")); //E axis abslute mode
|
||||
// Set the feedrates saved at the power panic.
|
||||
sprintf_P(cmd, PSTR("G1 F%d"), feedrate_rec);
|
||||
enquecommand(cmd);
|
||||
sprintf_P(cmd, PSTR("M220 S%d"), feedmultiply_rec);
|
||||
enquecommand(cmd);
|
||||
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_E_ABS))
|
||||
{
|
||||
enquecommand_P(PSTR("M82")); //E axis abslute mode
|
||||
}
|
||||
// Set the fan speed saved at the power panic.
|
||||
strcpy_P(cmd, PSTR("M106 S"));
|
||||
strcat(cmd, itostr3(int(fan_speed_rec)));
|
||||
|
|
Loading…
Add table
Reference in a new issue