From 6948b0e117118de30fdd830f678a221b21e53276 Mon Sep 17 00:00:00 2001 From: Terje Io Date: Thu, 15 May 2025 06:23:17 +0200 Subject: [PATCH] Added initial/enhanced support for toolsetter and second probe input. Moved inbuilt G65 macros to the core and added macro G65P5Q for selecting probe. Added probe id to real time report: |P: will be reported on probe select when more than one probe is available. Fix for WCO and Ov real time status report elements not beeing reported as they should in some circumstances. --- README.md | 2 +- changelog.md | 30 ++++++++++ crossbar.h | 4 ++ driver_opts.h | 17 ++++-- expanders_init.h | 22 +++++-- gcode.c | 29 +++++---- grbl.h | 2 +- grbllib.c | 13 ++++ hal.h | 20 +++++-- ioports.c | 11 ++-- motion_control.c | 41 ++++++++----- ngc_params.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++ ngc_params.h | 11 ++++ pin_bits_masks.h | 12 ++++ planner.h | 3 +- plugins_init.h | 5 ++ probe.h | 13 +++- protocol.c | 1 + report.c | 103 +++++++++++++++++++------------- settings.c | 107 ++++++++++++--------------------- settings.h | 7 ++- spindle_control.c | 2 +- system.c | 5 ++ system.h | 8 ++- tool_change.c | 10 ++-- 25 files changed, 453 insertions(+), 172 deletions(-) diff --git a/README.md b/README.md index c346e87..3fec15b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## grblHAL ## -Latest build date is 20250425, see the [changelog](changelog.md) for details. +Latest build date is 20250514, 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. diff --git a/changelog.md b/changelog.md index 89bc4a9..0519487 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,35 @@ ## grblHAL changelog +Build 20250514 + +Core: + +* Added initial/enhanced support for toolsetter and second probe input. +When more than one probe is available `PROBES:` is added to the `NEWOPTS` element in the `$I` report. `` is a bitfield where each bit set represents an available probe. + +* Moved inbuilt G65 macros to the core and added macro `G65P5Q` for selecting probe. `` is the probe id: `0` - primary probe, `1` - toolsetter, `2` - secondary probe. + +* Added probe id to real time report: `|P:` will be reported on probe select when more than one probe is available. + +* Fix for `WCO` and `Ov` real time status report elements not beeing reported as they should in some circumstances. + +Drivers: + +* All: fix for potential/actual hard fault when a basic on/off spindle is configured. Ref. ESP32 issue [#164](https://github.com/grblHAL/ESP32/issues/164). + +* STM32 drivers: fix for incorrect PWM output at max RPM when PWM output is inverted. + +Plugins: + +* Misc, probe relays: new plugin, can be configured to share the \(single\) probe input between up to three probes. +Probe switching is by the inbuilt `G65P5Q` macro or automatically on "@G59.3" tool changes for a toolsetter. One or two free auxiliary output ports required. + +* Misc, BLTouch: improved auto deploy capability. + +* SDCard, macros: moved inbuilt G65 macros to the core. + +--- + 20250504 Plugins: diff --git a/crossbar.h b/crossbar.h index b051486..de2437b 100644 --- a/crossbar.h +++ b/crossbar.h @@ -53,6 +53,8 @@ typedef enum { Input_MotorFaultX_2, Input_MotorFaultY_2, Input_MotorFaultZ_2, + Input_Probe2, + Input_Probe2Overtravel, Input_Toolsetter, Input_ToolsetterOvertravel, Input_MPGSelect, @@ -300,6 +302,8 @@ PROGMEM static const pin_name_t pin_names[] = { { .function = Input_MotorFaultX_2, .name = "X motor fault 2" }, { .function = Input_MotorFaultY_2, .name = "Y motor fault 2" }, { .function = Input_MotorFaultZ_2, .name = "Z motor fault 2" }, + { .function = Input_Probe2, .name = "Probe 2" }, + { .function = Input_Probe2Overtravel, .name = "Probe 2 overtravel" }, { .function = Input_Toolsetter, .name = "Toolsetter" }, { .function = Input_ToolsetterOvertravel, .name = "Toolsetter overtravel" }, { .function = Input_MPGSelect, .name = "MPG mode select" }, diff --git a/driver_opts.h b/driver_opts.h index 0229df8..3a376da 100644 --- a/driver_opts.h +++ b/driver_opts.h @@ -29,6 +29,11 @@ #include "hal.h" #include "nuts_bolts.h" + +#define MODBUS_RTU_ENABLED 0b001 +#define MODBUS_RTU_DIR_ENABLED 0b010 +#define MODBUS_TCP_ENABLED 0b100 + #include "expanders_init.h" #ifdef OPTS_POSTPROCESSING @@ -393,10 +398,6 @@ #endif #endif -#define MODBUS_RTU_ENABLED 0b001 -#define MODBUS_RTU_DIR_ENABLED 0b010 -#define MODBUS_TCP_ENABLED 0b100 - #if MODBUS_ENABLE == 2 #undef MODBUS_ENABLE #define MODBUS_ENABLE 0b011 @@ -476,6 +477,14 @@ #define LIMITS_OVERRIDE_ENABLE 0 #endif +#ifndef PROBE2_ENABLE +#define PROBE2_ENABLE 0 +#endif + +#ifndef TOOLSETTER_ENABLE +#define TOOLSETTER_ENABLE 0 +#endif + #if SAFETY_DOOR_ENABLE && defined(NO_SAFETY_DOOR_SUPPORT) #error "Driver does not support safety door functionality!" #endif diff --git a/expanders_init.h b/expanders_init.h index 472fd64..446adbb 100644 --- a/expanders_init.h +++ b/expanders_init.h @@ -63,17 +63,24 @@ extern void pca9654e_init(void); // ModBus expanders +#if PICOHAL_IO_ENABLE || R4SLS08_ENABLE +#if !defined(MODBUS_ENABLE) || !(MODBUS_ENABLE & MODBUS_RTU_ENABLED) +#error "Enabled IO expander(s) require Modbus RTU!" +#endif + +#if R4SLS08_ENABLE +extern void r4sls08_init (void); +#endif + +// Third party Modbus expander plugins goes after this line #if PICOHAL_IO_ENABLE - -#if !MODBUS_ENABLE -#error "Modbus must be enabled to use the Picohal IO expander!" -#endif - extern void picohal_io_init (void); #endif +#endif // ModBus expanders + // CANBus expanders // @@ -94,6 +101,10 @@ static inline void io_expanders_init (void) mcp4725_init(); #endif +#if R4SLS08_ENABLE + r4sls08_init(); +#endif + #if PCA9654E_ENABLE pca9654e_init(); #endif @@ -101,5 +112,4 @@ static inline void io_expanders_init (void) #if PICOHAL_IO_ENABLE picohal_io_init(); #endif - } diff --git a/gcode.c b/gcode.c index 52b6980..8e40900 100644 --- a/gcode.c +++ b/gcode.c @@ -393,7 +393,7 @@ void gc_init (bool stop) ngc_flowctrl_init(); #endif #if NGC_PARAMETERS_ENABLE - ngc_modal_state_invalidate(); + ngc_params_init(); #endif #if ENABLE_ACCELERATION_PROFILES gc_state.modal.acceleration_factor = gc_get_accel_factor(0); // Initialize machine with default @@ -762,15 +762,7 @@ status_code_t gc_execute_block (char *block) DCRAM static parser_block_t gc_block; -#if NGC_EXPRESSIONS_ENABLE - - static const parameter_words_t o_label = { - .o = On - }; - - static ngc_param_t ngc_params[NGC_N_ASSIGN_PARAMETERS_PER_BLOCK]; - - uint_fast8_t ngc_param_count = 0; +#if NGC_PARAMETERS_ENABLE // NOTE: this array has to match the parameter_words_t order! PROGMEM static const gc_value_ptr_t gc_value_ptr[] = { @@ -823,7 +815,19 @@ status_code_t gc_execute_block (char *block) { &gc_block.values.xyz[Z_AXIS], ValueType_Float } }; -#endif +#endif // NGC_PARAMETERS_ENABLE + +#if NGC_EXPRESSIONS_ENABLE + + static const parameter_words_t o_label = { + .o = On + }; + + static ngc_param_t ngc_params[NGC_N_ASSIGN_PARAMETERS_PER_BLOCK]; + + uint_fast8_t ngc_param_count = 0; + +#endif // NGC_EXPRESSIONS_ENABLE char *message = NULL; status_code_t status = Status_OK; @@ -2530,8 +2534,7 @@ status_code_t gc_execute_block (char *block) #if NGC_PARAMETERS_ENABLE if(!ngc_call_push(&gc_state + ngc_call_level())) FAIL(Status_FlowControlStackOverflow); // [Call level too deep] -#endif -#if NGC_EXPRESSIONS_ENABLE + // TODO: add context for local storage? { uint_fast8_t idx = 1; diff --git a/grbl.h b/grbl.h index 6b8ffa3..4eab895 100644 --- a/grbl.h +++ b/grbl.h @@ -42,7 +42,7 @@ #else #define GRBL_VERSION "1.1f" #endif -#define GRBL_BUILD 20250425 +#define GRBL_BUILD 20250514 #define GRBL_URL "https://github.com/grblHAL" diff --git a/grbllib.c b/grbllib.c index a49762f..fc92974 100644 --- a/grbllib.c +++ b/grbllib.c @@ -190,6 +190,16 @@ static void onLinestateChanged (serial_linestate_t state) on_linestate_changed(state); } +static bool onProbeToolsetter (tool_data_t *tool, coord_data_t *position, bool at_g59_3, bool on) +{ + bool ok = false; + + if(at_g59_3 && settings.probe.toolsetter_auto_select) + ok = hal.probe.select(on ? Probe_Toolsetter : Probe_Default); + + return ok; +} + static void settings_changed (settings_t *settings, settings_changed_flags_t changed) { hal_settings_changed(settings, changed); @@ -381,6 +391,9 @@ int grbl_enter (void) hal.stream.on_linestate_changed = onLinestateChanged; } + if(grbl.on_probe_toolsetter == NULL && hal.driver_cap.toolsetter && hal.probe.select) + grbl.on_probe_toolsetter = onProbeToolsetter; + // Initialization loop upon power-up or a system abort. For the latter, all processes // will return to this loop to be cleanly re-initialized. while(looping) { diff --git a/hal.h b/hal.h index 17fbfe9..ed8c4c1 100644 --- a/hal.h +++ b/hal.h @@ -68,11 +68,13 @@ typedef union { no_gcode_message_handling :1, odometers :1, pwm_spindle :1, - probe_latch :1, + probe_latch :1, //!< Deprecated. toolsetter :1, //!< Toolsetter (2nd probe) input is supported. + probe2 :1, //!< 2nd or 3rd probe input is supported. rtc :1, rtc_set :1, - unassigned :7; + bltouch_probe :1, + unassigned :6; }; } driver_cap_t; @@ -358,9 +360,9 @@ typedef struct { } delay_t; -/*********** - * Probe * - ***********/ +/************ + * Probes * + ************/ /*! \brief Pointer to function for getting probe status. \returns probe state in a \a #probe_state_t union. @@ -375,8 +377,15 @@ typedef probe_state_t (*probe_get_state_ptr)(void); */ typedef void (*probe_configure_ptr)(bool is_probe_away, bool probing); +/*! \brief Pointer to function for selecting probe input. +\param probe_id probe number. 0 - default probe, 1 - toolsetter, ... +\returns true if selectetion succeded, false otherwise. +*/ +typedef bool (*probe_select_ptr)(probe_id_t probe_id); + /*! \brief Pointer to function for toggling probe connected status. + If the driver does not support a probe connected input signal this can be used to implement toggling of probe connected status via a #CMD_PROBE_CONNECTED_TOGGLE real time command. */ @@ -386,6 +395,7 @@ typedef void (*probe_connected_toggle_ptr)(void); typedef struct { probe_configure_ptr configure; //!< Optional handler for setting probe operation mode. probe_get_state_ptr get_state; //!< Optional handler for getting probe status. Called from interrupt context. + probe_select_ptr select; //!< Optional handler for selecting probe to use. probe_connected_toggle_ptr connected_toggle; //!< Optional handler for toggling probe connected status. } probe_ptrs_t; diff --git a/ioports.c b/ioports.c index b35be10..9186b25 100644 --- a/ioports.c +++ b/ioports.c @@ -303,8 +303,10 @@ xbar_t *ioport_claim (io_port_type_t type, io_port_direction_t dir, uint8_t *por if(get_hcount(type, dir) == hcnt) dec_hcount(type, dir); - } else + } else { portinfo = NULL; + *port = IOPORT_UNASSIGNED; + } } return portinfo; @@ -1386,11 +1388,8 @@ static void ioports_configure (settings_t *settings) out_config.inverted = (settings->ioport.invert_out.mask & (1 << port)) && is_aux(cfg, xbar->function); out_config.open_drain = !!(settings->ioport.od_enable_out.mask & (1 << port)); xbar->config(xbar, &out_config, false); - } else { // TODO: same for inputs? - ioport_bus_t bus; - bus.mask = cfg->bus.mask & (1 << port); - setting_remove_elements(Settings_IoPort_InvertOut, bus.mask); - } + } else // TODO: same for inputs? + setting_remove_elements(Settings_IoPort_InvertOut, cfg->bus.mask & ~(1 << port)); } } while(port); diff --git a/motion_control.c b/motion_control.c index aee25bd..4c58ad7 100644 --- a/motion_control.c +++ b/motion_control.c @@ -999,27 +999,13 @@ gc_probe_t mc_probe_cycle (float *target, plan_line_data_t *pl_data, gc_parser_f if (!protocol_buffer_synchronize()) return GCProbe_Abort; // Return if system reset has been issued. - // Initialize probing control variables - sys.flags.probe_succeeded = Off; // Re-initialize probe history before beginning cycle. - hal.probe.configure(parser_flags.probe_is_away, true); - #if COMPATIBILITY_LEVEL <= 1 bool at_g59_3 = false, probe_toolsetter = grbl.on_probe_toolsetter != NULL && state_get() != STATE_TOOL_CHANGE && (sys.homed.mask & (X_AXIS_BIT|Y_AXIS_BIT)); if(probe_toolsetter) - grbl.on_probe_toolsetter(NULL, NULL, at_g59_3 = system_xy_at_fixture(CoordinateSystem_G59_3, TOOLSETTER_RADIUS), true); + pl_data->condition.probing_toolsetter = grbl.on_probe_toolsetter(NULL, NULL, at_g59_3 = system_xy_at_fixture(CoordinateSystem_G59_3, TOOLSETTER_RADIUS), true); #endif - // After syncing, check if probe is already triggered or not connected. If so, halt and issue alarm. - // NOTE: This probe initialization error applies to all probing cycles. - probe_state_t probe = hal.probe.get_state(); - if (probe.triggered || !probe.connected) { // Check probe state. - system_set_exec_alarm(Alarm_ProbeFailInitial); - protocol_execute_realtime(); - hal.probe.configure(false, false); // Re-initialize invert mask before returning. - return GCProbe_FailInit; // Nothing else to do but bail. - } - if(grbl.on_probe_start) { uint_fast8_t idx = N_AXIS; @@ -1037,6 +1023,31 @@ gc_probe_t mc_probe_cycle (float *target, plan_line_data_t *pl_data, gc_parser_f grbl.on_probe_start(axes, target, pl_data); } + // Initialize probing control variables + sys.flags.probe_succeeded = Off; // Re-initialize probe history before beginning cycle. + hal.probe.configure(parser_flags.probe_is_away, true); + + // After syncing, check if probe is already triggered or not connected. If so, halt and issue alarm. + // NOTE: This probe initialization error applies to all probing cycles. + probe_state_t probe = hal.probe.get_state(); + if (probe.triggered || !probe.connected) { // Check probe state. + + system_set_exec_alarm(Alarm_ProbeFailInitial); + protocol_execute_realtime(); + + hal.probe.configure(false, false); // Re-initialize invert mask before returning. + +#if COMPATIBILITY_LEVEL <= 1 + if(probe_toolsetter) + grbl.on_probe_toolsetter(NULL, NULL, at_g59_3, false); +#endif + + if(grbl.on_probe_completed) + grbl.on_probe_completed(); + + return GCProbe_FailInit; // Nothing else to do but bail. + } + // Setup and queue probing motion. Auto cycle-start should not start the cycle. if(!mc_line(target, pl_data)) return GCProbe_Abort; diff --git a/ngc_params.c b/ngc_params.c index 0a0b1a4..21babf9 100644 --- a/ngc_params.c +++ b/ngc_params.c @@ -37,6 +37,7 @@ #include "system.h" #include "settings.h" #include "ngc_params.h" +#include "state_machine.h" #ifndef NGC_MAX_CALL_LEVEL #define NGC_MAX_CALL_LEVEL 10 @@ -92,6 +93,7 @@ static ngc_rw_param_t *rw_params = NULL; static ngc_named_rw_param_t *rw_global_params = NULL; static ngc_string_id_t ref_id = (uint32_t)-1; static ngc_string_param_t *ngc_string_params = NULL; +static on_macro_execute_ptr on_macro_execute; static float _absolute_pos (uint_fast8_t axis) { @@ -963,4 +965,149 @@ uint8_t ngc_float_decimals (void) return settings.flags.report_inches ? N_DECIMAL_COORDVALUE_INCH : N_DECIMAL_COORDVALUE_MM; } +static status_code_t macro_get_setting (void) +{ + float setting_id; + status_code_t status = Status_OK; + const setting_detail_t *setting; + parameter_words_t args = gc_get_g65_arguments(); + + if(!args.q) + status = Status_GcodeValueWordMissing; + if(ngc_param_get(17 /* Q word */, &setting_id) && (setting = setting_get_details((setting_id_t)setting_id, NULL))) { + + uint_fast8_t offset = (setting_id_t)setting_id - setting->id; + + if(setting->datatype == Format_Decimal) { + ngc_named_param_set("_value", setting_get_float_value(setting, offset)); + ngc_named_param_set("_value_returned", 1.0f); + } else if(setting_is_integer(setting) || setting_is_list(setting)) { + ngc_named_param_set("_value", (float)setting_get_int_value(setting, offset)); + ngc_named_param_set("_value_returned", 1.0f); + } + } else + status = Status_GcodeValueOutOfRange; + + return status; +} + +static status_code_t macro_ngc_parameter_rw (void) +{ + float idx, value; + status_code_t status = Status_OK; + parameter_words_t args = gc_get_g65_arguments(); + + if(!args.i) + status = Status_GcodeValueWordMissing; + else if(ngc_param_get(4 /* I word */, &idx)) { + if(args.q) { + if(!(ngc_param_get(17 /* Q word */, &value) && ngc_param_set((ngc_param_id_t)idx, value))) + status = Status_GcodeValueOutOfRange; + } else if(ngc_param_get((ngc_param_id_t)idx, &value)) { + if(args.s) { + if(!(ngc_param_get(19 /* S word */, &idx) && ngc_param_set((ngc_param_id_t)idx, value))) + status = Status_GcodeValueOutOfRange; + } else { + ngc_named_param_set("_value", value); + ngc_named_param_set("_value_returned", 1.0f); + } + } else + status = Status_GcodeValueOutOfRange; + } else + status = Status_GcodeValueOutOfRange; + + return status; +} + +static status_code_t macro_get_machine_state (void) +{ + ngc_named_param_set("_value", (float)ffs(state_get())); + ngc_named_param_set("_value_returned", 1.0f); + + return Status_OK; +} + +static status_code_t macro_select_probe (void) +{ + float probe_id; + status_code_t status = Status_OK; + parameter_words_t args = gc_get_g65_arguments(); + + if(!args.q) + status = Status_GcodeValueWordMissing; + else if(ngc_param_get(17 /* Q word */, &probe_id) && (hal.probe.select ? hal.probe.select((probe_id_t)probe_id) : probe_id == 0.0f)) + system_add_rt_report(Report_ProbeId); + else + status = Status_GcodeValueOutOfRange; + + return status; +} + +#if N_TOOLS + +static status_code_t macro_get_tool_offset (void) +{ + float tool_id, axis_id; + status_code_t status = Status_OK; + parameter_words_t args = gc_get_g65_arguments(); + + if(!(args.q && args.r)) + status = Status_GcodeValueWordMissing; + else if(ngc_param_get(17 /* Q word */, &tool_id) && ngc_param_get(18 /* R word */, &axis_id)) { + if((uint32_t)tool_id <= grbl.tool_table.n_tools && (uint8_t)axis_id < N_AXIS) { + ngc_named_param_set("_value", grbl.tool_table.tool[(uint32_t)tool_id].offset[(uint8_t)axis_id]); + ngc_named_param_set("_value_returned", 1.0f); + } else + status = Status_GcodeIllegalToolTableEntry; + } else + status = Status_GcodeIllegalToolTableEntry; + + return status; +} + +#endif // N_TOOLS + +static status_code_t onMacroExecute (macro_id_t macro_id) +{ + status_code_t status = Status_Unhandled; + + switch((g65_inbuilt_t)macro_id) { + + case G65Macro_GetSetting: + status = macro_get_setting(); + break; +#if N_TOOLS + case G65Macro_GetToolOffset: + status = macro_get_tool_offset(); + break; +#endif + case G65Macro_ParameterRW: + status = macro_ngc_parameter_rw(); + break; + + case G65Macro_GetMachineState: + status = macro_get_machine_state(); + break; + + case G65Macro_SelectProbe: + status = macro_select_probe(); + break; + } + + return status == Status_Unhandled && on_macro_execute ? on_macro_execute(macro_id) : status; +} + +void ngc_params_init (void) +{ + static bool init_ok = false; + + if(!init_ok) { + init_ok = true; + on_macro_execute = grbl.on_macro_execute; + grbl.on_macro_execute = onMacroExecute; + } + + ngc_modal_state_invalidate(); +} + #endif // NGC_PARAMETERS_ENABLE diff --git a/ngc_params.h b/ngc_params.h index 3e3a3be..ea09e2d 100644 --- a/ngc_params.h +++ b/ngc_params.h @@ -105,6 +105,17 @@ typedef enum { NGCParam_Last } ncg_name_param_id_t; +typedef enum { + G65Macro_GetSetting = 1, +#if N_TOOLS || defined __DOXYGEN__ + G65Macro_GetToolOffset = 2, +#endif + G65Macro_ParameterRW = 3, + G65Macro_GetMachineState = 4, + G65Macro_SelectProbe = 5 +} g65_inbuilt_t; + +void ngc_params_init (void); uint8_t ngc_float_decimals (void); bool ngc_param_get (ngc_param_id_t id, float *value); bool ngc_param_set (ngc_param_id_t id, float value); diff --git a/pin_bits_masks.h b/pin_bits_masks.h index 1b51a04..223a8e4 100644 --- a/pin_bits_masks.h +++ b/pin_bits_masks.h @@ -226,6 +226,18 @@ static aux_ctrl_t aux_ctrl[] = { { .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 PROBE2_ENABLE && defined(PROBE2_PIN) +#ifndef PROBE2_PORT +#define PROBE2_PORT 0 +#endif + { .function = Input_Probe2, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Rising|IRQ_Mode_Falling), .cap = { .value = 0 }, .pin = PROBE2_PIN, .port = (void *)PROBE2_PORT }, +#endif +#if TOOLSETTER_ENABLE && defined(TOOLSETTER_PIN) +#ifndef TOOLSETTER_PORT +#define TOOLSETTER_PORT 0 +#endif + { .function = Input_Toolsetter, .aux_port = 0xFF, .irq_mode = (pin_irq_mode_t)(IRQ_Mode_Rising|IRQ_Mode_Falling), .cap = { .value = 0 }, .pin = TOOLSETTER_PIN, .port = (void *)TOOLSETTER_PORT }, +#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 = (void *)SAFETY_DOOR_PORT }, diff --git a/planner.h b/planner.h index bbe9f2b..33864c3 100644 --- a/planner.h +++ b/planner.h @@ -38,7 +38,8 @@ typedef union { is_laser_ppi_mode :1, target_valid :1, target_validated :1, - unassigned :5; + probing_toolsetter :1, + unassigned :4; coolant_state_t coolant; }; } planner_cond_t; diff --git a/plugins_init.h b/plugins_init.h index 4d73532..2133763 100644 --- a/plugins_init.h +++ b/plugins_init.h @@ -96,6 +96,11 @@ vfd_init(); #endif +#if PROBE_ENABLE > 1 + extern void probe_select_init (void); + probe_select_init(); +#endif + #if BLUETOOTH_ENABLE > 1 extern void bluetooth_init (void); bluetooth_init(); diff --git a/probe.h b/probe.h index 9ef62c2..cca5d9f 100644 --- a/probe.h +++ b/probe.h @@ -29,6 +29,12 @@ typedef enum { Probing_Active //!< 1 } probing_state_t; +typedef enum { + Probe_Default = 0, //!< 0 + Probe_Toolsetter, //!< 1 + Probe_2 //!< 2 +} probe_id_t; + typedef union { uint8_t value; struct { @@ -38,8 +44,13 @@ typedef union { is_probing :1, //!< For driver use irq_enabled :1, //!< For driver use tls_triggered :1, //!< Set to true when toolsetter is triggered. - unassigned :2; + probe_id :2; //!< Id of active probe (for now). }; } probe_state_t; +typedef struct { + uint8_t port; + bool latchable; +} probe_t; + #endif diff --git a/protocol.c b/protocol.c index 7da6fdc..56f2d79 100644 --- a/protocol.c +++ b/protocol.c @@ -869,6 +869,7 @@ ISR_CODE bool ISR_FUNC(protocol_enqueue_realtime_command)(char c) report.value = (uint32_t)Report_All; report.tool_offset = sys.report.tool_offset; report.m66result = sys.var5399 > -2; + report.probe_id = !!hal.probe.select; system_add_rt_report((report_tracking_t)report.value); } diff --git a/report.c b/report.c index db60daf..a953dd0 100644 --- a/report.c +++ b/report.c @@ -955,10 +955,17 @@ void report_build_info (char *line, bool extended) if(settings.homing.flags.enabled) strcat(buf, "HOME,"); - if(!hal.probe.get_state) + if(hal.probe.get_state == NULL) strcat(buf, "NOPROBE,"); - else if(hal.signals_cap.probe_disconnected) - strcat(buf, "PC,"); + else { + if(hal.probe.select) { + strcat(buf, "PROBES="); + strcat(buf, uitoa(0b001 | (hal.driver_cap.toolsetter << 1) | (hal.driver_cap.probe2 << 2))); + strcat(buf, ","); + } + if(hal.signals_cap.probe_disconnected) + strcat(buf, "PC,"); + } if(hal.signals_cap.stop_disable) strcat(buf, "OS,"); @@ -1140,8 +1147,9 @@ void report_realtime_status (void) { static bool probing = false; - float print_position[N_AXIS]; - report_tracking_flags_t report = system_get_rt_report_flags(); + uint_fast8_t idx; + float print_position[N_AXIS], wco[N_AXIS]; + report_tracking_flags_t report = system_get_rt_report_flags(), delayed_report = {}; probe_state_t probe_state = { .connected = On, .triggered = Off @@ -1212,14 +1220,11 @@ void report_realtime_status (void) break; } - uint_fast8_t idx; - float wco[N_AXIS]; - if(!settings.status_report.machine_position || report.wco) { + if(!settings.status_report.machine_position) { + // Apply work coordinate offsets and tool length offset to current position. for(idx = 0; idx < N_AXIS; idx++) { - // Apply work coordinate offsets and tool length offset to current position. wco[idx] = gc_get_offset(idx, true); - if(!settings.status_report.machine_position) - print_position[idx] -= wco[idx]; + print_position[idx] -= wco[idx]; } } @@ -1321,46 +1326,58 @@ void report_realtime_status (void) } } - if(settings.status_report.work_coord_offset) { - - if(wco_counter > 0 && !report.wco) { - if(wco_counter > (REPORT_WCO_REFRESH_IDLE_COUNT - 1) && state == STATE_IDLE) - wco_counter = REPORT_WCO_REFRESH_IDLE_COUNT - 1; - wco_counter--; - } else - wco_counter = state & (STATE_HOMING|STATE_CYCLE|STATE_HOLD|STATE_JOG|STATE_SAFETY_DOOR) - ? (REPORT_WCO_REFRESH_BUSY_COUNT - 1) // Reset counter for slow refresh - : (REPORT_WCO_REFRESH_IDLE_COUNT - 1); - } else - report.wco = Off; - if(settings.status_report.overrides) { - if (override_counter > 0 && !report.overrides) - override_counter--; - else { - if((report.overrides = !report.wco)) { - report.spindle = report.spindle || spindle_0_state.on; - report.coolant = report.coolant || hal.coolant.get_state().value != 0; - } + if((report.overrides = override_counter == 0 || report.overrides)) { + override_counter = state & (STATE_HOMING|STATE_CYCLE|STATE_HOLD|STATE_JOG|STATE_SAFETY_DOOR) ? (REPORT_OVERRIDE_REFRESH_BUSY_COUNT - 1) // Reset counter for slow refresh : (REPORT_OVERRIDE_REFRESH_IDLE_COUNT - 1); - } + + if(!report.all) { + report.spindle = report.spindle || spindle_0_state.on; + report.coolant = report.coolant || hal.coolant.get_state().value != 0; + } + } else + override_counter--; + + if(override_counter > (REPORT_OVERRIDE_REFRESH_IDLE_COUNT - 1) && state == STATE_IDLE) + override_counter = REPORT_OVERRIDE_REFRESH_IDLE_COUNT - 1; } else report.overrides = Off; + if(settings.status_report.work_coord_offset) { + + if((report.wco = wco_counter == 0 || report.wco)) { + + wco_counter = state & (STATE_HOMING|STATE_CYCLE|STATE_HOLD|STATE_JOG|STATE_SAFETY_DOOR) + ? (REPORT_WCO_REFRESH_BUSY_COUNT - 1) // Reset counter for slow refresh + : (REPORT_WCO_REFRESH_IDLE_COUNT - 1); + + // If protocol_buffer_synchronize() is running + // delay outputting WCO until sync is completed + // unless requested from stepper_driver_interrupt_handler. + if(!report.all && (report.overrides || (sys.flags.synchronizing && !report.force_wco))) { + report.wco = Off; + delayed_report.wco = On; + } + } else + wco_counter--; + + if(wco_counter > (REPORT_WCO_REFRESH_IDLE_COUNT - 1) && state == STATE_IDLE) + wco_counter = REPORT_WCO_REFRESH_IDLE_COUNT - 1; + } else + report.wco = Off; + if(report.value || gc_state.tool_change) { if(report.wco) { - // If protocol_buffer_synchronize() is running - // delay outputting WCO until sync is completed - // unless requested from stepper_driver_interrupt_handler. - if(report.force_wco || !sys.flags.synchronizing) { - hal.stream.write_all("|WCO:"); - hal.stream.write_all(get_axis_values(wco)); - } else - wco_counter = 0; + if(settings.status_report.machine_position) { + for(idx = 0; idx < N_AXIS; idx++) + wco[idx] = gc_get_offset(idx, true); + } + hal.stream.write_all("|WCO:"); + hal.stream.write_all(get_axis_values(wco)); } if(report.gwco) { @@ -1434,6 +1451,9 @@ void report_realtime_status (void) if(report.tool) hal.stream.write_all(appendbuf(2, "|T:", uitoa((uint32_t)gc_state.tool->tool_id))); + if(report.probe_id) + hal.stream.write_all(appendbuf(2, "|P:", uitoa((uint32_t)probe_state.probe_id))); + if(report.tlo_reference) hal.stream.write_all(appendbuf(2, "|TLR:", uitoa(sys.tlo_reference_set.mask != 0))); @@ -1487,7 +1507,8 @@ void report_realtime_status (void) hal.stream.write_all(">" ASCII_EOL); system_add_rt_report(Report_ClearAll); - if(settings.status_report.work_coord_offset && wco_counter == 0) + + if(delayed_report.wco) system_add_rt_report(Report_WCO); // Set to report on next request } diff --git a/settings.c b/settings.c index ec5e41b..c79cf3d 100644 --- a/settings.c +++ b/settings.c @@ -412,8 +412,12 @@ PROGMEM static const setting_group_detail_t setting_group_detail [] = { static bool machine_mode_changed = false; #if COMPATIBILITY_LEVEL <= 1 +static char probe_signals[] = "Probe,Toolsetter,Probe 2"; static char homing_options[] = "Enable,Enable single axis commands,Homing on startup required,Set machine origin to 0,Two switches shares one input,Allow manual,Override locks,N/A,Use limit switches,Per axis feedrates"; +#else +static char probe_signals[] = "Probe"; #endif +static char probing_options[] = "Allow feed override,Apply soft limits,N/A,Auto select toolsetter,Auto select probe 2"; static char control_signals[] = "Reset,Feed hold,Cycle start,Safety door,Block delete,Optional stop,EStop,Probe connected,Motor fault,Motor warning,Limits override,Single step blocks"; static char spindle_signals[] = "Spindle enable,Spindle direction,PWM"; static char coolant_signals[] = "Flood,Mist"; @@ -611,10 +615,13 @@ static status_code_t set_probe_invert (setting_id_t id, uint_fast16_t int_value) if(!hal.probe.configure) return Status_SettingDisabled; - settings.probe.invert_probe_pin = (int_value & 0b01); + settings.probe.invert_probe_pin = (int_value & 0b001); if(hal.driver_cap.toolsetter) - settings.probe.invert_toolsetter_input = !!(int_value & 0b10); + settings.probe.invert_toolsetter_input = !!(int_value & 0b010); + + if(hal.driver_cap.probe2) + settings.probe.invert_probe2_input = !!(int_value & 0b100); ioport_setting_changed(id); @@ -783,10 +790,13 @@ static status_code_t set_probe_disable_pullup (setting_id_t id, uint_fast16_t in if(!hal.probe.configure) return Status_SettingDisabled; - settings.probe.disable_probe_pullup = (int_value & 0b01); + settings.probe.disable_probe_pullup = (int_value & 0b001); if(hal.driver_cap.toolsetter) - settings.probe.disable_toolsetter_pullup = !!(int_value & 0b10); + settings.probe.disable_toolsetter_pullup = !!(int_value & 0b010); + + // if(hal.driver_cap.probe2) + // settings.probe.disable_probe2_pullup = !!(int_value & 0b100); ioport_setting_changed(id); @@ -1046,6 +1056,8 @@ static status_code_t set_probe_flags (setting_id_t id, uint_fast16_t int_value) settings.probe.allow_feed_override = bit_istrue(int_value, bit(0)); settings.probe.soft_limited = bit_istrue(int_value, bit(1)); settings.probe.enable_protection = bit_istrue(int_value, bit(2)); + settings.probe.toolsetter_auto_select = bit_istrue(int_value, bit(3)) && hal.driver_cap.toolsetter && hal.probe.select; + settings.probe.probe2_auto_select = bit_istrue(int_value, bit(4)) && hal.driver_cap.probe2 && hal.probe.select; return Status_OK; } @@ -1471,7 +1483,9 @@ static uint32_t get_int (setting_id_t id) case Setting_InvertProbePin: value = settings.probe.invert_probe_pin; if(hal.driver_cap.toolsetter && settings.probe.invert_toolsetter_input) - value |= 0b10; + value |= 0b010; + if(hal.driver_cap.probe2 && settings.probe.invert_probe2_input) + value |= 0b100; break; case Setting_GangedDirInvertMask: @@ -1570,7 +1584,11 @@ static uint32_t get_int (setting_id_t id) break; case Setting_ProbingFlags: - value = settings.probe.allow_feed_override | (settings.probe.soft_limited << 1) | (settings.probe.enable_protection << 2); + value = settings.probe.allow_feed_override | + (settings.probe.soft_limited << 1) | + (settings.probe.enable_protection << 2) | + (settings.probe.toolsetter_auto_select << 3) | + (settings.probe.probe2_auto_select << 4); break; case Setting_ToolChangeMode: @@ -1824,10 +1842,9 @@ static bool is_setting_available (const setting_detail_t *setting, uint_fast16_t available = hal.stepper.get_ganged && hal.stepper.get_ganged(false).mask != 0; break; + case Setting_InvertProbePin: + case Setting_ProbePullUpDisable: case Setting_ProbingFlags: -// case Setting_ToolChangeProbingDistance: -// case Setting_ToolChangeFeedRate: -// case Setting_ToolChangeSeekRate: available = hal.probe.get_state != NULL; break; @@ -1965,60 +1982,6 @@ static bool is_setting_available (const setting_detail_t *setting, uint_fast16_t return available; } -static bool toolsetter_available (const setting_detail_t *setting, uint_fast16_t offset) -{ - bool available = false; - -#if COMPATIBILITY_LEVEL <= 1 - - if(hal.probe.get_state && hal.driver_cap.toolsetter) switch(setting->id) { - - case Setting_InvertProbePin: - available = true; - break; - - case Setting_ProbePullUpDisable: - available = hal.signals_pullup_disable_cap.probe_triggered; - break; - - default: - break; - } - -#endif - - return available; -} - -static bool no_toolsetter_available (const setting_detail_t *setting, uint_fast16_t offset) -{ -#if COMPATIBILITY_LEVEL <= 1 - - bool available = false; - - if(hal.probe.get_state && !hal.driver_cap.toolsetter) switch(setting->id) { - - case Setting_InvertProbePin: - available = true; - break; - - case Setting_ProbePullUpDisable: - available = hal.signals_pullup_disable_cap.probe_triggered; - break; - - default: - break; - } - - return available; - -#else - - return !!hal.probe.get_state; - -#endif -} - PROGMEM static const setting_detail_t setting_detail[] = { { Setting_PulseMicroseconds, Group_Stepper, "Step pulse time", "microseconds", Format_Decimal, "#0.0", step_us_min, NULL, Setting_IsLegacyFn, set_pulse_width, get_float, NULL }, { Setting_StepperIdleLockTime, Group_Stepper, "Step idle delay", "milliseconds", Format_Int16, "####0", NULL, "65535", Setting_IsLegacy, &settings.steppers.idle_lock_time, NULL, NULL }, @@ -2034,8 +1997,7 @@ PROGMEM static const setting_detail_t setting_detail[] = { #else { Setting_LimitPinsInvertMask, Group_Limits, "Invert limit inputs", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsLegacyFn, set_limits_invert_mask, get_int, NULL }, #endif - { Setting_InvertProbePin, Group_Probing, "Invert probe input", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsLegacyFn, set_probe_invert, get_int, no_toolsetter_available }, - { Setting_InvertProbePin, Group_Probing, "Invert probe inputs", NULL, Format_Bitfield, "Probe,Toolsetter", NULL, NULL, Setting_IsLegacyFn, set_probe_invert, get_int, toolsetter_available }, + { Setting_InvertProbePin, Group_Probing, "Invert probe inputs", NULL, Format_Bitfield, probe_signals, NULL, NULL, Setting_IsLegacyFn, set_probe_invert, get_int, is_setting_available }, { Setting_SpindlePWMBehaviour, Group_Spindle, "Deprecated", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsLegacyFn, set_pwm_mode, get_int, is_setting_available }, { Setting_GangedDirInvertMask, Group_Stepper, "Ganged axes direction invert", NULL, Format_Bitfield, ganged_axes, NULL, NULL, Setting_IsExtendedFn, set_ganged_dir_invert, get_int, is_setting_available }, { Setting_SpindlePWMOptions, Group_Spindle, "PWM spindle options", NULL, Format_XBitfield, "Enable,RPM controls spindle enable signal,Disable laser mode capability", NULL, NULL, Setting_IsExtendedFn, set_pwm_options, get_int, is_setting_available }, @@ -2052,8 +2014,7 @@ PROGMEM static const setting_detail_t setting_detail[] = { { Setting_SpindleInvertMask, Group_Spindle, "Invert spindle signals", NULL, Format_Bitfield, spindle_signals, NULL, NULL, Setting_IsExtendedFn, set_spindle_invert, get_int, is_setting_available, { .reboot_required = On } }, { Setting_ControlPullUpDisableMask, Group_ControlSignals, "Pullup disable control inputs", NULL, Format_Bitfield, control_signals, NULL, NULL, Setting_IsExtendedFn, set_control_disable_pullup, get_int, NULL }, { Setting_LimitPullUpDisableMask, Group_Limits, "Pullup disable limit inputs", NULL, Format_AxisMask, NULL, NULL, NULL, Setting_IsExtended, &settings.limits.disable_pullup.mask, NULL, NULL }, - { Setting_ProbePullUpDisable, Group_Probing, "Pullup disable probe input", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_probe_disable_pullup, get_int, no_toolsetter_available }, - { Setting_ProbePullUpDisable, Group_Probing, "Pullup disable probe inputs", NULL, Format_Bitfield, "Probe,Toolsetter", NULL, NULL, Setting_IsLegacyFn, set_probe_disable_pullup, get_int, toolsetter_available }, + { Setting_ProbePullUpDisable, Group_Probing, "Pullup disable probe inputs", NULL, Format_Bitfield, probe_signals, NULL, NULL, Setting_IsLegacyFn, set_probe_disable_pullup, get_int, is_setting_available }, { Setting_SoftLimitsEnable, Group_Limits, "Soft limits enable", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsLegacyFn, set_soft_limits_enable, get_int, NULL }, #if COMPATIBILITY_LEVEL <= 1 #if N_AXIS > 3 @@ -2117,7 +2078,7 @@ PROGMEM static const setting_detail_t setting_detail[] = { { Setting_SleepEnable, Group_General, "Sleep enable", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_sleep_enable, get_int, is_setting_available }, { Setting_HoldActions, Group_General, "Feed hold actions", NULL, Format_Bitfield, "Disable laser during hold,Restore spindle and coolant state on resume", NULL, NULL, Setting_IsExtendedFn, set_hold_actions, get_int, NULL }, { Setting_ForceInitAlarm, Group_General, "Force init alarm", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_force_initialization_alarm, get_int, NULL }, - { Setting_ProbingFlags, Group_Probing, "Probing flags", NULL, Format_Bitfield, "Allow feed override,Apply soft limits", NULL, NULL, Setting_IsExtendedFn, set_probe_flags, get_int, is_setting_available }, + { Setting_ProbingFlags, Group_Probing, "Probing options", NULL, Format_Bitfield, probing_options, NULL, NULL, Setting_IsExtendedFn, set_probe_flags, get_int, is_setting_available }, #if ENABLE_SPINDLE_LINEARIZATION { Setting_LinearSpindlePiece1, Group_Spindle, "Spindle linearisation, 1st point", NULL, Format_String, "x(39)", NULL, "39", Setting_IsExtendedFn, set_linear_piece, get_linear_piece, NULL }, #if SPINDLE_NPWM_PIECES > 1 @@ -2593,6 +2554,9 @@ static void sanity_check (void) settings.flags.tool_change_fast_pulloff = On; } + settings.probe.probe2_auto_select &= hal.driver_cap.probe2 && hal.probe.select; + settings.probe.toolsetter_auto_select &= hal.driver_cap.toolsetter && hal.probe.select; + if(SLEEP_DURATION <= 0.0f) settings.flags.sleep_enable = Off; @@ -3466,6 +3430,13 @@ void settings_init (void) details->on_changed(&settings, changed); } while((details = details->next)); + uint32_t mask = 0b001 | (hal.driver_cap.toolsetter << 1) | (hal.driver_cap.probe2 << 2); + setting_remove_elements(Setting_InvertProbePin, mask); + setting_remove_elements(Setting_ProbePullUpDisable, mask); + + mask = 0b00011 | (hal.probe.select ? ((hal.driver_cap.toolsetter << 3) | (hal.driver_cap.probe2 << 4)) : 0); + setting_remove_elements(Setting_ProbingFlags, mask); + if(!settings.flags.settings_downgrade && settings.version.build != (GRBL_BUILD - 20000000UL)) { if(settings.version.build <= 250102) { diff --git a/settings.h b/settings.h index 9312ea4..af935ed 100644 --- a/settings.h +++ b/settings.h @@ -456,6 +456,8 @@ typedef enum { Setting_MacroATC_Options = 675, Setting_ResetActions = 676, Setting_StepperSpindle_Options = 677, + Setting_RelayPortToolsetter = 678, + Setting_RelayPortProbe2 = 679, Setting_SpindlePWMOptions1 = 709, @@ -610,7 +612,10 @@ typedef union { invert_toolsetter_input :1, disable_toolsetter_pullup :1, soft_limited :1, - unassigned :7; + toolsetter_auto_select :1, + invert_probe2_input :1, + probe2_auto_select :1, + unassigned :4; }; } probeflags_t; diff --git a/spindle_control.c b/spindle_control.c index c3fcf68..87e88e0 100644 --- a/spindle_control.c +++ b/spindle_control.c @@ -839,7 +839,7 @@ bool spindle_precompute_pwm_values (spindle_ptrs_t *spindle, spindle_pwm_t *pwm_ pwm_data->flags.rpm_controlled = settings->flags.enable_rpm_controlled; pwm_data->flags.laser_mode_disable = settings->flags.laser_mode_disable; if(settings->pwm_off_value == 0.0f) - pwm_data->off_value = pwm_data->flags.invert_pwm ? pwm_data->period : 0; + pwm_data->off_value = pwm_data->flags.invert_pwm ? pwm_data->period - pwm_data->offset : 0; else pwm_data->off_value = invert_pwm(pwm_data, (uint_fast16_t)(pwm_data->period * settings->pwm_off_value / 100.0f)); pwm_data->max_value = (uint_fast16_t)(pwm_data->period * settings->pwm_max_value / 100.0f) + pwm_data->offset; diff --git a/system.c b/system.c index ef8e91b..8975c6e 100644 --- a/system.c +++ b/system.c @@ -1290,6 +1290,11 @@ ISR_CODE void system_add_rt_report (report_tracking_t report) sys.report.wco = settings.status_report.work_coord_offset; break; + case Report_ProbeId: + if(hal.probe.select == NULL) + return; + break; + default: break; } diff --git a/system.h b/system.h index e5e99f2..bd69cf4 100644 --- a/system.h +++ b/system.h @@ -227,6 +227,7 @@ typedef enum { Report_TLOReference = (1 << 15), Report_Fan = (1 << 16), Report_SpindleId = (1 << 17), + Report_ProbeId = (1 << 18), Report_ForceWCO = (1 << 29), Report_CycleStart = (1 << 30), Report_All = 0x8003FFFF @@ -246,14 +247,15 @@ typedef union { wco :1, //!< Add work coordinates. gwco :1, //!< Add work coordinate. tool_offset :1, //!< Tool offsets changed. - m66result :1, //!< M66 result updated + m66result :1, //!< M66 result updated. pwm :1, //!< Add PWM information (optional: to be added by driver). motor :1, //!< Add motor information (optional: to be added by driver). encoder :1, //!< Add encoder information (optional: to be added by driver). tlo_reference :1, //!< Tool length offset reference changed. fan :1, //!< Fan on/off changed. - spindle_id :1, //!< Spindle changed - unassigned :11, // + spindle_id :1, //!< Spindle changed. + probe_id :1, //!< Probe changed. + unassigned :10, // force_wco :1, //!< Add work coordinates (due to WCO changed during motion). cycle_start :1, //!< Cycle start signal triggered. __NOTE:__ do __NOT__ add to Report_All enum above! all :1; //!< Set when CMD_STATUS_REPORT_ALL is requested, may be used by user code. diff --git a/tool_change.c b/tool_change.c index 06d90bb..85fff2f 100644 --- a/tool_change.c +++ b/tool_change.c @@ -313,13 +313,13 @@ static void execute_probe (void *data) target.values[plane.axis_linear] = offset.values[plane.axis_linear]; ok = mc_line(target.values, &plan_data); - if(ok && probe_toolsetter) - grbl.on_probe_toolsetter(next_tool, NULL, true, true); - plan_data.feed_rate = settings.tool_change.seek_rate; plan_data.condition.value = 0; plan_data.spindle.state.value = 0; + if(ok && probe_toolsetter) + plan_data.condition.probing_toolsetter = grbl.on_probe_toolsetter(next_tool, NULL, true, true); + set_probe_target(&target, plane.axis_linear); if((ok = ok && mc_probe_cycle(target.values, &plan_data, flags) == GCProbe_Found)) { @@ -602,12 +602,12 @@ status_code_t tc_probe_workpiece (void) // TODO: add check for reference offset set? bool ok; - gc_parser_flags_t flags = {0}; + gc_parser_flags_t flags = {}; plan_line_data_t plan_data; #if COMPATIBILITY_LEVEL <= 1 if(probe_toolsetter) - grbl.on_probe_toolsetter(next_tool, NULL, system_xy_at_fixture(CoordinateSystem_G59_3, TOOLSETTER_RADIUS), true); + plan_data.condition.probing_toolsetter = grbl.on_probe_toolsetter(next_tool, NULL, system_xy_at_fixture(CoordinateSystem_G59_3, TOOLSETTER_RADIUS), true); #endif // Get current position.