Skip to content

Commit b10b331

Browse files
committed
Fix for custom M-code commands claiming all axis words even when not using any.
Added setting $680 for configuring delay from stepper enable to first dir/step pulse. Adds to fixed ~2ms delay provided by most drivers.
1 parent 6948b0e commit b10b331

10 files changed

Lines changed: 75 additions & 20 deletions

File tree

changelog.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
## grblHAL changelog
22

3+
<a name="20250518">Build 20250518
4+
5+
Core:
6+
7+
* Fix for custom M-code commands claiming all axis words even when not using any.
8+
9+
* Added setting `$680` for configuring delay from stepper enable to first dir/step pulse. Added to fixed ~2ms delay provided by most drivers.
10+
11+
Drivers:
12+
13+
* STM32F4xx: added OpenPNP plugin.
14+
15+
* STM32F4xx, STM32F7xx: fix for second PWM spindle failing to compile and reading analog inputs returning the value from the last configured.
16+
17+
Plugins:
18+
19+
* OpenPNP: added support for reading/scaling analog inputs via `M123`, `M124` and `M125` custom M-codes.
20+
21+
* Keypad: changed to report itself even if no keypad is connected, added delay before probing the I2C bus to allow the keypad time to boot.
22+
23+
---
24+
325
<a name="20250514">Build 20250514
426

527
Core:
@@ -15,6 +37,8 @@ When more than one probe is available `PROBES:<bits>` is added to the `NEWOPTS`
1537

1638
Drivers:
1739

40+
* iMXRT1062: added `$BL` command for entering bootloader mode, allows use of the _Teensy Loader_ when access to the programming button is restricted.
41+
1842
* All: fix for potential/actual hard fault when a basic on/off spindle is configured. Ref. ESP32 issue [#164](https://github.com/grblHAL/ESP32/issues/164).
1943

2044
* STM32 drivers: fix for incorrect PWM output at max RPM when PWM output is inverted.

config.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,8 +1925,8 @@ Specify at least \ref X_AXIS_BIT if a common enable signal is used.
19251925
#endif
19261926
///@}
19271927

1928-
/*! @name $376 - Settings_Axis_Rotational
1929-
Designate ABC axes as rotational by \ref axismask. This will disable scaling (to mm) in inches mode.
1928+
/*! @name $376 - Settings_RotaryAxes
1929+
Designate ABC axes as rotary by \ref axismask. This will disable scaling (to mm) in inches mode.
19301930
Set steps/mm for the axes to the value that represent the desired movement per unit.
19311931
For the controller the distance is unitless and and can be in degrees, radians, rotations, ...
19321932
*/
@@ -1936,6 +1936,15 @@ For the controller the distance is unitless and and can be in degrees, radians,
19361936
#endif
19371937
///@}
19381938

1939+
/*! @name $680 - Setting_StepperEnableDelay
1940+
Allowed range 0 - 250 milliseconds. Driver adds ~2 milliseconds.
1941+
*/
1942+
///@{
1943+
#if !defined DEFAULT_STEPPER_ENABLE_DELAY || defined __DOXYGEN__
1944+
#define DEFAULT_STEPPER_ENABLE_DELAY 0
1945+
#endif
1946+
///@}
1947+
19391948
/*! @name $742 - Setting_MotorWarningsEnable
19401949
\brief \ref axismask controlling the which motor warning signals to enable.
19411950
Set this value to -1 or AXES_BITMASK to enable for all axes or specify which by mask.

gcode.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,14 +1776,16 @@ status_code_t gc_execute_block (char *block)
17761776
user_words.mask = gc_block.words.mask;
17771777
if((int_value = (uint_fast16_t)grbl.user_mcode.validate(&gc_block)))
17781778
FAIL((status_code_t)int_value);
1779-
user_words.mask ^= gc_block.words.mask; // Flag "taken" words for execution
1780-
1781-
if(user_words.i)
1782-
ijk_words.i = Off;
1783-
if(user_words.j)
1784-
ijk_words.j = Off;
1785-
if(user_words.k)
1786-
ijk_words.k = Off;
1779+
1780+
parameter_words_t taken_words;
1781+
1782+
user_words.mask ^= gc_block.words.mask; // Flag "taken" words for user M-code execution
1783+
1784+
if((taken_words.mask = user_words.mask & axis_words_mask.mask))
1785+
axis_words.mask &= ~gc_paramwords_to_axes(taken_words).mask;
1786+
1787+
ijk_words.mask &= ~(uint8_t)((user_words.mask >> 4) & 0b111);
1788+
17871789
if(user_words.f) {
17881790
single_meaning_value.f = gc_block.values.f;
17891791
gc_block.values.f = 0.0f;
@@ -1800,7 +1802,6 @@ status_code_t gc_execute_block (char *block)
18001802
single_meaning_value.t = gc_block.values.t;
18011803
gc_block.values.t = (tool_id_t)0;
18021804
}
1803-
axis_words.mask = 0;
18041805
}
18051806

18061807
// [1. Comments ]: MSG's may be supported by driver layer. Comment handling performed by protocol.

gcode.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ typedef enum {
242242
UserMCode_Generic2 = 102, //!< 102 - For private use only
243243
UserMCode_Generic3 = 103, //!< 103 - For private use only
244244
UserMCode_Generic4 = 104, //!< 104 - For private use only
245-
OpenPNP_GetADCReading = 105, //!< 105 - M105
246245
Fan_On = 106, //!< 106 - M106, Marlin format
247246
Fan_Off = 107, //!< 107 - M107, Marlin format
248247
OpenPNP_GetCurrentPosition = 114, //!< 114 - M114
@@ -254,6 +253,9 @@ typedef enum {
254253
LaserPPI_Rate = 127, //!< 127 - M127
255254
LaserPPI_PulseLength = 128, //!< 128 - M128
256255
Laser_Overdrive = 129, //!< 129 - M129
256+
OpenPNP_GetADCRaw = 143, //!< 143 - M143
257+
OpenPNP_GetADCScaled = 144, //!< 144 - M144
258+
OpenPNP_SetADCScaling = 145, //!< 145 - M145
257259
RGB_WriteLEDs = 150, //!< 150 - M150, Marlin format
258260
Plasma_SelectMaterial = 190, //!< 150 - M190, LinuxCNC format
259261
OpenPNP_SetJerk = 20130, //!< 20130 - M201.3
@@ -457,7 +459,7 @@ typedef struct {
457459
uint8_t l; //!< G10 or canned cycles parameters
458460
} gc_values_t;
459461

460-
//! Parameter words found by parser - do not change order!
462+
//! Parameter words found by parser - do NOT change order!
461463
typedef union {
462464
uint32_t mask; //!< All flags as a bitmap.
463465
uint32_t value; //!< Synonymous with \a mask.
@@ -676,6 +678,16 @@ typedef struct {
676678
#endif
677679
} parser_block_t;
678680

681+
682+
static inline axes_signals_t gc_paramwords_to_axes (parameter_words_t p_words)
683+
{
684+
#if N_AXIS == 3
685+
return (axes_signals_t){ (uint8_t)(p_words.mask >> 24) };
686+
#else
687+
return (axes_signals_t){ (uint8_t)(((p_words.mask >> 24) | ((p_words.mask << 2) & 0b00111000) | ((p_words.mask >> (21 - 6)) & 0b11000000)) & AXES_BITMASK) };
688+
#endif
689+
}
690+
679691
// Initialize the parser
680692
void gc_init (bool stop);
681693

grbl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#else
4343
#define GRBL_VERSION "1.1f"
4444
#endif
45-
#define GRBL_BUILD 20250514
45+
#define GRBL_BUILD 20250518
4646

4747
#define GRBL_URL "https://github.com/grblHAL"
4848

nvs_buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ nvs_io_t *nvs_buffer_get_physical (void)
404404
return hal.nvs.type == NVS_Emulated ? &physical_nvs : &hal.nvs;
405405
}
406406

407-
#ifdef DEBUGOUT
407+
#ifdef DEBUG
408408

409409
#include "report.h"
410410

settings.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ PROGMEM const settings_t defaults = {
9999
.probe.invert_toolsetter_input = DEFAULT_TOOLSETTER_SIGNAL_INVERT,
100100
.probe.disable_toolsetter_pullup = DEFAULT_TOOLSETTER_SIGNAL_DISABLE_PULLUP,
101101

102+
.stepper_enable_delay = DEFAULT_STEPPER_ENABLE_DELAY,
102103
.steppers.pulse_microseconds = DEFAULT_STEP_PULSE_MICROSECONDS,
103104
.steppers.pulse_delay_microseconds = DEFAULT_STEP_PULSE_DELAY,
104105
.steppers.idle_lock_time = DEFAULT_STEPPER_IDLE_LOCK_TIME,
@@ -2152,7 +2153,8 @@ PROGMEM static const setting_detail_t setting_detail[] = {
21522153
{ Setting_MotorWarningsInvert, Group_Stepper, "Invert motor warning inputs", NULL, Format_AxisMask, NULL, NULL, NULL, Setting_IsExtended, &settings.motor_warning_invert, NULL, is_setting_available },
21532154
{ Setting_MotorFaultsEnable, Group_Stepper, "Motor fault inputs enable", NULL, Format_AxisMask, NULL, NULL, NULL, Setting_IsExtended, &settings.motor_fault_enable, NULL, is_setting_available },
21542155
{ Setting_MotorFaultsInvert, Group_Stepper, "Invert motor fault inputs", NULL, Format_AxisMask, NULL, NULL, NULL, Setting_IsExtended, &settings.motor_fault_invert, NULL, is_setting_available },
2155-
{ Setting_ResetActions, Group_General, "Reset actions", NULL, Format_Bitfield, "Clear homed status if position was lost,Clear offsets (except G92)", NULL, NULL, Setting_IsExtendedFn, set_reset_actions, get_int, NULL }
2156+
{ Setting_ResetActions, Group_General, "Reset actions", NULL, Format_Bitfield, "Clear homed status if position was lost,Clear offsets (except G92)", NULL, NULL, Setting_IsExtendedFn, set_reset_actions, get_int, NULL },
2157+
{ Setting_StepperEnableDelay, Group_Stepper, "Stepper enable delay", "ms", Format_Int16, "##0", NULL, "250", Setting_IsExtended, &settings.stepper_enable_delay, NULL, NULL },
21562158
};
21572159

21582160
#ifndef NO_SETTINGS_DESCRIPTIONS
@@ -2357,7 +2359,8 @@ PROGMEM static const setting_descr_t setting_descr[] = {
23572359
{ Setting_FSOptions, "Auto mount SD card on startup." },
23582360
{ Setting_HomePinsInvertMask, "Inverts the axis home input signals." },
23592361
{ Setting_CoolantOnDelay, "Delay to allow coolant to start. 0 or 0.5 - 20s." },
2360-
{ Setting_ResetActions, "Controls actions taken on a soft reset." }
2362+
{ Setting_ResetActions, "Controls actions taken on a soft reset." },
2363+
{ Setting_StepperEnableDelay, "Delay from stepper enable to first step output. The driver typically adds ~2ms to this." }
23612364
/*
23622365
{ Setting_MotorWarningsEnable, "Motor warning enable" },
23632366
{ Setting_MotorWarningsInvert, "Invert motor warning inputs" },

settings.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ typedef enum {
458458
Setting_StepperSpindle_Options = 677,
459459
Setting_RelayPortToolsetter = 678,
460460
Setting_RelayPortProbe2 = 679,
461+
Setting_StepperEnableDelay = 680,
461462

462463
Setting_SpindlePWMOptions1 = 709,
463464

@@ -895,7 +896,8 @@ typedef struct {
895896
axes_signals_t motor_fault_invert;
896897
macro_atc_flags_t macro_atc_flags;
897898
stepper_spindle_settings_flags_t stepper_spindle_flags;
898-
char reserved[18]; // Reserved For future expansion
899+
uint16_t stepper_enable_delay; // Move to stepper_settings_t
900+
char reserved[16]; // Reserved For future expansion
899901
} settings_t;
900902

901903
typedef enum {

stepper.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ void st_wake_up (void)
201201

202202
hal.stepper.go_idle(true); // Reset step & dir outputs
203203
hal.stepper.wake_up();
204+
205+
if(settings.stepper_enable_delay) // TODO: do not add delay if deenergize is pending?
206+
hal.delay_ms(settings.stepper_enable_delay, NULL);
204207
}
205208

206209
// Stepper shutdown

system.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ static status_code_t rtc_action (sys_state_t state, char *args)
762762
return retval;
763763
}
764764

765-
#ifdef DEBUGOUT
765+
#ifdef DEBUG
766766

767767
#include "nvs_buffer.h"
768768

@@ -772,6 +772,7 @@ static status_code_t output_memmap (sys_state_t state, char *args)
772772

773773
return Status_OK;
774774
}
775+
775776
#endif
776777

777778
const char *help_rst (const char *cmd)
@@ -972,7 +973,7 @@ PROGMEM static const sys_command_t sys_commands[] = {
972973
{ "SDS", report_stepper_status, { .noargs = On, .allow_blocking = On, .help_fn = On }, { .fn = help_steppers } },
973974
{ "RTC", rtc_action, { .allow_blocking = On, .help_fn = On }, { .fn = help_rtc } },
974975
{ "DWNGRD", settings_downgrade, { .noargs = On, .allow_blocking = On }, { .str = "toggle setting flags for downgrade" } },
975-
#ifdef DEBUGOUT
976+
#ifdef DEBUG
976977
{ "Q", output_memmap, { .noargs = On }, { .str = "output NVS memory allocation" } },
977978
#endif
978979
};

0 commit comments

Comments
 (0)