diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 614b2552c..0392acaac 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -273,12 +273,21 @@ // Babystepping enables the user to control the axis in tiny amounts, independently from the normal printing process // it can e.g. be used to change z-positions in the print startup phase in realtime // does not respect endstops! - //#define BABYSTEPPING -//#define BABYSTEP_XY //not only z, but also XY - -#ifdef COREXY +#ifdef BABYSTEPPING + #define BABYSTEP_XY //not only z, but also XY in the menu. more clutter, more functions + #define BABYSTEP_INVERT_Z false //true for inverse movements in Z + #define BABYSTEP_Z_MULTIPLICATOR 2 //faster z movements + + #ifdef COREXY #error BABYSTEPPING not implemented for COREXY yet. + #endif + + #ifdef DELTA + #ifdef BABYSTEP_XY + #error BABYSTEPPING only implemented for Z axis on deltabots. + #endif + #endif #endif // extruder advance constant (s2/mm3) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 1dc3902b3..4f11ae9e3 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -1069,15 +1069,17 @@ void babystep(const uint8_t axis,const bool direction) #endif } - break; + break; + +#ifndef DELTA case Z_AXIS: { enable_z(); uint8_t old_z_dir_pin= READ(Z_DIR_PIN); //if dualzstepper, both point to same direction. //setup new step - WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction); + WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); #ifdef Z_DUAL_STEPPER_DRIVERS - WRITE(Z2_DIR_PIN,(INVERT_Z_DIR)^direction); + WRITE(Z2_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); #endif //perform step WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); @@ -1101,6 +1103,41 @@ void babystep(const uint8_t axis,const bool direction) } break; +#else //DELTA + case Z_AXIS: + { + enable_x(); + enable_y(); + enable_z(); + uint8_t old_x_dir_pin= READ(X_DIR_PIN); + uint8_t old_y_dir_pin= READ(Y_DIR_PIN); + uint8_t old_z_dir_pin= READ(Z_DIR_PIN); + //setup new step + WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction^BABYSTEP_INVERT_Z); + WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction^BABYSTEP_INVERT_Z); + WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); + + //perform step + WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); + WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + + //wait a tiny bit + { + float x=1./float(axis+1); //absolutely useless + } + WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); + WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); + WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); + + //get old pin state back. + WRITE(X_DIR_PIN,old_x_dir_pin); + WRITE(Y_DIR_PIN,old_y_dir_pin); + WRITE(Z_DIR_PIN,old_z_dir_pin); + + } + break; +#endif default: break; } diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 0a0df8f9e..0e8c8697d 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -367,7 +367,7 @@ static void lcd_babystep_z() { if (encoderPosition != 0) { - babystepsTodo[Z_AXIS]+=(int)encoderPosition; + babystepsTodo[Z_AXIS]+=BABYSTEP_Z_MULTIPLICATOR*(int)encoderPosition; encoderPosition=0; lcdDrawUpdate = 1; }