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

Added an option HOMING_SET_ORIGIN_AFTER_PULLOFF #1226

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
9 changes: 9 additions & 0 deletions grbl/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@
// define to force Grbl to always set the machine origin at the homed location despite switch orientation.
// #define HOMING_FORCE_SET_ORIGIN // Uncomment to enable.

// By default, Grbl sets the machine origin to zero at the exact point where the homing switches first
// make contact, then moves away from the switch by the homing pulloff distance given in setting 27.
// Even with soft limits enabled, this does not prevent the operator subsequently jogging right up to
// the machine origin and possibly triggering the limit switch. This option instead sets the machine
// origin to zero after it has performed the pulloff move, so that soft limits won't allow the machine
// to be jogged any closer to the limit switch than the pulloff distance.
// Note: this setting is ignored if HOMING_FORCE_SET_ORIGIN is enabled.
// #define HOMING_SET_ORIGIN_AFTER_PULLOFF

// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may
// be stored and executed in order. These startup blocks would typically be used to set the g-code
Expand Down
11 changes: 11 additions & 0 deletions grbl/limits.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,24 @@ void limits_go_home(uint8_t cycle_mask)
if (cycle_mask & bit(idx)) {
#ifdef HOMING_FORCE_SET_ORIGIN
set_axis_position = 0;
#else
#ifdef HOMING_SET_ORIGIN_AFTER_PULLOFF
if ( bit_istrue(settings.homing_dir_mask,bit(idx)) ) {
// Round up (i.e. away from the limit) to avoid a situation where a later
// rounding error sometimes causes the axis position after homing to be a tiny
// amount past max_travel, which immediately triggers its soft limit.
set_axis_position = lround(ceil(settings.max_travel[idx]*settings.steps_per_mm[idx]));
} else {
set_axis_position = 0;
}
#else
if ( bit_istrue(settings.homing_dir_mask,bit(idx)) ) {
set_axis_position = lround((settings.max_travel[idx]+settings.homing_pulloff)*settings.steps_per_mm[idx]);
} else {
set_axis_position = lround(-settings.homing_pulloff*settings.steps_per_mm[idx]);
}
#endif
#endif

#ifdef COREXY
if (idx==X_AXIS) {
Expand Down