-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refuses to move high number of steps #96
Comments
Tested with full steps and confirm same behavior. |
Thank you for providing the details and the sample code. The number seems to indicate an issue with 16-bit signed math as you probably surmised, but we use long even on 8-bit platform... will take a look |
I replaced the Arduino Nano Every with a knockoff Arduino Nano (common version with old bootloader), and this problem does not seem to persist. So it seems to be a problem particular to the Arduino Nano Every. |
I was unable to reproduce the problem with an Arduino Uno either. I don't have any megaAVR boards unfortunately. In Arduino the Every board has an option for 328 register emulation, is there a difference when enabling it ? |
Hmm, I have a suspicion. Can you please add this to the test sketch and let me know if it prints the expected value or not ? long v = 32768;
Serial.println(abs(v)); |
It prints the value as -32768 (negative) |
Use `labs()` explicitly when `abs()` was needed for `long` parameters. Reason: On Arduino Nano Every (ATmega4809), `int abs(int)` is used for a `long` argument, resulting in failure to move more than 32767 steps in one move operation.
Thank you for confirming, I will be creating 1.3.1 to hopefully address this |
Describe the bug
I'm having trouble telling my stepper to move a large amount of steps. This sketch successfully moves the motor 22934 steps, but when it is told to move 45868 steps, it will only move 19668 steps (checked using stepper.getStepsCompleted(), but I can also visually tell that the steps were not right).
To Reproduce
https://gist.github.com/joymonkey/b95d479af7c2375a7479c3a6775653e7
Expected behavior
Motor should move 45868 steps.
Platform Setup (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: