|
@@ -81,9 +81,9 @@ volatile uint8_t Planner::block_buffer_head = 0; // Index of the next
|
81
|
81
|
volatile uint8_t Planner::block_buffer_tail = 0;
|
82
|
82
|
|
83
|
83
|
float Planner::max_feedrate[NUM_AXIS]; // Max speeds in mm per minute
|
84
|
|
-float Planner::axis_steps_per_unit[NUM_AXIS];
|
85
|
|
-unsigned long Planner::axis_steps_per_sqr_second[NUM_AXIS];
|
86
|
|
-unsigned long Planner::max_acceleration_units_per_sq_second[NUM_AXIS]; // Use M201 to override by software
|
|
84
|
+float Planner::axis_steps_per_mm[NUM_AXIS];
|
|
85
|
+unsigned long Planner::max_acceleration_steps_per_s2[NUM_AXIS];
|
|
86
|
+unsigned long Planner::max_acceleration_mm_per_s2[NUM_AXIS]; // Use M201 to override by software
|
87
|
87
|
|
88
|
88
|
millis_t Planner::min_segment_time;
|
89
|
89
|
float Planner::min_feedrate;
|
|
@@ -155,7 +155,7 @@ void Planner::calculate_trapezoid_for_block(block_t* block, float entry_factor,
|
155
|
155
|
NOLESS(initial_rate, 120);
|
156
|
156
|
NOLESS(final_rate, 120);
|
157
|
157
|
|
158
|
|
- long accel = block->acceleration_st;
|
|
158
|
+ long accel = block->acceleration_steps_per_s2;
|
159
|
159
|
int32_t accelerate_steps = ceil(estimate_acceleration_distance(initial_rate, block->nominal_rate, accel));
|
160
|
160
|
int32_t decelerate_steps = floor(estimate_acceleration_distance(block->nominal_rate, final_rate, -accel));
|
161
|
161
|
|
|
@@ -549,10 +549,10 @@ void Planner::check_axes_activity() {
|
549
|
549
|
// Calculate target position in absolute steps
|
550
|
550
|
//this should be done after the wait, because otherwise a M92 code within the gcode disrupts this calculation somehow
|
551
|
551
|
long target[NUM_AXIS] = {
|
552
|
|
- lround(x * axis_steps_per_unit[X_AXIS]),
|
553
|
|
- lround(y * axis_steps_per_unit[Y_AXIS]),
|
554
|
|
- lround(z * axis_steps_per_unit[Z_AXIS]),
|
555
|
|
- lround(e * axis_steps_per_unit[E_AXIS])
|
|
552
|
+ lround(x * axis_steps_per_mm[X_AXIS]),
|
|
553
|
+ lround(y * axis_steps_per_mm[Y_AXIS]),
|
|
554
|
+ lround(z * axis_steps_per_mm[Z_AXIS]),
|
|
555
|
+ lround(e * axis_steps_per_mm[E_AXIS])
|
556
|
556
|
};
|
557
|
557
|
|
558
|
558
|
long dx = target[X_AXIS] - position[X_AXIS],
|
|
@@ -574,7 +574,7 @@ void Planner::check_axes_activity() {
|
574
|
574
|
SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
|
575
|
575
|
}
|
576
|
576
|
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
|
577
|
|
- if (labs(de) > axis_steps_per_unit[E_AXIS] * (EXTRUDE_MAXLENGTH)) {
|
|
577
|
+ if (labs(de) > axis_steps_per_mm[E_AXIS] * (EXTRUDE_MAXLENGTH)) {
|
578
|
578
|
position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
|
579
|
579
|
de = 0; // no difference
|
580
|
580
|
SERIAL_ECHO_START;
|
|
@@ -771,31 +771,31 @@ void Planner::check_axes_activity() {
|
771
|
771
|
#if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ)
|
772
|
772
|
float delta_mm[6];
|
773
|
773
|
#if ENABLED(COREXY)
|
774
|
|
- delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
|
775
|
|
- delta_mm[Y_HEAD] = dy / axis_steps_per_unit[B_AXIS];
|
776
|
|
- delta_mm[Z_AXIS] = dz / axis_steps_per_unit[Z_AXIS];
|
777
|
|
- delta_mm[A_AXIS] = (dx + dy) / axis_steps_per_unit[A_AXIS];
|
778
|
|
- delta_mm[B_AXIS] = (dx - dy) / axis_steps_per_unit[B_AXIS];
|
|
774
|
+ delta_mm[X_HEAD] = dx / axis_steps_per_mm[A_AXIS];
|
|
775
|
+ delta_mm[Y_HEAD] = dy / axis_steps_per_mm[B_AXIS];
|
|
776
|
+ delta_mm[Z_AXIS] = dz / axis_steps_per_mm[Z_AXIS];
|
|
777
|
+ delta_mm[A_AXIS] = (dx + dy) / axis_steps_per_mm[A_AXIS];
|
|
778
|
+ delta_mm[B_AXIS] = (dx - dy) / axis_steps_per_mm[B_AXIS];
|
779
|
779
|
#elif ENABLED(COREXZ)
|
780
|
|
- delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
|
781
|
|
- delta_mm[Y_AXIS] = dy / axis_steps_per_unit[Y_AXIS];
|
782
|
|
- delta_mm[Z_HEAD] = dz / axis_steps_per_unit[C_AXIS];
|
783
|
|
- delta_mm[A_AXIS] = (dx + dz) / axis_steps_per_unit[A_AXIS];
|
784
|
|
- delta_mm[C_AXIS] = (dx - dz) / axis_steps_per_unit[C_AXIS];
|
|
780
|
+ delta_mm[X_HEAD] = dx / axis_steps_per_mm[A_AXIS];
|
|
781
|
+ delta_mm[Y_AXIS] = dy / axis_steps_per_mm[Y_AXIS];
|
|
782
|
+ delta_mm[Z_HEAD] = dz / axis_steps_per_mm[C_AXIS];
|
|
783
|
+ delta_mm[A_AXIS] = (dx + dz) / axis_steps_per_mm[A_AXIS];
|
|
784
|
+ delta_mm[C_AXIS] = (dx - dz) / axis_steps_per_mm[C_AXIS];
|
785
|
785
|
#elif ENABLED(COREYZ)
|
786
|
|
- delta_mm[X_AXIS] = dx / axis_steps_per_unit[A_AXIS];
|
787
|
|
- delta_mm[Y_HEAD] = dy / axis_steps_per_unit[Y_AXIS];
|
788
|
|
- delta_mm[Z_HEAD] = dz / axis_steps_per_unit[C_AXIS];
|
789
|
|
- delta_mm[B_AXIS] = (dy + dz) / axis_steps_per_unit[B_AXIS];
|
790
|
|
- delta_mm[C_AXIS] = (dy - dz) / axis_steps_per_unit[C_AXIS];
|
|
786
|
+ delta_mm[X_AXIS] = dx / axis_steps_per_mm[A_AXIS];
|
|
787
|
+ delta_mm[Y_HEAD] = dy / axis_steps_per_mm[Y_AXIS];
|
|
788
|
+ delta_mm[Z_HEAD] = dz / axis_steps_per_mm[C_AXIS];
|
|
789
|
+ delta_mm[B_AXIS] = (dy + dz) / axis_steps_per_mm[B_AXIS];
|
|
790
|
+ delta_mm[C_AXIS] = (dy - dz) / axis_steps_per_mm[C_AXIS];
|
791
|
791
|
#endif
|
792
|
792
|
#else
|
793
|
793
|
float delta_mm[4];
|
794
|
|
- delta_mm[X_AXIS] = dx / axis_steps_per_unit[X_AXIS];
|
795
|
|
- delta_mm[Y_AXIS] = dy / axis_steps_per_unit[Y_AXIS];
|
796
|
|
- delta_mm[Z_AXIS] = dz / axis_steps_per_unit[Z_AXIS];
|
|
794
|
+ delta_mm[X_AXIS] = dx / axis_steps_per_mm[X_AXIS];
|
|
795
|
+ delta_mm[Y_AXIS] = dy / axis_steps_per_mm[Y_AXIS];
|
|
796
|
+ delta_mm[Z_AXIS] = dz / axis_steps_per_mm[Z_AXIS];
|
797
|
797
|
#endif
|
798
|
|
- delta_mm[E_AXIS] = (de / axis_steps_per_unit[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiplier[extruder] / 100.0;
|
|
798
|
+ delta_mm[E_AXIS] = (de / axis_steps_per_mm[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiplier[extruder] / 100.0;
|
799
|
799
|
|
800
|
800
|
if (block->steps[X_AXIS] <= dropsegments && block->steps[Y_AXIS] <= dropsegments && block->steps[Z_AXIS] <= dropsegments) {
|
801
|
801
|
block->millimeters = fabs(delta_mm[E_AXIS]);
|
|
@@ -936,27 +936,27 @@ void Planner::check_axes_activity() {
|
936
|
936
|
float steps_per_mm = block->step_event_count / block->millimeters;
|
937
|
937
|
long bsx = block->steps[X_AXIS], bsy = block->steps[Y_AXIS], bsz = block->steps[Z_AXIS], bse = block->steps[E_AXIS];
|
938
|
938
|
if (bsx == 0 && bsy == 0 && bsz == 0) {
|
939
|
|
- block->acceleration_st = ceil(retract_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
|
|
939
|
+ block->acceleration_steps_per_s2 = ceil(retract_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
|
940
|
940
|
}
|
941
|
941
|
else if (bse == 0) {
|
942
|
|
- block->acceleration_st = ceil(travel_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
|
|
942
|
+ block->acceleration_steps_per_s2 = ceil(travel_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
|
943
|
943
|
}
|
944
|
944
|
else {
|
945
|
|
- block->acceleration_st = ceil(acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
|
|
945
|
+ block->acceleration_steps_per_s2 = ceil(acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
|
946
|
946
|
}
|
947
|
947
|
// Limit acceleration per axis
|
948
|
|
- unsigned long acc_st = block->acceleration_st,
|
949
|
|
- xsteps = axis_steps_per_sqr_second[X_AXIS],
|
950
|
|
- ysteps = axis_steps_per_sqr_second[Y_AXIS],
|
951
|
|
- zsteps = axis_steps_per_sqr_second[Z_AXIS],
|
952
|
|
- esteps = axis_steps_per_sqr_second[E_AXIS],
|
|
948
|
+ unsigned long acc_st = block->acceleration_steps_per_s2,
|
|
949
|
+ x_acc_st = max_acceleration_steps_per_s2[X_AXIS],
|
|
950
|
+ y_acc_st = max_acceleration_steps_per_s2[Y_AXIS],
|
|
951
|
+ z_acc_st = max_acceleration_steps_per_s2[Z_AXIS],
|
|
952
|
+ e_acc_st = max_acceleration_steps_per_s2[E_AXIS],
|
953
|
953
|
allsteps = block->step_event_count;
|
954
|
|
- if (xsteps < (acc_st * bsx) / allsteps) acc_st = (xsteps * allsteps) / bsx;
|
955
|
|
- if (ysteps < (acc_st * bsy) / allsteps) acc_st = (ysteps * allsteps) / bsy;
|
956
|
|
- if (zsteps < (acc_st * bsz) / allsteps) acc_st = (zsteps * allsteps) / bsz;
|
957
|
|
- if (esteps < (acc_st * bse) / allsteps) acc_st = (esteps * allsteps) / bse;
|
|
954
|
+ if (x_acc_st < (acc_st * bsx) / allsteps) acc_st = (x_acc_st * allsteps) / bsx;
|
|
955
|
+ if (y_acc_st < (acc_st * bsy) / allsteps) acc_st = (y_acc_st * allsteps) / bsy;
|
|
956
|
+ if (z_acc_st < (acc_st * bsz) / allsteps) acc_st = (z_acc_st * allsteps) / bsz;
|
|
957
|
+ if (e_acc_st < (acc_st * bse) / allsteps) acc_st = (e_acc_st * allsteps) / bse;
|
958
|
958
|
|
959
|
|
- block->acceleration_st = acc_st;
|
|
959
|
+ block->acceleration_steps_per_s2 = acc_st;
|
960
|
960
|
block->acceleration = acc_st / steps_per_mm;
|
961
|
961
|
block->acceleration_rate = (long)(acc_st * 16777216.0 / (F_CPU / 8.0));
|
962
|
962
|
|
|
@@ -1057,7 +1057,7 @@ void Planner::check_axes_activity() {
|
1057
|
1057
|
block->advance = 0;
|
1058
|
1058
|
}
|
1059
|
1059
|
else {
|
1060
|
|
- long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st);
|
|
1060
|
+ long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_steps_per_s2);
|
1061
|
1061
|
float advance = ((STEPS_PER_CUBIC_MM_E) * (EXTRUDER_ADVANCE_K)) * (cse * cse * (EXTRUSION_AREA) * (EXTRUSION_AREA)) * 256;
|
1062
|
1062
|
block->advance = advance;
|
1063
|
1063
|
block->advance_rate = acc_dist ? advance / (float)acc_dist : 0;
|
|
@@ -1127,10 +1127,10 @@ void Planner::check_axes_activity() {
|
1127
|
1127
|
apply_rotation_xyz(bed_level_matrix, x, y, z);
|
1128
|
1128
|
#endif
|
1129
|
1129
|
|
1130
|
|
- long nx = position[X_AXIS] = lround(x * axis_steps_per_unit[X_AXIS]),
|
1131
|
|
- ny = position[Y_AXIS] = lround(y * axis_steps_per_unit[Y_AXIS]),
|
1132
|
|
- nz = position[Z_AXIS] = lround(z * axis_steps_per_unit[Z_AXIS]),
|
1133
|
|
- ne = position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS]);
|
|
1130
|
+ long nx = position[X_AXIS] = lround(x * axis_steps_per_mm[X_AXIS]),
|
|
1131
|
+ ny = position[Y_AXIS] = lround(y * axis_steps_per_mm[Y_AXIS]),
|
|
1132
|
+ nz = position[Z_AXIS] = lround(z * axis_steps_per_mm[Z_AXIS]),
|
|
1133
|
+ ne = position[E_AXIS] = lround(e * axis_steps_per_mm[E_AXIS]);
|
1134
|
1134
|
stepper.set_position(nx, ny, nz, ne);
|
1135
|
1135
|
previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
|
1136
|
1136
|
|
|
@@ -1141,14 +1141,14 @@ void Planner::check_axes_activity() {
|
1141
|
1141
|
* Directly set the planner E position (hence the stepper E position).
|
1142
|
1142
|
*/
|
1143
|
1143
|
void Planner::set_e_position_mm(const float& e) {
|
1144
|
|
- position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS]);
|
|
1144
|
+ position[E_AXIS] = lround(e * axis_steps_per_mm[E_AXIS]);
|
1145
|
1145
|
stepper.set_e_position(position[E_AXIS]);
|
1146
|
1146
|
}
|
1147
|
1147
|
|
1148
|
1148
|
// Recalculate the steps/s^2 acceleration rates, based on the mm/s^2
|
1149
|
1149
|
void Planner::reset_acceleration_rates() {
|
1150
|
1150
|
for (int i = 0; i < NUM_AXIS; i++)
|
1151
|
|
- axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i];
|
|
1151
|
+ max_acceleration_steps_per_s2[i] = max_acceleration_mm_per_s2[i] * axis_steps_per_mm[i];
|
1152
|
1152
|
}
|
1153
|
1153
|
|
1154
|
1154
|
#if ENABLED(AUTOTEMP)
|