|
@@ -112,7 +112,7 @@ float Planner::filament_size[EXTRUDERS], // As a baseline for the multip
|
112
|
112
|
uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N],
|
113
|
113
|
Planner::max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override by software
|
114
|
114
|
|
115
|
|
-millis_t Planner::min_segment_time;
|
|
115
|
+uint32_t Planner::min_segment_time_us;
|
116
|
116
|
|
117
|
117
|
// Initialized by settings.load()
|
118
|
118
|
float Planner::min_feedrate_mm_s,
|
|
@@ -159,7 +159,7 @@ float Planner::previous_speed[NUM_AXIS],
|
159
|
159
|
// Old direction bits. Used for speed calculations
|
160
|
160
|
unsigned char Planner::old_direction_bits = 0;
|
161
|
161
|
// Segment times (in µs). Used for speed calculations
|
162
|
|
- long Planner::axis_segment_time[2][3] = { {MAX_FREQ_TIME + 1, 0, 0}, {MAX_FREQ_TIME + 1, 0, 0} };
|
|
162
|
+ uint32_t Planner::axis_segment_time_us[2][3] = { { MAX_FREQ_TIME_US + 1, 0, 0 }, { MAX_FREQ_TIME_US + 1, 0, 0 } };
|
163
|
163
|
#endif
|
164
|
164
|
|
165
|
165
|
#if ENABLED(LIN_ADVANCE)
|
|
@@ -1057,15 +1057,15 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
1057
|
1057
|
// Slow down when the buffer starts to empty, rather than wait at the corner for a buffer refill
|
1058
|
1058
|
#if ENABLED(SLOWDOWN) || ENABLED(ULTRA_LCD) || defined(XY_FREQUENCY_LIMIT)
|
1059
|
1059
|
// Segment time im micro seconds
|
1060
|
|
- unsigned long segment_time = LROUND(1000000.0 / inverse_mm_s);
|
|
1060
|
+ uint32_t segment_time_us = LROUND(1000000.0 / inverse_mm_s);
|
1061
|
1061
|
#endif
|
1062
|
1062
|
#if ENABLED(SLOWDOWN)
|
1063
|
1063
|
if (WITHIN(moves_queued, 2, (BLOCK_BUFFER_SIZE) / 2 - 1)) {
|
1064
|
|
- if (segment_time < min_segment_time) {
|
|
1064
|
+ if (segment_time_us < min_segment_time_us) {
|
1065
|
1065
|
// buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more.
|
1066
|
|
- inverse_mm_s = 1000000.0 / (segment_time + LROUND(2 * (min_segment_time - segment_time) / moves_queued));
|
|
1066
|
+ inverse_mm_s = 1000000.0 / (segment_time_us + LROUND(2 * (min_segment_time_us - segment_time_us) / moves_queued));
|
1067
|
1067
|
#if defined(XY_FREQUENCY_LIMIT) || ENABLED(ULTRA_LCD)
|
1068
|
|
- segment_time = LROUND(1000000.0 / inverse_mm_s);
|
|
1068
|
+ segment_time_us = LROUND(1000000.0 / inverse_mm_s);
|
1069
|
1069
|
#endif
|
1070
|
1070
|
}
|
1071
|
1071
|
}
|
|
@@ -1073,7 +1073,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
1073
|
1073
|
|
1074
|
1074
|
#if ENABLED(ULTRA_LCD)
|
1075
|
1075
|
CRITICAL_SECTION_START
|
1076
|
|
- block_buffer_runtime_us += segment_time;
|
|
1076
|
+ block_buffer_runtime_us += segment_time_us;
|
1077
|
1077
|
CRITICAL_SECTION_END
|
1078
|
1078
|
#endif
|
1079
|
1079
|
|
|
@@ -1130,34 +1130,34 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
1130
|
1130
|
// Check and limit the xy direction change frequency
|
1131
|
1131
|
const unsigned char direction_change = block->direction_bits ^ old_direction_bits;
|
1132
|
1132
|
old_direction_bits = block->direction_bits;
|
1133
|
|
- segment_time = LROUND((float)segment_time / speed_factor);
|
|
1133
|
+ segment_time_us = LROUND((float)segment_time_us / speed_factor);
|
1134
|
1134
|
|
1135
|
|
- long xs0 = axis_segment_time[X_AXIS][0],
|
1136
|
|
- xs1 = axis_segment_time[X_AXIS][1],
|
1137
|
|
- xs2 = axis_segment_time[X_AXIS][2],
|
1138
|
|
- ys0 = axis_segment_time[Y_AXIS][0],
|
1139
|
|
- ys1 = axis_segment_time[Y_AXIS][1],
|
1140
|
|
- ys2 = axis_segment_time[Y_AXIS][2];
|
|
1135
|
+ uint32_t xs0 = axis_segment_time_us[X_AXIS][0],
|
|
1136
|
+ xs1 = axis_segment_time_us[X_AXIS][1],
|
|
1137
|
+ xs2 = axis_segment_time_us[X_AXIS][2],
|
|
1138
|
+ ys0 = axis_segment_time_us[Y_AXIS][0],
|
|
1139
|
+ ys1 = axis_segment_time_us[Y_AXIS][1],
|
|
1140
|
+ ys2 = axis_segment_time_us[Y_AXIS][2];
|
1141
|
1141
|
|
1142
|
1142
|
if (TEST(direction_change, X_AXIS)) {
|
1143
|
|
- xs2 = axis_segment_time[X_AXIS][2] = xs1;
|
1144
|
|
- xs1 = axis_segment_time[X_AXIS][1] = xs0;
|
|
1143
|
+ xs2 = axis_segment_time_us[X_AXIS][2] = xs1;
|
|
1144
|
+ xs1 = axis_segment_time_us[X_AXIS][1] = xs0;
|
1145
|
1145
|
xs0 = 0;
|
1146
|
1146
|
}
|
1147
|
|
- xs0 = axis_segment_time[X_AXIS][0] = xs0 + segment_time;
|
|
1147
|
+ xs0 = axis_segment_time_us[X_AXIS][0] = xs0 + segment_time_us;
|
1148
|
1148
|
|
1149
|
1149
|
if (TEST(direction_change, Y_AXIS)) {
|
1150
|
|
- ys2 = axis_segment_time[Y_AXIS][2] = axis_segment_time[Y_AXIS][1];
|
1151
|
|
- ys1 = axis_segment_time[Y_AXIS][1] = axis_segment_time[Y_AXIS][0];
|
|
1150
|
+ ys2 = axis_segment_time_us[Y_AXIS][2] = axis_segment_time_us[Y_AXIS][1];
|
|
1151
|
+ ys1 = axis_segment_time_us[Y_AXIS][1] = axis_segment_time_us[Y_AXIS][0];
|
1152
|
1152
|
ys0 = 0;
|
1153
|
1153
|
}
|
1154
|
|
- ys0 = axis_segment_time[Y_AXIS][0] = ys0 + segment_time;
|
|
1154
|
+ ys0 = axis_segment_time_us[Y_AXIS][0] = ys0 + segment_time_us;
|
1155
|
1155
|
|
1156
|
|
- const long max_x_segment_time = MAX3(xs0, xs1, xs2),
|
1157
|
|
- max_y_segment_time = MAX3(ys0, ys1, ys2),
|
1158
|
|
- min_xy_segment_time = min(max_x_segment_time, max_y_segment_time);
|
1159
|
|
- if (min_xy_segment_time < MAX_FREQ_TIME) {
|
1160
|
|
- const float low_sf = speed_factor * min_xy_segment_time / (MAX_FREQ_TIME);
|
|
1156
|
+ const uint32_t max_x_segment_time = MAX3(xs0, xs1, xs2),
|
|
1157
|
+ max_y_segment_time = MAX3(ys0, ys1, ys2),
|
|
1158
|
+ min_xy_segment_time = min(max_x_segment_time, max_y_segment_time);
|
|
1159
|
+ if (min_xy_segment_time < MAX_FREQ_TIME_US) {
|
|
1160
|
+ const float low_sf = speed_factor * min_xy_segment_time / (MAX_FREQ_TIME_US);
|
1161
|
1161
|
NOMORE(speed_factor, low_sf);
|
1162
|
1162
|
}
|
1163
|
1163
|
#endif // XY_FREQUENCY_LIMIT
|