diff --git a/Grbl_Esp32/Custom/CoreXY.cpp b/Grbl_Esp32/Custom/CoreXY.cpp index 39488722..59df1595 100644 --- a/Grbl_Esp32/Custom/CoreXY.cpp +++ b/Grbl_Esp32/Custom/CoreXY.cpp @@ -312,11 +312,6 @@ void kinematics_post_homing() { memcpy(gc_state.position, last_cartesian, n_axis * sizeof(last_cartesian[0])); } -// this is used used by Limits.cpp to see if the range of the machine is exceeded. -bool limitsCheckTravel(float* target) { - return false; -} - void user_m30() {} // ================ Local Helper functions ================= diff --git a/Grbl_Esp32/src/GCode.cpp b/Grbl_Esp32/src/GCode.cpp index d55eb1ed..335c4c36 100644 --- a/Grbl_Esp32/src/GCode.cpp +++ b/Grbl_Esp32/src/GCode.cpp @@ -1483,8 +1483,10 @@ Error gc_execute_line(char* line, uint8_t client) { // and absolute and incremental modes. pl_data->motion.rapidMotion = 1; // Set rapid motion flag. if (axis_command != AxisCommand::None) { + limitsCheckSoft(gc_block.values.xyz); cartesian_to_motors(gc_block.values.xyz, pl_data, gc_state.position); } + limitsCheckSoft(coord_data); cartesian_to_motors(coord_data, pl_data, gc_state.position); memcpy(gc_state.position, coord_data, sizeof(gc_state.position)); break; @@ -1513,9 +1515,11 @@ Error gc_execute_line(char* line, uint8_t client) { if (axis_command == AxisCommand::MotionMode) { GCUpdatePos gc_update_pos = GCUpdatePos::Target; if (gc_state.modal.motion == Motion::Linear) { + limitsCheckSoft(gc_block.values.xyz); cartesian_to_motors(gc_block.values.xyz, pl_data, gc_state.position); } else if (gc_state.modal.motion == Motion::Seek) { pl_data->motion.rapidMotion = 1; // Set rapid motion flag. + limitsCheckSoft(gc_block.values.xyz); cartesian_to_motors(gc_block.values.xyz, pl_data, gc_state.position); } else if ((gc_state.modal.motion == Motion::CwArc) || (gc_state.modal.motion == Motion::CcwArc)) { mc_arc(gc_block.values.xyz, diff --git a/Grbl_Esp32/src/Grbl.h b/Grbl_Esp32/src/Grbl.h index b89b7c4a..aef42df2 100644 --- a/Grbl_Esp32/src/Grbl.h +++ b/Grbl_Esp32/src/Grbl.h @@ -22,7 +22,7 @@ // Grbl versioning system const char* const GRBL_VERSION = "1.3a"; -const char* const GRBL_VERSION_BUILD = "20210816"; +const char* const GRBL_VERSION_BUILD = "20210825"; //#include #include diff --git a/Grbl_Esp32/src/Limits.cpp b/Grbl_Esp32/src/Limits.cpp index fec18cfd..9e172b5b 100644 --- a/Grbl_Esp32/src/Limits.cpp +++ b/Grbl_Esp32/src/Limits.cpp @@ -416,3 +416,12 @@ bool limitsSwitchDefined(uint8_t axis, uint8_t gang_index) { bool __attribute__((weak)) user_defined_homing(uint8_t cycle_mask) { return false; } + +void limitsCheckSoft(float* target) { + if (soft_limits->get()) { + // NOTE: Block jog state. Jogging is a special case and soft limits are handled independently. + if (sys.state != State::Jog && sys.state != State::Homing) { + limits_soft_check(target); + } + } +} diff --git a/Grbl_Esp32/src/Limits.h b/Grbl_Esp32/src/Limits.h index 3697f8e0..a3e52e09 100644 --- a/Grbl_Esp32/src/Limits.h +++ b/Grbl_Esp32/src/Limits.h @@ -57,3 +57,5 @@ bool limitsCheckTravel(float* target); // check if a switch has been defined bool limitsSwitchDefined(uint8_t axis, uint8_t gang_index); + +void limitsCheckSoft(float* target); diff --git a/Grbl_Esp32/src/MotionControl.cpp b/Grbl_Esp32/src/MotionControl.cpp index 00762b97..3b0b8fcd 100644 --- a/Grbl_Esp32/src/MotionControl.cpp +++ b/Grbl_Esp32/src/MotionControl.cpp @@ -45,14 +45,7 @@ bool mc_line(float* target, plan_line_data_t* pl_data) { bool submitted_result = false; // store the plan data so it can be cancelled by the protocol system if needed sys_pl_data_inflight = pl_data; - // If enabled, check for soft limit violations. Placed here all line motions are picked up - // from everywhere in Grbl. - if (soft_limits->get()) { - // NOTE: Block jog state. Jogging is a special case and soft limits are handled independently. - if (sys.state != State::Jog) { - limits_soft_check(target); - } - } + // If in check gcode mode, prevent motion by blocking planner. Soft limits still work. if (sys.state == State::CheckMode) { sys_pl_data_inflight = NULL; @@ -222,6 +215,7 @@ void mc_arc(float* target, position[axis_1] = center_axis1 + r_axis1; position[axis_linear] += linear_per_segment; pl_data->feed_rate = original_feedrate; // This restores the feedrate kinematics may have altered + limitsCheckSoft(position); cartesian_to_motors(position, pl_data, previous_position); previous_position[axis_0] = position[axis_0]; previous_position[axis_1] = position[axis_1]; @@ -233,6 +227,7 @@ void mc_arc(float* target, } } // Ensure last segment arrives at target location. + limitsCheckSoft(target); cartesian_to_motors(target, pl_data, previous_position); } @@ -419,6 +414,7 @@ GCUpdatePos mc_probe_cycle(float* target, plan_line_data_t* pl_data, uint8_t par } // Setup and queue probing motion. Auto cycle-start should not start the cycle. grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Found"); + limitsCheckSoft(target); cartesian_to_motors(target, pl_data, gc_state.position); // Activate the probing state monitor in the stepper module. sys_probe_state = Probe::Active;