From 725165787224e386c05f80a66a73d212a65712d2 Mon Sep 17 00:00:00 2001 From: chamnit Date: Mon, 25 Jul 2016 11:11:27 -0600 Subject: [PATCH] CoreXY homing fix attempt. --- grbl/config.h | 2 +- grbl/limits.c | 40 +++++++++++++++++++++++++++++----------- grbl/planner.c | 8 ++++---- grbl/system.c | 23 ++++++++++++++++++----- grbl/system.h | 3 +++ 5 files changed, 55 insertions(+), 21 deletions(-) diff --git a/grbl/config.h b/grbl/config.h index bd9c0d6..d524796 100644 --- a/grbl/config.h +++ b/grbl/config.h @@ -149,7 +149,7 @@ // defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as // described, if not, motions may move in strange directions. Grbl assumes the CoreXY A and B motors // have the same steps per mm internally. -// #define COREXY // Default disabled. Uncomment to enable. +#define COREXY // Default disabled. Uncomment to enable. // Inverts pin logic of the control command pins. This essentially means when this option is enabled // you can use normally-closed switches, rather than the default normally-open switches. diff --git a/grbl/limits.c b/grbl/limits.c index 6cd1cd9..947a6ed 100644 --- a/grbl/limits.c +++ b/grbl/limits.c @@ -184,7 +184,21 @@ void limits_go_home(uint8_t cycle_mask) // Set target location for active axes and setup computation for homing rate. if (bit_istrue(cycle_mask,bit(idx))) { n_active_axis++; - sys.position[idx] = 0; + #ifdef COREXY + int32_t axis_position; + if (idx == X_AXIS) { + axis_position = system_convert_corexy_to_x_axis_steps(sys.position); + sys.position[A_MOTOR] = axis_position; + sys.position[B_MOTOR] = -axis_position; + } else if (idx == Y_AXIS) { + axis_position = system_convert_corexy_to_y_axis_steps(sys.position); + sys.position[A_MOTOR] = sys.position[B_MOTOR] = axis_position; + } else { + sys.position[Z_AXIS] = 0; + } + #else + sys.position[idx] = 0; + #endif // Set target direction based on cycle mask and homing cycle approach state. // NOTE: This happens to compile smaller than any other implementation tried. if (bit_istrue(settings.homing_dir_mask,bit(idx))) { @@ -219,7 +233,14 @@ void limits_go_home(uint8_t cycle_mask) limit_state = limits_get_state(); for (idx=0; idx