1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-13 18:14:23 +02:00

Merge pull request #260 from bdring/Devt

Devt - Arc support for kinematics
This commit is contained in:
bdring
2019-10-22 10:15:01 -05:00
committed by GitHub
3 changed files with 30 additions and 5 deletions

View File

@@ -20,7 +20,7 @@
// Grbl versioning system
#define GRBL_VERSION "1.1f"
#define GRBL_VERSION_BUILD "20191016"
#define GRBL_VERSION_BUILD "20191018"
//#include <sdkconfig.h>
#include <Arduino.h>

View File

@@ -102,6 +102,14 @@ void mc_arc(float *target, plan_line_data_t *pl_data, float *position, float *of
float rt_axis0 = target[axis_0] - center_axis0;
float rt_axis1 = target[axis_1] - center_axis1;
#ifdef USE_KINEMATICS
float previous_position[N_AXIS];
uint16_t n;
for (n = 0; n < N_AXIS; n++) {
previous_position[n] = position[n];
}
#endif
// CCW angle between position and target from circle center. Only one atan2() trig computation required.
float angular_travel = atan2(r_axis0*rt_axis1-r_axis1*rt_axis0, r_axis0*rt_axis0+r_axis1*rt_axis1);
if (is_clockwise_arc) { // Correct atan2 output per direction
@@ -187,15 +195,25 @@ void mc_arc(float *target, plan_line_data_t *pl_data, float *position, float *of
position[axis_0] = center_axis0 + r_axis0;
position[axis_1] = center_axis1 + r_axis1;
position[axis_linear] += linear_per_segment;
#ifdef USE_KINEMATICS
mc_line_kins(position, pl_data, previous_position);
previous_position[axis_0] = position[axis_0];
previous_position[axis_1] = position[axis_1];
previous_position[axis_linear] = position[axis_linear];
#else
mc_line(position, pl_data);
#endif
// Bail mid-circle on system abort. Runtime command check already performed by mc_line.
if (sys.abort) { return; }
}
}
// Ensure last segment arrives at target location.
#ifdef USE_KINEMATICS
mc_line_kins(target, pl_data, previous_position);
#else
mc_line(target, pl_data);
#endif
}

View File

@@ -134,11 +134,18 @@ void inverse_kinematics(float *target, plan_line_data_t *pl_data, float *positio
polar_dist = sqrt( (p_dx * p_dx) + (p_dy * p_dy) +(p_dz * p_dz)); // calculate the total move distance
if (polar_dist == 0 || dist == 0) { // prevent 0 feed rate
polar_dist = dist; // default to same feed rate
float polar_rate_multiply = 1.0; // fail safe rate
if (polar_dist == 0 || dist == 0) { // prevent 0 feed rate and division by 0
polar_rate_multiply = 1.0; // default to same feed rate
} else {
// calc a feed rate multiplier
polar_rate_multiply = polar_dist / dist;
if (polar_rate_multiply < 0.5) { // prevent much slower speed
polar_rate_multiply = 0.5;
}
}
pl_data->feed_rate *= polar_dist / dist; // apply the distance ratio between coord systems
pl_data->feed_rate *= polar_rate_multiply; // apply the distance ratio between coord systems
// end determining new feed rate