Fixed polar kinematics feed rate handling, some tuning. Ref. issue #475.

Allowed plugins to inject commands when controller is in alarm state.
This commit is contained in:
Terje Io
2024-04-04 16:40:07 +02:00
parent c3aace735b
commit ec209ecba7
9 changed files with 65 additions and 26 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ It has been written to complement grblHAL and has features such as proper keyboa
---
Latest build date is 20240402, see the [changelog](changelog.md) for details.
Latest build date is 20240404, see the [changelog](changelog.md) for details.
__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.
+21 -1
View File
@@ -1,5 +1,25 @@
## grblHAL changelog
<a name="20240404"/>Build 20240404
Core:
* Fixed polar kinematics feed rate handling, some tuning. Ref. issue [#475](https://github.com/grblHAL/core/issues/475).
* Allowed plugins to inject commands when controller is in alarm state. Ref. keypad plugin issue [#11](https://github.com/grblHAL/Plugin_keypad/issues/11).
Drivers:
* STM32F1xx, STM32F3xx, STM32F4xx, STM32F7xx and iMXRT1062: now calls stepper enable via HAL. Ref. spindle issue [#28](https://github.com/grblHAL/Plugins_spindle/issues/28).
Plugins:
* Spindle: improved motor enable support for stepper spindle. Ref. issue [#28](https://github.com/grblHAL/Plugins_spindle/issues/28).
* Plasma: removed stray code causing compilation failure.
---
<a name="20240402"/>Build 20240402
Core:
@@ -12,7 +32,7 @@ Drivers:
* iMXRT1062: fixed typo in step inject code causing direction signal to fail for A+ axes.
Plugings:
Plugins:
* Spindle: added motor enable support for stepper spindle.
+1 -1
View File
@@ -42,7 +42,7 @@
#else
#define GRBL_VERSION "1.1f"
#endif
#define GRBL_BUILD 20240402
#define GRBL_BUILD 20240404
#define GRBL_URL "https://github.com/grblHAL"
+1 -1
View File
@@ -290,7 +290,7 @@ static float *delta_segment_line (float *target, float *position, plan_line_data
} else if(!pl_data->condition.rapid_motion && distance != 0.0f) {
float rate_multiplier = get_distance(mpos.values, machine.last_pos.values) / distance;
pl_data->feed_rate *= rate_multiplier;
pl_data->rate_multiplier = 1.0 / rate_multiplier;
pl_data->rate_multiplier = 1.0f / rate_multiplier;
}
memcpy(&machine.last_pos, &mpos, sizeof(coord_data_t));
+34 -15
View File
@@ -7,18 +7,18 @@
Note: homing is not implemented!
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/>.
*/
#include "../grbl.h"
@@ -39,6 +39,7 @@
static bool jog_cancel = false;
static coord_data_t last_pos = {0};
static on_program_completed_ptr on_program_completed;
static on_report_options_ptr on_report_options;
// Simple hypotenuse computation function.
@@ -68,17 +69,15 @@ static float *transform_to_cartesian (float *target, float *position)
// Returns machine position in mm converted from system position steps.
static float *polar_convert_array_steps_to_mpos (float *position, int32_t *steps)
{
float cpos[N_AXIS];
coord_data_t cpos;
uint_fast8_t idx = N_AXIS;
do {
idx--;
cpos[idx] = steps[idx] / settings.axis[idx].steps_per_mm;
cpos.values[idx] = steps[idx] / settings.axis[idx].steps_per_mm;
} while(idx);
return transform_to_cartesian(position, cpos);
return position;
return transform_to_cartesian(position, cpos.values);
}
// Transform absolute position from cartesian coordinate system to polar coordinate system
@@ -130,7 +129,6 @@ static float *polar_segment_line (float *target, float *position, plan_line_data
static bool segmented;
static float r_offset, distance;
static coord_data_t delta, segment_target, final_target, cpos;
// static plan_line_data_t plan;
uint_fast8_t idx = N_AXIS;
@@ -159,6 +157,8 @@ static float *polar_segment_line (float *target, float *position, plan_line_data
delta.values[idx] = delta.values[idx] / (float)iterations;
} while(idx);
distance /= (float)iterations;
} else {
iterations = 1;
memcpy(&segment_target, &final_target, sizeof(coord_data_t));
@@ -175,7 +175,6 @@ static float *polar_segment_line (float *target, float *position, plan_line_data
idx--;
segment_target.values[idx] += delta.values[idx];
} while(idx);
} else
memcpy(&segment_target, &final_target, sizeof(coord_data_t));
@@ -183,9 +182,11 @@ static float *polar_segment_line (float *target, float *position, plan_line_data
transform_from_cartesian(cpos.values, segment_target.values);
segment_target.values[RADIUS_AXIS] += r_offset;
if(!pl_data->condition.rapid_motion) {
float fr_mul = distance / get_distance(last_pos.values, cpos.values);
pl_data->feed_rate *= fr_mul == 0.0f ? 1.0 : (fr_mul < 0.5f ? 0.5f : fr_mul);
if(!pl_data->condition.rapid_motion && segmented) {
float rate_multiplier = get_distance(last_pos.values, cpos.values) / distance;
rate_multiplier = rate_multiplier == 0.0f ? 1.0 : (rate_multiplier < 0.5f ? 0.5f : rate_multiplier);
pl_data->feed_rate *= rate_multiplier;
pl_data->rate_multiplier = 1.0f / rate_multiplier;
}
memcpy(&last_pos, &cpos, sizeof(coord_data_t));
@@ -228,7 +229,7 @@ static void report_options (bool newopt)
on_report_options(newopt);
if(!newopt)
hal.stream.write("[KINEMATICS:Polar v0.01]" ASCII_EOL);
hal.stream.write("[KINEMATICS:Polar v0.02]" ASCII_EOL);
}
static bool polar_homing_cycle (axes_signals_t cycle, axes_signals_t auto_square)
@@ -238,6 +239,21 @@ static bool polar_homing_cycle (axes_signals_t cycle, axes_signals_t auto_square
return false;
}
static void onProgramCompleted (program_flow_t program_flow, bool check_mode)
{
coord_data_t cpos;
memset(last_pos.values, 0, sizeof(coord_data_t));
transform_from_cartesian(cpos.values, gc_state.position);
memcpy(&last_pos, &cpos, sizeof(coord_data_t));
sys.position[POLAR_AXIS] = lroundf(last_pos.values[POLAR_AXIS] * settings.axis[POLAR_AXIS].steps_per_mm);
plan_sync_position();
if(on_program_completed)
on_program_completed(program_flow, check_mode);
}
// Initialize API pointers for Wall Plotter kinematics
void polar_init (void)
{
@@ -251,6 +267,9 @@ void polar_init (void)
grbl.home_machine = polar_homing_cycle;
grbl.on_jog_cancel = cancel_jog;
on_program_completed = grbl.on_program_completed;
grbl.on_program_completed = onProgramCompleted;
on_report_options = grbl.on_report_options;
grbl.on_report_options = report_options;
}
+1 -1
View File
@@ -79,7 +79,7 @@ bool mc_line (float *target, plan_line_data_t *pl_data)
{
#ifdef KINEMATICS_API
float feed_rate = pl_data->feed_rate;
pl_data->rate_multiplier = 1.0;
pl_data->rate_multiplier = 1.0f;
target = kinematics.segment_line(target, plan_get_position(), pl_data, true);
#endif
+4 -4
View File
@@ -503,15 +503,15 @@ bool plan_buffer_line (float *target, plan_line_data_t *pl_data)
block->millimeters = convert_delta_vector_to_unit_vector(unit_vec);
block->acceleration = limit_acceleration_by_axis_maximum(unit_vec);
block->rapid_rate = limit_max_rate_by_axis_maximum(unit_vec);
#ifdef KINEMATICS_API
block->rate_multiplier = pl_data->rate_multiplier;
#endif
// Store programmed rate.
if (block->condition.rapid_motion)
block->programmed_rate = block->rapid_rate;
else {
block->programmed_rate = pl_data->feed_rate;
#ifdef KINEMATICS_API
block->rate_multiplier = pl_data->rate_multiplier;
#endif
if (block->condition.inverse_time)
block->programmed_rate *= block->millimeters;
}
@@ -692,6 +692,6 @@ void plan_data_init (plan_line_data_t *plan_data)
plan_data->spindle.hal = gc_state.spindle.hal ? gc_state.spindle.hal : spindle_get(0);
plan_data->condition.target_validated = plan_data->condition.target_valid = sys.soft_limits.mask == 0;
#ifdef KINEMATICS_API
plan_data->rate_multiplier = 1.0;
plan_data->rate_multiplier = 1.0f;
#endif
}
+1 -1
View File
@@ -74,7 +74,7 @@ static void protocol_exec_rt_suspend (sys_state_t state);
bool protocol_enqueue_gcode (char *gcode)
{
bool ok = xcommand[0] == '\0' &&
(state_get() == STATE_IDLE || (state_get() & (STATE_JOG|STATE_TOOL_CHANGE))) &&
(state_get() == STATE_IDLE || (state_get() & (STATE_ALARM|STATE_JOG|STATE_TOOL_CHANGE))) &&
bit_isfalse(sys.rt_exec_state, EXEC_MOTION_CANCEL);
if(ok && gc_state.file_run)
+1 -1
View File
@@ -1662,7 +1662,7 @@ static uint32_t get_int (setting_id_t id)
homing.use_limit_switches = settings.homing.flags.use_limit_switches;
value = homing.value;
#else
value = settings.homing.flags.enable;
value = settings.homing.flags.enabled;
#endif
break;