From 33f014aa744b3858f11f0ae79c540aeb18517fd1 Mon Sep 17 00:00:00 2001 From: Simen Svale Skogsrud Date: Fri, 11 Feb 2011 23:01:16 +0100 Subject: [PATCH] eliminated an abstraction violation where motion_control needed position information from the planner (untested) --- gcode.c | 3 ++- motion_control.c | 11 +++++------ motion_control.h | 4 ++-- planner.c | 4 ---- planner.h | 3 --- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/gcode.c b/gcode.c index 8f63008..281c577 100644 --- a/gcode.c +++ b/gcode.c @@ -388,7 +388,8 @@ uint8_t gc_execute_line(char *line) { double depth = target[gc.plane_axis_2]-gc.position[gc.plane_axis_2]; // Trace the arc mc_arc(theta_start, angular_travel, radius, depth, gc.plane_axis_0, gc.plane_axis_1, gc.plane_axis_2, - (gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode); + (gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode, + gc.position); // Finish off with a line to make sure we arrive exactly where we think we are mc_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], (gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode); diff --git a/motion_control.c b/motion_control.c index b3d9fa3..36c5bd8 100644 --- a/motion_control.c +++ b/motion_control.c @@ -48,14 +48,13 @@ void mc_dwell(uint32_t milliseconds) // positive angular_travel means clockwise, negative means counterclockwise. Radius == the radius of the // circle in millimeters. axis_1 and axis_2 selects the circle plane in tool space. Stick the remaining // axis in axis_l which will be the axis for linear travel if you are tracing a helical motion. +// position is a pointer to a vector representing the current position in millimeters. // The arc is approximated by generating a huge number of tiny, linear segments. The length of each // 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) + int axis_linear, double feed_rate, int invert_feed_rate, double *position) { - int32_t position[3]; - plan_get_position_steps(&position); 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)); @@ -70,13 +69,13 @@ void mc_arc(double theta, double angular_travel, double radius, double linear_tr // The linear motion for each segment double linear_per_segment = linear_travel/segments; // Compute the center of this circle - double center_x = (position[axis_1]/settings.steps_per_mm[axis_1])-sin(theta)*radius; - double center_y = (position[axis_2]/settings.steps_per_mm[axis_2])-cos(theta)*radius; + double center_x = position[axis_1]-sin(theta)*radius; + double center_y = position[axis_2]-cos(theta)*radius; // a vector to track the end point of each segment double target[3]; int i; // Initialize the linear axis - target[axis_linear] = position[axis_linear]/settings.steps_per_mm[axis_linear]; + target[axis_linear] = position[axis_linear]; for (i=0; i<=segments; i++) { target[axis_linear] += linear_per_segment; theta += theta_per_segment; diff --git a/motion_control.h b/motion_control.h index 225c749..11123b0 100644 --- a/motion_control.h +++ b/motion_control.h @@ -37,8 +37,8 @@ // circle in millimeters. axis_1 and axis_2 selects the circle plane in tool space. Stick the remaining // axis in axis_l which will be the axis for linear travel if you are tracing a helical motion. 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); - + int axis_linear, double feed_rate, int invert_feed_rate, double *position); + // Dwell for a couple of time units void mc_dwell(uint32_t milliseconds); diff --git a/planner.c b/planner.c index 7a5945f..4a2011c 100644 --- a/planner.c +++ b/planner.c @@ -412,7 +412,3 @@ void plan_buffer_line(double x, double y, double z, double feed_rate, int invert st_wake_up(); } -void plan_get_position_steps(int32_t (*vector)[3]) { - memcpy(vector, position, sizeof(position)); // vector[] = position[] -} - diff --git a/planner.h b/planner.h index 007cba4..b31ffb9 100644 --- a/planner.h +++ b/planner.h @@ -73,8 +73,5 @@ void plan_set_acceleration_manager_enabled(int enabled); // Is acceleration-management currently enabled? int plan_is_acceleration_manager_enabled(); - -// Copy the current absolute position in steps into the provided vector -void plan_get_position_steps(int32_t (*vector)[3]); #endif \ No newline at end of file