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

Conversation

thinkyhead
Copy link
Member

@thinkyhead thinkyhead commented Apr 25, 2016

An acceleration issue appears to be caused by conflicting signedness of block->steps and locals used in the acceleration handler. Can block-steps[] simply be made unsigned long? Why is it signed?
#3613 proposed an alternate solution.

@@ -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?

@Blue-Marlin
Copy link
Contributor

Let's pick some really bad numbers. M5 spindel, 400 steps/revolutionn, 1/128 microstepping -> 64000 steps / mm. 0x7fffffff = 2,147,483,647. 2,147,483,647 / 64000 = 33554 mm = 33.5m
Unlikely this will be reached.

@thinkyhead
Copy link
Member Author

Thanks for doing the maths. I am rushing around like a pigeon with its head cut off today.

@thinkyhead
Copy link
Member Author

Some time I would like to log acceleration behavior and see how the anomaly comes about. Buffer some diagnostic info in the stepper routine and serial-out the data in the main loop.

@thinkyhead thinkyhead closed this Apr 29, 2016
@thinkyhead thinkyhead deleted the rc_acceleration_fix2 branch April 29, 2016 23:39
@jbrazio jbrazio modified the milestone: 1.1.0 Jul 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants