Merge pull request #673 from Expatria-Technologies/PR_FAST_SEMIAUTO

Proposed PR for faster semi-automatic toolchanges.
This commit is contained in:
Terje Io
2025-02-25 09:40:21 +01:00
committed by GitHub
3 changed files with 35 additions and 12 deletions
+3 -2
View File
@@ -1019,7 +1019,7 @@ static status_code_t set_tool_change_mode (setting_id_t id, uint_fast16_t int_va
{
if(!hal.driver_cap.atc && hal.stream.suspend_read && int_value <= ToolChange_Ignore) {
#if COMPATIBILITY_LEVEL > 1
if((toolchange_mode_t)int_value == ToolChange_Manual_G59_3 || (toolchange_mode_t)int_value == ToolChange_SemiAutomatic)
if((toolchange_mode_t)int_value == ToolChange_Manual_G59_3 || (toolchange_mode_t)int_value == ToolChange_SemiAutomatic) || (toolchange_mode_t)int_value == FastToolChange_SemiAutomatic)
return Status_InvalidStatement;
#endif
settings.tool_change.mode = (toolchange_mode_t)int_value;
@@ -2109,7 +2109,7 @@ PROGMEM static const setting_detail_t setting_detail[] = {
{ Setting_AxisHomingFeedRate, Group_Axis0, "-axis homing locate feed rate", axis_rate, Format_Decimal, "###0", NULL, NULL, Setting_NonCoreFn, set_axis_setting, get_float, is_setting_available, AXIS_OPTS },
{ Setting_AxisHomingSeekRate, Group_Axis0, "-axis homing search seek rate", axis_rate, Format_Decimal, "###0", NULL, NULL, Setting_NonCoreFn, set_axis_setting, get_float, is_setting_available, AXIS_OPTS },
{ Setting_SpindleAtSpeedTolerance, Group_Spindle, "Spindle at speed tolerance", "percent", Format_Decimal, "##0.0", NULL, NULL, Setting_IsExtendedFn, set_float, get_float, is_setting_available },
{ Setting_ToolChangeMode, Group_Toolchange, "Tool change mode", NULL, Format_RadioButtons, "Normal,Manual touch off,Manual touch off @ G59.3,Automatic touch off @ G59.3,Ignore M6", NULL, NULL, Setting_IsExtendedFn, set_tool_change_mode, get_int, is_setting_available },
{ Setting_ToolChangeMode, Group_Toolchange, "Tool change mode", NULL, Format_RadioButtons, "Normal,Manual touch off,Manual touch off @ G59.3,Automatic touch off @ G59.3,Ignore M6, Fast Automatic touch off @ G59.3", NULL, NULL, Setting_IsExtendedFn, set_tool_change_mode, get_int, is_setting_available },
{ Setting_ToolChangeProbingDistance, Group_Toolchange, "Tool change probing distance", "mm", Format_Decimal, "#####0.0", NULL, NULL, Setting_IsExtendedFn, set_tool_change_probing_distance, get_float, is_setting_available },
{ Setting_ToolChangeFeedRate, Group_Toolchange, "Tool change locate feed rate", "mm/min", Format_Decimal, "#####0.0", NULL, NULL, Setting_IsExtended, &settings.tool_change.feed_rate, NULL, is_setting_available },
{ Setting_ToolChangeSeekRate, Group_Toolchange, "Tool change search seek rate", "mm/min", Format_Decimal, "#####0.0", NULL, NULL, Setting_IsExtended, &settings.tool_change.seek_rate, NULL, is_setting_available },
@@ -2303,6 +2303,7 @@ PROGMEM static const setting_descr_t setting_descr[] = {
"Manual touch off: retracts tool axis to home position for tool change, use jogging or $TPW for touch off.\\n\\n"
"Manual touch off @ G59.3: retracts tool axis to home position then to G59.3 position for tool change, use jogging or $TPW for touch off.\\n\\n"
"Automatic touch off @ G59.3: retracts tool axis to home position for tool change, then to G59.3 position for automatic touch off.\\n\\n"
"Fast Automatic touch off @ G59.3: Same as automatic mode, except that it uses G38.4 style probing for faster touch off."
"All modes except \"Normal\" and \"Ignore M6\" returns the tool (controlled point) to original position after touch off."
},
{ Setting_ToolChangeProbingDistance, "Maximum probing distance for automatic or $TPW touch off." },
+2 -1
View File
@@ -804,7 +804,8 @@ typedef enum {
ToolChange_Manual,
ToolChange_Manual_G59_3,
ToolChange_SemiAutomatic,
ToolChange_Ignore
ToolChange_Ignore,
ToolChange_FastSemiAutomatic
} toolchange_mode_t;
typedef struct {
+30 -9
View File
@@ -237,6 +237,15 @@ static void execute_probe (void *data)
{
system_convert_array_steps_to_mpos(target.values, sys.probe_position);
if(settings.tool_change.mode == ToolChange_FastSemiAutomatic){
// Retract slowly until contact lost.
plan_data.feed_rate = settings.tool_change.feed_rate;
target.values[plane.axis_linear] += TOOL_CHANGE_PROBE_RETRACT_DISTANCE;
flags.probe_is_away = true;
ok = mc_probe_cycle(target.values, &plan_data, flags) == GCProbe_Found;
} else {
// Retract a bit and perform slow probe.
plan_data.feed_rate = settings.tool_change.pulloff_rate;
target.values[plane.axis_linear] += TOOL_CHANGE_PROBE_RETRACT_DISTANCE;
@@ -246,6 +255,7 @@ static void execute_probe (void *data)
ok = mc_probe_cycle(target.values, &plan_data, flags) == GCProbe_Found;
}
}
}
if(ok) {
if(!(sys.tlo_reference_set.mask & bit(plane.axis_linear))) {
@@ -277,7 +287,12 @@ ISR_CODE static void ISR_FUNC(trap_control_cycle_start)(control_signals_t signal
if(signals.cycle_start) {
if(!execute_posted) {
if(!block_cycle_start)
execute_posted = protocol_enqueue_foreground_task(settings.tool_change.mode == ToolChange_SemiAutomatic ? execute_probe : execute_restore, NULL);
execute_posted = protocol_enqueue_foreground_task(
(settings.tool_change.mode == ToolChange_SemiAutomatic ||
settings.tool_change.mode == ToolChange_FastSemiAutomatic)
? execute_probe
: execute_restore,
NULL);
else
protocol_enqueue_foreground_task(execute_warning, NULL);
}
@@ -297,7 +312,12 @@ ISR_CODE static bool ISR_FUNC(trap_stream_cycle_start)(char c)
if((drop = (c == CMD_CYCLE_START || c == CMD_CYCLE_START_LEGACY))) {
if(!execute_posted) {
if(!block_cycle_start)
execute_posted = protocol_enqueue_foreground_task(settings.tool_change.mode == ToolChange_SemiAutomatic ? execute_probe : execute_restore, NULL);
execute_posted = protocol_enqueue_foreground_task(
(settings.tool_change.mode == ToolChange_SemiAutomatic ||
settings.tool_change.mode == ToolChange_FastSemiAutomatic)
? execute_probe
: execute_restore,
NULL);
else
protocol_enqueue_foreground_task(execute_warning, NULL);
}
@@ -336,7 +356,7 @@ static status_code_t tool_change (parser_state_t *parser_state)
return Status_OK;
#if COMPATIBILITY_LEVEL > 1
if(settings.tool_change.mode == ToolChange_Manual_G59_3 || settings.tool_change.mode == ToolChange_SemiAutomatic)
if(settings.tool_change.mode == ToolChange_Manual_G59_3 || settings.tool_change.mode == ToolChange_SemiAutomatic || settings.tool_change.mode == ToolChange_FastSemiAutomatic)
return Status_GcodeUnsupportedCommand;
#endif
@@ -361,12 +381,12 @@ static status_code_t tool_change (parser_state_t *parser_state)
if((sys.homed.mask & homed_req) != homed_req)
return Status_HomingRequired;
if(settings.tool_change.mode != ToolChange_SemiAutomatic && grbl.on_probe_completed != onProbeCompleted) {
on_probe_completed = grbl.on_probe_completed;
grbl.on_probe_completed = onProbeCompleted;
}
if(settings.tool_change.mode != ToolChange_SemiAutomatic &&
settings.tool_change.mode != ToolChange_FastSemiAutomatic)
grbl.on_probe_completed = on_probe_completed;
block_cycle_start = settings.tool_change.mode != ToolChange_SemiAutomatic;
block_cycle_start = (settings.tool_change.mode != ToolChange_SemiAutomatic &&
settings.tool_change.mode != ToolChange_FastSemiAutomatic);
// Stop spindle and coolant.
spindle_all_off();
@@ -376,7 +396,8 @@ static status_code_t tool_change (parser_state_t *parser_state)
probe_toolsetter = grbl.on_probe_toolsetter != NULL &&
(settings.tool_change.mode == ToolChange_Manual ||
settings.tool_change.mode == ToolChange_Manual_G59_3 ||
settings.tool_change.mode == ToolChange_SemiAutomatic);
settings.tool_change.mode == ToolChange_SemiAutomatic ||
settings.tool_change.mode == ToolChange_FastSemiAutomatic);
// Save current position.
system_convert_array_steps_to_mpos(previous.values, sys.position);