|
|
@ -81,9 +81,9 @@ volatile uint8_t Planner::block_buffer_head = 0; // Index of the next |
|
|
|
volatile uint8_t Planner::block_buffer_tail = 0; |
|
|
|
|
|
|
|
float Planner::max_feedrate[NUM_AXIS]; // Max speeds in mm per minute
|
|
|
|
float Planner::axis_steps_per_unit[NUM_AXIS]; |
|
|
|
unsigned long Planner::axis_steps_per_sqr_second[NUM_AXIS]; |
|
|
|
unsigned long Planner::max_acceleration_units_per_sq_second[NUM_AXIS]; // Use M201 to override by software
|
|
|
|
float Planner::axis_steps_per_mm[NUM_AXIS]; |
|
|
|
unsigned long Planner::max_acceleration_steps_per_s2[NUM_AXIS]; |
|
|
|
unsigned long Planner::max_acceleration_mm_per_s2[NUM_AXIS]; // Use M201 to override by software
|
|
|
|
|
|
|
|
millis_t Planner::min_segment_time; |
|
|
|
float Planner::min_feedrate; |
|
|
@ -155,7 +155,7 @@ void Planner::calculate_trapezoid_for_block(block_t* block, float entry_factor, |
|
|
|
NOLESS(initial_rate, 120); |
|
|
|
NOLESS(final_rate, 120); |
|
|
|
|
|
|
|
long accel = block->acceleration_st; |
|
|
|
long accel = block->acceleration_steps_per_s2; |
|
|
|
int32_t accelerate_steps = ceil(estimate_acceleration_distance(initial_rate, block->nominal_rate, accel)); |
|
|
|
int32_t decelerate_steps = floor(estimate_acceleration_distance(block->nominal_rate, final_rate, -accel)); |
|
|
|
|
|
|
@ -549,10 +549,10 @@ void Planner::check_axes_activity() { |
|
|
|
// Calculate target position in absolute steps
|
|
|
|
//this should be done after the wait, because otherwise a M92 code within the gcode disrupts this calculation somehow
|
|
|
|
long target[NUM_AXIS] = { |
|
|
|
lround(x * axis_steps_per_unit[X_AXIS]), |
|
|
|
lround(y * axis_steps_per_unit[Y_AXIS]), |
|
|
|
lround(z * axis_steps_per_unit[Z_AXIS]), |
|
|
|
lround(e * axis_steps_per_unit[E_AXIS]) |
|
|
|
lround(x * axis_steps_per_mm[X_AXIS]), |
|
|
|
lround(y * axis_steps_per_mm[Y_AXIS]), |
|
|
|
lround(z * axis_steps_per_mm[Z_AXIS]), |
|
|
|
lround(e * axis_steps_per_mm[E_AXIS]) |
|
|
|
}; |
|
|
|
|
|
|
|
long dx = target[X_AXIS] - position[X_AXIS], |
|
|
@ -574,7 +574,7 @@ void Planner::check_axes_activity() { |
|
|
|
SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP); |
|
|
|
} |
|
|
|
#if ENABLED(PREVENT_LENGTHY_EXTRUDE) |
|
|
|
if (labs(de) > axis_steps_per_unit[E_AXIS] * (EXTRUDE_MAXLENGTH)) { |
|
|
|
if (labs(de) > axis_steps_per_mm[E_AXIS] * (EXTRUDE_MAXLENGTH)) { |
|
|
|
position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
|
|
|
|
de = 0; // no difference
|
|
|
|
SERIAL_ECHO_START; |
|
|
@ -771,31 +771,31 @@ void Planner::check_axes_activity() { |
|
|
|
#if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ) |
|
|
|
float delta_mm[6]; |
|
|
|
#if ENABLED(COREXY) |
|
|
|
delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS]; |
|
|
|
delta_mm[Y_HEAD] = dy / axis_steps_per_unit[B_AXIS]; |
|
|
|
delta_mm[Z_AXIS] = dz / axis_steps_per_unit[Z_AXIS]; |
|
|
|
delta_mm[A_AXIS] = (dx + dy) / axis_steps_per_unit[A_AXIS]; |
|
|
|
delta_mm[B_AXIS] = (dx - dy) / axis_steps_per_unit[B_AXIS]; |
|
|
|
delta_mm[X_HEAD] = dx / axis_steps_per_mm[A_AXIS]; |
|
|
|
delta_mm[Y_HEAD] = dy / axis_steps_per_mm[B_AXIS]; |
|
|
|
delta_mm[Z_AXIS] = dz / axis_steps_per_mm[Z_AXIS]; |
|
|
|
delta_mm[A_AXIS] = (dx + dy) / axis_steps_per_mm[A_AXIS]; |
|
|
|
delta_mm[B_AXIS] = (dx - dy) / axis_steps_per_mm[B_AXIS]; |
|
|
|
#elif ENABLED(COREXZ) |
|
|
|
delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS]; |
|
|
|
delta_mm[Y_AXIS] = dy / axis_steps_per_unit[Y_AXIS]; |
|
|
|
delta_mm[Z_HEAD] = dz / axis_steps_per_unit[C_AXIS]; |
|
|
|
delta_mm[A_AXIS] = (dx + dz) / axis_steps_per_unit[A_AXIS]; |
|
|
|
delta_mm[C_AXIS] = (dx - dz) / axis_steps_per_unit[C_AXIS]; |
|
|
|
delta_mm[X_HEAD] = dx / axis_steps_per_mm[A_AXIS]; |
|
|
|
delta_mm[Y_AXIS] = dy / axis_steps_per_mm[Y_AXIS]; |
|
|
|
delta_mm[Z_HEAD] = dz / axis_steps_per_mm[C_AXIS]; |
|
|
|
delta_mm[A_AXIS] = (dx + dz) / axis_steps_per_mm[A_AXIS]; |
|
|
|
delta_mm[C_AXIS] = (dx - dz) / axis_steps_per_mm[C_AXIS]; |
|
|
|
#elif ENABLED(COREYZ) |
|
|
|
delta_mm[X_AXIS] = dx / axis_steps_per_unit[A_AXIS]; |
|
|
|
delta_mm[Y_HEAD] = dy / axis_steps_per_unit[Y_AXIS]; |
|
|
|
delta_mm[Z_HEAD] = dz / axis_steps_per_unit[C_AXIS]; |
|
|
|
delta_mm[B_AXIS] = (dy + dz) / axis_steps_per_unit[B_AXIS]; |
|
|
|
delta_mm[C_AXIS] = (dy - dz) / axis_steps_per_unit[C_AXIS]; |
|
|
|
delta_mm[X_AXIS] = dx / axis_steps_per_mm[A_AXIS]; |
|
|
|
delta_mm[Y_HEAD] = dy / axis_steps_per_mm[Y_AXIS]; |
|
|
|
delta_mm[Z_HEAD] = dz / axis_steps_per_mm[C_AXIS]; |
|
|
|
delta_mm[B_AXIS] = (dy + dz) / axis_steps_per_mm[B_AXIS]; |
|
|
|
delta_mm[C_AXIS] = (dy - dz) / axis_steps_per_mm[C_AXIS]; |
|
|
|
#endif |
|
|
|
#else |
|
|
|
float delta_mm[4]; |
|
|
|
delta_mm[X_AXIS] = dx / axis_steps_per_unit[X_AXIS]; |
|
|
|
delta_mm[Y_AXIS] = dy / axis_steps_per_unit[Y_AXIS]; |
|
|
|
delta_mm[Z_AXIS] = dz / axis_steps_per_unit[Z_AXIS]; |
|
|
|
delta_mm[X_AXIS] = dx / axis_steps_per_mm[X_AXIS]; |
|
|
|
delta_mm[Y_AXIS] = dy / axis_steps_per_mm[Y_AXIS]; |
|
|
|
delta_mm[Z_AXIS] = dz / axis_steps_per_mm[Z_AXIS]; |
|
|
|
#endif |
|
|
|
delta_mm[E_AXIS] = (de / axis_steps_per_unit[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiplier[extruder] / 100.0; |
|
|
|
delta_mm[E_AXIS] = (de / axis_steps_per_mm[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiplier[extruder] / 100.0; |
|
|
|
|
|
|
|
if (block->steps[X_AXIS] <= dropsegments && block->steps[Y_AXIS] <= dropsegments && block->steps[Z_AXIS] <= dropsegments) { |
|
|
|
block->millimeters = fabs(delta_mm[E_AXIS]); |
|
|
@ -936,27 +936,27 @@ void Planner::check_axes_activity() { |
|
|
|
float steps_per_mm = block->step_event_count / block->millimeters; |
|
|
|
long bsx = block->steps[X_AXIS], bsy = block->steps[Y_AXIS], bsz = block->steps[Z_AXIS], bse = block->steps[E_AXIS]; |
|
|
|
if (bsx == 0 && bsy == 0 && bsz == 0) { |
|
|
|
block->acceleration_st = ceil(retract_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
|
|
|
|
block->acceleration_steps_per_s2 = ceil(retract_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
|
|
|
|
} |
|
|
|
else if (bse == 0) { |
|
|
|
block->acceleration_st = ceil(travel_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
|
|
|
|
block->acceleration_steps_per_s2 = ceil(travel_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
|
|
|
|
} |
|
|
|
else { |
|
|
|
block->acceleration_st = ceil(acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
|
|
|
|
block->acceleration_steps_per_s2 = ceil(acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
|
|
|
|
} |
|
|
|
// Limit acceleration per axis
|
|
|
|
unsigned long acc_st = block->acceleration_st, |
|
|
|
xsteps = axis_steps_per_sqr_second[X_AXIS], |
|
|
|
ysteps = axis_steps_per_sqr_second[Y_AXIS], |
|
|
|
zsteps = axis_steps_per_sqr_second[Z_AXIS], |
|
|
|
esteps = axis_steps_per_sqr_second[E_AXIS], |
|
|
|
unsigned long acc_st = block->acceleration_steps_per_s2, |
|
|
|
x_acc_st = max_acceleration_steps_per_s2[X_AXIS], |
|
|
|
y_acc_st = max_acceleration_steps_per_s2[Y_AXIS], |
|
|
|
z_acc_st = max_acceleration_steps_per_s2[Z_AXIS], |
|
|
|
e_acc_st = max_acceleration_steps_per_s2[E_AXIS], |
|
|
|
allsteps = block->step_event_count; |
|
|
|
if (xsteps < (acc_st * bsx) / allsteps) acc_st = (xsteps * allsteps) / bsx; |
|
|
|
if (ysteps < (acc_st * bsy) / allsteps) acc_st = (ysteps * allsteps) / bsy; |
|
|
|
if (zsteps < (acc_st * bsz) / allsteps) acc_st = (zsteps * allsteps) / bsz; |
|
|
|
if (esteps < (acc_st * bse) / allsteps) acc_st = (esteps * allsteps) / bse; |
|
|
|
if (x_acc_st < (acc_st * bsx) / allsteps) acc_st = (x_acc_st * allsteps) / bsx; |
|
|
|
if (y_acc_st < (acc_st * bsy) / allsteps) acc_st = (y_acc_st * allsteps) / bsy; |
|
|
|
if (z_acc_st < (acc_st * bsz) / allsteps) acc_st = (z_acc_st * allsteps) / bsz; |
|
|
|
if (e_acc_st < (acc_st * bse) / allsteps) acc_st = (e_acc_st * allsteps) / bse; |
|
|
|
|
|
|
|
block->acceleration_st = acc_st; |
|
|
|
block->acceleration_steps_per_s2 = acc_st; |
|
|
|
block->acceleration = acc_st / steps_per_mm; |
|
|
|
block->acceleration_rate = (long)(acc_st * 16777216.0 / (F_CPU / 8.0)); |
|
|
|
|
|
|
@ -1057,7 +1057,7 @@ void Planner::check_axes_activity() { |
|
|
|
block->advance = 0; |
|
|
|
} |
|
|
|
else { |
|
|
|
long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st); |
|
|
|
long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_steps_per_s2); |
|
|
|
float advance = ((STEPS_PER_CUBIC_MM_E) * (EXTRUDER_ADVANCE_K)) * (cse * cse * (EXTRUSION_AREA) * (EXTRUSION_AREA)) * 256; |
|
|
|
block->advance = advance; |
|
|
|
block->advance_rate = acc_dist ? advance / (float)acc_dist : 0; |
|
|
@ -1127,10 +1127,10 @@ void Planner::check_axes_activity() { |
|
|
|
apply_rotation_xyz(bed_level_matrix, x, y, z); |
|
|
|
#endif |
|
|
|
|
|
|
|
long nx = position[X_AXIS] = lround(x * axis_steps_per_unit[X_AXIS]), |
|
|
|
ny = position[Y_AXIS] = lround(y * axis_steps_per_unit[Y_AXIS]), |
|
|
|
nz = position[Z_AXIS] = lround(z * axis_steps_per_unit[Z_AXIS]), |
|
|
|
ne = position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS]); |
|
|
|
long nx = position[X_AXIS] = lround(x * axis_steps_per_mm[X_AXIS]), |
|
|
|
ny = position[Y_AXIS] = lround(y * axis_steps_per_mm[Y_AXIS]), |
|
|
|
nz = position[Z_AXIS] = lround(z * axis_steps_per_mm[Z_AXIS]), |
|
|
|
ne = position[E_AXIS] = lround(e * axis_steps_per_mm[E_AXIS]); |
|
|
|
stepper.set_position(nx, ny, nz, ne); |
|
|
|
previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
|
|
|
|
|
|
|
@ -1141,14 +1141,14 @@ void Planner::check_axes_activity() { |
|
|
|
* Directly set the planner E position (hence the stepper E position). |
|
|
|
*/ |
|
|
|
void Planner::set_e_position_mm(const float& e) { |
|
|
|
position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS]); |
|
|
|
position[E_AXIS] = lround(e * axis_steps_per_mm[E_AXIS]); |
|
|
|
stepper.set_e_position(position[E_AXIS]); |
|
|
|
} |
|
|
|
|
|
|
|
// Recalculate the steps/s^2 acceleration rates, based on the mm/s^2
|
|
|
|
void Planner::reset_acceleration_rates() { |
|
|
|
for (int i = 0; i < NUM_AXIS; i++) |
|
|
|
axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i]; |
|
|
|
max_acceleration_steps_per_s2[i] = max_acceleration_mm_per_s2[i] * axis_steps_per_mm[i]; |
|
|
|
} |
|
|
|
|
|
|
|
#if ENABLED(AUTOTEMP) |
|
|
|