From 86556d8b514a67d4d60fd6c9b4f694fd9ec2e4f1 Mon Sep 17 00:00:00 2001 From: Jochen Kiemes Date: Thu, 8 Dec 2022 00:17:27 +0100 Subject: [PATCH] fix issue #152: lower max speed to 70kSteps/s --- CHANGELOG.md | 5 ++++- README.md | 6 +++--- examples/Issue151/Issue151.ino | 2 +- examples/Issue152/Issue152.ino | 2 +- .../simavr_based/test_sd_04_timing_2560/expect.txt | 2 +- .../simavr_based/test_sd_04_timing_328p/expect.txt | 14 +++++++------- .../test_sd_04_timing_328p_37k/expect.txt | 8 ++++---- library.properties | 4 ++-- src/StepperISR_avr.cpp | 2 +- 9 files changed, 24 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66e57ad6..f9c12797 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,11 @@ TODO: - #include-file structure needs to be cleaned up - setCurrentPosition() should adjust the maintained last position bits in queue. can be called a bug +0.28.3: +- reduce AVR max single stepper speed to 70kSteps/s due to issue [Issue #152](https://github.com/gin66/FastAccelStepper/issues/152) + 0.28.2: -- fix for issue [Issue #150](https://github.com/gin66/FastAccelStepper/issues/150) +- fix for issue [Issue #150](https://github.com/gin66/FastAccelStepper/issues/150) for low speed not reducing below startup speed 0.28.1: - try to fix [Issue #142](https://github.com/gin66/FastAccelStepper/issues/142) for esp32 mcpwm/pcnt and format code diff --git a/README.md b/README.md index 1ecef44a..5a4ea17c 100644 --- a/README.md +++ b/README.md @@ -96,21 +96,21 @@ Comments to pin sharing: ### AVR ATMega 328 -* allows up to 76000 generated steps per second for single stepper operation, 37000 for dual stepper +* allows up to 70000 generated steps per second for single stepper operation, 37000 for dual stepper * supports up to two stepper motors using Step/Direction/Enable Control (Direction and Enable is optional) * Uses `F_CPU` Macro for the relation tick value to time, so it should now not be limited to 16 MHz CPU frequency (untested) * Steppers' command queue depth: 16 ### AVR ATMega 32u4 -* allows up to 76000 generated steps per second for single stepper operation, 37000 for dual stepper and 25000 for three steppers +* allows up to 70000 generated steps per second for single stepper operation, 37000 for dual stepper and 25000 for three steppers * supports up to three stepper motors using Step/Direction/Enable Control (Direction and Enable is optional) * Uses `F_CPU` Macro for the relation tick value to time, so it should now not be limited to 16 MHz CPU frequency (untested) * Steppers' command queue depth: 16 ### AVR ATMega 2560 -* allows up to 76000 generated steps per second for single stepper operation, 37000 for dual stepper and 25000 for three steppers +* allows up to 70000 generated steps per second for single stepper operation, 37000 for dual stepper and 25000 for three steppers * supports up to three stepper motors using Step/Direction/Enable Control (Direction and Enable is optional) * Uses `F_CPU` Macro for the relation tick value to time, so it should now not be limited to 16 MHz CPU frequency (untested) * Steppers' command queue depth: 16 diff --git a/examples/Issue151/Issue151.ino b/examples/Issue151/Issue151.ino index fcfbd528..be21059c 100644 --- a/examples/Issue151/Issue151.ino +++ b/examples/Issue151/Issue151.ino @@ -40,7 +40,7 @@ void setup() { void loop() { // test to check single stepper high speed operation int32_t target = 20000; - stepper->setSpeedInHz(75000); + stepper->setSpeedInHz(70000); stepper->moveTo(target); while(stepper->isRunning()) { }; diff --git a/examples/Issue152/Issue152.ino b/examples/Issue152/Issue152.ino index 9f63fd49..ee323307 100644 --- a/examples/Issue152/Issue152.ino +++ b/examples/Issue152/Issue152.ino @@ -40,7 +40,7 @@ void setup() { void loop() { // test to check single stepper high speed operation int32_t target = 20000; - stepper->setSpeedInHz(75000); + stepper->setSpeedInHz(70000); stepper->moveTo(target); while(stepper->isRunning()) { }; diff --git a/extras/tests/simavr_based/test_sd_04_timing_2560/expect.txt b/extras/tests/simavr_based/test_sd_04_timing_2560/expect.txt index 56be1b42..1ae27175 100644 --- a/extras/tests/simavr_based/test_sd_04_timing_2560/expect.txt +++ b/extras/tests/simavr_based/test_sd_04_timing_2560/expect.txt @@ -17,7 +17,7 @@ Time in EnableA max=217159 us, total=217159 us Time in EnableB max=233738 us, total=233738 us -Time in EnableC max=242116 us, total=242116 us +Time in EnableC max=242115 us, total=242115 us Time in FillISR max=3655 us, total=2140393 us diff --git a/extras/tests/simavr_based/test_sd_04_timing_328p/expect.txt b/extras/tests/simavr_based/test_sd_04_timing_328p/expect.txt index 54347870..642a2a04 100644 --- a/extras/tests/simavr_based/test_sd_04_timing_328p/expect.txt +++ b/extras/tests/simavr_based/test_sd_04_timing_328p/expect.txt @@ -2,21 +2,21 @@ DirB: 1*L->H, 0*H->L EnableA: 1*L->H, 1*H->L EnableB: 2*L->H, 1*H->L - StepA: 1000*L->H, 1000*H->L, Max High=15us Total High=5505us - StepB: 1000*L->H, 1000*H->L, Max High=17us Total High=5540us + StepA: 1000*L->H, 1000*H->L, Max High=15us Total High=5504us + StepB: 1000*L->H, 1000*H->L, Max High=17us Total High=5497us Position[A]=1000 Position[B]=1000 -Time in EnableA max=213060 us, total=213060 us +Time in EnableA max=213059 us, total=213059 us -Time in EnableB max=225632 us, total=225632 us +Time in EnableB max=225630 us, total=225630 us -Time in FillISR max=2409 us, total=46255 us +Time in FillISR max=2409 us, total=46246 us -Time in StepA max=15 us, total=5505 us +Time in StepA max=15 us, total=5504 us -Time in StepB max=17 us, total=5540 us +Time in StepB max=17 us, total=5497 us Time in StepISR max=7 us, total=9224 us diff --git a/extras/tests/simavr_based/test_sd_04_timing_328p_37k/expect.txt b/extras/tests/simavr_based/test_sd_04_timing_328p_37k/expect.txt index 1471e35a..96fc4678 100644 --- a/extras/tests/simavr_based/test_sd_04_timing_328p_37k/expect.txt +++ b/extras/tests/simavr_based/test_sd_04_timing_328p_37k/expect.txt @@ -2,15 +2,15 @@ DirB: 1*L->H, 0*H->L EnableA: 1*L->H, 1*H->L EnableB: 1*L->H, 0*H->L - StepA: 1000*L->H, 1000*H->L, Max High=12us Total High=5258us + StepA: 1000*L->H, 1000*H->L, Max High=12us Total High=5262us StepB: 0*L->H, 0*H->L, Max High=0us Total High=0us Position[A]=1000 -Time in EnableA max=213060 us, total=213060 us +Time in EnableA max=213059 us, total=213059 us -Time in FillISR max=1937 us, total=26708 us +Time in FillISR max=1937 us, total=26715 us -Time in StepA max=12 us, total=5258 us +Time in StepA max=12 us, total=5262 us Time in StepISR max=7 us, total=4581 us diff --git a/library.properties b/library.properties index 0e124638..19598d7a 100644 --- a/library.properties +++ b/library.properties @@ -1,10 +1,10 @@ name=FastAccelStepper -version=0.28.2 +version=0.28.3 1icense=MIT author=Jochen Kiemes maintainer=Jochen Kiemes sentence=A high speed stepper library for Atmega 328p (nano), 32u4 (leonardo), 2560, ESP32, ESP32S2 and Atmel SAM Due -paragraph=Drive stepper motors with acceleration/deceleration profile up to 76 kSteps/s (Atmega) and 200kSteps/s (esp32). +paragraph=Drive stepper motors with acceleration/deceleration profile up to 70 kSteps/s (Atmega) and 200kSteps/s (esp32). url=https://github.com/gin66/FastAccelStepper repository=https://github.com/gin66/FastAccelStepper.git architectures=avr,esp32,sam diff --git a/src/StepperISR_avr.cpp b/src/StepperISR_avr.cpp index a03fae97..a93ca509 100644 --- a/src/StepperISR_avr.cpp +++ b/src/StepperISR_avr.cpp @@ -347,7 +347,7 @@ void StepperQueue::adjustSpeedToStepperCount(uint8_t steppers) { // using test_sd_04_timing_328p version 0.25.6 as reference // manageStepper (fillISR) already needs max 2.3 ms ! // - max_speed_in_ticks = 213 * steppers; + max_speed_in_ticks = (steppers == 1) ? 228 : 213 * steppers; } void fas_init_engine(FastAccelStepperEngine* engine, uint8_t cpu_core) {