mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-08-30 09:39:49 +02:00
Homing dead code elimination
This commit is contained in:
@@ -183,7 +183,10 @@ static ExecAlarm limits_handle_errors(bool approach, uint8_t cycle_mask) {
|
|||||||
// mask, which prevents the stepper algorithm from executing step pulses. Homing motions typically
|
// mask, which prevents the stepper algorithm from executing step pulses. Homing motions typically
|
||||||
// circumvent the processes for executing motions in normal operation.
|
// circumvent the processes for executing motions in normal operation.
|
||||||
// NOTE: Only the abort realtime command can interrupt this process.
|
// NOTE: Only the abort realtime command can interrupt this process.
|
||||||
static void limits_go_home(uint8_t cycle_mask, uint32_t n_locate_cycles) {
|
|
||||||
|
// cycle_mask cannot be 0. The 0 case - run all cycles - is
|
||||||
|
// handled by the caller mc_homing_cycle()
|
||||||
|
static void limits_run_one_homing_cycle(AxisMask cycle_mask) {
|
||||||
if (sys.abort) {
|
if (sys.abort) {
|
||||||
return; // Block if system reset has been issued.
|
return; // Block if system reset has been issued.
|
||||||
}
|
}
|
||||||
@@ -207,7 +210,7 @@ static void limits_go_home(uint8_t cycle_mask, uint32_t n_locate_cycles) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize variables used for homing computations.
|
// Initialize variables used for homing computations.
|
||||||
uint8_t n_cycle = (2 * n_locate_cycles + 1);
|
uint8_t n_cycle = (2 * NHomingLocateCycle + 1);
|
||||||
|
|
||||||
// approach is the direction of motion; it cycles between true and false
|
// approach is the direction of motion; it cycles between true and false
|
||||||
bool approach = true;
|
bool approach = true;
|
||||||
@@ -318,76 +321,6 @@ static void limits_go_home(uint8_t cycle_mask, uint32_t n_locate_cycles) {
|
|||||||
config->_axes->set_homing_mode(cycle_mask, false); // tell motors homing is done
|
config->_axes->set_homing_mode(cycle_mask, false); // tell motors homing is done
|
||||||
}
|
}
|
||||||
|
|
||||||
// return true if the mask has exactly one bit set,
|
|
||||||
// so it refers to exactly one axis
|
|
||||||
static bool mask_is_single_axis(AxisMask axis_mask) {
|
|
||||||
// This code depends on the fact that, for binary numberes
|
|
||||||
// with only one bit set - and only for such numbers -
|
|
||||||
// the bits in one less than the number are disjoint
|
|
||||||
// with that bit. For a number like B100, if you
|
|
||||||
// subtract one, the low order 00 bits will have to
|
|
||||||
// borrow from the high 1 bit and thus clear it.
|
|
||||||
// If any lower bits are 1, then there will be no
|
|
||||||
// borrow to clear the highest 1 bit.
|
|
||||||
return axis_mask && ((axis_mask & (axis_mask - 1)) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static AxisMask squaredAxes() {
|
|
||||||
AxisMask mask = 0;
|
|
||||||
auto axes = config->_axes;
|
|
||||||
auto n_axis = axes->_numberAxis;
|
|
||||||
for (int axis = 0; axis < n_axis; axis++) {
|
|
||||||
auto homing = axes->_axis[axis]->_homing;
|
|
||||||
if (homing && homing->_square) {
|
|
||||||
set_bitnum(mask, axis);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool axis_is_squared(AxisMask axis_mask) {
|
|
||||||
// Squaring can only be done if it is the only axis in the mask
|
|
||||||
|
|
||||||
// cases:
|
|
||||||
// axis_mask has one bit:
|
|
||||||
// axis is squared: return true
|
|
||||||
// else: return false
|
|
||||||
// else:
|
|
||||||
// one of the axes is squared: message and return false
|
|
||||||
// else return false
|
|
||||||
|
|
||||||
if (axis_mask & squaredAxes()) {
|
|
||||||
if (mask_is_single_axis(axis_mask)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
log_info("Cannot multi-axis home with squared axes. Homing normally");
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For this routine, homing_mask cannot be 0. The 0 case,
|
|
||||||
// meaning run all cycles, is handled by the caller mc_homing_cycle()
|
|
||||||
static void limits_run_one_homing_cycle(AxisMask homing_mask) {
|
|
||||||
if (axis_is_squared(homing_mask)) {
|
|
||||||
// For squaring, we first do the fast seek using both motors,
|
|
||||||
// skipping the second slow moving phase.
|
|
||||||
ganged_mode = gangDual;
|
|
||||||
limits_go_home(homing_mask, 0); // Do not do a second touch cycle
|
|
||||||
|
|
||||||
// Then we do the slow motion on the individual motors
|
|
||||||
ganged_mode = gangA;
|
|
||||||
limits_go_home(homing_mask, NHomingLocateCycle);
|
|
||||||
|
|
||||||
ganged_mode = gangB;
|
|
||||||
limits_go_home(homing_mask, NHomingLocateCycle);
|
|
||||||
|
|
||||||
ganged_mode = gangDual; // always return to dual
|
|
||||||
} else {
|
|
||||||
limits_go_home(homing_mask, NHomingLocateCycle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void limits_run_homing_cycles(AxisMask axis_mask) {
|
void limits_run_homing_cycles(AxisMask axis_mask) {
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
// Perform homing routine. NOTE: Special motion case. Only system reset works.
|
// Perform homing routine. NOTE: Special motion case. Only system reset works.
|
||||||
|
@@ -28,7 +28,6 @@ namespace Machine {
|
|||||||
// The homing cycles are 1,2,3 etc. 0 means not homed as part of home-all,
|
// The homing cycles are 1,2,3 etc. 0 means not homed as part of home-all,
|
||||||
// but you can still home it manually with e.g. $HA
|
// but you can still home it manually with e.g. $HA
|
||||||
int _cycle = -1; // what auto-homing cycle does this axis home on?
|
int _cycle = -1; // what auto-homing cycle does this axis home on?
|
||||||
bool _square = false;
|
|
||||||
bool _positiveDirection = true;
|
bool _positiveDirection = true;
|
||||||
float _mpos = 0.0f; // After homing this will be the mpos of the switch location
|
float _mpos = 0.0f; // After homing this will be the mpos of the switch location
|
||||||
float _feedRate = 50.0f; // pulloff and second touch speed
|
float _feedRate = 50.0f; // pulloff and second touch speed
|
||||||
@@ -49,7 +48,6 @@ namespace Machine {
|
|||||||
handler.item("seek_rate", _seekRate);
|
handler.item("seek_rate", _seekRate);
|
||||||
handler.item("debounce_ms", _debounce_ms);
|
handler.item("debounce_ms", _debounce_ms);
|
||||||
handler.item("pulloff", _pulloff);
|
handler.item("pulloff", _pulloff);
|
||||||
handler.item("square", _square);
|
|
||||||
handler.item("seek_scaler", _seek_scaler);
|
handler.item("seek_scaler", _seek_scaler);
|
||||||
handler.item("feed_scaler", _feed_scaler);
|
handler.item("feed_scaler", _feed_scaler);
|
||||||
}
|
}
|
||||||
|
@@ -40,8 +40,6 @@
|
|||||||
# define M_PI 3.14159265358979323846
|
# define M_PI 3.14159265358979323846
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GangMask ganged_mode = gangDual; // Run both motors at once
|
|
||||||
|
|
||||||
// mc_pl_data_inflight keeps track of a jog command sent to mc_line() so we can cancel it.
|
// mc_pl_data_inflight keeps track of a jog command sent to mc_line() so we can cancel it.
|
||||||
// this is needed if a jogCancel comes along after we have already parsed a jog and it is in-flight.
|
// this is needed if a jogCancel comes along after we have already parsed a jog and it is in-flight.
|
||||||
static volatile void* mc_pl_data_inflight; // holds a plan_line_data_t while cartesian_to_motors has taken ownership of a line motion
|
static volatile void* mc_pl_data_inflight; // holds a plan_line_data_t while cartesian_to_motors has taken ownership of a line motion
|
||||||
@@ -463,8 +461,6 @@ void mc_reset() {
|
|||||||
}
|
}
|
||||||
Stepper::go_idle(); // Force kill steppers. Position has likely been lost.
|
Stepper::go_idle(); // Force kill steppers. Position has likely been lost.
|
||||||
}
|
}
|
||||||
ganged_mode = gangDual; // in case an error occurred during squaring
|
|
||||||
|
|
||||||
config->_stepping->reset();
|
config->_stepping->reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -74,11 +74,3 @@ void mc_reset();
|
|||||||
void mc_cancel_jog();
|
void mc_cancel_jog();
|
||||||
|
|
||||||
void mc_init();
|
void mc_init();
|
||||||
|
|
||||||
typedef uint8_t GangMask;
|
|
||||||
const GangMask gangA = bit(0);
|
|
||||||
const GangMask gangB = bit(1);
|
|
||||||
const GangMask gangDual = gangA | gangB;
|
|
||||||
|
|
||||||
// TODO: Ideally, ganged_mode would be in the planner block instead of global
|
|
||||||
extern GangMask ganged_mode;
|
|
||||||
|
Reference in New Issue
Block a user