diff options
author | kliment <kliment.yanev@gmail.com> | 2011-07-12 05:30:10 -0700 |
---|---|---|
committer | kliment <kliment.yanev@gmail.com> | 2011-07-12 05:30:10 -0700 |
commit | 331653b519f052958cc553c6b9d0a97ee62a0658 (patch) | |
tree | 5d6ec76c4bdc4da58525a89aaf508ae896ca1603 /Sprinter | |
parent | 1c4cbe4da712fd670abb56ee2c2d0b48ec8d14c4 (diff) | |
parent | 8c13d978e4b0632c4c10953d9c6fa71d7dd45edf (diff) |
Merge pull request #49 from alexrj/master
Fix overflow on very long moves
Diffstat (limited to 'Sprinter')
-rw-r--r-- | Sprinter/Sprinter.pde | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde index 1aa91f7..b31a629 100644 --- a/Sprinter/Sprinter.pde +++ b/Sprinter/Sprinter.pde @@ -1010,7 +1010,11 @@ void linear_move(unsigned long axis_steps_remaining[]) // make linear move with } for(int i = 0; i < NUM_AXIS; i++) if(axis_steps_remaining[i] >0) { - new_axis_max_intervals[i] = slowest_start_axis_max_interval * axis_steps_remaining[slowest_start_axis] / axis_steps_remaining[i]; + // multiplying slowest_start_axis_max_interval by axis_steps_remaining[slowest_start_axis] + // could lead to overflows when we have long distance moves (say, 390625*390625 > sizeof(unsigned long)) + float steps_remaining_ratio = axis_steps_remaining[slowest_start_axis] / axis_steps_remaining[i]; + new_axis_max_intervals[i] = slowest_start_axis_max_interval * steps_remaining_ratio; + if(i == primary_axis) { max_interval = new_axis_max_intervals[i]; min_speed_steps_per_second = 100000000 / max_interval; |