cleaned up methods for enabling/disabling acceleration manger
This commit is contained in:
parent
7092b0e1fe
commit
cdcc7bf86e
@ -31,12 +31,10 @@
|
||||
|
||||
// The current position of the tool in absolute steps
|
||||
int32_t position[3];
|
||||
int8_t acceleration_management_enabled;
|
||||
|
||||
void mc_init()
|
||||
{
|
||||
clear_vector(position);
|
||||
acceleration_management_enabled = TRUE;
|
||||
}
|
||||
|
||||
void mc_dwell(uint32_t milliseconds)
|
||||
@ -45,15 +43,6 @@ void mc_dwell(uint32_t milliseconds)
|
||||
_delay_ms(milliseconds);
|
||||
}
|
||||
|
||||
void mc_set_acceleration_manager_enabled(uint8_t enabled) {
|
||||
if (enabled) {
|
||||
plan_enable_acceleration_management();
|
||||
} else {
|
||||
plan_disable_acceleration_management();
|
||||
}
|
||||
acceleration_management_enabled = enabled;
|
||||
}
|
||||
|
||||
// Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second
|
||||
// unless invert_feed_rate is true. Then the feed_rate means that the motion should be completed in
|
||||
// 1/feed_rate minutes.
|
||||
@ -96,7 +85,8 @@ void mc_line(double x, double y, double z, double feed_rate, int invert_feed_rat
|
||||
void mc_arc(double theta, double angular_travel, double radius, double linear_travel, int axis_1, int axis_2,
|
||||
int axis_linear, double feed_rate, int invert_feed_rate)
|
||||
{
|
||||
plan_disable_acceleration_management(); // disable acceleration management for the duration of the arc
|
||||
int acceleration_manager_was_enabled = plan_is_acceleration_manager_enabled();
|
||||
plan_set_acceleration_manager_enabled(FALSE); // disable acceleration management for the duration of the arc
|
||||
double millimeters_of_travel = hypot(angular_travel*radius, labs(linear_travel));
|
||||
if (millimeters_of_travel == 0.0) { return; }
|
||||
uint16_t segments = ceil(millimeters_of_travel/settings.mm_per_arc_segment);
|
||||
@ -122,8 +112,8 @@ void mc_arc(double theta, double angular_travel, double radius, double linear_tr
|
||||
target[axis_1] = center_x+sin(theta)*radius;
|
||||
target[axis_2] = center_y+cos(theta)*radius;
|
||||
mc_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], feed_rate, invert_feed_rate);
|
||||
}
|
||||
mc_set_acceleration_manager_enabled(acceleration_management_enabled); // restore acceleration management setting
|
||||
}
|
||||
plan_set_acceleration_manager_enabled(acceleration_manager_was_enabled);
|
||||
}
|
||||
|
||||
void mc_go_home()
|
||||
|
@ -27,9 +27,6 @@
|
||||
// Initializes the motion_control subsystem resources
|
||||
void mc_init();
|
||||
|
||||
// Enables or disables the look ahead acceleration manager. (Default: on)
|
||||
void mc_set_acceleration_manager_enabled(uint8_t enabled);
|
||||
|
||||
// Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second
|
||||
// unless invert_feed_rate is true. Then the feed_rate means that the motion should be completed in
|
||||
// (1 minute)/feed_rate time.
|
||||
|
@ -65,7 +65,7 @@ block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instructio
|
||||
volatile int block_buffer_head; // Index of the next block to be pushed
|
||||
volatile int block_buffer_tail; // Index of the block to process now
|
||||
|
||||
static uint8_t acceleration_management; // Acceleration management active?
|
||||
static uint8_t acceleration_manager_enabled; // Acceleration management active?
|
||||
|
||||
// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the
|
||||
// given acceleration:
|
||||
@ -333,21 +333,18 @@ void planner_recalculate() {
|
||||
void plan_init() {
|
||||
block_buffer_head = 0;
|
||||
block_buffer_tail = 0;
|
||||
plan_enable_acceleration_management();
|
||||
plan_set_acceleration_manager_enabled(TRUE);
|
||||
}
|
||||
|
||||
void plan_enable_acceleration_management() {
|
||||
if (!acceleration_management) {
|
||||
void plan_set_acceleration_manager_enabled(int enabled) {
|
||||
if ((!!acceleration_manager_enabled) != (!!enabled)) {
|
||||
st_synchronize();
|
||||
acceleration_management = TRUE;
|
||||
acceleration_manager_enabled = !!enabled;
|
||||
}
|
||||
}
|
||||
|
||||
void plan_disable_acceleration_management() {
|
||||
if(acceleration_management) {
|
||||
st_synchronize();
|
||||
acceleration_management = FALSE;
|
||||
}
|
||||
int plan_is_acceleration_manager_enabled() {
|
||||
return(acceleration_manager_enabled);
|
||||
}
|
||||
|
||||
// Add a new linear movement to the buffer. steps_x, _y and _z is the signed, relative motion in
|
||||
@ -393,7 +390,7 @@ void plan_buffer_line(int32_t steps_x, int32_t steps_y, int32_t steps_z, uint32_
|
||||
block->rate_delta = ceil(
|
||||
((settings.acceleration*60.0)/(ACCELERATION_TICKS_PER_SECOND))/ // acceleration mm/sec/sec per acceleration_tick
|
||||
travel_per_step); // convert to: acceleration steps/min/acceleration_tick
|
||||
if (acceleration_management) {
|
||||
if (acceleration_manager_enabled) {
|
||||
double safe_speed_factor = factor_for_safe_speed(block);
|
||||
calculate_trapezoid_for_block(block, safe_speed_factor, safe_speed_factor); // compute a conservative acceleration trapezoid for now
|
||||
} else {
|
||||
@ -411,7 +408,7 @@ void plan_buffer_line(int32_t steps_x, int32_t steps_y, int32_t steps_z, uint32_
|
||||
// Move buffer head
|
||||
block_buffer_head = next_buffer_head;
|
||||
|
||||
if (acceleration_management) {
|
||||
if (acceleration_manager_enabled) {
|
||||
planner_recalculate();
|
||||
} else {
|
||||
calculate_trapezoid_for_block(block, 1.0, 1.0);
|
||||
|
@ -68,8 +68,8 @@ void plan_init();
|
||||
void plan_buffer_line(int32_t steps_x, int32_t steps_y, int32_t steps_z, uint32_t microseconds, double millimeters);
|
||||
|
||||
// Enables acceleration-management for upcoming blocks
|
||||
void plan_enable_acceleration_management();
|
||||
// Disables acceleration-management for upcoming blocks
|
||||
void plan_disable_acceleration_management();
|
||||
void plan_set_acceleration_manager_enabled(int enabled);
|
||||
// Is acceleration-management currently enabled?
|
||||
int plan_is_acceleration_manager_enabled();
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user