Skip to content

Commit

Permalink
updated conditions for probe position update
Browse files Browse the repository at this point in the history
- updated conditions for probe position update
- probe position updated also on failure
- other probing actions like G39 and Plasma don't affect last probing result (independent)
  • Loading branch information
Paciente8159 committed Jan 17, 2024
1 parent 2d0669f commit 47278ba
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
6 changes: 6 additions & 0 deletions uCNC/src/cnc_hal_config_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ extern "C"
#define PROBE_PULLUP
#endif

#ifdef ENABLE_RT_PROBE_CHECKING
#ifdef PROBE_ISR
#undef PROBE_ISR
#endif
#endif

#ifdef ESTOP_PULLUP_ENABLE
#define ESTOP_PULLUP
#endif
Expand Down
11 changes: 3 additions & 8 deletions uCNC/src/core/motion_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -930,21 +930,17 @@ uint8_t mc_probe(float *target, uint8_t flags, motion_data_t *block_data)
}
} while (!itp_is_empty() || !planner_buffer_is_empty());

// wait for a stop
while (cnc_dotasks() && cnc_get_exec_state(EXEC_RUN));
// disables the probe
io_disable_probe();
itp_clear();
planner_clear();
// clears hold
cnc_clear_exec_state(EXEC_HOLD);
parser_update_probe_pos();

// sync the position of the motion control
mc_sync_position();
// HALT could not be cleared. Something is wrong
if (cnc_get_exec_state(EXEC_UNHOMED))
{
return STATUS_CRITICAL_FAIL;
}

cnc_delay_ms(g_settings.debounce_ms); // adds a delay before reading io pin (debounce)
probe_ok = io_get_probe();
Expand All @@ -957,7 +953,6 @@ uint8_t mc_probe(float *target, uint8_t flags, motion_data_t *block_data)
}
return STATUS_OK;
}

#endif

return STATUS_PROBE_SUCCESS;
Expand Down Expand Up @@ -1133,7 +1128,7 @@ uint8_t mc_build_hmap(float *target, float *offset, float retract_h, motion_data

// store position
int32_t probe_position[STEPPER_COUNT];
itp_get_rt_position(probe_position);
parser_get_probe(probe_position);
kinematics_steps_to_coordinates(probe_position, position);
hmap_offsets[i + H_MAPING_GRID_FACTOR * j] = position[AXIS_TOOL];
protocol_send_probe_result(1);
Expand Down
8 changes: 8 additions & 0 deletions uCNC/src/core/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ void parser_sync_probe(void)
itp_get_rt_position(rt_probe_step_pos);
}

void parser_get_probe(int32_t *position){
memcpy(position, rt_probe_step_pos, sizeof(rt_probe_step_pos));
}

void parser_update_probe_pos(void)
{
kinematics_steps_to_coordinates(rt_probe_step_pos, parser_parameters.last_probe_position);
Expand Down Expand Up @@ -1711,8 +1715,12 @@ uint8_t parser_exec_command(parser_state_t *new_state, parser_words_t *words, pa
}
else
{
// failed at this position
parser_sync_probe();
parser_parameters.last_probe_ok = 0;
}
// sync probe position
parser_update_probe_pos();

if (error == STATUS_OK)
{
Expand Down
1 change: 1 addition & 0 deletions uCNC/src/core/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ extern "C"
void parser_get_coordsys(uint8_t system_num, float *axis);
bool parser_get_wco(float *axis);
void parser_sync_probe(void);
void parser_get_probe(int32_t *position);
void parser_update_probe_pos(void);
uint8_t parser_get_probe_result(void);
void parser_parameters_load(void);
Expand Down

0 comments on commit 47278ba

Please sign in to comment.