Skip to content

Commit

Permalink
Added faster soft limits check for arcs when work envelope is a cuboi…
Browse files Browse the repository at this point in the history
…d, fixed some related obscure bugs.

New/modified core entry points for soft limit checking.
More delta robot tuning, added setting warning in $DELTA output if some settings are inconsistent such as steps/rad, acceleration etc.
Fix for issue #361, HOME status is not reported or reported late when auto reporting is enabled with setting $481.
  • Loading branch information
terjeio committed Sep 14, 2023
1 parent 049f0f1 commit c3fd2db
Show file tree
Hide file tree
Showing 17 changed files with 337 additions and 93 deletions.
22 changes: 21 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
## grblHAL changelog

<a name="20230913"/>Build 20230913

Core:

* Added faster soft limits check for arcs when work envelope is a cuboid, fixed some related obscure bugs. New/modified core entry points for soft limit checking.

* More delta robot tuning, added setting warning in `$DELTA` output if some settings are inconsistent such as steps/rad, acceleration etc.

* Fix for issue [#361](https://github.com/grblHAL/core/issues/361), `HOME` status is not reported or reported late when auto reporting is enabled with setting `$481`.

Drivers:

* iMXRT1062: fix for MCP3221 ADC regression, [issue #68](https://github.com/grblHAL/iMXRT1062/issues/68#).

* STM32F4xx: SPI pin definition typo, [issue #139](https://github.com/grblHAL/STM32F4xx/issues/139).

* RP2040: workaround for [issue #74](https://github.com/grblHAL/RP2040/issues/74), odd TMC driver addressing.

* Remaining drivers updated for [improved handling of limit inputs](#20230903):

<a name="20230907"/>Build 20230907

Core:

* Delta robot kinematics tuning: soft limits checks, extended $DELTA command++. Still work in progress \(getting closer to working version\).
* Delta robot kinematics tuning: soft limits checks, extended `$DELTA` command++. Still work in progress \(getting closer to working version\).

Plugins:

Expand Down
5 changes: 4 additions & 1 deletion core_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ typedef struct {

typedef bool (*enqueue_gcode_ptr)(char *data);
typedef bool (*protocol_enqueue_realtime_command_ptr)(char c);
typedef bool (*travel_limits_ptr)(float *target, bool is_cartesian);
typedef bool (*travel_limits_ptr)(float *target, axes_signals_t axes, bool is_cartesian);
typedef bool (*arc_limits_ptr)(coord_data_t *target, coord_data_t *position, point_2d_t center, float radius, plane_t plane, int32_t turns);

typedef void (*jog_limits_ptr)(float *target, float *position);
typedef bool (*home_machine_ptr)(axes_signals_t cycle, axes_signals_t auto_square);

Expand Down Expand Up @@ -175,6 +177,7 @@ typedef struct {
// core entry points - set up by core before driver_init() is called.
home_machine_ptr home_machine;
travel_limits_ptr check_travel_limits;
arc_limits_ptr check_arc_travel_limits;
jog_limits_ptr apply_jog_limits;
enqueue_gcode_ptr enqueue_gcode;
enqueue_realtime_command_ptr enqueue_realtime_command;
Expand Down
13 changes: 7 additions & 6 deletions gcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2634,7 +2634,7 @@ status_code_t gc_execute_block (char *block)
float h_x2_div_d = 4.0f * gc_block.values.r * gc_block.values.r - x * x - y * y;

if (h_x2_div_d < 0.0f)
FAIL(Status_GcodeArcRadiusError); // [Arc radius error]
FAIL(Status_GcodeArcRadiusError); // [Arc radius error] TODO: this will fail due to limited float precision...

// Finish computing h_x2_div_d.
h_x2_div_d = -sqrtf(h_x2_div_d) / hypot_f(x, y); // == -(h * 2 / d)
Expand Down Expand Up @@ -2845,6 +2845,7 @@ status_code_t gc_execute_block (char *block)
// Initialize planner data struct for motion blocks.
plan_line_data_t plan_data;
memset(&plan_data, 0, sizeof(plan_line_data_t)); // Zero plan_data struct
plan_data.condition.target_validated = plan_data.condition.target_valid = sys.soft_limits.mask == 0;

// Intercept jog commands and complete error checking for valid jog commands and execute.
// NOTE: G-code parser state is not updated, except the position to ensure sequential jog
Expand Down Expand Up @@ -3339,16 +3340,16 @@ status_code_t gc_execute_block (char *block)
case MotionMode_CcwArc:
// fail if spindle synchronized motion?
mc_arc(gc_block.values.xyz, &plan_data, gc_state.position, gc_block.values.ijk, gc_block.values.r,
plane, gc_parser_flags.arc_is_clockwise ? gc_block.arc_turns : - gc_block.arc_turns);
plane, gc_parser_flags.arc_is_clockwise ? -gc_block.arc_turns : gc_block.arc_turns);
break;

case MotionMode_CubicSpline:
{
point_2d cp1 = {
point_2d_t cp1 = {
.x = gc_state.position[X_AXIS] + gc_block.values.ijk[X_AXIS],
.y = gc_state.position[Y_AXIS] + gc_block.values.ijk[Y_AXIS]
};
point_2d cp2 = {
point_2d_t cp2 = {
.x = gc_block.values.xyz[X_AXIS] + gc_state.modal.spline_pq[X_AXIS],
.y = gc_block.values.xyz[Y_AXIS] + gc_state.modal.spline_pq[Y_AXIS]
};
Expand All @@ -3358,11 +3359,11 @@ status_code_t gc_execute_block (char *block)

case MotionMode_QuadraticSpline:
{
point_2d cp1 = {
point_2d_t cp1 = {
.x = gc_state.position[X_AXIS] + (gc_block.values.ijk[X_AXIS] * 2.0f) / 3.0f,
.y = gc_state.position[Y_AXIS] + (gc_block.values.ijk[Y_AXIS] * 2.0f) / 3.0f
};
point_2d cp2 = {
point_2d_t cp2 = {
.x = gc_block.values.xyz[X_AXIS] + ((gc_state.position[X_AXIS] + gc_block.values.ijk[X_AXIS] - gc_block.values.xyz[X_AXIS]) * 2.0f) / 3.0f,
.y = gc_block.values.xyz[Y_AXIS] + ((gc_state.position[Y_AXIS] + gc_block.values.ijk[Y_AXIS] - gc_block.values.xyz[Y_AXIS]) * 2.0f) / 3.0f
};
Expand Down
11 changes: 7 additions & 4 deletions gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,13 @@ typedef struct {
} coord_system_t;

//! Axis index to plane assignment.
typedef struct {
uint8_t axis_0;
uint8_t axis_1;
uint8_t axis_linear;
typedef union {
uint8_t axis[3];
struct {
uint8_t axis_0;
uint8_t axis_1;
uint8_t axis_linear;
};
} plane_t;

/*! \brief G- and M-code parameter values
Expand Down
2 changes: 1 addition & 1 deletion grbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#else
#define GRBL_VERSION "1.1f"
#endif
#define GRBL_BUILD 20230907
#define GRBL_BUILD 20230913

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

Expand Down
Loading

0 comments on commit c3fd2db

Please sign in to comment.