Skip to content

Commit

Permalink
More fixes for issue grblHAL#332: setting tool table data cleared cur…
Browse files Browse the repository at this point in the history
…rent coordinate system offset, incomplete handling of G10 L10 and L11.

Added free memory to $I output when available, example: [FREE MEMORY:102K]
Changed reported position for failed probe to target. Parameters #5061 - #5069 returns position in coordinate system used when probing.
  • Loading branch information
terjeio committed Aug 8, 2023
1 parent 909b7f9 commit 244bbb3
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ It has been written to complement grblHAL and has features such as proper keyboa

---

Latest build date is 20230729, see the [changelog](changelog.md) for details.
Latest build date is 20230808, see the [changelog](changelog.md) for details.
__NOTE:__ A settings reset will be performed on an update of builds earlier than 20230125. Backup and restore of settings is recommended.
__IMPORTANT!__ A new setting has been introduced for ganged axes motors in build 20211121.
I have only bench tested this for a couple of drivers, correct function should be verified after updating by those who have more than three motors configured.
Expand Down
22 changes: 22 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
## grblHAL changelog

<a name="20230808"/>202300808

Core:

* More fixes for issue #332: setting tool table data cleared current coordinate system offset, incomplete handling of G10 L10 and L11.

* Added free memory to $I output when available, example: `[FREE MEMORY:102K]`

* Changed reported position for failed probe to target. Parameters #5061 - #5069 returns position in coordinate system used when probing.

Drivers:

* RP2040: Added fans plugin.

* STM32F4xx: implemented free memory call.

Plugins:

* Fans: fixed some bugs and typos.

---

<a name="20230805"/>202300805

Core:
Expand Down
31 changes: 21 additions & 10 deletions gcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2140,18 +2140,23 @@ status_code_t gc_execute_block (char *block)
if(gc_block.values.l == 11 && !settings_read_coord_data(CoordinateSystem_G59_3, &g59_3_offset))
FAIL(Status_SettingReadFail);

if(gc_block.values.l == 1)
settings_read_tool_data(p_value, &tool_table[p_value]);

idx = N_AXIS;
do {
if (bit_istrue(axis_words.mask, bit(--idx))) {
if(bit_istrue(axis_words.mask, bit(--idx))) {
if(gc_block.values.l == 1)
tool_table[p_value].offset[idx] = gc_block.values.xyz[idx];
else if(gc_block.values.l == 10)
tool_table[p_value].offset[idx] = gc_state.position[idx] - gc_state.g92_coord_offset[idx] - gc_block.values.xyz[idx];
tool_table[p_value].offset[idx] = gc_state.position[idx] - gc_state.modal.coord_system.xyz[idx] - gc_state.g92_coord_offset[idx] - gc_block.values.xyz[idx];
else if(gc_block.values.l == 11)
tool_table[p_value].offset[idx] = g59_3_offset[idx] - gc_block.values.xyz[idx];
if (gc_block.values.l != 1)
tool_table[p_value].offset[idx] -= gc_state.tool_length_offset[idx];
}
// if(gc_block.values.l != 1)
// tool_table[p_value].offset[idx] -= gc_state.tool_length_offset[idx];
} else if(gc_block.values.l == 10 || gc_block.values.l == 11)
tool_table[p_value].offset[idx] = gc_state.tool_length_offset[idx];

// else, keep current stored value.
} while(idx);

Expand Down Expand Up @@ -3216,12 +3221,18 @@ status_code_t gc_execute_block (char *block)
switch(gc_block.non_modal_command) {

case NonModal_SetCoordinateData:
settings_write_coord_data(gc_block.values.coord_data.id, &gc_block.values.coord_data.xyz);
// Update system coordinate system if currently active.
if (gc_state.modal.coord_system.id == gc_block.values.coord_data.id) {
memcpy(gc_state.modal.coord_system.xyz, gc_block.values.coord_data.xyz, sizeof(gc_state.modal.coord_system.xyz));
system_flag_wco_change();
#if N_TOOLS
if(gc_block.values.l == 2 || gc_block.values.l == 20) {
#endif
settings_write_coord_data(gc_block.values.coord_data.id, &gc_block.values.coord_data.xyz);
// Update system coordinate system if currently active.
if (gc_state.modal.coord_system.id == gc_block.values.coord_data.id) {
memcpy(gc_state.modal.coord_system.xyz, gc_block.values.coord_data.xyz, sizeof(gc_state.modal.coord_system.xyz));
system_flag_wco_change();
}
#if N_TOOLS
}
#endif
break;

case NonModal_GoHome_0:
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 20230805
#define GRBL_BUILD 20230808

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

Expand Down
2 changes: 1 addition & 1 deletion machine_limits.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void limits_set_machine_positions (axes_signals_t cycle, bool add_pulloff)
sys.home_position[idx] = bit_istrue(settings.homing.dir_mask.value, bit(idx))
? settings.axis[idx].max_travel + pulloff
: - pulloff;
sys.position[idx] = sys.home_position[idx] * settings.axis[idx].steps_per_mm;
sys.position[idx] = lroundf(sys.home_position[idx] * settings.axis[idx].steps_per_mm);
}
} while(idx);
}
Expand Down
23 changes: 14 additions & 9 deletions motion_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,10 +944,19 @@ status_code_t mc_homing_cycle (axes_signals_t cycle)
// 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)
{
uint_fast8_t idx = N_AXIS;

// TODO: Need to update this cycle so it obeys a non-auto cycle start.
if (state_get() == STATE_CHECK_MODE)
return GCProbe_CheckMode;

do {
idx--;
sys.probe_position[idx] = lroundf(target[idx] * settings.axis[idx].steps_per_mm);
} while(idx);

sys.probe_coordsys_id = gc_state.modal.coord_system.id;

// Finish all queued commands and empty planner buffer before starting probe cycle.
if (!protocol_buffer_synchronize())
return GCProbe_Abort; // Return if system reset has been issued.
Expand Down Expand Up @@ -1007,16 +1016,12 @@ gc_probe_t mc_probe_cycle (float *target, plan_line_data_t *pl_data, gc_parser_f
// Probing cycle complete!

// Set state variables and error out, if the probe failed and cycle with error is enabled.
if (sys.probing_state == Probing_Active) {
if (parser_flags.probe_is_no_error)
memcpy(sys.probe_position, sys.position, sizeof(sys.position));
else
if(sys.probing_state == Probing_Active) {
memcpy(sys.probe_position, sys.position, sizeof(sys.position));
if(!parser_flags.probe_is_no_error)
system_set_exec_alarm(Alarm_ProbeFailContact);
} else {
// Indicate to system the probing cycle completed successfully.
sys.probe_coordsys_id = gc_state.modal.coord_system.id;
sys.flags.probe_succeeded = On;
}
} else
sys.flags.probe_succeeded = On; // Indicate to system the probing cycle completed successfully.

sys.probing_state = Probing_Off; // Ensure probe state monitor is disabled.
hal.probe.configure(false, false); // Re-initialize invert mask.
Expand Down
6 changes: 6 additions & 0 deletions report.c
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,12 @@ void report_build_info (char *line, bool extended)
hal.stream.write("]" ASCII_EOL);
}

if(hal.get_free_mem) {
hal.stream.write("[FREE MEMORY:");
hal.stream.write(uitoa(hal.get_free_mem() / 1024));
hal.stream.write("K]" ASCII_EOL);
}

if(hal.info) {
hal.stream.write("[DRIVER:");
hal.stream.write(hal.info);
Expand Down

0 comments on commit 244bbb3

Please sign in to comment.