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 acceleration limits, when axes have differing requirements. #7

Open
wants to merge 1 commit into
base: Marlin_v1
Choose a base branch
from
Open
Show file tree
Hide file tree
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/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# from the commandline with "make HARDWARE_MOTHERBOARD=71" for example

# This defined the board you are compiling for (see Configuration.h for the options)
HARDWARE_MOTHERBOARD ?= 11
HARDWARE_MOTHERBOARD ?= 7

# Arduino source install directory, and version number
ARDUINO_INSTALL_DIR ?= ../../arduino-0022
Expand Down
20 changes: 15 additions & 5 deletions Marlin/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,8 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
}
float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides

// Calculate speed in mm/second for each axis. No divide by zero due to previous checks.

// calculate moves/second for this move. No divide by zero due to previous checks.
float inverse_second = feed_rate * inverse_millimeters;

int moves_queued=(block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
Expand Down Expand Up @@ -718,15 +719,24 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
block->acceleration_st = ceil(acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
// Limit acceleration per axis
if(((float)block->acceleration_st * (float)block->steps_x / (float)block->step_event_count) > axis_steps_per_sqr_second[X_AXIS])
block->acceleration_st = axis_steps_per_sqr_second[X_AXIS];
// acceleration is too fast for x, so limit acceleration to a rate that just passes the test on previous line
block->acceleration_st = axis_steps_per_sqr_second[X_AXIS] * (float)block->step_event_count/(float)block->steps_x;

if(((float)block->acceleration_st * (float)block->steps_y / (float)block->step_event_count) > axis_steps_per_sqr_second[Y_AXIS])
block->acceleration_st = axis_steps_per_sqr_second[Y_AXIS];
// acceleration is too fast for y, so limit acceleration to a rate that just passes the test on previous line
block->acceleration_st = axis_steps_per_sqr_second[Y_AXIS] * (float)block->step_event_count/(float)block->steps_y;

if(((float)block->acceleration_st * (float)block->steps_e / (float)block->step_event_count) > axis_steps_per_sqr_second[E_AXIS])
block->acceleration_st = axis_steps_per_sqr_second[E_AXIS];
// acceleration is too fast for e, so limit acceleration to a rate that just passes the test on previous line
block->acceleration_st = axis_steps_per_sqr_second[E_AXIS] * (float)block->step_event_count/(float)block->steps_e;

if(((float)block->acceleration_st * (float)block->steps_z / (float)block->step_event_count ) > axis_steps_per_sqr_second[Z_AXIS])
block->acceleration_st = axis_steps_per_sqr_second[Z_AXIS];
// acceleration is too fast for z, so limit acceleration to a rate that just passes the test on previous line
block->acceleration_st = axis_steps_per_sqr_second[Z_AXIS] * (float)block->step_event_count/(float)block->steps_z;
}
block->acceleration = block->acceleration_st / steps_per_mm;

// TODO: What is the significance of 8.388608? Should it be defined as a constant, or static somewhere? Could it ever change?
block->acceleration_rate = (long)((float)block->acceleration_st * 8.388608);

#if 0 // Use old jerk for now
Expand Down