|
@@ -94,7 +94,7 @@ float Planner::max_feedrate_mm_s[XYZE_N], // Max speeds in mm per second
|
94
|
94
|
uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N],
|
95
|
95
|
Planner::max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override by software
|
96
|
96
|
|
97
|
|
-millis_t Planner::min_segment_time;
|
|
97
|
+uint32_t Planner::min_segment_time_us;
|
98
|
98
|
|
99
|
99
|
// Initialized by settings.load()
|
100
|
100
|
float Planner::min_feedrate_mm_s,
|
|
@@ -140,7 +140,7 @@ float Planner::previous_speed[NUM_AXIS],
|
140
|
140
|
// Old direction bits. Used for speed calculations
|
141
|
141
|
unsigned char Planner::old_direction_bits = 0;
|
142
|
142
|
// Segment times (in µs). Used for speed calculations
|
143
|
|
- long Planner::axis_segment_time[2][3] = { {MAX_FREQ_TIME + 1, 0, 0}, {MAX_FREQ_TIME + 1, 0, 0} };
|
|
143
|
+ uint32_t Planner::axis_segment_time_us[2][3] = { { MAX_FREQ_TIME_US + 1, 0, 0 }, { MAX_FREQ_TIME_US + 1, 0, 0 } };
|
144
|
144
|
#endif
|
145
|
145
|
|
146
|
146
|
#if ENABLED(LIN_ADVANCE)
|
|
@@ -1036,15 +1036,15 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
1036
|
1036
|
// Slow down when the buffer starts to empty, rather than wait at the corner for a buffer refill
|
1037
|
1037
|
#if ENABLED(SLOWDOWN) || ENABLED(ULTRA_LCD) || defined(XY_FREQUENCY_LIMIT)
|
1038
|
1038
|
// Segment time im micro seconds
|
1039
|
|
- unsigned long segment_time = LROUND(1000000.0 / inverse_mm_s);
|
|
1039
|
+ uint32_t segment_time_us = LROUND(1000000.0 / inverse_mm_s);
|
1040
|
1040
|
#endif
|
1041
|
1041
|
#if ENABLED(SLOWDOWN)
|
1042
|
1042
|
if (WITHIN(moves_queued, 2, (BLOCK_BUFFER_SIZE) / 2 - 1)) {
|
1043
|
|
- if (segment_time < min_segment_time) {
|
|
1043
|
+ if (segment_time_us < min_segment_time_us) {
|
1044
|
1044
|
// buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more.
|
1045
|
|
- inverse_mm_s = 1000000.0 / (segment_time + LROUND(2 * (min_segment_time - segment_time) / moves_queued));
|
|
1045
|
+ inverse_mm_s = 1000000.0 / (segment_time_us + LROUND(2 * (min_segment_time_us - segment_time_us) / moves_queued));
|
1046
|
1046
|
#if defined(XY_FREQUENCY_LIMIT) || ENABLED(ULTRA_LCD)
|
1047
|
|
- segment_time = LROUND(1000000.0 / inverse_mm_s);
|
|
1047
|
+ segment_time_us = LROUND(1000000.0 / inverse_mm_s);
|
1048
|
1048
|
#endif
|
1049
|
1049
|
}
|
1050
|
1050
|
}
|
|
@@ -1052,7 +1052,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
1052
|
1052
|
|
1053
|
1053
|
#if ENABLED(ULTRA_LCD)
|
1054
|
1054
|
CRITICAL_SECTION_START
|
1055
|
|
- block_buffer_runtime_us += segment_time;
|
|
1055
|
+ block_buffer_runtime_us += segment_time_us;
|
1056
|
1056
|
CRITICAL_SECTION_END
|
1057
|
1057
|
#endif
|
1058
|
1058
|
|
|
@@ -1109,34 +1109,34 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
1109
|
1109
|
// Check and limit the xy direction change frequency
|
1110
|
1110
|
const unsigned char direction_change = block->direction_bits ^ old_direction_bits;
|
1111
|
1111
|
old_direction_bits = block->direction_bits;
|
1112
|
|
- segment_time = LROUND((float)segment_time / speed_factor);
|
|
1112
|
+ segment_time_us = LROUND((float)segment_time_us / speed_factor);
|
1113
|
1113
|
|
1114
|
|
- long xs0 = axis_segment_time[X_AXIS][0],
|
1115
|
|
- xs1 = axis_segment_time[X_AXIS][1],
|
1116
|
|
- xs2 = axis_segment_time[X_AXIS][2],
|
1117
|
|
- ys0 = axis_segment_time[Y_AXIS][0],
|
1118
|
|
- ys1 = axis_segment_time[Y_AXIS][1],
|
1119
|
|
- ys2 = axis_segment_time[Y_AXIS][2];
|
|
1114
|
+ uint32_t xs0 = axis_segment_time_us[X_AXIS][0],
|
|
1115
|
+ xs1 = axis_segment_time_us[X_AXIS][1],
|
|
1116
|
+ xs2 = axis_segment_time_us[X_AXIS][2],
|
|
1117
|
+ ys0 = axis_segment_time_us[Y_AXIS][0],
|
|
1118
|
+ ys1 = axis_segment_time_us[Y_AXIS][1],
|
|
1119
|
+ ys2 = axis_segment_time_us[Y_AXIS][2];
|
1120
|
1120
|
|
1121
|
1121
|
if (TEST(direction_change, X_AXIS)) {
|
1122
|
|
- xs2 = axis_segment_time[X_AXIS][2] = xs1;
|
1123
|
|
- xs1 = axis_segment_time[X_AXIS][1] = xs0;
|
|
1122
|
+ xs2 = axis_segment_time_us[X_AXIS][2] = xs1;
|
|
1123
|
+ xs1 = axis_segment_time_us[X_AXIS][1] = xs0;
|
1124
|
1124
|
xs0 = 0;
|
1125
|
1125
|
}
|
1126
|
|
- xs0 = axis_segment_time[X_AXIS][0] = xs0 + segment_time;
|
|
1126
|
+ xs0 = axis_segment_time_us[X_AXIS][0] = xs0 + segment_time_us;
|
1127
|
1127
|
|
1128
|
1128
|
if (TEST(direction_change, Y_AXIS)) {
|
1129
|
|
- ys2 = axis_segment_time[Y_AXIS][2] = axis_segment_time[Y_AXIS][1];
|
1130
|
|
- ys1 = axis_segment_time[Y_AXIS][1] = axis_segment_time[Y_AXIS][0];
|
|
1129
|
+ ys2 = axis_segment_time_us[Y_AXIS][2] = axis_segment_time_us[Y_AXIS][1];
|
|
1130
|
+ ys1 = axis_segment_time_us[Y_AXIS][1] = axis_segment_time_us[Y_AXIS][0];
|
1131
|
1131
|
ys0 = 0;
|
1132
|
1132
|
}
|
1133
|
|
- ys0 = axis_segment_time[Y_AXIS][0] = ys0 + segment_time;
|
|
1133
|
+ ys0 = axis_segment_time_us[Y_AXIS][0] = ys0 + segment_time_us;
|
1134
|
1134
|
|
1135
|
|
- const long max_x_segment_time = MAX3(xs0, xs1, xs2),
|
1136
|
|
- max_y_segment_time = MAX3(ys0, ys1, ys2),
|
1137
|
|
- min_xy_segment_time = min(max_x_segment_time, max_y_segment_time);
|
1138
|
|
- if (min_xy_segment_time < MAX_FREQ_TIME) {
|
1139
|
|
- const float low_sf = speed_factor * min_xy_segment_time / (MAX_FREQ_TIME);
|
|
1135
|
+ const uint32_t max_x_segment_time = MAX3(xs0, xs1, xs2),
|
|
1136
|
+ max_y_segment_time = MAX3(ys0, ys1, ys2),
|
|
1137
|
+ min_xy_segment_time = min(max_x_segment_time, max_y_segment_time);
|
|
1138
|
+ if (min_xy_segment_time < MAX_FREQ_TIME_US) {
|
|
1139
|
+ const float low_sf = speed_factor * min_xy_segment_time / (MAX_FREQ_TIME_US);
|
1140
|
1140
|
NOMORE(speed_factor, low_sf);
|
1141
|
1141
|
}
|
1142
|
1142
|
#endif // XY_FREQUENCY_LIMIT
|