diff --git a/config.h b/config.h index 10bcd9a..3a7d180 100644 --- a/config.h +++ b/config.h @@ -133,6 +133,6 @@ void store_setting(int parameter, double value); #define DEFAULT_STEPPING_INVERT_MASK 0 // The temporal resolution of the acceleration management subsystem -#define ACCELERATION_TICKS_PER_SECOND 10L +#define ACCELERATION_TICKS_PER_SECOND 20L #endif diff --git a/motion_control.c b/motion_control.c index c509137..fb82943 100644 --- a/motion_control.c +++ b/motion_control.c @@ -30,11 +30,13 @@ #include "wiring_serial.h" // The current position of the tool in absolute steps -int32_t position[3]; +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) @@ -49,6 +51,7 @@ void mc_set_acceleration_manager_enabled(uint8_t enabled) { } else { plan_disable_acceleration_management(); } + acceleration_management_enabled = enabled; } // Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second @@ -92,7 +95,8 @@ void mc_line(double x, double y, double z, double feed_rate, int invert_feed_rat // segment is configured in settings.mm_per_arc_segment. 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 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); @@ -118,7 +122,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 } void mc_go_home() diff --git a/script/console b/script/console index 5eeac80..66c1d0c 100755 --- a/script/console +++ b/script/console @@ -1,4 +1,4 @@ socat -d -d READLINE /dev/tty.usbmodem24121,nonblock=1,clocal=1 +socat -d -d READLINE /dev/tty.usbserial-A700e0GO,clocal=1,nonblock=1,cread=1,cs8,ixon=1,ixoff=1 socat -d -d READLINE /dev/tty.usbserial-A9007QcR,clocal=1,nonblock=1,cread=1,cs8,ixon=1,ixoff=1 - #socat -d -d READLINE /dev/tty.FireFly-A964-SPP-1,clocal=1,nonblock=1,cread=1,cs8,ixon=1,ixoff=1 diff --git a/stepper_plan.c b/stepper_plan.c index 0f6906c..16408f7 100644 --- a/stepper_plan.c +++ b/stepper_plan.c @@ -326,6 +326,8 @@ void plan_buffer_line(int32_t steps_x, int32_t steps_y, int32_t steps_z, uint32_ block->speed_z = block->steps_z*multiplier/settings.steps_per_mm[2]; block->nominal_speed = millimeters*multiplier; block->nominal_rate = ceil(block->step_event_count*multiplier); + block->millimeters = millimeters; + block->entry_factor = 0.0; // Compute the acceleration rate for the trapezoid generator. Depending on the slope of the line // average travel per step event changes. For a line along one axis the travel per step event @@ -340,8 +342,9 @@ void plan_buffer_line(int32_t steps_x, int32_t steps_y, int32_t steps_z, uint32_ if (acceleration_management) { calculate_trapezoid_for_block(block,0,0); // compute a conservative acceleration trapezoid for now } else { + block->initial_rate = block->nominal_rate; block->accelerate_until = 0; - block->decelerate_after = 0; + block->decelerate_after = block->step_event_count; block->rate_delta = 0; }