Skip to content
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

Fix an acceleration anomaly by making block->steps unsigned #3614

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Marlin/planner.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
// the source g-code and may never actually be reached if acceleration management is active.
typedef struct {
// Fields used by the bresenham algorithm for tracing the line
long steps[NUM_AXIS]; // Step count along each axis
unsigned long steps[NUM_AXIS]; // Step count along each axis
unsigned long step_event_count; // The number of step events required to complete this block
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that steps and step_event_count are treated as though they cannot go over 0x7FFFFFFF in the Bresenham algorithm. The negative of the value is assigned to a counter. Then the algorithm looks for the counter to go over zero. If steps or step_event_count are ever 0x80000000 or higher, the code will fail. But surely there could never be more than 2.14 billion steps in a single move, right?

long accelerate_until; // The index of the step event on which to stop acceleration
long decelerate_after; // The index of the step event on which to start decelerating
Expand Down