From 3da20db02404f3654631bf99d8c4d8aea0e8c709 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 27 Jan 2020 18:50:17 +0100 Subject: [PATCH] Really poweroff Z motors when PSU_Delta is defined enable/disable_z behave differently when PSU_Delta is defined. During powerpanic and kill however we do *really* need to save energy and poweroff the motors. Rename enable/disable_z as poweron/poweroff_z and define some aliases so that we can use the low-level function where needed. --- Firmware/Marlin.h | 35 +++++++++++++++++------------------ Firmware/Marlin_main.cpp | 8 ++++---- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 58b3351d..a0b3c19b 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -146,40 +146,39 @@ void manage_inactivity(bool ignore_stepper_queue=false); #if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1 #if defined(Z_AXIS_ALWAYS_ON) #ifdef Z_DUAL_STEPPER_DRIVERS - #define enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); } - #define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; } + #define poweron_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); } + #define poweroff_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; } #else - #define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON) - #define disable_z() {} + #define poweron_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON) + #define poweroff_z() {} #endif #else #ifdef Z_DUAL_STEPPER_DRIVERS - #define enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); } - #define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; } + #define poweron_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); } + #define poweroff_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; } #else - #define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON) - #define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; } + #define poweron_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON) + #define poweroff_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; } #endif #endif #else - #define enable_z() {} - #define disable_z() {} + #define poweron_z() {} + #define poweroff_z() {} #endif -#ifdef PSU_Delta +#ifndef PSU_Delta + #define enable_z() poweron_z() + #define disable_z() poweroff_z() +#else void init_force_z(); void check_force_z(); - #undef disable_z - #define disable_z() disable_force_z() - void disable_force_z(); - #undef enable_z - #define enable_z() enable_force_z() void enable_force_z(); + void disable_force_z(); + #define enable_z() enable_force_z() + #define disable_z() disable_force_z() #endif // PSU_Delta - - //#if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1 //#ifdef Z_DUAL_STEPPER_DRIVERS //#define enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); } diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index a204f9f0..c80199a2 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -9595,7 +9595,7 @@ void kill(const char *full_screen_message, unsigned char id) disable_x(); // SERIAL_ECHOLNPGM("kill - disable Y"); disable_y(); - disable_z(); + poweroff_z(); disable_e0(); disable_e1(); disable_e2(); @@ -10579,7 +10579,7 @@ void uvlo_() + UVLO_Z_AXIS_SHIFT; plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS]/60, active_extruder); st_synchronize(); - disable_z(); + poweroff_z(); // Write the file position. eeprom_update_dword((uint32_t*)(EEPROM_FILE_POSITION), sd_position); @@ -10638,7 +10638,7 @@ void uvlo_() WRITE(BEEPER,HIGH); // All is set: with all the juice left, try to move extruder away to detach the nozzle completely from the print - enable_z(); + poweron_z(); current_position[X_AXIS] = (current_position[X_AXIS] < 0.5f * (X_MIN_POS + X_MAX_POS)) ? X_MIN_POS : X_MAX_POS; plan_buffer_line_curposXYZE(500, active_extruder); st_synchronize(); @@ -10693,7 +10693,7 @@ void uvlo_tiny() + UVLO_TINY_Z_AXIS_SHIFT; plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS]/60, active_extruder); st_synchronize(); - disable_z(); + poweroff_z(); // Update Z position eeprom_update_float((float*)(EEPROM_UVLO_TINY_CURRENT_POSITION_Z), current_position[Z_AXIS]);