mirror of
https://github.com/grblHAL/core.git
synced 2026-08-17 16:41:45 +08:00
Updated motion in units per revolution mode (G95) to handle spindle RPM changes.
Changed initial wait for two index pulses to check RPM > 0 before starting such motion.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
## grblHAL ##
|
||||
|
||||
Latest build date is 20250925, see the [changelog](changelog.md) for details.
|
||||
Latest build date is 20250926, 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.
|
||||
@@ -89,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.
|
||||
|
||||
---
|
||||
20250925
|
||||
20250926
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
## grblHAL changelog
|
||||
|
||||
<a name="20250926">Build 20250926
|
||||
|
||||
Core:
|
||||
|
||||
* Updated motion in units per revolution mode (G95) to handle spindle RPM changes. Changed initial wait for two index pulses to check RPM > 0 before starting such motion.
|
||||
|
||||
---
|
||||
|
||||
<a name="20250925">Build 20250925
|
||||
|
||||
Core:
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#else
|
||||
#define GRBL_VERSION "1.1f"
|
||||
#endif
|
||||
#define GRBL_BUILD 20250925
|
||||
#define GRBL_BUILD 20250926
|
||||
|
||||
#define GRBL_URL "https://github.com/grblHAL"
|
||||
|
||||
|
||||
@@ -615,7 +615,7 @@ ISR_CODE void task_delete (foreground_task_ptr fn, void *data)
|
||||
hal.irq_disable();
|
||||
|
||||
if((task = next_task)) do {
|
||||
if(fn == task->fn && data == task->data) {
|
||||
if(fn == task->fn && (data == NULL || data == task->data)) {
|
||||
if(prev)
|
||||
prev->next = task->next;
|
||||
else
|
||||
|
||||
+9
-9
@@ -171,7 +171,7 @@ static float tool_offset (ngc_param_id_t id)
|
||||
{
|
||||
uint_fast8_t axis = id % 10;
|
||||
|
||||
return axis <= N_AXIS ? gc_state.tool_length_offset[axis] : 0.0f;
|
||||
return _convert_pos(axis <= N_AXIS ? gc_state.tool_length_offset[axis] : 0.0f, axis);
|
||||
}
|
||||
|
||||
static float g28_home (ngc_param_id_t id)
|
||||
@@ -183,7 +183,7 @@ static float g28_home (ngc_param_id_t id)
|
||||
if(axis <= N_AXIS && settings_read_coord_data(CoordinateSystem_G28, &data.xyz))
|
||||
value = data.xyz[axis - 1];
|
||||
|
||||
return value;
|
||||
return _convert_pos(value, axis);
|
||||
}
|
||||
|
||||
static float g30_home (ngc_param_id_t id)
|
||||
@@ -195,13 +195,13 @@ static float g30_home (ngc_param_id_t id)
|
||||
#if COMPATIBILITY_LEVEL > 1
|
||||
if(id <= CoordinateSystem_G59) {
|
||||
#endif
|
||||
if (axis <= N_AXIS && settings_read_coord_data(CoordinateSystem_G30, &data.xyz))
|
||||
if(axis <= N_AXIS && settings_read_coord_data(CoordinateSystem_G30, &data.xyz))
|
||||
value = data.xyz[axis - 1];
|
||||
#if COMPATIBILITY_LEVEL > 1
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
return _convert_pos(value, axis);
|
||||
}
|
||||
|
||||
static float coord_system (ngc_param_id_t id)
|
||||
@@ -220,7 +220,7 @@ static float coord_system_offset (ngc_param_id_t id)
|
||||
if (axis > 0 && axis <= N_AXIS && settings_read_coord_data((coord_system_id_t)id, &data.xyz))
|
||||
value = data.xyz[axis - 1];
|
||||
|
||||
return value;
|
||||
return _convert_pos(value, axis);
|
||||
}
|
||||
|
||||
static float g92_offset_applied (ngc_param_id_t id)
|
||||
@@ -232,7 +232,7 @@ static float g92_offset (ngc_param_id_t id)
|
||||
{
|
||||
uint_fast8_t axis = id % 10;
|
||||
|
||||
return axis <= N_AXIS ? gc_state.g92_coord_offset [axis - 1] : 0.0f;
|
||||
return _convert_pos(axis <= N_AXIS ? gc_state.g92_coord_offset[axis - 1] : 0.0f, axis);
|
||||
}
|
||||
|
||||
static float work_position (ngc_param_id_t id)
|
||||
@@ -677,7 +677,7 @@ static char *ngc_name_tolower (char *s)
|
||||
static char name[NGC_MAX_PARAM_LENGTH + 1];
|
||||
|
||||
uint_fast8_t len = 0;
|
||||
char c, *s1 = s, *s2 = name;
|
||||
char c, *s1 = s, *s2 = name;
|
||||
|
||||
while((c = *s1++) && len <= NGC_MAX_PARAM_LENGTH) {
|
||||
if(c > ' ') {
|
||||
@@ -687,7 +687,7 @@ static char *ngc_name_tolower (char *s)
|
||||
}
|
||||
*s2 = '\0';
|
||||
|
||||
return name;
|
||||
return name;
|
||||
}
|
||||
|
||||
bool ngc_named_param_get (char *name, float *value)
|
||||
@@ -999,7 +999,7 @@ uint_fast8_t ngc_call_level (void)
|
||||
|
||||
uint8_t ngc_float_decimals (void)
|
||||
{
|
||||
return settings.flags.report_inches ? N_DECIMAL_COORDVALUE_INCH : N_DECIMAL_COORDVALUE_MM;
|
||||
return settings.flags.report_inches ? N_DECIMAL_COORDVALUE_INCH : N_DECIMAL_COORDVALUE_MM;
|
||||
}
|
||||
|
||||
static status_code_t macro_get_setting (void)
|
||||
|
||||
@@ -307,7 +307,7 @@ bool plan_check_full_buffer (void)
|
||||
float plan_compute_profile_nominal_speed (plan_block_t *block)
|
||||
{
|
||||
float nominal_speed = block->condition.units_per_rev || block->spindle.state.synchronized
|
||||
? block->programmed_rate * block->spindle.hal->get_data(SpindleData_RPM)->rpm
|
||||
? block->programmed_rate * (pl.actual_rpm = block->spindle.hal->get_data(SpindleData_RPM)->rpm)
|
||||
: block->programmed_rate;
|
||||
|
||||
if(block->condition.rapid_motion)
|
||||
@@ -711,6 +711,20 @@ static bool plan_update_velocity_profile_parameters (void)
|
||||
return block_buffer_tail != block_buffer_head;
|
||||
}
|
||||
|
||||
// Re-calulates feed rate on RPM changes for units per revolution blocks (G95)
|
||||
// Called periodically from stepper.c
|
||||
void plan_sync_velocity (void *block)
|
||||
{
|
||||
float rpm = ((plan_block_t *)block)->spindle.hal->get_data(SpindleData_RPM)->rpm;
|
||||
|
||||
if(pl.actual_rpm != rpm) {
|
||||
pl.actual_rpm = rpm;
|
||||
if(plan_update_velocity_profile_parameters())
|
||||
plan_cycle_reinitialize();
|
||||
} else
|
||||
task_add_delayed(plan_sync_velocity, block, 10);
|
||||
}
|
||||
|
||||
// Set feed overrides
|
||||
void plan_feed_override (override_t feed_override, override_t rapid_override)
|
||||
{
|
||||
|
||||
@@ -147,6 +147,7 @@ typedef struct {
|
||||
// i.e. arcs, canned cycles, and backlash compensation.
|
||||
float previous_unit_vec[N_AXIS]; // Unit vector of previous path line segment
|
||||
float previous_nominal_speed; // Nominal speed of previous path line segment
|
||||
float actual_rpm; // Updated when in units per revolution blocks (G95) mode.
|
||||
} planner_t;
|
||||
|
||||
// Initialize and reset the motion plan subsystem
|
||||
@@ -194,4 +195,6 @@ void plan_feed_override (override_t feed_override, override_t rapid_override);
|
||||
|
||||
void plan_data_init (plan_line_data_t *plan_data);
|
||||
|
||||
void plan_sync_velocity (void *block);
|
||||
|
||||
#endif
|
||||
|
||||
+20
-9
@@ -266,22 +266,33 @@ void state_set (sys_state_t new_state)
|
||||
if (block->spindle.hal->reset_data)
|
||||
block->spindle.hal->reset_data();
|
||||
|
||||
uint32_t index = block->spindle.hal->get_data(SpindleData_Counters)->index_count + 2;
|
||||
if(!block->condition.units_per_rev) {
|
||||
|
||||
while(index != block->spindle.hal->get_data(SpindleData_Counters)->index_count) {
|
||||
uint32_t index = block->spindle.hal->get_data(SpindleData_Counters)->index_count + 2;
|
||||
|
||||
if(hal.get_elapsed_ticks() - ms > 5000) {
|
||||
while(index != block->spindle.hal->get_data(SpindleData_Counters)->index_count) {
|
||||
|
||||
if(hal.get_elapsed_ticks() - ms > 5000) {
|
||||
system_raise_alarm(Alarm_Spindle);
|
||||
return;
|
||||
}
|
||||
|
||||
if(sys.rt_exec_state & (EXEC_RESET|EXEC_STOP)) {
|
||||
system_set_exec_state_flag(EXEC_RESET);
|
||||
return;
|
||||
}
|
||||
// TODO: allow real time reporting?
|
||||
}
|
||||
|
||||
if(block->spindle.hal->get_data(SpindleData_RPM)->rpm == 0.0f) {
|
||||
system_raise_alarm(Alarm_Spindle);
|
||||
return;
|
||||
}
|
||||
|
||||
if(sys.rt_exec_state & (EXEC_RESET|EXEC_STOP)) {
|
||||
system_set_exec_state_flag(EXEC_RESET);
|
||||
return;
|
||||
}
|
||||
// TODO: allow real time reporting?
|
||||
} else if(block->spindle.hal->get_data(SpindleData_RPM)->rpm == 0.0f) {
|
||||
system_raise_alarm(Alarm_Spindle);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
st_wake_up();
|
||||
stateHandler = state_cycle;
|
||||
|
||||
@@ -216,6 +216,8 @@ ISR_CODE void ISR_FUNC(st_go_idle)(void)
|
||||
stepping = false;
|
||||
hal.stepper.go_idle(false);
|
||||
|
||||
task_delete(plan_sync_velocity, NULL);
|
||||
|
||||
// Set stepper driver idle state, disabled or enabled, depending on settings and circumstances.
|
||||
if(((settings.steppers.idle_lock_time != 255) || sys.rt_exec_alarm || state == STATE_SLEEP) && state != STATE_HOMING) {
|
||||
if(settings.steppers.idle_lock_time == 0 || state == STATE_SLEEP)
|
||||
@@ -813,6 +815,9 @@ void st_prep_buffer (void)
|
||||
if (pl_block == NULL)
|
||||
return; // No planner blocks. Exit.
|
||||
|
||||
if(pl_block->condition.units_per_rev)
|
||||
task_add_delayed(plan_sync_velocity, pl_block, 10);
|
||||
|
||||
// Check if we need to only recompute the velocity profile or load a new block.
|
||||
if (prep.recalculate.velocity_profile) {
|
||||
if(settings.parking.flags.enabled) {
|
||||
@@ -1253,6 +1258,9 @@ void st_prep_buffer (void)
|
||||
// Check for exit conditions and flag to load next planner block.
|
||||
if (mm_remaining <= prep.mm_complete) {
|
||||
|
||||
if(pl_block->condition.units_per_rev)
|
||||
task_delete(plan_sync_velocity, NULL);
|
||||
|
||||
// End of planner block or forced-termination. No more distance to be executed.
|
||||
if (mm_remaining > 0.0f) { // At end of forced-termination.
|
||||
// Reset prep parameters for resuming and then bail. Allow the stepper ISR to complete
|
||||
|
||||
Reference in New Issue
Block a user