Skip to content

Commit

Permalink
Merge pull request #589 from doudar/home-safety
Browse files Browse the repository at this point in the history
Added a couple safety features to homing
  • Loading branch information
doudar authored Nov 7, 2024
2 parents a358091 + fcf94eb commit a48325a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ jobs:
pull-requests: write

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'

Expand Down
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- Knob homing if calibrate trainer is selected in an app.

### Changed

### Hardware

## [24.11.5]

### Added
- Knob homing if calibrate trainer is selected in an app.

### Changed
- Added backing off of the stop before we test to prevent runaway grinding during homing.
- User can abort homing by pressing shifter.

### Hardware

## [24.10.30]

### Added
Expand Down
29 changes: 25 additions & 4 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,18 +570,27 @@ void SS2K::goHome(bool bothDirections) {
vTaskDelay(50 / portTICK_PERIOD_MS);
driver.ihold((uint8_t)(1));
vTaskDelay(50 / portTICK_PERIOD_MS);
this->updateStepperSpeed(1500);
bool stalled = false;
int threshold = 0;
vTaskDelay(1000 / portTICK_PERIOD_MS);
bool stalled = false;
if (bothDirections) {
// Back off limit in case we are alread here.
stepper->move(-userConfig->getShiftStep());
while (stepper->isRunning()) {
vTaskDelay(50 / portTICK_PERIOD_MS);
}
this->updateStepperSpeed(1500);
vTaskDelay(500 / portTICK_PERIOD_MS);
stepper->runForward();
vTaskDelay(250 / portTICK_PERIOD_MS); // wait until stable
threshold = driver.SG_RESULT(); // take reading
Serial.printf("%d ", driver.SG_RESULT());
vTaskDelay(250 / portTICK_PERIOD_MS);
while (!stalled) {
// stalled = (threshold < 200); // Were we already at the stop?
if (abs(rtConfig->getShifterPosition() - ss2k->lastShifterPosition)) { // let the user abort with the shift button.
userConfig->setHMin(INT32_MIN);
userConfig->setHMax(INT32_MIN);
return;
}
stalled = (driver.SG_RESULT() < threshold - 100);
}
stalled = false;
Expand All @@ -591,13 +600,25 @@ void SS2K::goHome(bool bothDirections) {
rtConfig->setMaxStep(stepper->getCurrentPosition() - 200);
SS2K_LOG(MAIN_LOG_TAG, "Max Position found: %d.", rtConfig->getMaxStep());
stepper->enableOutputs();
} else { // Back off limit in case we are alread here.
stepper->move(userConfig->getShiftStep());
while (stepper->isRunning()) {
vTaskDelay(50 / portTICK_PERIOD_MS);
}
this->updateStepperSpeed(1500);
vTaskDelay(500 / portTICK_PERIOD_MS);
}
stepper->runBackward();
vTaskDelay(250 / portTICK_PERIOD_MS);
threshold = driver.SG_RESULT();
Serial.printf("%d ", driver.SG_RESULT());
vTaskDelay(250 / portTICK_PERIOD_MS);
while (!stalled) {
if (abs(rtConfig->getShifterPosition() - ss2k->lastShifterPosition)) { // let the user abort with the shift button.
userConfig->setHMin(INT32_MIN);
userConfig->setHMax(INT32_MIN);
return;
}
stalled = (driver.SG_RESULT() < threshold - 75);
}
stepper->forceStop();
Expand Down

0 comments on commit a48325a

Please sign in to comment.