1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-21 05:41:50 +02:00

Homing fixes

This commit is contained in:
Mitch Bradley
2021-07-29 09:45:38 -10:00
parent ab29243efb
commit 6ddbb7ce84
3 changed files with 13 additions and 13 deletions

View File

@@ -28,6 +28,8 @@ namespace Machine {
_sharedStepperDisable.report("Shared stepper disable"); _sharedStepperDisable.report("Shared stepper disable");
} }
release_all_motors();
// certain motors need features to be turned on. Check them here // certain motors need features to be turned on. Check them here
for (uint8_t axis = X_AXIS; axis < _numberAxis; axis++) { for (uint8_t axis = X_AXIS; axis < _numberAxis; axis++) {
auto a = _axis[axis]; auto a = _axis[axis];
@@ -80,24 +82,24 @@ namespace Machine {
// Put the motors in the given axes into homing mode, returning a // Put the motors in the given axes into homing mode, returning a
// mask of which motors (considering gangs) can do homing. // mask of which motors (considering gangs) can do homing.
MotorMask Axes::set_homing_mode(AxisMask homing_mask, bool isHoming) { MotorMask Axes::set_homing_mode(AxisMask axisMask, bool isHoming) {
release_all_motors(); // On homing transitions, cancel all motor lockouts release_all_motors(); // On homing transitions, cancel all motor lockouts
MotorMask can_home = 0; MotorMask motorsCanHome = 0;
for (uint8_t axis = X_AXIS; axis < _numberAxis; axis++) { for (uint8_t axis = X_AXIS; axis < _numberAxis; axis++) {
if (bitnum_is_true(homing_mask, axis)) { if (bitnum_is_true(axisMask, axis)) {
auto a = _axis[axis]; auto a = _axis[axis];
if (a != nullptr) { if (a != nullptr) {
for (uint8_t gang = 0; gang < Axis::MAX_NUMBER_GANGED; gang++) { for (uint8_t gang = 0; gang < Axis::MAX_NUMBER_GANGED; gang++) {
if (a->_gangs[gang]->_motor->set_homing_mode(isHoming)) { if (a->_gangs[gang]->_motor->set_homing_mode(isHoming)) {
set_bitnum(can_home, gang * 16 + axis); set_bitnum(motorsCanHome, gang * 16 + axis);
} }
} }
} }
} }
} }
return can_home; return motorsCanHome;
} }
void Axes::release_all_motors() { _motorLockoutMask = 0xffffffff; } void Axes::release_all_motors() { _motorLockoutMask = 0xffffffff; }

View File

@@ -33,7 +33,7 @@ namespace Machine {
// During homing, this is used to stop stepping on motors that have // During homing, this is used to stop stepping on motors that have
// reached their limit switches, by clearing bits in the mask. // reached their limit switches, by clearing bits in the mask.
MotorMask _motorLockoutMask = 0; MotorMask _motorLockoutMask = 0xffffffff;
public: public:
Axes(); Axes();

View File

@@ -52,7 +52,7 @@ namespace Machine {
AxisMask axesMask = 0; AxisMask axesMask = 0;
// Find the axis that will take the longest // Find the axis that will take the longest
for (int axis = 0; axis < n_axis; axis++) { for (int axis = 0; axis < n_axis; axis++) {
if (bits_are_false(motors, axis | (axis << 16))) { if (bitnum_is_false(motors, axis) && bitnum_is_false(motors, axis + 16)) {
continue; continue;
} }
@@ -89,10 +89,6 @@ namespace Machine {
travel = std::max(travel, axisConfig->_gangs[1]->_endstops->_pulloff); travel = std::max(travel, axisConfig->_gangs[1]->_endstops->_pulloff);
} }
} }
// We know that endstop is not nullptr because we checked for a
// valid endstop configuration before starting to home.
travel = endstop->_pulloff;
} }
// First we compute the maximum-time-to-completion vector; later we will // First we compute the maximum-time-to-completion vector; later we will
@@ -107,11 +103,11 @@ namespace Machine {
} }
} }
// Scale the target array, currently in units of time, back to positions // Scale the target array, currently in units of time, back to positions
// When approaching a small fudge factor to ensure that the limit is reached - // When approaching add a fudge factor (scaler) to ensure that the limit is reached -
// but no fudge factor when pulling off. // but no fudge factor when pulling off.
for (int axis = 0; axis < n_axis; axis++) { for (int axis = 0; axis < n_axis; axis++) {
if (bitnum_is_true(axesMask, axis)) { if (bitnum_is_true(axesMask, axis)) {
auto homing = config->_axes->_axis[axis]->_homing; auto homing = axes->_axis[axis]->_homing;
auto scaler = approach ? (seek ? homing->_seek_scaler : homing->_feed_scaler) : 1.0; auto scaler = approach ? (seek ? homing->_seek_scaler : homing->_feed_scaler) : 1.0;
target[axis] *= limitingRate * scaler; target[axis] *= limitingRate * scaler;
} }
@@ -148,6 +144,8 @@ namespace Machine {
uint32_t settling_ms = plan_move(remainingMotors, approach, seek); uint32_t settling_ms = plan_move(remainingMotors, approach, seek);
config->_axes->release_all_motors();
do { do {
if (approach) { if (approach) {
// Check limit state. Lock out cycle axes when they change. // Check limit state. Lock out cycle axes when they change.