mirror of
https://github.com/grblHAL/core.git
synced 2026-03-27 10:47:56 +08:00
Changed core tool change routine to play nice with plugins subscribing to probe event.
This commit is contained in:
18
changelog.md
18
changelog.md
@@ -1,5 +1,23 @@
|
||||
## grblHAL changelog
|
||||
|
||||
<a name="20250126">Build 20250126
|
||||
|
||||
Core:
|
||||
|
||||
* Changed core tool change routine to play nice with plugins subscribing to probe event.
|
||||
|
||||
* Fixed typos in PR [#660](https://github.com/grblHAL/core/pull/660).
|
||||
|
||||
Drivers:
|
||||
|
||||
* STM32F4xx: updated the SuperLongBoard map.
|
||||
|
||||
Plugins:
|
||||
|
||||
* BLTouch: added `$BLRESET` command to reset the probe and stow of probe on soft reset.
|
||||
|
||||
---
|
||||
|
||||
<a name="20250124">Build 20250124
|
||||
|
||||
Core:
|
||||
|
||||
2
grbl.h
2
grbl.h
@@ -42,7 +42,7 @@
|
||||
#else
|
||||
#define GRBL_VERSION "1.1f"
|
||||
#endif
|
||||
#define GRBL_BUILD 20250124
|
||||
#define GRBL_BUILD 20250126
|
||||
|
||||
#define GRBL_URL "https://github.com/grblHAL"
|
||||
|
||||
|
||||
@@ -219,27 +219,27 @@ static aux_ctrl_t aux_ctrl[] = {
|
||||
// The following pins are bound explicitly to aux input pins
|
||||
#if PROBE_ENABLE && defined(PROBE_PIN) && defined(AUX_DEVICES)
|
||||
#ifdef PROBE_PORT
|
||||
{ .function = Input_Probe, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Rising|IRQ_Mode_Falling), .cap = { .value = 0 }, .pin = PROBE_PIN, .port = PROBE_PORT },
|
||||
{ .function = Input_Probe, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Rising|IRQ_Mode_Falling), .cap = { .value = 0 }, .pin = PROBE_PIN, .port = (void *)PROBE_PORT },
|
||||
#else
|
||||
{ .function = Input_Probe, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Rising|IRQ_Mode_Falling), .cap = { .value = 0 }, .pin = PROBE_PIN, .port = NULL },
|
||||
#endif
|
||||
#endif
|
||||
#if SAFETY_DOOR_ENABLE && defined(SAFETY_DOOR_PIN)
|
||||
#ifdef SAFETY_DOOR_PORT
|
||||
{ .function = Input_SafetyDoor, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Rising|IRQ_Mode_Falling), .cap = { .safety_door_ajar = On }, .pin = SAFETY_DOOR_PIN, .port = SAFETY_DOOR_PORT },
|
||||
{ .function = Input_SafetyDoor, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Rising|IRQ_Mode_Falling), .cap = { .safety_door_ajar = On }, .pin = SAFETY_DOOR_PIN, .port = (void *)SAFETY_DOOR_PORT },
|
||||
#else
|
||||
{ .function = Input_SafetyDoor, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Rising|IRQ_Mode_Falling), .cap = { .safety_door_ajar = On }, .pin = SAFETY_DOOR_PIN, .port = NULL },
|
||||
#endif
|
||||
#endif
|
||||
#if MOTOR_FAULT_ENABLE && defined(MOTOR_FAULT_PIN)
|
||||
#ifdef MOTOR_FAULT_PORT
|
||||
{ .function = Input_MotorFault, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Rising|IRQ_Mode_Falling), .cap = { .motor_fault = On }, .pin = MOTOR_FAULT_PIN, .port = MOTOR_FAULT_PORT },
|
||||
{ .function = Input_MotorFault, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Rising|IRQ_Mode_Falling), .cap = { .motor_fault = On }, .pin = MOTOR_FAULT_PIN, .port = (void *)MOTOR_FAULT_PORT },
|
||||
#else
|
||||
{ .function = Input_MotorFault, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Rising|IRQ_Mode_Falling), .cap = { .motor_fault = On }, .pin = MOTOR_FAULT_PIN, .port = NULL },
|
||||
#endif
|
||||
#if MOTOR_WARNING_ENABLE && defined(MOTOR_WARNING_PIN)
|
||||
#ifdef MOTOR_WARNING_PORT
|
||||
{ .function = Input_MotorWarning, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Rising|IRQ_Mode_Falling), .cap = { .motor_fault = On }, .pin = MOTOR_WARNING_PIN, .port = MOTOR_WARNING_PORT },
|
||||
{ .function = Input_MotorWarning, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Rising|IRQ_Mode_Falling), .cap = { .motor_fault = On }, .pin = MOTOR_WARNING_PIN, .port = (void *)MOTOR_WARNING_PORT },
|
||||
#else
|
||||
{ .function = Input_MotorWarning, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Rising|IRQ_Mode_Falling), .cap = { .motor_warning = On }, .pin = MOTOR_WARNING_PIN, .port = NULL },
|
||||
#endif
|
||||
@@ -247,21 +247,21 @@ static aux_ctrl_t aux_ctrl[] = {
|
||||
#endif
|
||||
#if I2C_STROBE_ENABLE && defined(I2C_STROBE_PIN) && defined(AUX_DEVICES)
|
||||
#ifdef I2C_STROBE_PORT
|
||||
{ .function = Input_I2CStrobe, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Change), .cap = { .value = 0 }, .pin = I2C_STROBE_PIN, .port = I2C_STROBE_PORT },
|
||||
{ .function = Input_I2CStrobe, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Change), .cap = { .value = 0 }, .pin = I2C_STROBE_PIN, .port = (void *)I2C_STROBE_PORT },
|
||||
#else
|
||||
{ .function = Input_I2CStrobe, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Change), .cap = { .value = 0 }, .pin = I2C_STROBE_PIN, .port = NULL },
|
||||
#endif
|
||||
#endif
|
||||
#if MPG_ENABLE == 1 && defined(MPG_MODE_PIN) && defined(AUX_DEVICES)
|
||||
#ifdef MPG_MODE_PORT
|
||||
{ .function = Input_MPGSelect, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Change), .cap = { .value = 0 }, .pin = MPG_MODE_PIN, .port = MPG_MODE_PORT },
|
||||
{ .function = Input_MPGSelect, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Change), .cap = { .value = 0 }, .pin = MPG_MODE_PIN, .port = (void *)MPG_MODE_PORT },
|
||||
#else
|
||||
{ .function = Input_MPGSelect, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Change), .cap = { .value = 0 }, .pin = MPG_MODE_PIN, .port = NULL },
|
||||
#endif
|
||||
#endif
|
||||
#if QEI_SELECT_ENABLE && defined(QEI_SELECT_PIN) && defined(AUX_DEVICES)
|
||||
#ifdef QEI_SELECT_PORT
|
||||
{ .function = Input_QEI_Select, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Rising|IRQ_Mode_Falling), .cap = { .value = 0 }, .pin = QEI_SELECT_PIN, .port = QEI_SELECT_PORT },
|
||||
{ .function = Input_QEI_Select, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Rising|IRQ_Mode_Falling), .cap = { .value = 0 }, .pin = QEI_SELECT_PIN, .port = (void *)QEI_SELECT_PORT },
|
||||
#else
|
||||
{ .function = Input_QEI_Select, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Rising|IRQ_Mode_Falling), .cap = { .value = 0 }, .pin = QEI_SELECT_PIN, .port = NULL },
|
||||
#endif
|
||||
@@ -415,38 +415,38 @@ static aux_ctrl_out_t aux_ctrl_out[] = {
|
||||
#ifndef SPINDLE_ENABLE_PORT
|
||||
#define SPINDLE_ENABLE_PORT NULL
|
||||
#endif
|
||||
{ .function = Output_SpindleOn, .aux_port = 0xFF, .pin = SPINDLE_ENABLE_PIN, .port = SPINDLE_ENABLE_PORT },
|
||||
{ .function = Output_SpindleOn, .aux_port = 0xFF, .pin = SPINDLE_ENABLE_PIN, .port = (void *)SPINDLE_ENABLE_PORT },
|
||||
#endif
|
||||
#ifdef SPINDLE_PWM_PIN
|
||||
#ifndef SPINDLE_PWM_PORT
|
||||
#define SPINDLE_PWM_PORT NULL
|
||||
#endif
|
||||
{ .function = Output_SpindlePWM, .aux_port = 0xFF, .pin = SPINDLE_PWM_PIN, .port = SPINDLE_PWM_PORT },
|
||||
{ .function = Output_SpindlePWM, .aux_port = 0xFF, .pin = SPINDLE_PWM_PIN, .port = (void *)SPINDLE_PWM_PORT },
|
||||
#endif
|
||||
#ifdef SPINDLE_DIRECTION_PIN
|
||||
#ifndef SPINDLE_DIRECTION_PORT
|
||||
#define SPINDLE_DIRECTION_PORT NULL
|
||||
#endif
|
||||
{ .function = Output_SpindleDir, .aux_port = 0xFF, .pin = SPINDLE_DIRECTION_PIN, .port = SPINDLE_DIRECTION_PORT },
|
||||
{ .function = Output_SpindleDir, .aux_port = 0xFF, .pin = SPINDLE_DIRECTION_PIN, .port = (void *)SPINDLE_DIRECTION_PORT },
|
||||
#endif
|
||||
|
||||
#ifdef SPINDLE1_ENABLE_PIN
|
||||
#ifndef SPINDLE1_ENABLE_PORT
|
||||
#define SPINDLE1_ENABLE_PORT NULL
|
||||
#endif
|
||||
{ .function = Output_Spindle1On, .aux_port = 0xFF, .pin = SPINDLE1_ENABLE_PIN, .port = SPINDLE1_ENABLE_PORT },
|
||||
{ .function = Output_Spindle1On, .aux_port = 0xFF, .pin = SPINDLE1_ENABLE_PIN, .port = (void *)SPINDLE1_ENABLE_PORT },
|
||||
#endif
|
||||
#ifdef SPINDLE1_PWM_PIN
|
||||
#ifndef SPINDLE1_PWM_PORT
|
||||
#define SPINDLE1_PWM_PORT NULL
|
||||
#endif
|
||||
{ .function = Output_Spindle1PWM, .aux_port = 0xFF, .pin = SPINDLE1_PWM_PIN, .port = SPINDLE1_PWM_PORT },
|
||||
{ .function = Output_Spindle1PWM, .aux_port = 0xFF, .pin = SPINDLE1_PWM_PIN, .port = (void *)SPINDLE1_PWM_PORT },
|
||||
#endif
|
||||
#ifdef SPINDLE1_DIRECTION_PIN
|
||||
#ifndef SPINDLE1_DIRECTION_PORT
|
||||
#define SPINDLE1_DIRECTION_PORT NULL
|
||||
#endif
|
||||
{ .function = Output_Spindle1Dir, .aux_port = 0xFF, .pin = SPINDLE1_DIRECTION_PIN, .port = SPINDLE1_DIRECTION_PORT },
|
||||
{ .function = Output_Spindle1Dir, .aux_port = 0xFF, .pin = SPINDLE1_DIRECTION_PIN, .port = (void *)SPINDLE1_DIRECTION_PORT },
|
||||
#endif
|
||||
#endif // SPINDLES
|
||||
|
||||
@@ -455,13 +455,13 @@ static aux_ctrl_out_t aux_ctrl_out[] = {
|
||||
#ifndef COOLANT_FLOOD_PORT
|
||||
#define COOLANT_FLOOD_PORT NULL
|
||||
#endif
|
||||
{ .function = Output_CoolantFlood, .aux_port = 0xFF, .pin = COOLANT_FLOOD_PIN, .port = COOLANT_FLOOD_PORT },
|
||||
{ .function = Output_CoolantFlood, .aux_port = 0xFF, .pin = COOLANT_FLOOD_PIN, .port = (void *)COOLANT_FLOOD_PORT },
|
||||
#endif
|
||||
#ifdef COOLANT_MIST_PIN
|
||||
#ifndef COOLANT_MIST_PORT
|
||||
#define COOLANT_MIST_PORT NULL
|
||||
#endif
|
||||
{ .function = Output_CoolantMist, .aux_port = 0xFF, .pin = COOLANT_MIST_PIN, .port = COOLANT_MIST_PORT },
|
||||
{ .function = Output_CoolantMist, .aux_port = 0xFF, .pin = COOLANT_MIST_PIN, .port = (void *)COOLANT_MIST_PORT },
|
||||
#endif
|
||||
#endif // COOLANT
|
||||
|
||||
@@ -469,13 +469,13 @@ static aux_ctrl_out_t aux_ctrl_out[] = {
|
||||
#ifndef COPROC_RESET_PORT
|
||||
#define COPROC_RESET_PORT NULL
|
||||
#endif
|
||||
{ .function = Output_CoProc_Reset, .aux_port = 0xFF, .pin = COPROC_RESET_PIN, .port = COPROC_RESET_PORT },
|
||||
{ .function = Output_CoProc_Reset, .aux_port = 0xFF, .pin = COPROC_RESET_PIN, .port = (void *)COPROC_RESET_PORT },
|
||||
#endif
|
||||
#ifdef COPROC_BOOT0_PIN
|
||||
#ifndef COPROC_BOOT0_PORT
|
||||
#define COPROC_BOOT0_PORT NULL
|
||||
#endif
|
||||
{ .function = Output_CoProc_Boot0, .aux_port = 0xFF, .pin = COPROC_BOOT0_PIN, .port = COPROC_BOOT0_PORT },
|
||||
{ .function = Output_CoProc_Boot0, .aux_port = 0xFF, .pin = COPROC_BOOT0_PIN, .port = (void *)COPROC_BOOT0_PORT },
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -556,7 +556,7 @@ bool plan_buffer_line (float *target, plan_line_data_t *pl_data)
|
||||
// Profiles are calculated as symmetrical (calculate to 1/2 programmed rate, then double)
|
||||
float time_to_max_accel = block->max_acceleration / block->jerk; // unit: min - time it takes to reach max acceleration
|
||||
float speed_after_jerkramp = 0.5f * block->jerk * time_to_max_accel * time_to_max_accel; // unit: mm / min - velocity after one completed jerk ramp up - Vt = V0 + A0T + 1/2 jerk*T
|
||||
if (0.5*block->programmed_rate > speed_after_jerkramp)
|
||||
if(0.5f * block->programmed_rate > speed_after_jerkramp)
|
||||
// Profile time = 2x (1 complete jerk ramp + additional time at max_accel to reach desired speed)
|
||||
block->acceleration = block->programmed_rate / (2.0f *(time_to_max_accel + (0.5f * block->programmed_rate - speed_after_jerkramp) / block->max_acceleration));
|
||||
else
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#if ENABLE_SPINDLE_LINEARIZATION
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "hal.h"
|
||||
#include "protocol.h"
|
||||
|
||||
@@ -875,7 +875,7 @@ void st_prep_buffer (void)
|
||||
float speed_var; // Speed worker variable
|
||||
float mm_remaining = pl_block->millimeters; // New segment distance from end of block.
|
||||
float minimum_mm = mm_remaining - prep.req_mm_increment; // Guarantee at least one step.
|
||||
#if ENABLE_ACCELERATION_PROFILES
|
||||
#if ENABLE_JERK_ACCELERATION
|
||||
float time_to_jerk; // time needed for jerk ramp
|
||||
float jerk_rampdown; // calculated startpoint of jerk rampdown
|
||||
#endif
|
||||
|
||||
@@ -48,6 +48,7 @@ static driver_reset_ptr driver_reset = NULL;
|
||||
static enqueue_realtime_command_ptr enqueue_realtime_command = NULL;
|
||||
static control_signals_callback_ptr control_interrupt_callback = NULL;
|
||||
static on_homing_completed_ptr on_homing_completed = NULL;
|
||||
static on_probe_completed_ptr on_probe_completed;
|
||||
|
||||
// Clear tool length offset on homing
|
||||
static void tc_on_homing_complete (axes_signals_t homing_cycle, bool success)
|
||||
@@ -61,7 +62,7 @@ static void tc_on_homing_complete (axes_signals_t homing_cycle, bool success)
|
||||
|
||||
// Set tool offset on successful $TPW probe, prompt for retry on failure.
|
||||
// Called via probe completed event.
|
||||
static void on_probe_completed (void)
|
||||
static void onProbeCompleted (void)
|
||||
{
|
||||
if(!sys.flags.probe_succeeded)
|
||||
grbl.report.feedback_message(Message_ProbeFailedRetry);
|
||||
@@ -92,7 +93,9 @@ static void change_completed (void)
|
||||
if(probe_toolsetter)
|
||||
grbl.on_probe_toolsetter(¤t_tool, NULL, true, false);
|
||||
|
||||
grbl.on_probe_completed = NULL;
|
||||
if(grbl.on_probe_completed == onProbeCompleted)
|
||||
grbl.on_probe_completed = on_probe_completed;
|
||||
|
||||
gc_state.tool_change = probe_toolsetter = false;
|
||||
|
||||
#ifndef NO_SAFETY_DOOR_SUPPORT
|
||||
@@ -358,8 +361,10 @@ 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 = on_probe_completed;
|
||||
if(settings.tool_change.mode != ToolChange_SemiAutomatic && grbl.on_probe_completed != onProbeCompleted) {
|
||||
on_probe_completed = grbl.on_probe_completed;
|
||||
grbl.on_probe_completed = onProbeCompleted;
|
||||
}
|
||||
|
||||
block_cycle_start = settings.tool_change.mode != ToolChange_SemiAutomatic;
|
||||
|
||||
@@ -474,7 +479,7 @@ void tc_init (void)
|
||||
}
|
||||
|
||||
// Perform a probe cycle: set tool length offset and restart job if successful.
|
||||
// Note: tool length offset is set by the on_probe_completed event handler.
|
||||
// Note: tool length offset is set by the onProbeCompleted event handler.
|
||||
// Called by the $TPW system command.
|
||||
status_code_t tc_probe_workpiece (void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user