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

Add Setting for Axis Limitpos #606

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
4 changes: 2 additions & 2 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ specific needs, i.e. performance tuning or adjusting to non-typical machines.
If more than 3 axes are configured a compliant driver and board map file is needed.
*/
#ifndef N_AXIS
#define N_AXIS 3 // Number of axes
#define N_AXIS 4 // Number of axes
#endif

/*! \def AXIS_REMAP_ABC2UVW
Expand Down Expand Up @@ -498,7 +498,7 @@ by a driver or a plugin.
#endif

#if !defined ENABLE_BACKLASH_COMPENSATION || defined __DOXYGEN__
#define ENABLE_BACKLASH_COMPENSATION Off
#define ENABLE_BACKLASH_COMPENSATION On
#endif

#if COMPATIBILITY_LEVEL == 0 || defined __DOXYGEN__
Expand Down
15 changes: 10 additions & 5 deletions machine_limits.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@ void limits_set_work_envelope (void)
sys.work_envelope.max.values[idx] = - (settings.axis[idx].max_travel + pulloff);
}
} else {
sys.work_envelope.min.values[idx] = settings.axis[idx].max_travel + pulloff;
sys.work_envelope.max.values[idx] = - pulloff;
sys.work_envelope.min.values[idx] = 0.0f;
sys.work_envelope.max.values[idx] = settings.axis[idx].limit_pos - pulloff;;
//sys.work_envelope.min.values[idx] = settings.axis[idx].max_travel + pulloff;
//sys.work_envelope.max.values[idx] = - pulloff;
}
} else
sys.work_envelope.min.values[idx] = sys.work_envelope.max.values[idx] = 0.0f;
Expand All @@ -155,9 +157,12 @@ void limits_set_machine_positions (axes_signals_t cycle, bool add_pulloff)
} while(idx);
} else do {
if (cycle.mask & bit(--idx)) {
sys.home_position[idx] = bit_istrue(settings.homing.dir_mask.value, bit(idx))
? settings.axis[idx].max_travel + pulloff
: - pulloff;

// sys.position[idx] = settings.axis[idx].limit_pos - pulloff;
sys.home_position[idx] = settings.axis[idx].limit_pos - pulloff;
//sys.home_position[idx] = bit_istrue(settings.homing.dir_mask.value, bit(idx))
// ? settings.axis[idx].max_travel + pulloff
// : - pulloff;
sys.position[idx] = lroundf(sys.home_position[idx] * settings.axis[idx].steps_per_mm);
}
} while(idx);
Expand Down
21 changes: 18 additions & 3 deletions settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ PROGMEM const settings_t defaults = {
.axis[X_AXIS].acceleration = (DEFAULT_X_ACCELERATION * 60.0f * 60.0f),
.axis[X_AXIS].max_travel = (-DEFAULT_X_MAX_TRAVEL),
.axis[X_AXIS].dual_axis_offset = 0.0f,
.axis[X_AXIS].limit_pos = 0.0f,
#if ENABLE_BACKLASH_COMPENSATION
.axis[X_AXIS].backlash = 0.0f,
#endif
Expand All @@ -219,6 +220,7 @@ PROGMEM const settings_t defaults = {
.axis[Y_AXIS].max_travel = (-DEFAULT_Y_MAX_TRAVEL),
.axis[Y_AXIS].acceleration = (DEFAULT_Y_ACCELERATION * 60.0f * 60.0f),
.axis[Y_AXIS].dual_axis_offset = 0.0f,
.axis[Y_AXIS].limit_pos = 0.0f,
#if ENABLE_BACKLASH_COMPENSATION
.axis[Y_AXIS].backlash = 0.0f,
#endif
Expand All @@ -228,6 +230,7 @@ PROGMEM const settings_t defaults = {
.axis[Z_AXIS].acceleration = (DEFAULT_Z_ACCELERATION * 60.0f * 60.0f),
.axis[Z_AXIS].max_travel = (-DEFAULT_Z_MAX_TRAVEL),
.axis[Z_AXIS].dual_axis_offset = 0.0f,
.axis[Z_AXIS].limit_pos = 0.0f,
#if ENABLE_BACKLASH_COMPENSATION
.axis[Z_AXIS].backlash = 0.0f,
#endif
Expand All @@ -238,6 +241,7 @@ PROGMEM const settings_t defaults = {
.axis[A_AXIS].acceleration =(DEFAULT_A_ACCELERATION * 60.0f * 60.0f),
.axis[A_AXIS].max_travel = (-DEFAULT_A_MAX_TRAVEL),
.axis[A_AXIS].dual_axis_offset = 0.0f,
.axis[A_AXIS].limit_pos = 0.0f,
#if ENABLE_BACKLASH_COMPENSATION
.axis[A_AXIS].backlash = 0.0f,
#endif
Expand All @@ -250,6 +254,7 @@ PROGMEM const settings_t defaults = {
.axis[B_AXIS].acceleration = (DEFAULT_B_ACCELERATION * 60.0f * 60.0f),
.axis[B_AXIS].max_travel = (-DEFAULT_B_MAX_TRAVEL),
.axis[B_AXIS].dual_axis_offset = 0.0f,
.axis[B_AXIS].limit_pos = 0.0f,
#if ENABLE_BACKLASH_COMPENSATION
.axis[B_AXIS].backlash = 0.0f,
#endif
Expand All @@ -262,6 +267,7 @@ PROGMEM const settings_t defaults = {
.axis[C_AXIS].max_rate = DEFAULT_C_MAX_RATE,
.axis[C_AXIS].max_travel = (-DEFAULT_C_MAX_TRAVEL),
.axis[C_AXIS].dual_axis_offset = 0.0f,
.axis[C_AXIS].limit_pos = 0.0f,
#if ENABLE_BACKLASH_COMPENSATION
.axis[C_AXIS].backlash = 0.0f,
#endif
Expand All @@ -274,6 +280,7 @@ PROGMEM const settings_t defaults = {
.axis[U_AXIS].max_rate = DEFAULT_U_MAX_RATE,
.axis[U_AXIS].max_travel = (-DEFAULT_U_MAX_TRAVEL),
.axis[U_AXIS].dual_axis_offset = 0.0f,
.axis[U_AXIS].limit_pos = 0.0f,
#if ENABLE_BACKLASH_COMPENSATION
.axis[U_AXIS].backlash = 0.0f,
#endif
Expand All @@ -285,6 +292,7 @@ PROGMEM const settings_t defaults = {
.axis[V_AXIS].max_rate = DEFAULT_V_MAX_RATE,
.axis[V_AXIS].max_travel = (-DEFAULT_V_MAX_TRAVEL),
.axis[V_AXIS].dual_axis_offset = 0.0f,
.axis[V_AXIS].limit_pos = 0.0f,
#if ENABLE_BACKLASH_COMPENSATION
.axis[V_AXIS].backlash = 0.0f,
#endif
Expand Down Expand Up @@ -596,6 +604,7 @@ PROGMEM static const setting_detail_t setting_detail[] = {
{ Setting_AxisMaxRate, Group_Axis0, "-axis maximum rate", axis_rate, Format_Decimal, "#####0.000", NULL, NULL, Setting_IsLegacyFn, set_axis_setting, get_float, NULL, AXIS_OPTS },
{ Setting_AxisAcceleration, Group_Axis0, "-axis acceleration", axis_accel, Format_Decimal, "#####0.000", NULL, NULL, Setting_IsLegacyFn, set_axis_setting, get_float, NULL, AXIS_OPTS },
{ Setting_AxisMaxTravel, Group_Axis0, "-axis maximum travel", axis_dist, Format_Decimal, "#####0.000", NULL, NULL, Setting_IsLegacyFn, set_axis_setting, get_float, NULL, AXIS_OPTS },
{ Setting_AxisLimitPos, Group_Axis0, "-axis limit pos", axis_dist, Format_Decimal, "#####0.000", NULL, NULL, Setting_IsLegacyFn, set_axis_setting, get_float, NULL, AXIS_OPTS },
#if ENABLE_BACKLASH_COMPENSATION
{ Setting_AxisBacklash, Group_Axis0, "-axis backlash compensation", axis_dist, Format_Decimal, "#####0.000##", NULL, NULL, Setting_IsExtendedFn, set_axis_setting, get_float, NULL, AXIS_OPTS },
#endif
Expand Down Expand Up @@ -773,6 +782,7 @@ PROGMEM static const setting_descr_t setting_descr[] = {
{ Setting_AxisMaxRate, "Maximum rate. Used as G0 rapid rate." },
{ Setting_AxisAcceleration, "Acceleration. Used for motion planning to not exceed motor torque and lose steps." },
{ Setting_AxisMaxTravel, "Maximum axis travel distance from homing switch. Determines valid machine space for soft-limits and homing search distances." },
{ Setting_AxisLimitPos, "Limit Position" },
#if ENABLE_BACKLASH_COMPENSATION
{ Setting_AxisBacklash, "Backlash distance to compensate for." },
#endif
Expand Down Expand Up @@ -1394,7 +1404,7 @@ static const char *set_axis_setting_unit (setting_id_t setting_id, uint_fast8_t
unit = is_rotary ? "step/deg" : "step/mm";
break;

case Setting_AxisMaxRate:
case Setting_AxisMaxRate:
unit = is_rotary ? "deg/min" : "mm/min";
break;

Expand All @@ -1403,6 +1413,7 @@ static const char *set_axis_setting_unit (setting_id_t setting_id, uint_fast8_t
break;

case Setting_AxisMaxTravel:
case Setting_AxisLimitPos:
case Setting_AxisBacklash:
unit = is_rotary ? "deg" : "mm";
break;
Expand Down Expand Up @@ -1529,7 +1540,9 @@ static status_code_t set_axis_setting (setting_id_t setting, float value)
}
tmp_set_soft_limits();
break;

case Setting_AxisLimitPos:
settings.axis[idx].limit_pos = value;
break;
case Setting_AxisBacklash:
#if ENABLE_BACKLASH_COMPENSATION
if(settings.axis[idx].backlash != value) {
Expand Down Expand Up @@ -1583,7 +1596,9 @@ static float get_float (setting_id_t setting)
case Setting_AxisMaxTravel:
value = -settings.axis[idx].max_travel; // Store as negative for grbl internal use.
break;

case Setting_AxisLimitPos:
value = settings.axis[idx].limit_pos;
break;
#if ENABLE_BACKLASH_COMPENSATION
case Setting_AxisBacklash:
value = settings.axis[idx].backlash;
Expand Down
7 changes: 4 additions & 3 deletions settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,9 @@ typedef enum {
Setting_AxisMicroSteps = Setting_AxisSettingsBase + 5 * AXIS_SETTINGS_INCREMENT,
Setting_AxisBacklash = Setting_AxisSettingsBase + 6 * AXIS_SETTINGS_INCREMENT,
Setting_AxisAutoSquareOffset = Setting_AxisSettingsBase + 7 * AXIS_SETTINGS_INCREMENT,
Setting_AxisHomingFeedRate = Setting_AxisSettingsBase + 8 * AXIS_SETTINGS_INCREMENT,
Setting_AxisHomingSeekRate = Setting_AxisSettingsBase + 9 * AXIS_SETTINGS_INCREMENT,

// Setting_AxisHomingFeedRate = Setting_AxisSettingsBase + 8 * AXIS_SETTINGS_INCREMENT,
// Setting_AxisHomingSeekRate = Setting_AxisSettingsBase + 9 * AXIS_SETTINGS_INCREMENT,
Setting_AxisLimitPos = Setting_AxisSettingsBase + 8 * AXIS_SETTINGS_INCREMENT,
// Calculated base values for driver/plugin stepper settings
Setting_AxisExtended0 = Setting_AxisSettingsBase2,
Setting_AxisExtended1 = Setting_AxisSettingsBase2 + AXIS_SETTINGS_INCREMENT,
Expand Down Expand Up @@ -716,6 +716,7 @@ typedef struct {
float acceleration;
float max_travel;
float dual_axis_offset;
float limit_pos;
#if ENABLE_BACKLASH_COMPENSATION
float backlash;
#endif
Expand Down
2 changes: 2 additions & 0 deletions stepper2.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ static const char *st2_set_axis_setting_unit (setting_id_t setting_id, uint_fast
break;

case Setting_AxisMaxTravel:
case Setting_AxisLimitPos:
case Setting_AxisBacklash:
unit = "--";
break;
Expand Down Expand Up @@ -192,6 +193,7 @@ static const char *st2_setting_get_description (setting_id_t id)
break;

case Setting_AxisBacklash:
case Setting_AxisLimitPos:
case Setting_AxisMaxTravel:
if(bit_istrue(spindle_motors, bit(axis_idx)))
descr = "This setting is ignored for stepper spindles.";
Expand Down