|
@@ -80,29 +80,31 @@ block_t Planner::block_buffer[BLOCK_BUFFER_SIZE];
|
80
|
80
|
volatile uint8_t Planner::block_buffer_head = 0; // Index of the next block to be pushed
|
81
|
81
|
volatile uint8_t Planner::block_buffer_tail = 0;
|
82
|
82
|
|
83
|
|
-float Planner::max_feedrate_mm_s[NUM_AXIS]; // Max speeds in mm per second
|
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
|
|
83
|
+float Planner::max_feedrate_mm_s[NUM_AXIS], // Max speeds in mm per second
|
|
84
|
+ Planner::axis_steps_per_mm[NUM_AXIS],
|
|
85
|
+ Planner::steps_to_mm[NUM_AXIS];
|
|
86
|
+
|
|
87
|
+unsigned long Planner::max_acceleration_steps_per_s2[NUM_AXIS],
|
|
88
|
+ Planner::max_acceleration_mm_per_s2[NUM_AXIS]; // Use M201 to override by software
|
87
|
89
|
|
88
|
90
|
millis_t Planner::min_segment_time;
|
89
|
|
-float Planner::min_feedrate_mm_s;
|
90
|
|
-float Planner::acceleration; // Normal acceleration mm/s^2 DEFAULT ACCELERATION for all printing moves. M204 SXXXX
|
91
|
|
-float Planner::retract_acceleration; // Retract acceleration mm/s^2 filament pull-back and push-forward while standing still in the other axes M204 TXXXX
|
92
|
|
-float Planner::travel_acceleration; // Travel acceleration mm/s^2 DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX
|
93
|
|
-float Planner::max_xy_jerk; // The largest speed change requiring no acceleration
|
94
|
|
-float Planner::max_z_jerk;
|
95
|
|
-float Planner::max_e_jerk;
|
96
|
|
-float Planner::min_travel_feedrate_mm_s;
|
|
91
|
+float Planner::min_feedrate_mm_s,
|
|
92
|
+ Planner::acceleration, // Normal acceleration mm/s^2 DEFAULT ACCELERATION for all printing moves. M204 SXXXX
|
|
93
|
+ Planner::retract_acceleration, // Retract acceleration mm/s^2 filament pull-back and push-forward while standing still in the other axes M204 TXXXX
|
|
94
|
+ Planner::travel_acceleration, // Travel acceleration mm/s^2 DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX
|
|
95
|
+ Planner::max_xy_jerk, // The largest speed change requiring no acceleration
|
|
96
|
+ Planner::max_z_jerk,
|
|
97
|
+ Planner::max_e_jerk,
|
|
98
|
+ Planner::min_travel_feedrate_mm_s;
|
97
|
99
|
|
98
|
100
|
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
|
99
|
101
|
matrix_3x3 Planner::bed_level_matrix; // Transform to compensate for bed level
|
100
|
102
|
#endif
|
101
|
103
|
|
102
|
104
|
#if ENABLED(AUTOTEMP)
|
103
|
|
- float Planner::autotemp_max = 250;
|
104
|
|
- float Planner::autotemp_min = 210;
|
105
|
|
- float Planner::autotemp_factor = 0.1;
|
|
105
|
+ float Planner::autotemp_max = 250,
|
|
106
|
+ Planner::autotemp_min = 210,
|
|
107
|
+ Planner::autotemp_factor = 0.1;
|
106
|
108
|
bool Planner::autotemp_enabled = false;
|
107
|
109
|
#endif
|
108
|
110
|
|
|
@@ -110,9 +112,8 @@ float Planner::min_travel_feedrate_mm_s;
|
110
|
112
|
|
111
|
113
|
long Planner::position[NUM_AXIS] = { 0 };
|
112
|
114
|
|
113
|
|
-float Planner::previous_speed[NUM_AXIS];
|
114
|
|
-
|
115
|
|
-float Planner::previous_nominal_speed;
|
|
115
|
+float Planner::previous_speed[NUM_AXIS],
|
|
116
|
+ Planner::previous_nominal_speed;
|
116
|
117
|
|
117
|
118
|
#if ENABLED(DISABLE_INACTIVE_EXTRUDER)
|
118
|
119
|
uint8_t Planner::g_uc_extruder_last_move[EXTRUDERS] = { 0 };
|
|
@@ -783,31 +784,37 @@ void Planner::check_axes_activity() {
|
783
|
784
|
#if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ)
|
784
|
785
|
float delta_mm[6];
|
785
|
786
|
#if ENABLED(COREXY)
|
786
|
|
- delta_mm[X_HEAD] = dx / axis_steps_per_mm[A_AXIS];
|
787
|
|
- delta_mm[Y_HEAD] = dy / axis_steps_per_mm[B_AXIS];
|
788
|
|
- delta_mm[Z_AXIS] = dz / axis_steps_per_mm[Z_AXIS];
|
789
|
|
- delta_mm[A_AXIS] = (dx + dy) / axis_steps_per_mm[A_AXIS];
|
790
|
|
- delta_mm[B_AXIS] = (dx - dy) / axis_steps_per_mm[B_AXIS];
|
|
787
|
+ delta_mm[X_HEAD] = dx * steps_to_mm[A_AXIS];
|
|
788
|
+ delta_mm[Y_HEAD] = dy * steps_to_mm[B_AXIS];
|
|
789
|
+ delta_mm[Z_AXIS] = dz * steps_to_mm[Z_AXIS];
|
|
790
|
+ delta_mm[A_AXIS] = (dx + dy) * steps_to_mm[A_AXIS];
|
|
791
|
+ delta_mm[B_AXIS] = (dx - dy) * steps_to_mm[B_AXIS];
|
791
|
792
|
#elif ENABLED(COREXZ)
|
792
|
|
- delta_mm[X_HEAD] = dx / axis_steps_per_mm[A_AXIS];
|
793
|
|
- delta_mm[Y_AXIS] = dy / axis_steps_per_mm[Y_AXIS];
|
794
|
|
- delta_mm[Z_HEAD] = dz / axis_steps_per_mm[C_AXIS];
|
795
|
|
- delta_mm[A_AXIS] = (dx + dz) / axis_steps_per_mm[A_AXIS];
|
796
|
|
- delta_mm[C_AXIS] = (dx - dz) / axis_steps_per_mm[C_AXIS];
|
|
793
|
+ delta_mm[X_HEAD] = dx * steps_to_mm[A_AXIS];
|
|
794
|
+ delta_mm[Y_AXIS] = dy * steps_to_mm[Y_AXIS];
|
|
795
|
+ delta_mm[Z_HEAD] = dz * steps_to_mm[C_AXIS];
|
|
796
|
+ delta_mm[A_AXIS] = (dx + dz) * steps_to_mm[A_AXIS];
|
|
797
|
+ delta_mm[C_AXIS] = (dx - dz) * steps_to_mm[C_AXIS];
|
797
|
798
|
#elif ENABLED(COREYZ)
|
798
|
|
- delta_mm[X_AXIS] = dx / axis_steps_per_mm[A_AXIS];
|
799
|
|
- delta_mm[Y_HEAD] = dy / axis_steps_per_mm[Y_AXIS];
|
800
|
|
- delta_mm[Z_HEAD] = dz / axis_steps_per_mm[C_AXIS];
|
801
|
|
- delta_mm[B_AXIS] = (dy + dz) / axis_steps_per_mm[B_AXIS];
|
802
|
|
- delta_mm[C_AXIS] = (dy - dz) / axis_steps_per_mm[C_AXIS];
|
|
799
|
+ delta_mm[X_AXIS] = dx * steps_to_mm[X_AXIS];
|
|
800
|
+ delta_mm[Y_HEAD] = dy * steps_to_mm[B_AXIS];
|
|
801
|
+ delta_mm[Z_HEAD] = dz * steps_to_mm[C_AXIS];
|
|
802
|
+ delta_mm[B_AXIS] = (dy + dz) * steps_to_mm[B_AXIS];
|
|
803
|
+ delta_mm[C_AXIS] = (dy - dz) * steps_to_mm[C_AXIS];
|
803
|
804
|
#endif
|
804
|
805
|
#else
|
805
|
806
|
float delta_mm[4];
|
806
|
|
- delta_mm[X_AXIS] = dx / axis_steps_per_mm[X_AXIS];
|
807
|
|
- delta_mm[Y_AXIS] = dy / axis_steps_per_mm[Y_AXIS];
|
808
|
|
- delta_mm[Z_AXIS] = dz / axis_steps_per_mm[Z_AXIS];
|
|
807
|
+ #if ENABLED(DELTA)
|
|
808
|
+ // On delta all axes (should!) have the same steps-per-mm
|
|
809
|
+ // so calculate distance in steps first, then do one division
|
|
810
|
+ // at the end to get millimeters
|
|
811
|
+ #else
|
|
812
|
+ delta_mm[X_AXIS] = dx * steps_to_mm[X_AXIS];
|
|
813
|
+ delta_mm[Y_AXIS] = dy * steps_to_mm[Y_AXIS];
|
|
814
|
+ delta_mm[Z_AXIS] = dz * steps_to_mm[Z_AXIS];
|
|
815
|
+ #endif
|
809
|
816
|
#endif
|
810
|
|
- delta_mm[E_AXIS] = (de / axis_steps_per_mm[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiplier[extruder] / 100.0;
|
|
817
|
+ delta_mm[E_AXIS] = 0.01 * (de * steps_to_mm[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiplier[extruder];
|
811
|
818
|
|
812
|
819
|
if (block->steps[X_AXIS] <= dropsegments && block->steps[Y_AXIS] <= dropsegments && block->steps[Z_AXIS] <= dropsegments) {
|
813
|
820
|
block->millimeters = fabs(delta_mm[E_AXIS]);
|
|
@@ -820,10 +827,16 @@ void Planner::check_axes_activity() {
|
820
|
827
|
sq(delta_mm[X_HEAD]) + sq(delta_mm[Y_AXIS]) + sq(delta_mm[Z_HEAD])
|
821
|
828
|
#elif ENABLED(COREYZ)
|
822
|
829
|
sq(delta_mm[X_AXIS]) + sq(delta_mm[Y_HEAD]) + sq(delta_mm[Z_HEAD])
|
|
830
|
+ #elif ENABLED(DELTA)
|
|
831
|
+ sq(dx) + sq(dy) + sq(dz)
|
823
|
832
|
#else
|
824
|
833
|
sq(delta_mm[X_AXIS]) + sq(delta_mm[Y_AXIS]) + sq(delta_mm[Z_AXIS])
|
825
|
834
|
#endif
|
826
|
|
- );
|
|
835
|
+ )
|
|
836
|
+ #if ENABLED(DELTA)
|
|
837
|
+ * steps_to_mm[X_AXIS]
|
|
838
|
+ #endif
|
|
839
|
+ ;
|
827
|
840
|
}
|
828
|
841
|
float inverse_millimeters = 1.0 / block->millimeters; // Inverse millimeters to remove multiple divides
|
829
|
842
|
|
|
@@ -875,7 +888,7 @@ void Planner::check_axes_activity() {
|
875
|
888
|
while (filwidth_delay_dist >= MMD_MM) filwidth_delay_dist -= MMD_MM;
|
876
|
889
|
|
877
|
890
|
// Convert into an index into the measurement array
|
878
|
|
- filwidth_delay_index1 = (int)(filwidth_delay_dist / 10.0 + 0.0001);
|
|
891
|
+ filwidth_delay_index1 = (int)(filwidth_delay_dist * 0.1 + 0.0001);
|
879
|
892
|
|
880
|
893
|
// If the index has changed (must have gone forward)...
|
881
|
894
|
if (filwidth_delay_index1 != filwidth_delay_index2) {
|
|
@@ -962,7 +975,7 @@ void Planner::check_axes_activity() {
|
962
|
975
|
block->acceleration_steps_per_s2 = (max_acceleration_steps_per_s2[E_AXIS] * block->step_event_count) / block->steps[E_AXIS];
|
963
|
976
|
}
|
964
|
977
|
block->acceleration = block->acceleration_steps_per_s2 / steps_per_mm;
|
965
|
|
- block->acceleration_rate = (long)(block->acceleration_steps_per_s2 * 16777216.0 / ((F_CPU) / 8.0));
|
|
978
|
+ block->acceleration_rate = (long)(block->acceleration_steps_per_s2 * 16777216.0 / ((F_CPU) * 0.125));
|
966
|
979
|
|
967
|
980
|
#if 0 // Use old jerk for now
|
968
|
981
|
|
|
@@ -1008,10 +1021,12 @@ void Planner::check_axes_activity() {
|
1008
|
1021
|
#endif
|
1009
|
1022
|
|
1010
|
1023
|
// Start with a safe speed
|
1011
|
|
- float vmax_junction = max_xy_jerk / 2;
|
1012
|
|
- float vmax_junction_factor = 1.0;
|
1013
|
|
- float mz2 = max_z_jerk / 2, me2 = max_e_jerk / 2;
|
1014
|
|
- float csz = current_speed[Z_AXIS], cse = current_speed[E_AXIS];
|
|
1024
|
+ float vmax_junction = max_xy_jerk * 0.5,
|
|
1025
|
+ vmax_junction_factor = 1.0,
|
|
1026
|
+ mz2 = max_z_jerk * 0.5,
|
|
1027
|
+ me2 = max_e_jerk * 0.5,
|
|
1028
|
+ csz = current_speed[Z_AXIS],
|
|
1029
|
+ cse = current_speed[E_AXIS];
|
1015
|
1030
|
if (fabs(csz) > mz2) vmax_junction = min(vmax_junction, mz2);
|
1016
|
1031
|
if (fabs(cse) > me2) vmax_junction = min(vmax_junction, me2);
|
1017
|
1032
|
vmax_junction = min(vmax_junction, block->nominal_speed);
|
|
@@ -1164,6 +1179,7 @@ void Planner::check_axes_activity() {
|
1164
|
1179
|
void Planner::set_e_position_mm(const float& e) {
|
1165
|
1180
|
position[E_AXIS] = lround(e * axis_steps_per_mm[E_AXIS]);
|
1166
|
1181
|
stepper.set_e_position(position[E_AXIS]);
|
|
1182
|
+ previous_speed[E_AXIS] = 0.0;
|
1167
|
1183
|
}
|
1168
|
1184
|
|
1169
|
1185
|
// Recalculate the steps/s^2 acceleration rates, based on the mm/s^2
|
|
@@ -1172,6 +1188,13 @@ void Planner::reset_acceleration_rates() {
|
1172
|
1188
|
max_acceleration_steps_per_s2[i] = max_acceleration_mm_per_s2[i] * axis_steps_per_mm[i];
|
1173
|
1189
|
}
|
1174
|
1190
|
|
|
1191
|
+// Recalculate position, steps_to_mm if axis_steps_per_mm changes!
|
|
1192
|
+void Planner::refresh_positioning() {
|
|
1193
|
+ LOOP_XYZE(i) planner.steps_to_mm[i] = 1.0 / planner.axis_steps_per_mm[i];
|
|
1194
|
+ set_position_mm(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
1195
|
+ reset_acceleration_rates();
|
|
1196
|
+}
|
|
1197
|
+
|
1175
|
1198
|
#if ENABLED(AUTOTEMP)
|
1176
|
1199
|
|
1177
|
1200
|
void Planner::autotemp_M109() {
|