From 59a4d2ef06bc5ce09f6d38735f4638b1a63642e7 Mon Sep 17 00:00:00 2001 From: chamnit Date: Mon, 25 Jul 2016 13:50:08 -0600 Subject: [PATCH] CoreXY homing bug fix attempt 2. --- grbl/config.h | 4 ++-- grbl/limits.c | 7 +++---- grbl/planner.c | 4 ++-- grbl/system.c | 3 +-- grbl/system.h | 1 + 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/grbl/config.h b/grbl/config.h index d524796..f01935b 100644 --- a/grbl/config.h +++ b/grbl/config.h @@ -72,8 +72,8 @@ // on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits // will not be affected by pin sharing. // NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y. -#define HOMING_CYCLE_0 (1<step_event_count = max(block->step_event_count, block->steps[idx]); if (idx == A_MOTOR) { - delta_mm = ((target_steps[X_AXIS]-pl.position[X_AXIS]) + (target_steps[Y_AXIS]-pl.position[Y_AXIS]))/settings.steps_per_mm[idx]; + delta_mm = (target_steps[X_AXIS]-pl.position[X_AXIS] + target_steps[Y_AXIS]-pl.position[Y_AXIS])/settings.steps_per_mm[idx]; } else if (idx == B_MOTOR) { - delta_mm = ((target_steps[X_AXIS]-pl.position[X_AXIS]) - (target_steps[Y_AXIS]-pl.position[Y_AXIS]))/settings.steps_per_mm[idx]; + delta_mm = (target_steps[X_AXIS]-pl.position[X_AXIS] - target_steps[Y_AXIS]+pl.position[Y_AXIS])/settings.steps_per_mm[idx]; } else { delta_mm = (target_steps[idx] - pl.position[idx])/settings.steps_per_mm[idx]; } diff --git a/grbl/system.c b/grbl/system.c index ff678f7..f16b8e8 100644 --- a/grbl/system.c +++ b/grbl/system.c @@ -288,12 +288,11 @@ void system_convert_array_steps_to_mpos(float *position, int32_t *steps) } +// CoreXY calculation only. Returns x or y-axis "steps" based on CoreXY motor steps. int32_t system_convert_corexy_to_x_axis_steps(int32_t *steps) { return( (steps[A_MOTOR] + steps[B_MOTOR])/2 ); } - - int32_t system_convert_corexy_to_y_axis_steps(int32_t *steps) { return( (steps[A_MOTOR] - steps[B_MOTOR])/2 ); diff --git a/grbl/system.h b/grbl/system.h index 6774d54..09a3171 100644 --- a/grbl/system.h +++ b/grbl/system.h @@ -106,6 +106,7 @@ float system_convert_axis_steps_to_mpos(int32_t *steps, uint8_t idx); // Updates a machine 'position' array based on the 'step' array sent. void system_convert_array_steps_to_mpos(float *position, int32_t *steps); +// CoreXY calculation only. Returns x or y-axis "steps" based on CoreXY motor steps. int32_t system_convert_corexy_to_x_axis_steps(int32_t *steps); int32_t system_convert_corexy_to_y_axis_steps(int32_t *steps);