Fix for incorrect sequencing of init calls when corexy and backlash compensation is enabled at the same time.

Added call to driver to immediately set stepper enable signals when $37 (Stepper deenergize) is changed.
Some minor improvements in settings handling and options reporting.
This commit is contained in:
Terje Io
2022-07-09 18:36:01 +02:00
parent 0db09ab6e9
commit e8530a45ab
7 changed files with 76 additions and 10 deletions
+24 -1
View File
@@ -1,5 +1,28 @@
## grblHAL changelog
20220709:
Core:
* Fix for incorrect sequencing of init calls when corexy and backlash compensation is enabled at the same time, [ESP32 issue #25](https://github.com/grblHAL/ESP32/issues/25).
* Added call to driver to immediately set stepper enable signals when `$37` \(Stepper deenergize\) is changed.
* Some minor improvements in settings handling and options reporting.
Drivers:
* iMXRT1062: Updated [SD card driver patch](https://github.com/grblHAL/iMXRT1062/tree/master/patches) with workaround for non word-aligned writes that caused file corruption. Fix for [WebUI issue #4](https://github.com/grblHAL/Plugin_WebUI/issues/4).
* STM32F4xx: Added option for using timer 2 for spindle sync RPM timer as this allows spindle sync for low pin count MCUs.
Note that timer 2 is a 16 bit timer that had to be extended virtually to 32 bit - this _may_ affect spindle sync operation/performance.
Templates:
* Added plugin for Marlin style M17/M18 (M84) commands for enabing/disabling stepper drivers as fix for issue #184.
---
20220703:
Core:
@@ -11,7 +34,7 @@ $9: PWM Spindle as bitfield where setting bit 0 enables the rest:
1 - RPM controls spindle enable signal (2)
```
Bit 1 in this setting replaces setting `$7`, bit 0 controls the PWM output.
__NOTE:__ M3 and M4 with S0 will now set the spindle enable output if `$9` is `1`. Ref issue #156.
__NOTE:__ M3 and M4 with S0 will now set the spindle enable output if `$9` is `1`. Ref [issue #156](https://github.com/grblHAL/core/issues/156).
__NOTE:__ the change is not backwards compatible with current 3rd party drivers, these has to be updated to match changes in the core.
+14
View File
@@ -26,6 +26,7 @@
#include <math.h>
#include "hal.h"
#include "settings.h"
#include "planner.h"
#include "kinematics.h"
@@ -35,6 +36,8 @@
#define A_MOTOR X_AXIS // Must be X_AXIS
#define B_MOTOR Y_AXIS // Must be Y_AXIS
static on_report_options_ptr on_report_options;
// Returns x or y-axis "steps" based on CoreXY motor steps.
inline static int32_t corexy_convert_to_a_motor_steps (int32_t *steps)
{
@@ -195,6 +198,14 @@ static float homing_cycle_get_feedrate (float feedrate, axes_signals_t cycle)
return feedrate * sqrtf(2.0f);
}
static void report_options (bool newopt)
{
on_report_options(newopt);
if(!newopt)
hal.stream.write("[KINEMATICS:CoreXY v2.00]" ASCII_EOL);
}
// Initialize API pointers for CoreXY kinematics
void corexy_init (void)
{
@@ -206,6 +217,9 @@ void corexy_init (void)
kinematics.segment_line = kinematics_segment_line;
kinematics.homing_cycle_validate = homing_cycle_validate;
kinematics.homing_cycle_get_feedrate = homing_cycle_get_feedrate;
on_report_options = grbl.on_report_options;
grbl.on_report_options = report_options;
}
#endif
+1 -1
View File
@@ -34,7 +34,7 @@
#else
#define GRBL_VERSION "1.1f"
#endif
#define GRBL_BUILD 20220703
#define GRBL_BUILD 20220709
// The following symbols are set here if not already set by the compiler or in config.h
// Do NOT change here!
+4
View File
@@ -213,6 +213,10 @@ int grbl_enter (void)
wall_plotter_init();
#endif
#ifdef ENABLE_BACKLASH_COMPENSATION
mc_backlash_init((axes_signals_t){AXES_BITMASK});
#endif
sys.driver_started = sys.alarm != Alarm_SelftestFailed;
// "Wire" homing switches to limit switches if not provided by the driver.
+1 -1
View File
@@ -58,7 +58,7 @@
#ifdef ENABLE_BACKLASH_COMPENSATION
static float target_prev[N_AXIS];
static float target_prev[N_AXIS] = {0};
static axes_signals_t dir_negative = {0}, backlash_enabled = {0};
void mc_backlash_init (axes_signals_t axes)
+19 -6
View File
@@ -359,6 +359,7 @@ static status_code_t set_probe_allow_feed_override (setting_id_t id, uint_fast16
static status_code_t set_tool_change_mode (setting_id_t id, uint_fast16_t int_value);
static status_code_t set_tool_change_probing_distance (setting_id_t id, float value);
static status_code_t set_ganged_dir_invert (setting_id_t id, uint_fast16_t int_value);
static status_code_t set_stepper_deenergize_mask (setting_id_t id, uint_fast16_t int_value);
#ifndef NO_SAFETY_DOOR_SUPPORT
static status_code_t set_parking_enable (setting_id_t id, uint_fast16_t int_value);
static status_code_t set_restore_overrides (setting_id_t id, uint_fast16_t int_value);
@@ -449,7 +450,7 @@ PROGMEM static const setting_detail_t setting_detail[] = {
{ Setting_PWMOffValue, Group_Spindle, "Spindle PWM off value", "percent", Format_Decimal, "##0.0", NULL, "100", Setting_IsExtended, &settings.spindle.pwm_off_value, NULL, is_setting_available },
{ Setting_PWMMinValue, Group_Spindle, "Spindle PWM min value", "percent", Format_Decimal, "##0.0", NULL, "100", Setting_IsExtended, &settings.spindle.pwm_min_value, NULL, is_setting_available },
{ Setting_PWMMaxValue, Group_Spindle, "Spindle PWM max value", "percent", Format_Decimal, "##0.0", NULL, "100", Setting_IsExtended, &settings.spindle.pwm_max_value, NULL, is_setting_available },
{ Setting_StepperDeenergizeMask, Group_Stepper, "Steppers deenergize", NULL, Format_AxisMask, NULL, NULL, NULL, Setting_IsExtended, &settings.steppers.deenergize.mask, NULL, NULL },
{ Setting_StepperDeenergizeMask, Group_Stepper, "Steppers deenergize", NULL, Format_AxisMask, NULL, NULL, NULL, Setting_IsExtendedFn, set_stepper_deenergize_mask, get_int, NULL },
{ Setting_SpindlePPR, Group_Spindle, "Spindle pulses per revolution (PPR)", NULL, Format_Int16, "###0", NULL, NULL, Setting_IsExtended, &settings.spindle.ppr, NULL, is_setting_available },
{ Setting_EnableLegacyRTCommands, Group_General, "Enable legacy RT commands", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_enable_legacy_rt_commands, get_int, NULL },
{ Setting_JogSoftLimited, Group_Jogging, "Limit jog commands", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_jog_soft_limited, get_int, NULL },
@@ -802,6 +803,15 @@ static status_code_t set_ganged_dir_invert (setting_id_t id, uint_fast16_t int_v
return Status_OK;
}
static status_code_t set_stepper_deenergize_mask (setting_id_t id, uint_fast16_t int_value)
{
settings.steppers.deenergize.mask = int_value;
hal.stepper.enable(settings.steppers.deenergize);
return Status_OK;
}
static status_code_t set_report_mask (setting_id_t id, uint_fast16_t int_value)
{
#if COMPATIBILITY_LEVEL <= 1
@@ -1342,6 +1352,10 @@ static uint32_t get_int (setting_id_t id)
(settings.homing.flags.keep_on_reset ? bit(7) : 0);
break;
case Setting_StepperDeenergizeMask:
value = settings.steppers.deenergize.mask;
break;
case Setting_EnableLegacyRTCommands:
value = settings.flags.legacy_rt_commands;
break;
@@ -1550,7 +1564,7 @@ static bool is_setting_available (const setting_detail_t *setting)
#endif
case Setting_SpindleAtSpeedTolerance:
available = hal.spindle.cap.at_speed;
available = hal.spindle.cap.at_speed || hal.driver_cap.spindle_sync;
break;
case Setting_SpindleOnDelay:
@@ -1733,7 +1747,8 @@ void settings_restore (settings_restore_t restore)
settings.spindle.invert.ccw &= spindle_get_caps().direction;
settings.spindle.invert.pwm &= spindle_get_caps().pwm_invert;
#ifdef ENABLE_BACKLASH_COMPENSATION
mc_backlash_init((axes_signals_t){AXES_BITMASK});
if(sys.driver_started)
mc_backlash_init((axes_signals_t){AXES_BITMASK});
#endif
settings_write_global();
}
@@ -2321,9 +2336,7 @@ void settings_init (void)
settings_read_tool_data(idx, &tool_table[idx]);
#endif
report_init();
#ifdef ENABLE_BACKLASH_COMPENSATION
mc_backlash_init((axes_signals_t){AXES_BITMASK});
#endif
hal.settings_changed(&settings);
if(hal.probe.configure) // Initialize probe invert mask.
+13 -1
View File
@@ -31,10 +31,10 @@
#include <math.h>
#include <string.h>
#include "hal.h"
#include "settings.h"
#include "planner.h"
#include "kinematics.h"
#include "hal.h"
#define A_MOTOR X_AXIS // Must be X_AXIS
#define B_MOTOR Y_AXIS // Must be Y_AXIS
@@ -58,6 +58,7 @@ typedef struct {
static bool jog_cancel = false;
static machine_t machine = {0};
static on_report_options_ptr on_report_options;
// Returns machine position in mm converted from system position steps.
// TODO: perhaps change to double precision here - float calculation results in errors of a couple of micrometers.
@@ -284,6 +285,14 @@ static void cancel_jog (sys_state_t state)
jog_cancel = true;
}
static void report_options (bool newopt)
{
on_report_options(newopt);
if(!newopt)
hal.stream.write("[KINEMATICS:WallPlotter v2.00]" ASCII_EOL);
}
// Initialize API pointers for Wall Plotter kinematics
void wall_plotter_init (void)
{
@@ -308,6 +317,9 @@ void wall_plotter_init (void)
kinematics.segment_line = wp_segment_line;
grbl.on_jog_cancel = cancel_jog;
on_report_options = grbl.on_report_options;
grbl.on_report_options = report_options;
}
#endif