Max Value for position?

55 views
Skip to first unread message

Doug Hanson

unread,
Mar 27, 2025, 7:53:37 PMMar 27
to accelstepper
Just learning the library and not a great programmer. My sketch works but things go crazy if I try a position number above 35,000. Is position limited to a signed double byte? I guess that would be ~32,000. I have a standard Nema17 motor with 200 steps per revolution and my driver is set up for 1/8 microsteps to a lead screw with lead =8. So I need 200 steps per millimeter. That is why I am getting into such big position numbers. Is the answer to use 1/4 microstepping on the driver? I need my nut travel to be 300mm total. I probably have it all wrong. But I can't find an answer in the docs regarding max position number. Thanks for any help.

gjgsm...@gmail.com

unread,
Mar 27, 2025, 11:22:17 PMMar 27
to accelstepper

AccelStepper itself is not limited to ±32,767 steps. It uses 32-bit signed longs for positions (±2,147,483,647). If you are hitting a limit near 32,000,–,35,000, it’s almost certainly because your own variables or function parameters are declared as a 16-bit int instead of a 32-bit long (or long long). Simply use a larger integer type in your code, and AccelStepper can handle those big step counts.

Microstepping can be chosen based on mechanical requirements (resolution vs. speed/torque), not because the code is limited to small values.

Would need to see your complete code for any further assistance.

Geoff

Reply all
Reply to author
Forward
0 new messages