Skip to content

Commit

Permalink
Merge pull request #564 from doudar/Big_Table_2
Browse files Browse the repository at this point in the history
fixed bug with stepper speed not updating
  • Loading branch information
doudar authored Aug 7, 2024
2 parents 843a5f7 + 9a9cbfa commit 69961f3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed bug in CPS service for Wahoo app (and probably others).
- Depreciated the SPIFFS->LittleFS upgrader.
- Increased ERG mode sensitivity.
- removed extra logging when loading table.
- prevent table returns from going in the wrong direction.
- many small bug fixes.
- Removed extra logging when loading table.
- Prevent table returns from going in the wrong direction.
- Fixed bug with stepper speed not updating.


### Hardware
Expand Down
29 changes: 14 additions & 15 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,7 @@ void SS2K::restartWifi() {
}

void SS2K::moveStepper(void *pvParameters) {
engine.init();
bool _stepperDir = userConfig->getStepperDir();
stepper = engine.stepperConnectToPin(currentBoard.stepPin);
stepper->setDirectionPin(currentBoard.dirPin, _stepperDir);
stepper->setEnablePin(currentBoard.enablePin);
stepper->setAutoEnable(true);
stepper->setSpeedInHz(DEFAULT_STEPPER_SPEED);
stepper->setAcceleration(STEPPER_ACCELERATION);
stepper->setDelayToDisable(1000);

while (1) {
if (stepper) {
Expand Down Expand Up @@ -494,23 +486,30 @@ void SS2K::resetIfShiftersHeld() {
}

void SS2K::setupTMCStepperDriver() {
// FastAccel setup
engine.init();
stepper = engine.stepperConnectToPin(currentBoard.stepPin);
stepper->setDirectionPin(currentBoard.dirPin, userConfig->getStepperDir());
stepper->setEnablePin(currentBoard.enablePin);
stepper->setAutoEnable(true);
stepper->setSpeedInHz(DEFAULT_STEPPER_SPEED);
stepper->setAcceleration(STEPPER_ACCELERATION);
stepper->setDelayToDisable(1000);

// TMC Driver Setup
driver.begin();
driver.pdn_disable(true);
driver.mstep_reg_select(true);

ss2k->updateStepperSpeed();
ss2k->updateStepperPower();
driver.microsteps(4); // Set microsteps to 1/8th
driver.irun(currentBoard.pwrScaler);
driver.ihold((uint8_t)(currentBoard.pwrScaler * .5)); // hold current % 0-DRIVER_MAX_PWR_SCALER
driver.iholddelay(10); // Controls the number of clock cycles for motor
// power down after standstill is detected
// power down after standstill is detected
driver.TPOWERDOWN(128);

driver.toff(5);
bool t_bool = userConfig->getStealthChop();
driver.en_spreadCycle(!t_bool);
driver.pwm_autoscale(t_bool);
driver.pwm_autograd(t_bool);
ss2k->updateStealthChop();
}

// Applies current power to driver
Expand Down

0 comments on commit 69961f3

Please sign in to comment.