eliminated an abstraction violation where motion_control needed position information from the planner (untested)

This commit is contained in:
Simen Svale Skogsrud 2011-02-11 23:01:16 +01:00
parent 3b51a4b81e
commit 33f014aa74
5 changed files with 9 additions and 16 deletions

View File

@ -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);

View File

@ -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;

View File

@ -37,7 +37,7 @@
// 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);

View File

@ -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[]
}

View File

@ -74,7 +74,4 @@ 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