Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix to homing #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up. This forces
// the user to perform the homing cycle (or override the locks) before doing anything else. This is
// mainly a safety feature to remind the user to home, since position is unknown to Grbl.
#define HOMING_INIT_LOCK // Comment to disable
//#define HOMING_INIT_LOCK // Comment to disable

// Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode
// to quickly engage the limit switches, followed by a slower locate mode, and finished by a short
Expand All @@ -74,7 +74,8 @@
// 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<<Z_AXIS) // REQUIRED: First move Z to clear workspace.
//#define HOMING_CYCLE_1 ((1<<X_AXIS)|(1<<Y_AXIS)) // OPTIONAL: Then move X,Y at the same time.
#define HOMING_CYCLE_0 ((1<<X_AXIS)|(1<<Y_AXIS))
#define HOMING_CYCLE_0 ((1<<X_AXIS))
#define HOMING_CYCLE_1 ((1<<Y_AXIS))
// #define HOMING_CYCLE_2 // OPTIONAL: Uncomment and add axes mask to enable

// Number of homing cycles performed after when the machine initially jogs to limit switches.
Expand Down Expand Up @@ -150,7 +151,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.
Expand Down
21 changes: 19 additions & 2 deletions limits.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ void limits_go_home(uint8_t cycle_mask)
}
}

#ifdef COREXY
sys.position[A_MOTOR] = 0;
sys.position[B_MOTOR] = 0;
plan_sync_position();
#endif

// Set search mode with approach at seek rate to quickly engage the specified cycle_mask limit switches.
bool approach = true;
float homing_rate = settings.homing_seek_rate;
Expand All @@ -181,7 +187,12 @@ 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;
#ifndef COREXY
sys.position[idx] = 0;
#else
sys.position[A_MOTOR] = 0;
sys.position[B_MOTOR] = 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))) {
Expand Down Expand Up @@ -216,7 +227,13 @@ void limits_go_home(uint8_t cycle_mask)
limit_state = limits_get_state();
for (idx=0; idx<N_AXIS; idx++) {
if (axislock & step_pin[idx]) {
if (limit_state & (1 << idx)) { axislock &= ~(step_pin[idx]); }
if (limit_state & (1 << idx)) {
#ifndef COREXY
axislock &= ~(step_pin[idx]);
#else
axislock &= ~(step_pin[A_MOTOR]|step_pin[B_MOTOR]);
#endif
}
}
}
sys.homing_axis_lock = axislock;
Expand Down