Skip to content

Commit 9a9cbfa

Browse files
committed
fixed bug with stepper speed not updating
1 parent f5e2069 commit 9a9cbfa

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3535
- Fixed bug in CPS service for Wahoo app (and probably others).
3636
- Depreciated the SPIFFS->LittleFS upgrader.
3737
- Increased ERG mode sensitivity.
38-
- removed extra logging when loading table.
39-
- prevent table returns from going in the wrong direction.
40-
- many small bug fixes.
38+
- Removed extra logging when loading table.
39+
- Prevent table returns from going in the wrong direction.
40+
- Fixed bug with stepper speed not updating.
4141

4242
### Hardware
4343
- added Yesoul S3.

src/Main.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -372,15 +372,7 @@ void SS2K::restartWifi() {
372372
}
373373

374374
void SS2K::moveStepper(void *pvParameters) {
375-
engine.init();
376375
bool _stepperDir = userConfig->getStepperDir();
377-
stepper = engine.stepperConnectToPin(currentBoard.stepPin);
378-
stepper->setDirectionPin(currentBoard.dirPin, _stepperDir);
379-
stepper->setEnablePin(currentBoard.enablePin);
380-
stepper->setAutoEnable(true);
381-
stepper->setSpeedInHz(DEFAULT_STEPPER_SPEED);
382-
stepper->setAcceleration(STEPPER_ACCELERATION);
383-
stepper->setDelayToDisable(1000);
384376

385377
while (1) {
386378
if (stepper) {
@@ -494,23 +486,30 @@ void SS2K::resetIfShiftersHeld() {
494486
}
495487

496488
void SS2K::setupTMCStepperDriver() {
489+
// FastAccel setup
490+
engine.init();
491+
stepper = engine.stepperConnectToPin(currentBoard.stepPin);
492+
stepper->setDirectionPin(currentBoard.dirPin, userConfig->getStepperDir());
493+
stepper->setEnablePin(currentBoard.enablePin);
494+
stepper->setAutoEnable(true);
495+
stepper->setSpeedInHz(DEFAULT_STEPPER_SPEED);
496+
stepper->setAcceleration(STEPPER_ACCELERATION);
497+
stepper->setDelayToDisable(1000);
498+
499+
// TMC Driver Setup
497500
driver.begin();
498501
driver.pdn_disable(true);
499502
driver.mstep_reg_select(true);
500-
503+
ss2k->updateStepperSpeed();
501504
ss2k->updateStepperPower();
502505
driver.microsteps(4); // Set microsteps to 1/8th
503506
driver.irun(currentBoard.pwrScaler);
504507
driver.ihold((uint8_t)(currentBoard.pwrScaler * .5)); // hold current % 0-DRIVER_MAX_PWR_SCALER
505508
driver.iholddelay(10); // Controls the number of clock cycles for motor
506-
// power down after standstill is detected
509+
// power down after standstill is detected
507510
driver.TPOWERDOWN(128);
508-
509511
driver.toff(5);
510-
bool t_bool = userConfig->getStealthChop();
511-
driver.en_spreadCycle(!t_bool);
512-
driver.pwm_autoscale(t_bool);
513-
driver.pwm_autograd(t_bool);
512+
ss2k->updateStealthChop();
514513
}
515514

516515
// Applies current power to driver

0 commit comments

Comments
 (0)