From ff6fa09ecf188272761f8d4a08df9749a70c1d7e Mon Sep 17 00:00:00 2001 From: Erik van der Zalm Date: Sun, 9 Jun 2013 13:10:06 +0200 Subject: [PATCH] Moved corexy implementation from stepper to planner (Thanks iquizzle) --- Marlin/Configuration.h | 5 ++ Marlin/planner.cpp | 32 +++++++++-- Marlin/stepper.cpp | 119 ++++++++++------------------------------- 3 files changed, 62 insertions(+), 94 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 2daeef4d80..d507832292 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -238,6 +238,11 @@ const bool Y_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. //#define DISABLE_MAX_ENDSTOPS +// Disable max endstops for compatibility with endstop checking routine +#if defined(COREXY) && !defined(DISABLE_MAX_ENDSTOPS) + #define DISABLE_MAX_ENDSTOPS +#endif + // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1 #define X_ENABLE_ON 0 #define Y_ENABLE_ON 0 diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index 24a20b1cd3..8eff191751 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -564,8 +564,16 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa block->busy = false; // Number of steps for each axis - block->steps_x = labs(target[X_AXIS]-position[X_AXIS]); - block->steps_y = labs(target[Y_AXIS]-position[Y_AXIS]); +#ifndef COREXY +// default non-h-bot planning +block->steps_x = labs(target[X_AXIS]-position[X_AXIS]); +block->steps_y = labs(target[Y_AXIS]-position[Y_AXIS]); +#else +// corexy planning +// these equations follow the form of the dA and dB equations on http://www.corexy.com/theory.html +block->steps_x = labs((target[X_AXIS]-position[X_AXIS]) + (target[Y_AXIS]-position[Y_AXIS])); +block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS])); +#endif block->steps_z = labs(target[Z_AXIS]-position[Z_AXIS]); block->steps_e = labs(target[E_AXIS]-position[E_AXIS]); block->steps_e *= extrudemultiply; @@ -586,6 +594,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa // Compute direction bits for this block block->direction_bits = 0; +#ifndef COREXY if (target[X_AXIS] < position[X_AXIS]) { block->direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<steps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments ) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 6a012b54b6..3d88b38383 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -345,12 +345,31 @@ ISR(TIMER1_COMPA_vect) // Set directions TO DO This should be done once during init of trapezoid. Endstops -> interrupt out_bits = current_block->direction_bits; - // Set direction en check limit switches - if ((out_bits & (1< -1 @@ -365,11 +384,6 @@ ISR(TIMER1_COMPA_vect) } } else { // +direction - #if !defined COREXY //NOT COREXY - WRITE(X_DIR_PIN,!INVERT_X_DIR); - #endif - - count_direction[X_AXIS]=1; CHECK_ENDSTOPS { #if defined(X_MAX_PIN) && X_MAX_PIN > -1 @@ -384,11 +398,11 @@ ISR(TIMER1_COMPA_vect) } } + #ifndef COREXY if ((out_bits & (1< -1 @@ -403,10 +417,6 @@ ISR(TIMER1_COMPA_vect) } } else { // +direction - #if !defined COREXY //NOT COREXY - WRITE(Y_DIR_PIN,!INVERT_Y_DIR); - #endif - count_direction[Y_AXIS]=1; CHECK_ENDSTOPS { #if defined(Y_MAX_PIN) && Y_MAX_PIN > -1 @@ -420,28 +430,7 @@ ISR(TIMER1_COMPA_vect) #endif } } - - - #ifdef COREXY //coreXY kinematics defined - if((current_block->steps_x >= current_block->steps_y)&&((out_bits & (1<steps_x >= current_block->steps_y)&&((out_bits & (1<steps_y > current_block->steps_x)&&((out_bits & (1<steps_y > current_block->steps_x)&&((out_bits & (1<steps_x; if (counter_x > 0) { WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); @@ -532,56 +520,7 @@ ISR(TIMER1_COMPA_vect) count_position[Y_AXIS]+=count_direction[Y_AXIS]; WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); } - #endif - #ifdef COREXY - counter_x += current_block->steps_x; - counter_y += current_block->steps_y; - - if ((counter_x > 0)&&!(counter_y>0)){ //X step only - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); - counter_x -= current_block->step_event_count; - count_position[X_AXIS]+=count_direction[X_AXIS]; - WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); - WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); - } - - if (!(counter_x > 0)&&(counter_y>0)){ //Y step only - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); - counter_y -= current_block->step_event_count; - count_position[Y_AXIS]+=count_direction[Y_AXIS]; - WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); - WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); - } - - if ((counter_x > 0)&&(counter_y>0)){ //step in both axes - if (((out_bits & (1<step_event_count; - WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); - step_wait(); - count_position[X_AXIS]+=count_direction[X_AXIS]; - count_position[Y_AXIS]+=count_direction[Y_AXIS]; - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); - counter_y -= current_block->step_event_count; - WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); - } - else{ //X and Y in same direction - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); - counter_x -= current_block->step_event_count; - WRITE(X_STEP_PIN, INVERT_X_STEP_PIN) ; - step_wait(); - count_position[X_AXIS]+=count_direction[X_AXIS]; - count_position[Y_AXIS]+=count_direction[Y_AXIS]; - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); - counter_y -= current_block->step_event_count; - WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); - } - } - #endif //corexy - counter_z += current_block->steps_z; if (counter_z > 0) { WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN);