Improved grbl.on_probe_fixture event signature, some minor fixes

This commit is contained in:
Terje Io
2021-10-15 09:54:33 +02:00
parent 79882cf094
commit 465cdd32a3
11 changed files with 88 additions and 14 deletions
+2 -2
View File
@@ -11,7 +11,7 @@ It has been written to complement grblHAL and has features such as proper keyboa
---
Latest build date is 20211010, see the [changelog](changelog.md) for details.
Latest build date is 20211015, see the [changelog](changelog.md) for details.
__NOTE:__ Drivers built with more than three axes configured \(`N_AXIS` > `3`\) will force a settings reset when upgraded. Backup and restore of settings is recommended for these.
---
@@ -80,4 +80,4 @@ List of Supported G-Codes:
Some [plugins](https://github.com/grblHAL/plugins) implements additional M-codes.
---
2021-10-10
2021-10-15
+19 -1
View File
@@ -1,10 +1,28 @@
## grblHAL changelog
Build 2021015:
Core:
* Improved `grbl.on_probe_fixture` event signature by adding pointer to the pending tool when fired when M6 is executing \(NULL if not\) and a flag indicating that the current XY-position is within 5mm of G59.3.
* A few minor fixes.
Plugins:
* I2C keypad: Switch to metric mode when jogging.
* WebUI: added option to store read-only webui files in flash.
Templates:
* Updated the [probe select](https://github.com/grblHAL/Templates/blob/master/my_plugin/probe%20select/my_plugin.c) example for the `grbl.on_probe_fixture` signature change and added an optional mode select parameter to M401.
---
Build 2021010:
Core:
* Added enum and associated get function for system defined named parameters.
* Added events (function pointers) for tool change mode 2 and 3 events (can be used to switch between probes) and for publishing active homing feedrate.
* Added events (function pointers) for tool change mode 2 and 3 events \(can be used to switch between probes\) and for publishing active homing feedrate.
Drivers:
* Improved stream support in many drivers by adding support for _write_n_ characters. This is mainly used for outputting human readable settings descriptions.
+13 -1
View File
@@ -361,6 +361,14 @@ __NOTE:__ these definitions are only referenced in this file. Do __NOT__ change!
//#define DEFAULT_TOOLCHANGE_SEEK_RATE 200.0f // mm/min
//#define DEFAULT_TOOLCHANGE_PULLOFF_RATE 200.0f // mm/min
// The grbl.on_probe_fixture event handler is called by the default tool change algorithm when probing at G59.3.
// In addition it will be called on a "normal" probe sequence if the XY position is
// within the radius of the G59.3 position defined below.
// Uncomment and change if the default value of 5mm is not suitable or set it to 0.0f to disable.
// NOTE: A grbl.on_probe_fixture event handler is not installed by the core, it has to be provided
// by a driver or a plugin.
//#define TOOLSETTER_RADIUS 5.0f
// By default, Grbl sets all input pins to normal-low operation with their internal pull-up resistors
// enabled. This simplifies the wiring for users by requiring only a normally closed (NC) switch connected
// to ground. It is not recommended to use normally-open (NO) switches as this increases the risk
@@ -642,6 +650,10 @@ __NOTE:__ these definitions are only referenced in this file. Do __NOT__ change!
#endif // DEFAULT_HOMING_ENABLE
// Uncomment to enable experimental support for parameters and expressions
#define NGC_EXPRESSIONS_ENABLE 1
//#define NGC_EXPRESSIONS_ENABLE 1
#ifndef TOOLSETTER_RADIUS
#define TOOLSETTER_RADIUS 5.0f // Default value - do not change here!
#endif
#endif
+1 -1
View File
@@ -80,7 +80,7 @@ typedef void (*on_unknown_feedback_message_ptr)(stream_write_ptr stream_write);
typedef void (*on_stream_changed_ptr)(stream_type_t type);
typedef bool (*on_laser_ppi_enable_ptr)(uint_fast16_t ppi, uint_fast16_t pulse_length);
typedef void (*on_homing_rate_set_ptr)(axes_signals_t axes, float rate);
typedef void (*on_probe_fixture_ptr)(bool on);
typedef bool (*on_probe_fixture_ptr)(tool_data_t *tool, bool at_g59_3, bool on);
typedef status_code_t (*on_unknown_sys_command_ptr)(sys_state_t state, char *line); // return Status_Unhandled.
typedef status_code_t (*on_user_command_ptr)(char *line);
typedef sys_commands_t *(*on_get_commands_ptr)(void);
+1 -1
View File
@@ -34,7 +34,7 @@
#else
#define GRBL_VERSION "1.1f"
#endif
#define GRBL_VERSION_BUILD "20211010"
#define GRBL_VERSION_BUILD "20211015"
// The following symbols are set here if not already set by the compiler or in config.h
// Do NOT change here!
+14 -3
View File
@@ -792,7 +792,7 @@ status_code_t mc_homing_cycle (axes_signals_t cycle)
gc_state.modal.coolant.mask = 0;
coolant_set_state(gc_state.modal.coolant);
// -------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// Perform homing routine. NOTE: Special motion case. Only system reset works.
if (!home_all) // Perform homing cycle based on mask.
@@ -835,7 +835,7 @@ status_code_t mc_homing_cycle (axes_signals_t cycle)
}
// Homing cycle complete! Setup system for normal operation.
// -------------------------------------------------------------------------------------
// ---------------------------------------------------------
// Sync gcode parser and planner positions to homed position.
sync_position();
@@ -848,7 +848,6 @@ status_code_t mc_homing_cycle (axes_signals_t cycle)
: Status_OK;
}
// Perform tool length probe cycle. Requires probe switch.
// NOTE: Upon probe failure, the program will be stopped and placed into ALARM state.
gc_probe_t mc_probe_cycle (float *target, plan_line_data_t *pl_data, gc_parser_flags_t parser_flags)
@@ -882,6 +881,13 @@ gc_probe_t mc_probe_cycle (float *target, plan_line_data_t *pl_data, gc_parser_f
// Activate the probing state monitor in the stepper module.
sys.probing_state = Probing_Active;
#if COMPATIBILITY_LEVEL <= 1
bool at_g59_3 = false, probe_fixture = grbl.on_probe_fixture != NULL && state_get() != STATE_TOOL_CHANGE;
if(probe_fixture)
grbl.on_probe_fixture(NULL, at_g59_3 = system_xy_at_fixture(CoordinateSystem_G59_3, TOOLSETTER_RADIUS), true);
#endif
// Perform probing cycle. Wait here until probe is triggered or motion completes.
system_set_exec_state_flag(EXEC_CYCLE_START);
do {
@@ -904,6 +910,11 @@ gc_probe_t mc_probe_cycle (float *target, plan_line_data_t *pl_data, gc_parser_f
hal.probe.configure(false, false); // Re-initialize invert mask.
protocol_execute_realtime(); // Check and execute run-time commands
#if COMPATIBILITY_LEVEL <= 1
if(probe_fixture)
grbl.on_probe_fixture(NULL, at_g59_3, false);
#endif
// Reset the stepper and planner buffers to remove the remainder of the probe motion.
st_reset(); // Reset step segment buffer.
plan_reset(); // Reset planner buffer. Zero planner positions. Ensure probing motion is cleared.
+1 -1
View File
@@ -254,7 +254,7 @@ static status_code_t execute_unary (float *operand, ngc_unary_op_t operation)
break;
case NGCUnaryOp_FIX:
*operand = floor(*operand);
*operand = floorf(*operand);
break;
case NGCUnaryOp_FUP:
+5
View File
@@ -57,6 +57,11 @@
#endif
#endif
#ifdef __MSP430F5529__
#define isnanf(x) __isnanf(x)
#define isinff(x) __isinff(x)
#endif
// Axis array index values. Must start with 0 and be continuous.
#define X_AXIS 0 // Axis indexing value.
#define Y_AXIS 1
+23
View File
@@ -83,6 +83,12 @@ static status_code_t set_startup_line1 (sys_state_t state, char *args);
static status_code_t output_memmap (sys_state_t state, char *args);
#endif
// Simple hypotenuse computation function.
inline static float hypot_f (float x, float y)
{
return sqrtf(x*x + y*y);
}
// Pin change interrupt for pin-out commands, i.e. cycle start, feed hold, and reset. Sets
// only the realtime command execute variable to have the main program execute these when
// its ready. This works exactly like the character-based realtime commands when picked off
@@ -898,6 +904,23 @@ void system_convert_array_steps_to_mpos (float *position, int32_t *steps)
#endif
}
// Checks if XY position is within coordinate system XY with given tolerance.
// If tolerance is 0 false is returned.
bool system_xy_at_fixture (coord_system_id_t id, float tolerance)
{
bool ok = false;
coord_data_t target, position;
if(tolerance > 0.0f && settings_read_coord_data(id, &target.values)) {
system_convert_array_steps_to_mpos(position.values, sys.position);
ok = hypot_f(position.x - target.x, position.y - target.y) <= tolerance;
}
return ok;
}
// Checks and reports if target array exceeds machine travel limits. Returns false if check failed.
// NOTE: max_travel is stored as negative
// TODO: only check homed axes?
+3
View File
@@ -287,6 +287,9 @@ void system_flag_wco_change (void);
//! Updates a machine 'position' array based on the 'step' array sent.
void system_convert_array_steps_to_mpos (float *position, int32_t *steps);
//! Checks if XY position is within coordinate system XY with given tolerance.
bool system_xy_at_fixture (coord_system_id_t id, float tolerance);
//! Checks and reports if target array exceeds machine travel limits.
bool system_check_travel_limits (float *target);
+6 -4
View File
@@ -79,7 +79,7 @@ static void change_completed (void)
}
if(probe_fixture)
grbl.on_probe_fixture(false);
grbl.on_probe_fixture(&current_tool, true, false);
grbl.on_probe_completed = NULL;
gc_state.tool_change = probe_fixture = false;
@@ -175,7 +175,7 @@ static void execute_probe (sys_state_t state)
gc_parser_flags_t flags = {0};
if(probe_fixture)
grbl.on_probe_fixture(true);
grbl.on_probe_fixture(next_tool, true, true);
// G59.3 contains offsets to position of TLS.
settings_read_coord_data(CoordinateSystem_G59_3, &offset.values);
@@ -328,7 +328,9 @@ static status_code_t tool_change (parser_state_t *parser_state)
execute_posted = false;
probe_fixture = grbl.on_probe_fixture != NULL &&
(settings.tool_change.mode == ToolChange_Manual_G59_3 || settings.tool_change.mode == ToolChange_SemiAutomatic);
(settings.tool_change.mode == ToolChange_Manual ||
settings.tool_change.mode == ToolChange_Manual_G59_3 ||
settings.tool_change.mode == ToolChange_SemiAutomatic);
parser_state->tool_change = true;
// Save current position.
@@ -443,7 +445,7 @@ status_code_t tc_probe_workpiece (void)
plan_line_data_t plan_data = {0};
if(probe_fixture)
grbl.on_probe_fixture(true);
grbl.on_probe_fixture(next_tool, system_xy_at_fixture(CoordinateSystem_G59_3, TOOLSETTER_RADIUS), true);
// Get current position.
system_convert_array_steps_to_mpos(target.values, sys.position);