From 9a9cbfa8f51eecbb6671d47b15c8f827abd4b2ba Mon Sep 17 00:00:00 2001 From: doudar Date: Wed, 7 Aug 2024 08:31:47 -0500 Subject: [PATCH] fixed bug with stepper speed not updating --- CHANGELOG.md | 6 +++--- src/Main.cpp | 29 ++++++++++++++--------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff20c240..e886e7e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,9 +35,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 - added Yesoul S3. diff --git a/src/Main.cpp b/src/Main.cpp index 5fee390e..f662a821 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -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) { @@ -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