Added setting definition for macro ATC options.

Now hides core toolchange settings when macro based ATC is active to avoid confusion.
"hardened" parser tool change code a bit.
This commit is contained in:
Terje Io
2025-01-28 09:22:00 +01:00
parent 0462c97dc9
commit dfa1b262a4
8 changed files with 82 additions and 50 deletions
+2 -6
View File
@@ -1,14 +1,10 @@
## grblHAL ##
Latest build date is 20250124, see the [changelog](changelog.md) for details.
Latest build date is 20250128, see the [changelog](changelog.md) for details.
> [!NOTE]
> A settings reset will be performed on an update of builds prior to 20241208. Backup and restore of settings is recommended.
> [!NOTE]
> Build 20240222 has moved the probe input to the ioPorts pool of inputs and will be allocated from it when configured.
The change is major and _potentially dangerous_, it may damage your probe, so please _verify correct operation_ after installing this, or later, builds.
---
A web app for [building for some drivers](http://svn.io-engineering.com:8080/) is now available, feedback will be appreciated.
@@ -93,4 +89,4 @@ G/M-codes not supported by [legacy Grbl](https://github.com/gnea/grbl/wiki) are
Some [plugins](https://github.com/grblHAL/plugins) implements additional M-codes.
---
20250124
20250128
+16 -5
View File
@@ -1,20 +1,31 @@
## grblHAL changelog
<a name="20250126">Build 20250126
<a name="20250128">Build 20250128
Core:
* Changed core tool change routine to play nice with plugins subscribing to probe event.
* Added setting definition for macro ATC options. Now hides core toolchange settings when macro based ATC is active to avoid confusion.
* Fixed typos in PR [#660](https://github.com/grblHAL/core/pull/660).
* "hardened" parser tool change code a bit.
Drivers:
* STM32F4xx: updated the SuperLongBoard map.
* ESP32: fixed issue with Trinamic SPI code for "chained" drivers. Only bench tested with single driver. Ref. issue [#666](https://github.com/grblHAL/core/issues/666).
* RP2040: updated to SDK 2.1.0 for Pico2 W support.
Plugins:
* BLTouch: added `$BLRESET` command to reset the probe and stow of probe on soft reset.
* SD card: "hardened" code, now reports error 62 if mounted card is removed without unmounting and a file listing is asked for.
Added mounted state change element to the real-time report report: `|SD:0` when not mounted, `|SD:1` when mounted,
`|SD:2` when not mounted and card detect is available and `|SD:3` when mounted automatically on card detected event.
* SD card, macros: added setting `$675` for macro ATC options, currently one flag to enable execution of `M6T0` to unload tool.
This setting was added to keep backwards compatibility, only enable if the tool change macro can handle it.
Templates:
* Persistent tool: did not set parser state correctly causing `M61Q0` to be ignored after restart.
---
+28 -23
View File
@@ -1313,7 +1313,7 @@ status_code_t gc_execute_block (char *block)
break;
case 6:
if(settings.tool_change.mode != ToolChange_Ignore) {
if(hal.driver_cap.atc || settings.tool_change.mode != ToolChange_Ignore) {
if(hal.stream.suspend_read || hal.tool.change)
word_bit.modal_group.M6 = On;
else
@@ -1911,7 +1911,7 @@ status_code_t gc_execute_block (char *block)
gc_block.words.q = Off;
#if NGC_EXPRESSIONS_ENABLE
if(hal.stream.file) {
gc_state.tool_pending = 0; // force set tool
gc_state.tool_pending = (uint32_t)-1; // force set tool
if(grbl.tool_table.n_tools) {
if(gc_state.g43_pending) {
gc_block.values.h = gc_state.g43_pending;
@@ -3232,38 +3232,43 @@ status_code_t gc_execute_block (char *block)
//
// [5. Select tool ]: Only tracks tool value if ATC or manual tool change is not possible.
if(gc_state.tool_pending != gc_block.values.t && !check_mode) {
if(gc_state.tool_pending != gc_block.values.t) {
tool_data_t *pending_tool = tool_get_pending((gc_state.tool_pending = gc_block.values.t));
gc_state.tool_pending = gc_block.values.t;
// If M6 not available or M61 commanded set new tool immediately
if(set_tool || settings.tool_change.mode == ToolChange_Ignore || !(hal.stream.suspend_read || hal.tool.change)) {
if(!check_mode) {
tool_set(pending_tool);
tool_data_t *pending_tool = tool_get_pending(gc_state.tool_pending);
if(grbl.on_tool_selected) {
// If M6 not available or M61 commanded set new tool immediately
if(set_tool || (hal.driver_cap.atc ? !hal.tool.change : settings.tool_change.mode == ToolChange_Ignore || !(hal.stream.suspend_read || hal.tool.change))) {
spindle_state_t state = sspindle ? sspindle->state : (spindle_state_t){0};
tool_set(pending_tool);
grbl.on_tool_selected(pending_tool);
if(grbl.on_tool_selected) {
if(sspindle && state.value != sspindle->state.value) {
command_words.M7 = On;
gc_block.spindle_modal.state = sspindle->state;
spindle_state_t state = sspindle ? sspindle->state : (spindle_state_t){0};
grbl.on_tool_selected(pending_tool);
if(sspindle && state.value != sspindle->state.value) {
command_words.M7 = On;
gc_block.spindle_modal.state = sspindle->state;
}
}
if(grbl.on_tool_changed)
grbl.on_tool_changed(gc_state.tool);
system_add_rt_report(Report_Tool);
}
if(grbl.on_tool_changed)
grbl.on_tool_changed(gc_state.tool);
system_add_rt_report(Report_Tool);
// Prepare tool carousel when available
if(hal.tool.select)
hal.tool.select(pending_tool, !set_tool);
else
system_add_rt_report(Report_Tool);
}
// Prepare tool carousel when available
if(hal.tool.select)
hal.tool.select(pending_tool, !set_tool);
else
system_add_rt_report(Report_Tool);
}
// [5a. HAL pin I/O ]: M62 - M68. (Modal group M10)
+1 -1
View File
@@ -42,7 +42,7 @@
#else
#define GRBL_VERSION "1.1f"
#endif
#define GRBL_BUILD 20250126
#define GRBL_BUILD 20250128
#define GRBL_URL "https://github.com/grblHAL"
+15 -6
View File
@@ -1779,6 +1779,15 @@ static bool is_setting_available (const setting_detail_t *setting, uint_fast16_t
available = SLEEP_DURATION > 0.0f;
break;
case Setting_ToolChangeMode:
case Setting_ToolChangeProbingDistance:
case Setting_ToolChangeFeedRate:
case Setting_ToolChangeSeekRate:
case Setting_ToolChangePulloffRate:
case Setting_ToolChangeRestorePosition:
available = !hal.driver_cap.atc;
break;
case Setting_DualAxisLengthFailPercent:
case Setting_DualAxisLengthFailMin:
case Setting_DualAxisLengthFailMax:
@@ -2051,12 +2060,12 @@ 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, NULL },
{ Setting_ToolChangeProbingDistance, Group_Toolchange, "Tool change probing distance", "mm", Format_Decimal, "#####0.0", NULL, NULL, Setting_IsExtendedFn, set_tool_change_probing_distance, get_float, NULL },
{ 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, NULL },
{ 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, NULL },
{ Setting_ToolChangePulloffRate, Group_Toolchange, "Tool change probe pull-off rate", "mm/min", Format_Decimal, "#####0.0", NULL, NULL, Setting_IsExtended, &settings.tool_change.pulloff_rate, NULL, NULL },
{ Setting_ToolChangeRestorePosition, Group_Toolchange, "Restore position after M6", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_tool_restore_pos, get_int, NULL },
{ 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_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 },
{ Setting_ToolChangePulloffRate, Group_Toolchange, "Tool change probe pull-off rate", "mm/min", Format_Decimal, "#####0.0", NULL, NULL, Setting_IsExtended, &settings.tool_change.pulloff_rate, NULL, is_setting_available },
{ Setting_ToolChangeRestorePosition, Group_Toolchange, "Restore position after M6", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_tool_restore_pos, get_int, is_setting_available },
{ Setting_DualAxisLengthFailPercent, Group_Limits_DualAxis, "Dual axis length fail", "percent", Format_Decimal, "##0.0", "0", "100", Setting_IsExtended, &settings.homing.dual_axis.fail_length_percent, NULL, is_setting_available },
{ Setting_DualAxisLengthFailMin, Group_Limits_DualAxis, "Dual axis length fail min", "mm", Format_Decimal, "#####0.000", NULL, NULL, Setting_IsExtended, &settings.homing.dual_axis.fail_distance_min, NULL, is_setting_available },
{ Setting_DualAxisLengthFailMax, Group_Limits_DualAxis, "Dual axis length fail max", "mm", Format_Decimal, "#####0.000", NULL, NULL, Setting_IsExtended, &settings.homing.dual_axis.fail_distance_max, NULL, is_setting_available },
+12 -1
View File
@@ -453,6 +453,7 @@ typedef enum {
Setting_Reserved672 = 672,
Setting_CoolantOnDelay = 673,
Setting_THC_Options = 674,
Setting_MacroATC_Options = 675,
Setting_SpindleInvertMask1 = 716,
@@ -816,6 +817,15 @@ typedef struct {
float probing_distance;
} tool_change_settings_t;
typedef union {
uint8_t value;
struct {
uint8_t execute_m6t0 :1,
random_toolchanger :1,
unassigned :6;
};
} macro_atc_flags_t;
typedef union {
uint32_t value;
struct {
@@ -862,7 +872,8 @@ typedef struct {
axes_signals_t motor_warning_invert;
axes_signals_t motor_fault_enable;
axes_signals_t motor_fault_invert;
char reserved[20]; // Reserved For future expansion
macro_atc_flags_t macro_atc_flags;
char reserved[19]; // Reserved For future expansion
} settings_t;
typedef enum {
+2 -2
View File
@@ -5,7 +5,7 @@
Part of grblHAL
Copyright (c) 2022-2024 Terje Io
Copyright (c) 2022-2025 Terje Io
grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -204,7 +204,7 @@ static vfs_mount_t root = {
static vfs_mount_t *cwdmount = &root;
static char cwd[100] = "/";
int vfs_errno = 0;
volatile int vfs_errno = 0;
vfs_events_t vfs = {0};
static vfs_mount_t *get_rootfs (void)
+6 -6
View File
@@ -5,20 +5,20 @@
Part of grblHAL
Copyright (c) 2022-2024 Terje Io
Copyright (c) 2022-2025 Terje Io
Grbl is free software: you can redistribute it and/or modify
grblHAL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Grbl is distributed in the hope that it will be useful,
grblHAL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
along with grblHAL. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INCLUDE_VFS_H
@@ -200,7 +200,7 @@ struct vfs_dir {
uint8_t handle __attribute__ ((aligned (4))); // must be last!
};
extern int vfs_errno;
extern volatile int vfs_errno;
extern vfs_events_t vfs;
char *vfs_fixpath (char *path);